CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
how to understand nagios plugins

 



sh.ajay12
User

Feb 26, 2014, 5:13 AM

Post #1 of 9 (2772 views)
how to understand nagios plugins Can't Post

Hello Members,

Please let me know. Is there any resource to understand nagios plugins.

for example. this one. check_snmp_load.pl

similarly there are many plugins. where can I get information about these plugins.

Thanks & Regards,
Ajay Sharma


Kenosis
User

Feb 26, 2014, 12:13 PM

Post #2 of 9 (2766 views)
Re: [sh.ajay12] how to understand nagios plugins [In reply to] Can't Post

Did you visit the nagios.org site for info about the check_snmp_load.pl plugin?


sh.ajay12
User

Feb 27, 2014, 1:43 AM

Post #3 of 9 (2738 views)
Re: [Kenosis] how to understand nagios plugins [In reply to] Can't Post

Thank You for the helpful link.

But i want to understand the code for check_snmp_load.pl

is there any site, where i can understand the code of the script.

Thank You once again.


FishMonger
Veteran / Moderator

Feb 27, 2014, 6:32 AM

Post #4 of 9 (2722 views)
Re: [sh.ajay12] how to understand nagios plugins [In reply to] Can't Post

There is no site which gives a line-by-line explanation of the code.

You could use the perl debugger to step through the script to see how it works/flows.

I assume you have read the code. What part(s) do you not understand?


sh.ajay12
User

Feb 28, 2014, 12:58 AM

Post #5 of 9 (2690 views)
Re: [FishMonger] how to understand nagios plugins [In reply to] Can't Post

Hello FishMonger,

This is written in the starting of the script.

what is the meaning of this code..

# SNMP Datas

# Generic with host-ressource-mib
my $base_proc = "1.3.6.1.2.1.25.3.3.1"; # oid for all proc info
my $proc_id = "1.3.6.1.2.1.25.3.3.1.1"; # list of processors (product ID)
my $proc_load = "1.3.6.1.2.1.25.3.3.1.2"; # %time the proc was not idle over last minute

# Linux load

my $linload_table= "1.3.6.1.4.1.2021.10.1"; # net-snmp load table
my $linload_name = "1.3.6.1.4.1.2021.10.1.2"; # text 'Load-1','Load-5', 'Load-15'
my $linload_load = "1.3.6.1.4.1.2021.10.1.3"; # effective load table

# Cisco cpu/load

my $cisco_cpu_5m = "1.3.6.1.4.1.9.2.1.58.0"; # Cisco CPU load (5min %)
my $cisco_cpu_1m = "1.3.6.1.4.1.9.2.1.57.0"; # Cisco CPU load (1min %)
my $cisco_cpu_5s = "1.3.6.1.4.1.9.2.1.56.0"; # Cisco CPU load (5sec %)

# Cisco catalyst cpu/load

my $ciscocata_cpu_5m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5.9"; # Cisco CPU load (5min %)
my $ciscocata_cpu_1m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.3.9"; # Cisco CPU load (1min %)
my $ciscocata_cpu_5s = ".1.3.6.1.4.1.9.9.109.1.1.1.1.4.9"; # Cisco CPU load (5sec %)

Thanks, Ajay
Smile


FishMonger
Veteran / Moderator

Feb 28, 2014, 6:19 AM

Post #6 of 9 (2670 views)
Re: [sh.ajay12] how to understand nagios plugins [In reply to] Can't Post

Those are simple var declarations/assignments.

Each var is assigned a specific SNMP OID which is used to extract specific data from the devices and the comment after each assignment tells you what type of data that OID tracks.

Personally, I'd use a hash to define the OID's instead of the individual scalars.


sh.ajay12
User

Mar 5, 2014, 4:13 AM

Post #7 of 9 (2518 views)
Re: [FishMonger] how to understand nagios plugins [In reply to] Can't Post

Hello FishMonger,

Please let me know, from where I can understand these argument variables which are passed to the script, so that i can understand the script.

[root@opbay03nagios libexec]# ./check_snmp
check_snmp: Could not parse arguments
Usage:check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]
[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]
[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]
[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]
[-A authpasswd] [-X privpasswd]
[root@opbay03nagios libexec]#
[root@opbay03nagios libexec]# pwd
/usr/local/nagios/libexec
[root@opbay03nagios libexec]#


FishMonger
Veteran / Moderator

Mar 5, 2014, 2:54 PM

Post #8 of 9 (2477 views)
Re: [sh.ajay12] how to understand nagios plugins [In reply to] Can't Post

Did you read the info in the page that Kenosis pointed you to?

It covers each of the option parameters and tells you what they are used for.

The script uses the Getopt::Long module to parse the command options and assigns the vars. If you want to know how that module works, you'll want to read its documentation.
http://search.cpan.org/~jv/Getopt-Long-2.42/lib/Getopt/Long.pm

To understand the script, you'll need to read the code. Start at the top and work through it a few lines at a time. when you get to a section that you don't understand, ask a specific question about that portion.

You can also step through the script using the perl debugger to see it in action.

Since you didn't understand the basic var assignments at the beginning, I might suggest that you start by picking up a good beginner level perl book before diving into this script.
http://shop.oreilly.com/product/0636920018452.do

IMO, the script wasn't written very well, so trying to understand what it does will take some work/effort.


sh.ajay12
User

Mar 11, 2014, 12:37 AM

Post #9 of 9 (1862 views)
Re: [FishMonger] how to understand nagios plugins [In reply to] Can't Post

Yes FishMonger, I am reading those links.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives