Fire Immediate Check from Command Line
Fire Immediate Check from Command Line
NagiosXI 2014R1.2
RHEL 6.5
If there a way to trigger immediate check for a service from the command line?
Please advice how to go about this.
Thanks.
RHEL 6.5
If there a way to trigger immediate check for a service from the command line?
Please advice how to go about this.
Thanks.
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
RHEL 6 & 7
rrdcached & ramdisk optimisation
Re: Fire Immediate Check from Command Line
You'll want to look into writing to the command file:
http://old.nagios.org/developerinfo/ext ... and_id=128
http://old.nagios.org/developerinfo/ext ... and_id=129
http://old.nagios.org/developerinfo/ext ... and_id=128
http://old.nagios.org/developerinfo/ext ... and_id=129
Former Nagios employee
Re: Fire Immediate Check from Command Line
SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>tmcdonald wrote:You'll want to look into writing to the command file:
http://old.nagios.org/developerinfo/ext ... and_id=128
http://old.nagios.org/developerinfo/ext ... and_id=129
Code: Select all
#!/bin/sh
# This is a sample shell script showing how you can submit the SCHEDULE_FORCED_HOST_CHECK command
# to Nagios. Adjust variables to fit your environment as necessary.
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] SCHEDULE_FORCED_HOST_CHECK;host1;1110741500\n" $now > $commandfile
BTW, in RHEL 6.5 printf is in /usr/bin
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
RHEL 6 & 7
rrdcached & ramdisk optimisation
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Fire Immediate Check from Command Line
Yeah, that was probably written a while ago. The example timestamp would need to be changed, as you can see at the top of that quoted code block:
Shell Script Usage Example:
Re: Fire Immediate Check from Command Line
slansing wrote:Yeah, that was probably written a while ago. The example timestamp would need to be changed, as you can see at the top of that quoted code block:
Shell Script Usage Example:
Code: Select all
Old
/bin/printf "[%lu] SCHEDULE_FORCED_HOST_CHECK;host1;1110741500\n" $now > $commandfile
Will change to the following and test it out.
/usr/bin/printf "[%lu] SCHEDULE_FORCED_HOST_CHECK;host1;$now\n" $now > $commandfile
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
RHEL 6 & 7
rrdcached & ramdisk optimisation
Re: Fire Immediate Check from Command Line
That looks right. Let us know how it works out for you.
Former Nagios employee
Re: Fire Immediate Check from Command Line
tmcdonald wrote:That looks right. Let us know how it works out for you.
One more question. Is there a way to execute reports from the script using wget etc?
I need the state history report in CSV in the nagios server for some processing.
Reports->State History
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
RHEL 6 & 7
rrdcached & ramdisk optimisation
Re: Fire Immediate Check from Command Line
You can get the statehistory csv from the cli (but you will need an active session (or valid ticketid) to get it:
You will have to explore the different get parameters for yourself.
Code: Select all
curl "http://<ip>/nagiosxi/reports/statehistory.php?1&host=<hostname>&service=<optional service description>&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=hard&reporttimesubmitbutton=Update&manual_run=1&page=1&records=25&mode=csv&username=<nagios xi user>&ticket=<xi user ticket id>"Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Fire Immediate Check from Command Line
Thanks I will check this out.abrist wrote:You can get the statehistory csv from the cli (but you will need an active session (or valid ticketid) to get it:You will have to explore the different get parameters for yourself.Code: Select all
curl "http://<ip>/nagiosxi/reports/statehistory.php?1&host=<hostname>&service=<optional service description>&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=hard&reporttimesubmitbutton=Update&manual_run=1&page=1&records=25&mode=csv&username=<nagios xi user>&ticket=<xi user ticket id>"
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
RHEL 6 & 7
rrdcached & ramdisk optimisation
Re: Fire Immediate Check from Command Line
Let us know how it turns out. We'll keep the thread open for a little bit in case you do have questions.
Former Nagios employee