NAME

  check_interface_table.pl -H <host> -C <community string> [OPTIONS]
        
=head1 DESCRIPTION

Introduction

check_interface_table.pl is a Nagios(R) plugin that allows you to monitor one network device (e.g. router, switch, server) without knowing each interface in detail. Only the hostname (or ip address) and the snmp community string are required.

  Simple Example:
  
  # check_interface_table.pl -H server1 -C public
  
  Output:
  
  <a href="/nagios/interfacetable/server1-Interfacetable.html">total 3 interface(s)</a>

The above example polls our netware server (server1) and reads all interfaces. The output is a HTML link to a web page which shows all interface in a table.

When clicking on the link the output looks like:

  server1 updated: Fri Nov 16 13:22:08 2007 (1 sec.)
  Name      Uptime        System Information 
  ---------------------------------------------------------------
  server1 71d 17h 56m   Novell NetWare 5.70.06 October 26, 2006
  index Description Alias AdminStatus OperStatus Speed IP 
  -------------------------------------------------------- 
  1 HP NC10xx/... Gigabit Server Adapter   up up 1.00 Gbit 10.1.1.4/255.255.0.0 
  2 HP NC10xx/... Gigabit Server Adapter (0x000f2097890c)   up up 1.00 Gbit 10.4.1.2/255.255.0.0 
  3 3COM Etherlink PCI   up up 100.00 Mbit 192.168.17.4/255.255.0.0 
  
  [back] [reset table]

The first line tells the name and when the table was last updated. (1 sec.) means that the polling process took one second.

``Name'', ``Uptime'' and ``System Information'' are for information only.

The table below these information fields shows different interface properties. The last line has two ascii buttons which allow to navigate back and to reset the table.

Theory of operation

The perl program polls the remote machine in a highly efficient manner. It collects all data from all interfaces and stores these data into the directory /tmp/.ifState.

  Each host (option -H) holds one text file:
  # ls /tmp/.ifState/*.txt
  /tmp/.ifState/server1-Interfacetable.txt

When the program is called twice, three times, etc. it retreives new information from the network and compares it against this state file.


SYNOPSIS

  check_interface_table.pl -H <host> -C <snmp community> [options]
  check_interface_table.pl -H <host> -C <snmp community> -w <warn> -c <crit> [options]
 
=head1 PREREQUISITS

This chapter describes the operating system prerequisits to get this program running:

net-snmp installed

The snmpwalk command must be available on your operating system.

  Test your snmpwalk output with a command like:
  
  # snmpwalk -Oqn -v 1 -c public router.itdesign.at | head -3
  
  .1.3.6.1.2.1.1.1.0 Cisco IOS Software, 2174 Software Version 11.7(3c), REL.
  SOFTWARE (fc2)Technical Support: http://www.cisco.com/techsupport
  Copyright (c) 1986-2005 by Cisco Systems, Inc.
  Compiled Mon 22-Oct-03 9:46 by antonio
  .1.3.6.1.2.1.1.2.0 .1.3.6.1.4.1.9.1.620
  .1.3.6.1.2.1.1.3.0 9:11:09:19.48
    
  snmpwalk parameters:
  
  -Oqn -v 1 ............ some noise (please read "man snmpwalk")
  -c public  ........... snmp community string
  router.itdesign.at ... host where you do the snmp queries

snmpwalk is part of the net-snmp suit (http://net-snmp.sourceforge.net/). Some more unix commands to find it:

  # whereis snmpwalk
  snmpwalk: /usr/bin/snmpwalk /usr/share/man/man1/snmpwalk.1.gz
  
  # which snmpwalk
  /usr/bin/snmpwalk
  
  # rpm -qa | grep snmp
  net-snmp-5.3.0.1-25.15  
  
  # rpm -ql net-snmp-5.3.0.1-25.15 | grep snmpwalk
  /usr/bin/snmpwalk
  /usr/share/man/man1/snmpwalk.1.gz

PERL V5 installed

You need a working perl 5.x installation. Currently we use V5.8.8 under SUSE Linux Enterprise Server 10 SP1 for development. We know that it works with other versions, too.


Get your perl version with:

  # perl -V

PERL Net::SNMP library

Net::SNMP is the perl's snmp library. Some ideas to see if it is installed:


  # rpm -qa|grep -i perl|grep -i snmp
  perl-Net-SNMP-5.2.0-12.2
  # find /usr -name SNMP.pm
  /usr/lib/perl5/vendor_perl/5.8.8/Net/SNMP.pm
  
  if it is not installed please check your operating systems packages or install it
  from CPAN:
  
  http://search.cpan.org/search?query=Net%3A%3ASNMP&mode=all

PERL Config::General library installed

Config::General is the only ``excotic'' library typically not installed on your OS. We use this excelent library to write all interface information data back to the file system.


  See:

  http://search.cpan.org/search?query=Config%3A%3AGeneral&mode=all

Version 2.31 of this library is part of the kit here - but it should work with
newer versions, too.

Installation is quite easy - extract the kit and type

  perl Makefile.PL 
  make
  make install

CGI script to reset the interface table

If everything is working fine you need the possibility to reset the interface table. Often it is necessary that someone changes ip addresses or other properties. These changes are necessary and you want to update (=reset) the table.

Resetting the table means to delete the state file in /tmp/.ifState.

Withing this kit you find an example shell script which does this job for you. To install this cgi script do the following:

  1) Copy the cgi script to the correct location on your WEB server
  
  # cp -i InterfaceTableReset.cgi /usr/local/nagios/sbin
  2) Check permissions
  
  # ls -l /usr/local/nagios/sbin/InterfaceTableReset.cgi
  -rwxr-xr-x 1 nagios nagios 2522 Nov 16 13:14 /usr/local/nagios/sbin/Inte...
  
  3) Prepare the /etc/sudoers file so that the web server's account can call
  the cgi script (as shell script)
  
  # visudo  
  wwwrun ALL=(ALL) NOPASSWD: /usr/local/nagios/sbin/InterfaceTableReset.cgi

The above unix commands are tested under SUSE Linux Enterprise Server 10 SP1 with apache2 installed and nagios Version 3 compiled into /usr/local/nagios.

Please send me an email if you have information from other operating systems on these details. I will update the documentation.

Configure Nagios 3.x to display HTML links in Plugin Output

In Nagios version 3.x there is html output per default disabled.

  1) Edit cgi.cfg and set this option to zero
      escape_html_tags=0

cgi.cfg is located in your configuration directory. (/usr/local/nagios/etc on SuSe Linux)


OPTIONS

-H <host> (required option)

 no default

Specifies the remote host to poll.

-C <snmp community string> (required)

 default = public

Specifies the snmp version 1 community string. Other snmp versions are not implemented.

-w <warning counter> (optional)

Must be a positiv integer number. Changes in the interface table are compared against this threshold.

  Example:
  
    ... -H server1 -C public -w 1 
    
  Leads to WARNING (exit code 1) when one or more interface properties were
  changed.

-c <critical counter> (optional)

Must be a positiv integer number. Changes in the interface table are compared against this threshold.

  Example:
  
    ... -H server1 -C public -c 1 
    
  Leads to CRITICAL (exit code 2) when one or more interface properties were
  changed.

-Exclude <interface description> [optional]

Let's you exclude some interfaces from tracking. This is useful when you know that some interfaces tend to flap and you do not want to track these.

  Example:
  ... -H router -C public -Exclude Dialer0,BVI20,FastEthernet0

Interface descriptions must match exactly!

-Include <interface description> [optional]

This is the opposite to the -Exclude option and incudes only some interfaces.

  Example:
  ... -H router -C public -Ixclude FastEthernet0,FastEthernet1

-HTMLDir <directory> (optional)

 default = /usr/local/nagios/share/interfacetable

Sets another directory where the interfae HTML files are stored. Specifies the path in the file system. See option -HTMLUrl for changing the HTML link.

-HTMLUrl <url praefix> (optional)

 default = /nagios/interfacetable

-HTMLUrl allows you to change the URL praefix in the output of the plugin.

  Example 1:
  # check_interface_table.txt -H server1 -C public -HTMLUrl ''  
  <a href="/server1-Interfacetable.html">total 3 interface(s)</a>
  Example 2:
  # check_interface_table.txt -H server1 -C public -HTMLUrl 'https://server1/iftbls'  
  <a href="https://server1/iftbls/server1-Interfacetable.html">total 3 interface(s)</a>

Specifies the HTML link only. See option HTMLDir for the file system path.

-ResetUrl <url praefix> (optional)

-ResetUrl allows you to change the URL praefix for the reset cgi program.

  Example - SUSE Linux paths':
  # check_interface_table/check_interface_table.txt -H server1 -C public \
    -HTMLDir '/srv/www/htdocs' -ResetUrl 'cgi-bin' -HTMLUrl ''

-StateDir <directory> (optional)

 default = /tmp/.ifState

Sets another directory where the interfae states are stored.

  Example:
  check_interface_table.txt -H server1 -C public -StateDir '/var/tmp'

Interface states are stored in a reference txt file. This option changes the file system location of that file.

ATTENTION! When implementing the ``table reset'' feature you must modify your InterfaceTableReset.cgi program, too.

-h <host> (optinal option)

 if omitted it defaults to the host with -H

Specifies the remote host to display in the HTML link.

 Example:
 
 check_interface_table.pl -h firewall -H srv-itd-99.itdesign.at -C mkjz65a

This option is maybe useful when you want to poll a host with -H and display another link for it.


ATTENTION - KNOWN ISSUES

Interaction with Nagios

If you use this program with Nagios then it is typically called in the ``nagios'' users context. This means that the user ``nagios'' must have the correct permissions to write all required files into the filesystem (see chapter ``Theory of operation'').

Reset table

The ``reset table button'' is the next challange. Clicking in the web browser means to trigger the ``InterfaceTableReset.cgi'' script which then tries to remove the state file.

 If this does not work please check the following:
 * correct directory and permissions of InterfaceTableReset.cgi
 * correct entry in the /etc/sudoers file
 * look at /var/log/messages or /var/log/secure to see what "sudo" calls
 * look at the web servers access and error log files

/tmp cleanup

Some operating systems clean up the /tmp directory during reboot (I know that OpenBSD does this). This leads to the problem that the /tmp/.ifState directory is deleted and you loose your interface information states. The solution for this is to set the -StateDir <directory> switch from command line.

umask on file and directory creation

This program generats some files and directories on demand:

  /tmp/.ifState ... directory with table states
  /tmp/.ifCache ... directory with caching data
  /usr/local/nagios/share/interfacetable ... directory with html tables

To avoid file system conflicts we simply set the umask to 0000 so that all files and directories are created with everyone read/write permissions.

If you don't want this - change the $UMASK variable in this program and test it very carefully - especially under the account where the program is executed.

  Example:
  
  # su - nagios
  nagios> check_interface_table.pl -H <host> -C <community string> -Debug 1


LICENSE

This program was demonstrated from me during the Nagios conference in Nuernberg (Germany) on the 12th of october 2007. Normally it is part of our commercial suite of monitoring add ons around Nagios. This version is free software under the terms and conditions of GPLV3.

Copyright (C) [2007] [ITdesign Software Projects & Consulting GmbH]

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.


COMMERCIAL Version

This version differs from our commercial version in the following:

 * Throughput on each intefcace is measured and displayed as graphs
 * Warning and critical can be set on throughput, too
 * Frequency of updates and bug fixes

Why dont't we have these features here?

From the technical point of view it is very time consuming to extract these features out of our closed suite of add ons around nagios so we decided not to do it.

What is out commercial version?

Our commercial suite of add ons around nagios contains the following features:

 * Service Level Agreement calculation 
 * AS/400, iSeries Monitoring
 * VMWARE ESX Monitoring
 * Servicemonitorung 
 * Graph and Reports
 * Extended notification possibilities (distribution lists, 
   Notify by mobile phone, UDP, FTP, etc.)
 * and much much more
 
More details see:
 http://www.watchit.at


CONTACT INFORMATION

 Werner Neunteufl
 ITdesign Software Projects & Consulting
 Anton Freunschlaggasse 49, 1230 Wien
 Werner.Neunteufl@itdesign.at