SMS notification - Delay before sending next

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rogersochieng
Posts: 7
Joined: Mon Dec 01, 2014 7:09 am

SMS notification - Delay before sending next

Post by rogersochieng »

I have SMS notification command working if specify one or two contacts but has problem when there are more contacts. It seems my SMS gateway requires delay before submitting another request.I have below command, please let me know if there is a way to introuduce delay before next contact in the service notification is processed

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | wget "http://192.168.155.6:8000/sms?usr=nagio ... sh=0&text=** $NOTIFICATIONTYPE$ Service Alert: $SERVICEDESC$ on $HOSTNAME$ State: $SERVICESTATE$ @ $LONGDATETIME$ **"
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: SMS notification - Delay before sending next

Post by tmcdonald »

Without making some modifications to the Core code and recompiling, the only thing I could think of at the moment is maybe to put a "sleep" call somewhere in there with a random delay:

Code: Select all

sleep \$(( ( RANDOM % 10 )  + 1 ))
Make sure to escape the dollar sign as I have done otherwise it will be treated as a macro. This isn't a perfect solution since the random delay could cause two or more alerts to have the same delay, but it's a good starting point. Someone else might be able to improve on my answer.
Former Nagios employee
rogersochieng
Posts: 7
Joined: Mon Dec 01, 2014 7:09 am

Re: SMS notification - Delay before sending next

Post by rogersochieng »

Do you mean add this to the command? I tried inserting it in the notification command but I get "syntax error near unexpected token '('
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: SMS notification - Delay before sending next

Post by tmcdonald »

It would go before the "/usr/bin/printf" part. It might take some fiddling with to get it to run. Like I said, not the most elegant solution but it was the first thing that came to mind.

Edit: Might also be worth making a command queue using "at": http://linux.about.com/library/cmd/blcmdl1_at.htm

Edit2: Using a name pipe might also be an interesting approach: http://stackoverflow.com/questions/1300 ... mmand-line

Then just submit the command along with a delay to that pipe, so they will be executed in the order they are received but with the delay.
Former Nagios employee
Locked