Hi,
I forgot to post my solution to this one..
rc = database.open("provider=nis;database=nis;driver=none")
query = "SELECT message from nas_transaction_summary where created > DATE_SUB(CURRENT_TIMESTAMP(),INTERVAL 2 HOUR) and message like 'MESSAGE TEXT%' and hostname like 'HOSTNAME%' union select 'Dummy Record' from dual limit 1;"
alarms, rc = database.query(query)
for _, al in pairs (alarms) do
message = "ALERT TEXT"
SUPPKEY = "*******"
SUBSYS = "1.1"
SOURCE = "**********"
if regexp (al.message,"*REGEX FOR MESSAGE*")
--then print (al.message)
then print ("Everything is fine")
--else print (al.message)
else nimbus.alarm (4, message , SUPPKEY , SUBSYS , SOURCE)
database.close()
end
end
So...in my case I wanted to check if a job ran on an AS400 Server. I created a metric within the History probe to create an informational alert to state that the job has ran. This is useful to monitor jobs that run very briefly i.e. 1 second.
The Jobs probe is not very reliable to monitor for these types of jobs.
So the script above looks back over the last 2 hours and checks to ensure that the informational "Job completed" alert is present. If not, then it alerts.
You have to enter a dummy record into your DB as the regex check doesn't work with a blank result.
Hope it helps others!