Hooking script into Nagios

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Infrastructure Monitoring Hooking script into Nagios
# 1  
Old 08-19-2010
Hooking script into Nagios

Hi!

I have a perl script which returns data in the following format -
Code:
AppName : BillingApp
	"status" = "OK";

AppName : PaymentApp
        "status" = "WARN";

AppName : OrderApp
         "status" = "ERROR";

AppName : OrderApp
         "status" = "FATAL";

the output consists of 100+ apps, with each one of them returning their status.

Here is what I need -

Want to create a wrapper script which returns a cumulative summary. I need a step by step instructions on how to hook a script like this into nagios?

What I desire -

Instead of a cumulative result, can I display the result in Nagios on a per application basis using this one script (and a wrapper script on top of it)?
I would need clear instructions here.

If you can also provide me with a wrapper script for reference in relation to how the result can be presented to Nagios that would be great.

Please help!!

Thanks,
Jack

---------- Post updated at 05:59 PM ---------- Previous update was at 03:14 PM ----------

Can you folks help?

Thanks,
jack

Last edited by vbe; 08-20-2010 at 05:44 AM.. Reason: code tags..
# 2  
Old 08-20-2010
Not really understand what you ask for.

So why not provide the expect output directly?

If you need summary the status, try it:

Code:
$ awk 'BEGIN{RS=""}{a[$3 FS $6]++}END{for (i in a) print i , a[i]}' urfile
PaymentApp "WARN"; 1
OrderApp "FATAL"; 1
OrderApp "ERROR"; 1
BillingApp "OK"; 1

# 3  
Old 08-20-2010
Thanks for your reply!

I have a script which basically does a wget on a set of URLs and returns the health of the application in the format that I gave above.

I want to plug this into Nagios so that I can see the output within Nagios 3.x.

Do you know how to achieve that?

Also what I desire is that from the output I can create a single check for each of the apps as if they are different checks (but in this case being returned from a single script).

Thanks,

Jack
# 4  
Old 08-20-2010
Use exit code SO nagios can understand error.
# 5  
Old 08-20-2010
The following is far from perfect or complete, but it should give you an idea:

Declare a nagios command and send the name of the service as a parameter by using nagios built-in macros.

Code:
define command{
command_name check_app
command_line /path/to/your/script $SERVICEDESC$
}



Then use a generic script to evaluate the status of the service. (based in rdcwayx' code):
Code:
#!/bin/bash
if [ -n "$(awk 'BEGIN{RS=""}/'$1'/{a[$3 FS $6]++}END{for (i in a) print i , a[i]}' your_file)" ]; then
	echo "App is OK" && exit $0;
else
	echo 'App down!' && exit 2;
else
	echo "Unknown Status" && exit 3;
fi


You might need to adjust paths according to your nagios.cfg file.

Smilie

Last edited by verdepollo; 08-20-2010 at 03:08 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Memcache in Nagios

Hello, I want to setup Nagios with service Memcache...We have Amazon Cloud..Please help me to setup this service on my Nagios Client. How to check Memcache is working or not on my server?? 1. Please provide us the command defination to set on Nagios Server for .cfg file. 2.Please provide... (1 Reply)
Discussion started by: chetan
1 Replies

2. Shell Programming and Scripting

Nagios script to get total and free memory

Hi Experts, need some help. I`m trying to write a shell script to get free, used and total memory on our linux servers. It's working great, but i need follow some standards to make it a real nagios plugin. It's pretty simple, you just type two parameters to the script, check_ram -w 80 -c 90... (4 Replies)
Discussion started by: berveglieri
4 Replies

3. Shell Programming and Scripting

Expect script works on CLI, but not under Nagios

I'm having a problem scripting Expect to work as a Nagios check. The script runs fine from the cli, but not when run as a Nagios check. I turn on the debug output, and it looks like it's not seeing the whole buffer's worth of info, like it's paged interactively somehow. I'm new to Expect, but this... (1 Reply)
Discussion started by: dhargens
1 Replies

4. Infrastructure Monitoring

Nagios check dependent on second nagios server

We have a dual Nagios server setup. One is setup for internal server monitoring on our LAN, while the second Nagios server is hosted externally and is used for external checks only such as URL and ping checks form the WAN side. I was wondering if there is any way to setup cross dependencies... (1 Reply)
Discussion started by: eugenes18t
1 Replies

5. Infrastructure Monitoring

How secure using Nagios?

Hello Experts, I have my windows servers located at different data-centers across US and I am monitoring all of them using Nagios server configured on a CentOS. All communications are done via public IP address and I doubt it can invite some security threats too. Can anyone let me know if it is... (3 Replies)
Discussion started by: naw_deepak
3 Replies

6. Red Hat

Nagios Problem

Hello, I installed Nagios on the Centreon Platform <----"Centralized monitoring platform" anyways now every time i click on any of the tabs inside centreon interface, it gives me a Blank page, i have no idea what to do. i thought of resetting nagios to an earlier time when it was running... (2 Replies)
Discussion started by: waelkd
2 Replies

7. UNIX and Linux Applications

Problems Hooking Sudoers into PAM/LDAP

Greetings!! I am attempting to solve a rather thorny issue and I was hoping that someone might have some insight into what is going on here.. At this point I have an openLDAP server that is working quite splendidly! :) I have a working directory with users able to authenticate it and TLS... (2 Replies)
Discussion started by: bluethundr
2 Replies

8. Infrastructure Monitoring

Nagios script output issue

Hi Folks, Nagios is acting a little weird for me, I have this external script which I hooked into Nagios, it merely does a curl/wget on a URL and returns the status based on string in the content/output. Initially for 2-3 hrs the script returns the right status and Nagios reports correctly i.e.... (4 Replies)
Discussion started by: jacki
4 Replies

9. Infrastructure Monitoring

Nagios on Linux

Hi All, I am new in Linux. I want to install Nagios on Linux. Kindly provide me guidelines for the same. Its urgent.......... (1 Reply)
Discussion started by: sunray
1 Replies

10. Solaris

Hooking up to Console's on sun's

it there any docs out there anyhwre that have the specs for cabing to a sun console. I have an e420 here, i cant seem to get a console connection, i have triewd the silver serial connectors that come with the new dsun servers, but no luck with those. (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies
Login or Register to Ask a Question