' ' Nagios Plugn for reading smartmeter missing data ' It is intended to use with NSClient++ ' ' To reset the alerts,sqlJobs ' ' Author: Simone Vola ' Email: simone.vola@gmail.com ' Created on: 2014-05-27 Dim rad,txt,dag,alert,status Set cnn = CreateObject("ADODB.Connection") Set Rs = CreateObject("ADODB.Recordset") cnn.ConnectionString = "driver={SQL Server};server=mysqlserver;User ID=sa;password=;database=msdb;Persist Security Info=False" cnn.Open exitcode = 0 txt="" allert() rs.close If txt > "" Then txt = "Job Failed: \n" & txt & " | " exitcode=2 else txt = "Status OK" exitcode=0 End If wscript.echo(txt) wscript.quit exitcode Function allert() Dim oFSO Dim file Set oFSO = CreateObject("scripting.filesystemobject") set cmd = createObject("ADODB.Command") cmd.ActiveConnection=Cnn cmd.commandtext = "exec sp_help_job" set rs = cmd.execute() Do While Not rs.EOF if rs("enabled")=1 then If rs("enabled") = 1 Then Select Case rs("last_run_outcome") Case 0: rad = rs("name") & " : " & rs("originating_server") & " : Status=Failed" & Chr(10) txt = txt + rad Case 3: rad = rs("name") & " : " & rs("originating_server") & " : Status=Canceled" & Chr(10) txt = txt + rad Case 5: rad = rs("name") & " : " & rs("originating_server") & " : Status=Unknown" & Chr(10) txt = txt + rad End Select End If end if rs.MoveNext Loop exitcode = 0 Exit Function End Function