I have Server Monitor v4.2.
I need to be able to set the status of the monitor to ok if the FireActions is true. I also have Resolved Actions I would like to run when that happens.
This is probably a settings issue, so here are my settings: Configure Actions > Fire actions when a problem is first detected, with opt escalation, and later when it is resolved.
Configure Options > Error Actions > Email Action in Do Immediately. Configure Options > Resolved Actions > Email Action.
Advanced Monitor Actions > Alert Suppression > Dont suppress. Advanced Monitor Actions > Status > Make the monitor red. Other options unchecked.
In case this is a script issue, here is my anonymized script. The monitor script itself works perfectly. The monitor just does not change to okay when the FireActions var is set to true. The resolved notification is never fired.
' VBScript Reference: http://msdn.microsoft.com/en-us/library/d1wf56tt.aspx
'Status definitions:
'Changed to string to simplify using Get\StoreValue
const msOK = "1" 'no problems (green - OK, alert suppressed, training, etc)
const msALERT = "2" 'error actions will be fired (yellow - alert state, threshold passed, etc)
Dim failedCount: failedCount=0
Dim monitorStatus: monitorStatus = GetValue("LastState")
If monitorStatus = "" Then ' First run, set to ok
monitorStatus = msOK
End If
Details = "Count Errors in DB"
FireActions = DbFail()
If FireActions Then
StoreValue "LastState", msALERT
Else
StoreValue "LastState", msOK
End If
Function DbFail()
Dim mConnection, mRecordSet
Dim connString:connString = "DRIVER={SQL Server};SERVER=MyMsftSqlServer;DATABASE=MyDb;Trusted Connection=yes"
Dim sql:sql = "SELECT COUNT(*) FROM sometable WHERE this=that"
Set mConnection = CreateObject("ADODB.Connection")
Set mRecordset = CreateObject("ADODB.Recordset")
mConnection.Open connString
mRecordset.Open sql, mConnection
' Because I am only expection one record.
If Not mRecordset.eof Then
failedCount=mRecordset.Fields(0)
End If
' Return true if failed count greater than 50 for past 24 hours.
' Reset to true if zero errors in past 24 hours.
DbFail = Not ( (failedCount < 50 And monitorStatus = msOK) Or (failedCount = 0 And monitorStatus = msAlert) )
End Function