#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name Eventid=190## Here mention the Event Id to get the details LogName="Veeam Agent" ##Here Please enter the LogName Hours=72 ##Here mention the hours to check. (It should be same as monitoring time period) import os import sys import re import ctypes import _winreg import ctypes def alert(arg): sys.stderr.write("%d%d%d" % (arg, arg, arg)) def eventid(): class disable_file_system_redirection: _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection def __enter__(self): self.old_value = ctypes.c_long() self.success = self._disable(ctypes.byref(self.old_value)) def __exit__(self, type, value, traceback): if self.success: self._revert(self.old_value) with disable_file_system_redirection(): setpolicy=os.popen('powershell "Set-ExecutionPolicy RemoteSigned"').read() cmd= 'powershell.exe ' + '"'+'Get-EventLog -Log '+"'"+LogName+"'"+' -After (Get-Date).AddHours(-%s)'%Hours+'| where {$_.eventID -eq "%s"}| Group-Object -Property Source -NoElement | Sort-Object -Property Count'%Eventid+'"' print cmd logs= os.popen(cmd).read() logs= logs.strip() print logs if logs: pattern= re.compile(r'.*\n.*\n.*\s(\d{1,}).*') m= re.match(pattern,logs) count= m.group(1) alert(1) print "The no. of Events for the Event ID:%d for the past %d Hours is:%s"%(Eventid,Hours,count) else: alert(0) print "No Events Occured with eventid= %s"%Eventid eventid()