Nagios script request - nagiostats

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

Nagios script request - nagiostats

Post by knobdy »

I see that nagios has an executable called nagiostats that will dump data into mrtg format - is it possible that this will provide nagios statistics we could graph in Cacti?
User avatar
nebj00la
Cacti User
Posts: 112
Joined: Fri Feb 17, 2006 9:02 pm
Location: Massachusetts, USA
Contact:

Re: Nagios script request - nagiostats

Post by nebj00la »

knobdy wrote:I see that nagios has an executable called nagiostats that will dump data into mrtg format - is it possible that this will provide nagios statistics we could graph in Cacti?
I would also like to see this supported.
Thanks,
nebj00la
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

I'm taking a stab at writing a wrapper script and creating some templates to handle this. I'll post my results if it turns out well.
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

Okay, here's what I've come up with. First, my Nagios and Cacti instances both sit on the same box, so the wrapper script that returns data from nagiostats is run locally. If your Nagios instance sits elsewhere, you'll have to retool this a bit.

To use, first place the attached script in your cacti scripts directory. Second, alter the following section of the script to fit your Nagios configuration:

Code: Select all

# nagios binary and configuration locations
my %nagiostat = ( 'bin' => '/usr/local/nagios/bin/nagiostats',
                  'cfg' => '/usr/local/nagios/etc/nagios.cfg');
Third, import the graph templates you wish to use. Finally, create new graphs on localhost and assign the just imported templates.

This is my first attempt at exporting, so please be gentle if this blows up :D. Don't hesitate with comments, questions, or suggestions.[/code]
Attachments
nagiostats_parse.pl
Wrapper for nagiostats written in Perl. Will return a subset of data based on the given command line argument. Please view the script for available options.
(1.83 KiB) Downloaded 712 times
cacti_graph_template_nagios_-_active_checks_5_min.xml
Average active service and host checks run per 5 minutes.
(11.32 KiB) Downloaded 401 times
cacti_graph_template_nagios_-_cached_checks_5_min.xml
Average checks that have been cached, per 5 min
(11.39 KiB) Downloaded 496 times
cacti_graph_template_nagios_-_external_command_buffers.xml
External command buffer usage.
(11.34 KiB) Downloaded 533 times
cacti_graph_template_nagios_-_host_latency_and_execution_time.xml
Host check latency and execution times.
(11.42 KiB) Downloaded 546 times
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

few more..
Attachments
cacti_graph_template_nagios_-_hosts_summary.xml
Host status summary.
(16.46 KiB) Downloaded 388 times
cacti_graph_template_nagios_-_service_check_latency_and_execution_time.xml
Service check latency and execution times.
(10.9 KiB) Downloaded 545 times
cacti_graph_template_nagios_-_services_summary.xml
Service status summary.
(19.96 KiB) Downloaded 406 times
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

and some examples..
Attachments
service_latency.png
service_latency.png (36.92 KiB) Viewed 10508 times
services_summary.png
services_summary.png (30.38 KiB) Viewed 10508 times
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Post by sterpstra »

Okay, here's what I've come up with. First, my Nagios and Cacti instances both sit on the same box, so the wrapper script that returns data from nagiostats is run locally. If your Nagios instance sits elsewhere, you'll have to retool this a bit.

To use, first place the attached script in your cacti scripts directory. Second, alter the following section of the script to fit your Nagios configuration:
I installed all of this but no go... CMD partial error in the Cacti logs... So I did the following:

- append the Data Input with /usr/bin/perl and still not working
- checked script runs OK via command line, script runs fine, results are expected.

Not sure where to go from this point....
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

sterpstra wrote:
Okay, here's what I've come up with. First, my Nagios and Cacti instances both sit on the same box, so the wrapper script that returns data from nagiostats is run locally. If your Nagios instance sits elsewhere, you'll have to retool this a bit.

To use, first place the attached script in your cacti scripts directory. Second, alter the following section of the script to fit your Nagios configuration:
I installed all of this but no go... CMD partial error in the Cacti logs... So I did the following:

- append the Data Input with /usr/bin/perl and still not working
- checked script runs OK via command line, script runs fine, results are expected.

Not sure where to go from this point....
Is there any more detail in the cacti log?
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Post by sterpstra »

Unfortunately, no...
crazyfrog
Posts: 10
Joined: Fri Mar 28, 2008 1:49 am

Post by crazyfrog »

Got the same error. Script via command line works:

./nagiostats_parse.pl SVCCOUNT
NUMSERVICES:110 NUMSVCOK:103 NUMSVCWARN:3 NUMSVCUNKN:0 NUMSVCCRIT:4
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

I'm stumped on this one. I'm not sure what that error message indicates. Are you both on version 0.8.7b? Can you paste the errors in their entirety?
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Post by sterpstra »

I ran Cacti in Debug logging mode... Shows the full command with the same result, which is a "U" like it's processing the "Die" portion of the script. Run the script manually, no problems...

09/25/2008 11:20:05 AM - CMDPHP: Poller[0] Host[1] DS[1654] WARNING: Result from CMD not valid. Partial Result:
crony
Posts: 9
Joined: Wed Jul 30, 2008 11:08 am

Post by crony »

sterpstra wrote:I ran Cacti in Debug logging mode... Shows the full command with the same result, which is a "U" like it's processing the "Die" portion of the script. Run the script manually, no problems...

09/25/2008 11:20:05 AM - CMDPHP: Poller[0] Host[1] DS[1654] WARNING: Result from CMD not valid. Partial Result:
The source code contains:

Code: Select all

cacti_log("Host[$host_id] DS[$data_source] WARNING: Result from CMD not valid.  Partial Result: " . substr($output, 0, $strout), $print_data_to_stdout);
which means it should be printing out the results from the poller in the error message. In this case it appears to be returning nothing. So either the script isn't being run, or the results are lost in translation somewhere. The script is definitely located in <path_cacti>/scripts with the executable bits set? If you prefaced the command with /usr/bin/perl that probably wouldn't matter, but it's a shot in the dark.
sterpstra
Posts: 45
Joined: Tue May 27, 2008 11:48 pm
Location: So Cal
Contact:

Post by sterpstra »

Tried that, no go... Same results either way.
crazyfrog
Posts: 10
Joined: Fri Mar 28, 2008 1:49 am

Post by crazyfrog »

Maybe a userrights issue?

Cacti and Nagios running from different users.
Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests