EXTERNAL COMMANDS from Script

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
MartinS
Posts: 3
Joined: Mon Feb 09, 2015 10:26 am

EXTERNAL COMMANDS from Script

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: EXTERNAL COMMANDS from Script

Post 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)
Be sure to check out our Knowledgebase for helpful articles and solutions!
MartinS
Posts: 3
Joined: Mon Feb 09, 2015 10:26 am

Re: EXTERNAL COMMANDS from Script

Post 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
MartinS
Posts: 3
Joined: Mon Feb 09, 2015 10:26 am

Re: EXTERNAL COMMANDS from Script

Post by MartinS »

Right spotted my error can you see the , rather than the ; in the script... D'oh
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: EXTERNAL COMMANDS from Script

Post by tmcdonald »

Hey, it could have been worse :)

Let's close this up.
Former Nagios employee
Locked