Page 1 of 1
Notification (misc) command, send string to serial port
Posted: Mon Mar 02, 2015 9:21 am
by gust102
We have a device, who can be triggered via serial communication, to call or send text message in GSM mobile network.
To trigger this, I just send string 'ALARM$' to serial port:
If I do this from the Linux promt (logged in as user nagios), it works fine.
But, if I add this as a notification (misc) commad, the notification triggers, but nothing happens.
Does anyone know what could be the problem here?
Re: Notification (misc) command, send string to serial port
Posted: Mon Mar 02, 2015 10:52 am
by jdalrymple
Can we see your command definition?
My initial thought is the literal $ character. This is a special character to Nagios, you may need to escape it with a backslash '\'.
Re: Notification (misc) command, send string to serial port
Posted: Tue Mar 03, 2015 6:42 am
by gust102
This is my latest try:
Code: Select all
define command{
command_name notify-roc-1
command_line /usr/bin/printf "%b" "ALARM$" | tee /dev/ttyS1
}
I will try escape the dollar sign (but it woks from the Linux command prompt).
Re: Notification (misc) command, send string to serial port
Posted: Tue Mar 03, 2015 3:41 pm
by gust102
I managed to solve it by embedding it in a script, with the string ALARM as a parameter.
Script:
Code: Select all
#!/bin/bash
/usr/bin/printf "%b" "$1"$ | tee /dev/ttyS1
Definition:
Code: Select all
define command{
command_name notify-roc-1
command_line /usr/lib/nagios/plugins/notify_roc_1.sh ALARM
}
Thanks for all suggestions!
Re: Notification (misc) command, send string to serial port
Posted: Tue Mar 03, 2015 3:48 pm
by cmerchant
We'll go ahead and close the thread. Thanks.