kill the application process

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
juanlopez1990
Posts: 3
Joined: Wed Apr 19, 2017 8:34 am

kill the application process

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: kill the application process

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
juanlopez1990
Posts: 3
Joined: Wed Apr 19, 2017 8:34 am

Re: kill the application process

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: kill the application process

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
juanlopez1990
Posts: 3
Joined: Wed Apr 19, 2017 8:34 am

Re: kill the application process

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: kill the application process

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked