How to monitor using custom scripts in nagios.

vinod.e vinod.e at enlume.com
Thu Mar 5 11:56:33 CET 2009


Hi Friends,
I Want share My experience  of   monitoring  scripts on  nagios , Very 
simple and Easy.
I am 3 months experienced with nagios  and  u should  make copy of all 
your modifying  files initially.

Actually I want to  monitor tomcat threads,memory etc.. along with other 
services , i could not find plug ins similar  to  mysql.
In my office  we have inbuilt scripts  to monitor  tomcat manually.
On test bases I had taken one of this script  and tested , I had success.
There are other ways thanks to Mr.Richard Quintin  who  shared his 
knowledge of using nagiosgraph  and scripts to monitor tomcat but my 
suse10.2 , monitoring server have few issues i  could not go head 
instead tried this.

Monitoring   nagios using  scripts.
Example:
Monitoring tomcat Threads.

At remote host side i.e where nrpe is installed / monitored box

Created a file tomcat_threads.sh using vi editor

#vi tomcat_threads.sh
Entered  following  three line code

#!/bin/sh
totalThreads=`ps -C java -L -o pid,tid,pcpu,state | wc -l`
echo "Total Threads Available:$totalThreads"

Save the file and quit

Made sure first  script runs at  # prompt.

Moved script to  /usr/local/nagios/libexec  folder if its not created here.

Set permission
#chmod  755 tomcat_threads.sh

Give ownner ship to nagios user only.
#chown   nagios:nagios  tomcat_threads.sh


#cd /usr/local/nagios/etc
#vi nrpe.cfg

Append below command  line

command[tomcat_threads.sh]=/usr/local/nagios/libexec/tomcat_threads.sh

Save and quit

Restart  xinetd to make  changes effected.
#service xinetd restart


At monitoring server side /  where nagios monitoring  server  installed.
#cd /usr/local/nagios/etc/

#vi services.cfg
Append this  service

define service{
          use                              generic-service
          host_name                   amazon
         service_description       tomcat_threads.sh
        check_command           check_nrpe!tomcat_threads.sh
         notifications_enabled     0
         }

Save and quit

check for erorrs
#/usr/local/nagios/bin /nagios -v  /usr/local/nagios/etc/nagios.cfg
correct your erorror if any.

Restart nagios service
#service nagios restart
  
DISCLAIMER:
This is what worked for me  and i am confident i will add as many as 
scripts i want in future.
You make changes as it suits to you and i own no responsibility  for 
typo error or if some thing  goes wrong.

Please share your knowledge, knowledges grows by sharing while money  
reduces by sharing.

Regards
Gajula Vinod Kumar Eleshetty
SYSTEM ADMINISTRATOR/DATA BASE ADMINISTRATOR
Enlume technologis.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090305/f0596ebe/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list