Notification (misc) command, send string to serial port

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
gust102
Posts: 4
Joined: Mon Mar 02, 2015 8:42 am

Notification (misc) command, send string to serial port

Post 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:

Code: Select all

/bin/echo 'ALARM$' > /dev/ttyS1
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?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Notification (misc) command, send string to serial port

Post 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 '\'.
gust102
Posts: 4
Joined: Mon Mar 02, 2015 8:42 am

Re: Notification (misc) command, send string to serial port

Post 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).
gust102
Posts: 4
Joined: Mon Mar 02, 2015 8:42 am

Re: Notification (misc) command, send string to serial port

Post 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!
cmerchant
Posts: 546
Joined: Wed Sep 24, 2014 11:19 am

Re: Notification (misc) command, send string to serial port

Post by cmerchant »

We'll go ahead and close the thread. Thanks.
Locked