automation - Invoke a shell script execution using nagios -


hi having script restarts components(.jar files) present in server (/scripts/startall.sh). whenever server goes down, want invoke execution of script using nagios, running on different linux server. possible so? kindly on how invoke execution of script using nagios?

event handlers

nagios , naemon allow executing custom scripts, both hosts , services entering 'problem state.' since implementation restarting specific applications, yours need service event handlers.

from nagios documentation:

event handlers can enabled or disabled on program-wide basis using enable_event_handlers in main configuration file.

host- , service-specific event handlers can enabled or disabled using event_handler_enabled directive in host , service definitions. host- , service-specific event handlers not executed if global enable_event_handlers option disabled.


enabling , creating event handler commands service or host

  1. first, enable event handlers modifying or adding following line nagios config file.

[ie: /usr/local/nagios/etc/nagios.cfg]:

enable_event_handlers=1

  1. define , enable event handler on service failure(s) trigger script. adding 2 event_handler directives inside of service you've defined.

[ie: /usr/local/nagios/etc/services.cfg]:

define service{     host_name       my-server     service_description my-check     check_command       my-check-command!arg1!arg2!etc     ....     event_handler my-eventhandler     event_handler_enabled   1     } 
  1. the last step create event_handler command named in step 2, , point script you've created. there few approaches (ssh, nrpe, locally-hosted, remotely hosted). i'll use simplest method, hosting bash script on monitor system connect via ssh , execute:

[ie: /usr/local/nagios/etc/objects/commands.cfg]:

 define command{          command_name    my-eventhandler          command_line    /usr/local/nagios/libexec/eventhandlers/my-eventhandler.sh          } 

in example, script "my-eventhandler.sh" should use ssh connect remote system, , execute commands you've decided on.

note: intended quick, working solution one box in environment. in practice, better create event handler script remotely, , use agent such nrpe execute command while passing $hostname$ variable (thus allowing solution scale across more 1 system). simplest tutorial i've found using nrpe execute event handler can found here.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -