Page 1 of 1

kill the application process

Posted: Mon Jul 30, 2018 10:15 am
by juanlopez1990
Hello,
I have a server that works with an application with port 10000 and I have it monitored and when this application is blocked it stops listening to port 10000 and I get a drop mail from nagios.
I want to kill the application process when nagios detects that it is down.
Information:
NagiosĀ® Coreā„¢ 4.2.3
define service{
use generic-srv ;
hostgroup_name check;
service_description check 10000
check_command check_tcp!10000
}
Server Windows Server 2008 R2 with nsclient monitor CPU, HDD and everything is correct.

Re: kill the application process

Posted: Mon Jul 30, 2018 10:26 am
by scottwilkerson
You would need an agent installed on this server, and then call a script on an event handler that kills the process.

The below article is how to restart a service using nsclient and XI, but most of the information transfers, you will just be modifying config files instead of using the GUI

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: kill the application process

Posted: Tue Jul 31, 2018 6:11 am
by juanlopez1990
Hello,
I have configured everything and it works and I can restart the service and the process.
But how do I set it so that when the alert pops up, launch the script?

Sorry for my English.

Re: kill the application process

Posted: Tue Jul 31, 2018 8:16 am
by scottwilkerson
You need to create a command in nagios for the script, and then add the command as a event_handler for this service

Re: kill the application process

Posted: Wed Aug 01, 2018 10:23 am
by juanlopez1990
I can restart a service but I can not finish a process.
Example:

@echo off
net stop service
taskkill / f / t / im Name_process.exe
timeout / t 5
net start service
Alert_MAIL.vbs
@exit 0

Re: kill the application process

Posted: Wed Aug 01, 2018 12:10 pm
by scottwilkerson
looks like you have extra spaces in there, shouldn't be spaces after the /

Code: Select all

@echo off
net stop service
taskkill /f /t /im Name_process.exe
timeout /t 5
net start service
Alert_MAIL.vbs
@exit 0