Scheduled Downtime keeps being set by script
Posted: Thu Oct 18, 2018 12:34 am
Nagios 4.3.4
Nsclient 4.4.3
Windows 2012 R2 Windows 2016 Windows 2019 Windows 10 Windows 8.1
I created a fake service that is set to manual on all the machines OS above.
When I apply updates to the machines I want to start the fake service named patches.
When patches is started the I run a script on the Nagios server that sets the downtime
That all works fine.
My problem is that it still continues to schedule a downtime over and over even after restarting server or desktop and the fake service is stopped.
Here are my entries
So in summary when the service patching is stopped no action should take place. As soon as the service is started then the Downtime should be scheduled.
Any thoughts
Thank you in advance
Tom
Nsclient 4.4.3
Windows 2012 R2 Windows 2016 Windows 2019 Windows 10 Windows 8.1
I created a fake service that is set to manual on all the machines OS above.
When I apply updates to the machines I want to start the fake service named patches.
When patches is started the I run a script on the Nagios server that sets the downtime
That all works fine.
My problem is that it still continues to schedule a downtime over and over even after restarting server or desktop and the fake service is stopped.
Here are my entries
Code: Select all
# patches.proto
define service{
use generic-service
host_name hostname
service_description Patching Service Check
is_volatile 0
check_period 24x7
max_check_attempts 3
check_interval 5
retry_interval 1
contacts noalerts
notification_interval 0
notification_period 24x7
notification_options n
check_command check_nrpe!check_winservice! -a '--service Patches'
check_period backup_period
notification_period backup_period
servicegroups Services
}
define service{
use generic-service
host_name hostname
service_description Schedule Patching Downtime
is_volatile 0
check_period 24x7
max_check_attempts 3
check_interval 5
retry_interval 1
contacts noalerts
notification_interval 0
notification_period 24x7
notification_options w,u,c,r
check_command patching_downtime
check_period backup_period
notification_period backup_period
servicegroups Services
}
define servicedependency {
host_name hostname
service_description Patching Service Check
dependent_service_description Schedule Patching Downtime
execution_failure_criteria u,c,p,w
notification_failure_criteria u,c,p,w
dependency_period 24x7
servicegroups Services
Code: Select all
#!/bin/sh
# This is a sample shell script showing how you can submit the SCHEDULE_HOST_DOWNTIME command
# to Nagios. Adjust variables to fit your environment as necessary.
#
# SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
#
now=`date +%s`
end=`date --date='1 hour' +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
host=$1
/bin/printf "[%lu] SCHEDULE_HOST_DOWNTIME;%s;%lu;%lu;1;0;600;Patching Svc;Monitoring is disabled due to patching\n" ${now} ${host} ${now} ${end} > $commandfile
root@tgcs017:/usr/local/nagios/etc/objects/windowsservers#
Code: Select all
# 'patching_downtime.sh' command definition
define command{
command_name patching_downtime
command_line /usr/local/nagios/libexec/patching_downtime.sh
}
Any thoughts
Thank you in advance
Tom