Page 1 of 1

Disable Host Service Checks External Command

Posted: Mon Nov 26, 2018 9:53 am
by hbouma
It appears that the DISABLE_HOST_SVC_CHECKS https://assets.nagios.com/downloads/nag ... mand_id=34 command only disables the active checks. Is there a command that disables all passive checks on the host?

We have a script that disables host and service checks when we start or stop a server, and we don't have a way currently to do this for passive checks. The DISABLE_PASSIVE_SERVICE_CHECKS does not fit our need as it requires the service name, which varries based on the host.

Code: Select all

#!/bin/bash
# This is a sample shell script showing how you can submit the DISABLE_HOST_SVC_CHECKS command
# to Nagios.  Adjust variables to fit your environment as necessary.

now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
servers=(Nagios Services)
[ "$#" -lt 1 ]

  for host do
        /bin/printf "[%lu] DISABLE_HOST_SVC_CHECKS;${host%-*}\n" $now > $commandfile
        /bin/printf "[%lu] DISABLE_HOST_CHECK;${host%-*}\n" $now > $commandfile
        /bin/printf "[%lu] DISABLE_PASSIVE_HOST_CHECKS;${host%-*}\n" $now > $commandfile
  done

    for i in "${servers[@]}"; do
      for host do
       ssh -tt $(whoami)@$i 'bash -s' << EOF
/bin/printf "[%lu] DISABLE_HOST_SVC_CHECKS;${host%-*}\n" $now > $commandfile && \
/bin/printf "[%lu] DISABLE_HOST_CHECK;${host%-*}\n" $now > $commandfile && \
/bin/printf "[%lu] DISABLE_PASSIVE_HOST_CHECKS;${host%-*}\n" $now > $commandfile
exit
EOF
       done
     done

Re: Disable Host Service Checks External Command

Posted: Mon Nov 26, 2018 12:29 pm
by scottwilkerson
Unfortunately DISABLE_PASSIVE_SERVICE_CHECKS is the closest command that is built into core for accomplishing this.

The only way I see to accomplish this would be to collect a list of services from the REST API and call that command for each service.

Re: Disable Host Service Checks External Command

Posted: Mon Nov 26, 2018 12:33 pm
by hbouma
Can this be put into a feature request?

Re: Disable Host Service Checks External Command

Posted: Mon Nov 26, 2018 1:05 pm
by scottwilkerson
Sure, new request made
https://github.com/NagiosEnterprises/na ... issues/594

This is a Nagios Core change with new API changes required, the earliest I would expect to see it would be in Core 5.0.0