Page 1 of 1

EXTERNAL COMMANDS from Script

Posted: Mon Feb 09, 2015 10:32 am
by MartinS
Hi,

I am having problem getting EXTERNAL COMMAND to work when send the command directly to the nagios.cmd file.

When I run from a script all I get in the log file is...

From Script

[1423495647] EXTERNAL COMMAND: SCHEDULE_HOST_DOWNTIME;Laserjet-3015;1423495646;1423496246;1;0;7200,martin.stevens;test-from-script


When I work through the Web GUI, it also triggers the HOST DOWNTIME ALERT

From WebUI

[1423495661] EXTERNAL COMMAND: SCHEDULE_HOST_DOWNTIME;Laserjet-3015;1423495618;1423502818;1;0;7200;Martin Stevens(Systems Administrator);Testing
[1423495661] HOST DOWNTIME ALERT: Laserjet-3015;STARTED; Host has entered a period of scheduled downtime

Permissions wouldn't seem to be the issue, as I can insert the command.

Any ideas ?

Martin

Re: EXTERNAL COMMANDS from Script

Posted: Mon Feb 09, 2015 5:37 pm
by tgriep
In the external script, is "martin.stevens" a valid contact in Nagios?

Try changing it to the following and see if that works for you.

Code: Select all

Martin Stevens(Systems Administrator)

Re: EXTERNAL COMMANDS from Script

Posted: Tue Feb 10, 2015 4:09 am
by MartinS
I've tested with both contact_name and the alias, and it doesn't seem to make any difference.

The contact name also matches the name in the passwd file.

Code: Select all

define contact{
        contact_name            martin.stevens
        use                     generic-contact
        alias                   Martin Stevens(Systems Administrator)
        email                   [email protected]
        }
Using this shell script

Code: Select all

#!/bin/sh
now=`date +%s`
time=`date +%H:%M:%S`
commandfile='/var/spool/nagios/cmd/nagios.cmd'

MINUTES=10

STARTTIME=$(date +"%s")
ENDTIME=$(date +"%s" -d "$MINUTES min")

/usr/bin/printf "[%lu] SCHEDULE_HOST_DOWNTIME;Laserjet-3015;$STARTTIME;$ENDTIME;1;0;7200,Martin Stevens(Systems Administrator);Host Down at $time\n" $now > $commandfile

Re: EXTERNAL COMMANDS from Script

Posted: Tue Feb 10, 2015 6:03 am
by MartinS
Right spotted my error can you see the , rather than the ; in the script... D'oh

Re: EXTERNAL COMMANDS from Script

Posted: Tue Feb 10, 2015 10:14 am
by tmcdonald
Hey, it could have been worse :)

Let's close this up.