Procedure(s) to Trigger Alerts

Does anyone have any experience with the procedures that are to trigger alerts? I noted that even when 0 is passed as an argument to def alert(), it still causes the procedure to fail and send an alert. Is there something that I am missing? I created a small test procedure and unless I don’t pass arguments to the alerts function it always throws an alert. Sample code below…


import sys
import os

def alert(arg):
sys.stderr.write("%d%d%d" % (arg, arg, arg))

num=50

Force alert argument to be 0

if num<=50:
print ("Current value: ", num)
alert(0)
else:
alert(1)


@SumoGoodLife ,

We apologize for this occurrence. We have notified our Script Developers of the outcome of your test and we’ll provide you an update shortly

Thank you!

Hi @SumoGoodLife

we are pleased to help you with your request.

please make ensure that all the indentation must be appropriate within the script before running it.

In alert () function accepts only the integer value as a passing argument.
CASE1: if you’re sending 0 as an argument it will return 000 which means alert would be in OFF state.
CASE2: if you’re sending 1 as an argument it will return 111 which means alert would be in ON state.

we have fixed the indentation errors in your sample code: Try this code


import sys
import os

def alert(arg):
sys.stderr.write("%d%d%d" % (arg, arg, arg))

num=50

Force alert argument to be 0

if num<=50:
print ("Current value: ", num)
alert(0)
else:
alert(1)


Hope this information will satisfy your needs.
please provide the feedback we are here to assist you.

Thanks

@SumoGoodLife ,

We have forwarded your output to our Script Developers. We will provide you an update shortly.

Hi @SumoGoodLife

The following function which is used to trigger an alert in ITSM:

def alert(arg):
sys.stderr.write(“%d%d%d” % (arg, arg, arg))

Please use “alert(1)” to turn on the monitor(trigger an alert)

Please use “alert(0)” to turn off the monitor(disable an alert)

The script which doesn’t met the alert on condition (i.e)

num =50

Whenever the num value is greater than or equal to 50 (num<=50) Then only it will trigger an alert.

Otherwise it won’t trigger an alert.

This is the problem you have been faced.

if you need to trigger an alert with that script make sure to give num value as greater than 50.

kindly refer the attached screenshots with different num value for triggering an alert and disabling an alert.

Thanks

!(upload://5Tm12Q0hnjMgdODjVWgccqFxVvC.png)

!(upload://5Tm12Q0hnjMgdODjVWgccqFxVvC.png)

!(upload://5Tm12Q0hnjMgdODjVWgccqFxVvC.png)

@Tamilselvam ,

Thanks for the reply. That’s my problem, the results of my script should be zero which should NOT trigger an alert. The problem is that it does trigger an alert. What precipitated this was that I ran the S.M.A.R.T script against several computers. Even though the result passed a zero to the alert function which should not have triggered an alert, I received an email for all of the them that were run Regardless of the result. That’s what led me to creating a very simple script to test the alert function. I would be more than happy to do a shared session with you to show you what it’s doing.

Regards,

Micah

Hi @SumoGoodLife

Yeah sure, we will make the session and surely will bring you out of from this trouble.

Our support team will contact you soon through the email.

Thanks for your valuable feedback