Custom event handler command giving service not defined

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
BDT
Posts: 3
Joined: Wed Jun 26, 2019 1:37 pm

Custom event handler command giving service not defined

Post by BDT »

I went through the Nagios Core Event Handlers documentation and created an event to restart the video service when the swap usage gets out of control. Problem is that I'm getting a service not defined error when running the pre-flight check. Aside from the configurations below I've also confirmed that the paths to the configuration files in nagios.cfg are pointed to the files I'm editing. Would someone please lend a hand?

Code: Select all

Checking objects...
Error: Event handler command 'restart-videoservice' specified in service 'Swap Usage' for host 'localhost' not defined anywhere
        Checked 268 services.
        Checked 47 hosts.
        Checked 6 host groups.
        Checked 3 service groups.
        Checked 2 contacts.
        Checked 1 contact groups.
        Checked 25 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 47 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   1
The restart-videoservice is part of the localhost.cfg swap usage service:

Code: Select all

define service{
         use                          local-service     
         host_name               localhost
         service_description             Swap Usage
         max_check_attempts           4
         check_command                  check_local_swap!20!10
         event_handler                     restart-videoservice
         }
I've also defined the command in the commands.cfg file:

Code: Select all

# 'restart-videoservice' command definition
define command{
        command_name  restart_videoservice
        command_line    /usr/local/nagios/libexec/eventhandlers/restart-videoservice $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$         
}
Locked