diff -urN chirp-0.5/CHANGES.txt chirp-0.6pre1/CHANGES.txt --- chirp-0.5/CHANGES.txt Wed Dec 31 18:00:00 1969 +++ chirp-0.6pre1/CHANGES.txt Mon Jul 24 01:43:29 2000 @@ -0,0 +1,68 @@ +ToDo for 0.6: + Upper/Lowercase issues + Identify should bail as soon as snmp doesn't respond + Differentiate between unknown, no SNMP daemon, no device + Fixup UCD::UCD.pm + Allow drivers to add messages to output + Allow drivers to have their own versions + Add additional drivers + Finding id.cfg + configure script for fixing path to perl + Rename id.cfg? + +Version 0.6: + CHANGES WHICH BREAK COMPATABILITY: (sorry) + chirptree.pl now requires the base/root directory for where Cricket's + configuration files should be generated to be specified in a + required parameter to the script (basedir). This eliminates + the need for the base directory to be specified in the script + which aids in portability. + chirptree.pl no longer calls Cricket's compile script. There were + two bad side effects to chirptree.pl calling compile: + 1) It needs to know the path to the compile script. + 2) The administrator may not want chirptree.pl + calling compile. (They may want to call + chirptree.pl several times concurrently for + performance reasons) + + OTHER CHANGES: + Added chirpid.pl. A script to help aid in debugging. + Added lib::UCD::UCD.pm - a driver for the UCD SNMP daemon for UNIX. + Deprecated the necessity of -h for hostname in chirp.pl and -f for + filename in chirptree.pl. For backward compatability, + these flags are allowed, but ignored. + Blatantly stole snmpUtils.pm from Cricket and trimmed it for + use with CHIRP. It is now lib/SNMP.pm. Removed Cricket + logging features from it since they weren't useful with + CHIRP. Also removed trap stuffs as they contained WebTV + specific stuff. They can always be re-added if we find + a use for SNMP traps. + Modified chirp.pl and chirptree.pl to use Getopt::Long instead of + Getopt::Std. Getopt::Long is much cooler. + Modified lib/Identify.pm to also return the name for the matched + device with the other tags. This was needed for chirpid.pl. + The device name is stored in the {name} key. + Modified all drivers to use lib::SNMP.pm. This removes the need + for the 'use lib "/usr/local/cricket/lib"' statement in + the drivers. This is good. After this, I suspect, but + have not tested, that CHIRP may now run under NT without + modification. + Modified chirptree.pl to use the CHIRP.pm lib instead of calling + chirp.pl + Modified chirptree.pl to allow the device list to come from + stdin instead of a file. (Use - for filename) + Modified lib/WriteConfig.pm to detect if a value being written to + a Cricket config file should be quoted and automatically + quote it if necessary. Thanks to Lars Thegler for this + idea and patch. + Fixed a potential bug in lib/Identify.pm which could have resulted + in devices not being identified properly if --order-- + was not set by GenConfig while reading id.cfg. + Fixed a bug in lib/Identify.pm which caused subsequent calls of + CHIRP::Identify::Identify to use the same snmp cache for + different devices. + Default id.cfg file had an invalid Match entry for Cisco_Cat1900. + Default id.cfg file can now distinguish between unknown and none. + +Version 0.5: + First release diff -urN chirp-0.5/INSTALL.txt chirp-0.6pre1/INSTALL.txt --- chirp-0.5/INSTALL.txt Thu Apr 27 10:39:25 2000 +++ chirp-0.6pre1/INSTALL.txt Mon Jul 24 01:26:32 2000 @@ -1,7 +1,7 @@ -This document covers the recommended steps for installing CHIRP. +This document covers the recommended steps for installing CHIRP under UNIX. Step 1: - To install CHIRP, ungzip and untar the package to your favorite + To install CHIRP, gunzip and untar the package to your favorite location. We recommend /usr/local/chirp. Do the same thing with CHIRP that you do with Cricket. If you have Cricket in /usr/local/cricket and a symbolic link in /home/cricket, put CHIRP @@ -9,24 +9,27 @@ pointing to /usr/local/chirp. Step 2: - You may need to edit the various Perl modules for "use lib" - statements. Currently, most of the modules (all the .pm files) - have a statement like "use lib "/usr/local/cricket/lib";" This - is neccesary for locating the snmpUtils Perl module distributed - with Cricket. If you have installed Cricket in a location other - than /usr/local/cricket, or you are running on a system that - doesn't understand the path "/usr/local/cricket/lib" such as - NT, you will have to modify these statements to match your - system. + CHIRP requires SNMP_Session to be installed. As of the time of + this writing, SNMP_Session is version 0.77. SNMP_Session is + available at http://www.switch.ch/misc/leinen/snmp/perl and is + required for Cricket as well. Step 3: + You may need to edit the various Perl modules for "use lib" + statements. While every effort is made to keep any paths out + of the Perl scripts and modules, sometimes a hardcoded path + might sneak by. In particular, you'll want to watch out for + 'use lib "/usr/local/cricket/lib";' statements in the driver + modules. + +Step 4: You may have to edit the Perl executables (all the .pl files) for the first line of the file. The first line contains the command line to run under UNIX (#!/usr/bin/perl -w). If your system has Perl in another location (such as /bin/perl), you will have to correct these files. -Step 4: +Step 5: You may want to create a site.cfg file. This file looks similar to any ordinary Cricket config file. You specify this file with the -s option to chirp.pl. If this option is there, CHIRP will parse @@ -72,7 +75,7 @@ or for specific devices. Check out the samples directory for some sample site.cfg files. -Step 5: +Step 6: You may need to edit the id.cfg file if you add additional drivers that were not distributed with CHIRP. The id.cfg file contains the methods for identifying a particular device and @@ -113,7 +116,7 @@ option to chirp.pl or chirp.pl will look in the current directory for a file named id.cfg. -Step 6: +Step 7: Call chirp.pl for all of your devices. CHIRP will generate the configuration file on STDOUT, so it is up to you to redirect that to another file for Cricket. Update Cricket to make sure it will @@ -126,3 +129,9 @@ of your network devices that you would like Cricket to monitor. Chirptree.pl is suitable for calling from cron. Please see USAGE.txt for more information. + + Yet another utility is included called chirpid.pl. This is a Perl + script useful for debugging id.cfg. Run it with a hostname and + optional community and port parameters and it will query the + device and report the name of the device entry in id.cfg that + matched the device. diff -urN chirp-0.5/README.txt chirp-0.6pre1/README.txt --- chirp-0.5/README.txt Thu Apr 27 13:40:34 2000 +++ chirp-0.6pre1/README.txt Sat Jul 22 05:39:52 2000 @@ -50,12 +50,12 @@ CHIRP is a foundation for developing "drivers" which generate Cricket configuration files. It's structure is designed to facilitate the easy and rapid development of new drivers for new SNMP capable devices. A -plugin style environment is provided for easy installing new drivers in -a running environment. +plugin style environment is provided for easy installation of new drivers +in a running environment. Currently, drivers are provided for Cisco Catalyst 5000 series switches, HP Procurve 4000m, HP AdvanceStack hubs, Fore Systems ASX ATM switches, -and IBM S/390. It is our hope that other people will develope drivers +and IBM S/390. It is our hope that other people will develop drivers for other types of network nodes and contribute those drivers back to this project. @@ -87,7 +87,7 @@ Documentation is currently a bunch of .txt file in the root of the distribution directory. We hope that some day some ambitious young -Cricket lover will write all these docs up into fancy fancy web pages +CHIRP lover will write all these docs up into fancy fancy web pages and put them in a directory named "doc". A samples directory has some sample site.cfg and devicelist files. diff -urN chirp-0.5/TODO.txt chirp-0.6pre1/TODO.txt --- chirp-0.5/TODO.txt Thu Apr 27 10:37:18 2000 +++ chirp-0.6pre1/TODO.txt Sat Jul 22 05:36:09 2000 @@ -16,34 +16,6 @@ or OR "|" or NOT "!". ->> Identify.pm should detect whether or not a device exists and provide a -"No device" page. The driver for "No device" exists as "lib::None::None.pm" -Just need to figure out a way for Identify.pm to determine no device and -call this driver in a somewhat sane way that fits with the rest of the config. -The user should be able to change what driver is called for "No device". -Maybe something like this in the Id.cfg file: - # set aside a special device name for none: --none-- - Device --none-- - module = "lib::None::None" - package = "CHIRP::None::None" - options = "" - vendor = "None" - model = "None" -or: - # set aside a special match tag for none: - Device None - module = "lib::None::None" - package = "CHIRP::None::None" - options = "" - vendor = "None" - model = "None" - match = "none://" -The distinction between "No device" and "Unknown device" is a little tricky. -If a device doesn't respond to SNMP, does that make it a "No device", or an -"Unknown device". I don't know. What if it's an RMON device (I know nothing -about RMON) or someother thing that will use a non "snmp://" match tag? - - >> Add support for additional match tags: snmpget:// (Really just the default for snmp://) snmpgetnext:// (Nice for certain devices which may not always @@ -74,4 +46,4 @@ to be more extensive than just * for everything. It would be fairly trivial to allow this to use Perl regular expressions for chunk matching. ->> Write man pages for chirp.pl and chirptree.pl +>> Write man pages for chirp.pl, chirptree.pl, and chirpid.pl diff -urN chirp-0.5/USAGE.txt chirp-0.6pre1/USAGE.txt --- chirp-0.5/USAGE.txt Thu Apr 27 13:15:04 2000 +++ chirp-0.6pre1/USAGE.txt Mon Jul 24 01:22:58 2000 @@ -8,19 +8,22 @@ on standard output. It is up to the user to redirect the output into an appropriately named configuration file. -chirp.pl [-H] -h hostname [-c community] [-p port] [-i file] [-s file] - -H: This page - -h: Hostname for SNMP query - -c: Community for SNMP query - -p: Port for SNMP query - -i: ID config file - -s: Config file with additional site specific commands +Usage: ./chirp.pl [-H] hostname [-c community] [-p port] [-i file] [-s file] + Required parameters: + hostname: Hostname for SNMP query + + Optional parameters: + -H|--Help: This page + -c|--community: Community for SNMP query (Defaults to "public") + -p|--port: Port for SNMP query (Defaults to port 161) + -i|--idfile: ID config file + -s|--sitefile: Site config file -The -h parameter is required and specifies the hostname (or IP address) +The hostname parameter is required and specifies the hostname (or IP address) used to locate the device. The -c parameter can be used to specify explicitly what SNMP community -name should used in querying the device. If this parameter is not supplied, +name should be used in querying the device. If this parameter is not supplied, it will default to "public". The -p parameter can be used to specify explicitly what SNMP port @@ -39,33 +42,47 @@ Chirptree.pl: -Chirptree.pl is another utility included to help in mass generation of -configuration trees. You may need to edit this script to change certain -parameters specific to your setup. The variables are located near the -top of the file: - ROOT_DIR = "/home/cricket/cricket-config" - CHIRP = "./chirp.pl" - COMPILE = "/home/cricket/cricket/compile" +Chirptree.pl is a utility included to help in mass generation of configuration +trees. It works by generating configurations for a set of devices and storing +the output into the Cricket configuration tree. The set of devices is +determined by the file passed to chirptree.pl via the filename parameter. + +Usage: ./chirptree.pl [-H] filename basedir [-i file] [-q] + Required parameters: + filename: File with device list (Use - for stdin) + Format of file is: + SUBTREE:DEVICE_NAME:HOSTNAME:SNMP_COMMUNITY:SNMP_PORT:SITE_FILE:COMMENT + basedir: Base directory for cricket config files + + Optional parameters: + -H|--Help: This page + -i|--idfile: ID config file + -q|--quiet: Quiet mode + +The filename parameter specifies the file from which to read the device list. +The format for this file is outlined below. This parameter can be specfied +as "-" to read the list from stdin. -chirptree.pl [-H] -f filename [-i file] [-q] - -H: This page - -f: Filename for Devices - Format of file is: - SUBTREE:DEVICE_NAME:HOSTNAME:SNMP_COMMUNITY:SNMP_PORT:SITE_FILE:COMMENT - -i: ID config file - -q: quiet mode +The basedir parameter specfies the root of the Cricket config tree and is a +required parameter. + +The -i parameter is used to specify explicitly the id.cfg file to be used +by CHIRP. If this is not provided, CHIRP will look in the current directory +for a file named "id.cfg". If CHIRP is unable to locate this file, the +configuration files generated will be for an "Unknown device" type. -Chirptree.pl works by calling chirp.pl for a set of devices and storing the -output into the Cricket configuration tree. The set of devices is determined -by the file passed to chirptree.pl via the -f parameter. +The -q parameter may be used to specify that no output (other than errors) +be displayed. -The file consists of lines containing colon ":" separated fields. The fields -are specified below: +The file specified by the filename parameter should have the format below. All +fields should be separated by colons. SUBTREE, DEVICE_NAME, and HOSTNAME are +required, all others are optional. Comments are allowed in the file prefixed +by a #. Leaving a field blank will cause it to be set to a default. SUBTREE - The directory structure to be created under ROOT_DIR. - The created config file will be put under this - directory in a directory named by DEVICE_NAME in the - file "Targets". + The directory structure to be created under the directory + specified by the basedir parameter. The created config file + will be put under this directory in a directory named by + DEVICE_NAME in the file "Targets". DEVICE_NAME A name for the device. A directory will be created under SUBTREE by this name. @@ -82,3 +99,36 @@ after the configuration is generated. COMMENT An (optional) comment. This is not processed. + + +ChirpID.pl: + +ChirpID.pl is a utility used for debugging the id.cfg file. When invoked, +it queries the specified device until it matches an entry in the id.cfg file. +The name of the first device in the id.cfg file to match is displayed. The +algorithm used for determining the device type is the same as that used by +chirp.pl and chirptree.pl. + +chirpid.pl [-H] -h hostname [-c community] [-p port] [-i file] + -H: This page + -h: Hostname for SNMP query + -c: Community for SNMP query + -p: Port for SNMP query + -i: ID config file + +The -h parameter is required and specifies the hostname (or IP address) +used to locate the device. + +The -c parameter can be used to specify explicitly what SNMP community +name should used in querying the device. If this parameter is not supplied, +it will default to "public". + +The -p parameter can be used to specify explicitly what SNMP port +should be used in querying the device. If this parameter is not supplied, +it will default to port 161. + +The -i parameter is used to specify explicitly the id.cfg file to be used +by CHIRP. If this is not provided, CHIRP will look in the current directory +for a file named "id.cfg". If CHIRP is unable to locate this file, the +configuration file generated will be for an "Unknown device" type. + diff -urN chirp-0.5/VERSION.txt chirp-0.6pre1/VERSION.txt --- chirp-0.5/VERSION.txt Wed Apr 26 16:46:17 2000 +++ chirp-0.6pre1/VERSION.txt Sat Jul 22 05:05:01 2000 @@ -1 +1 @@ -0.5 +0.6 diff -urN chirp-0.5/WRITING_DRIVERS.txt chirp-0.6pre1/WRITING_DRIVERS.txt --- chirp-0.5/WRITING_DRIVERS.txt Thu Apr 27 13:20:26 2000 +++ chirp-0.6pre1/WRITING_DRIVERS.txt Sat Jul 22 05:09:15 2000 @@ -73,7 +73,7 @@ It is also highly recommended that the driver include the following with the intent being to allow for easy sharing of driver files that - should work on all systems regardless of what is previousely defined + should work on all systems regardless of what is previously defined in a Defaults file. Datasource view @@ -125,6 +125,9 @@ It will be printed as: target --default-- MyTag = "My Text String" + + Note: As of CHIRP version 0.6, CHIRP will automatically quote + values containing spaces that are not already quoted. Step 7: CHIRP determines which driver to use for a particular device by diff -urN chirp-0.5/chirp.pl chirp-0.6pre1/chirp.pl --- chirp-0.5/chirp.pl Wed Apr 26 17:12:16 2000 +++ chirp-0.6pre1/chirp.pl Mon Jul 24 00:25:51 2000 @@ -14,7 +14,7 @@ } -use Getopt::Std; +use Getopt::Long; use lib "$installRoot"; use lib::CHIRP; @@ -23,49 +23,50 @@ use lib::WriteConfig; -my($options_ref) = {}; +my(%options); +my($Help) = 0; +my($deprecated); my($hostname) = ""; my($community) = "public"; -my($snmp_port) = "161"; +my($port) = "161"; my($idfile) = "id.cfg"; my($sitefile); my($config); -getopts('Hh:c:p:i:s:', $options_ref); -if($options_ref->{H} || !$options_ref->{h} || $#ARGV != -1) { - print STDERR "Usage: $0 [-H] -h hostname [-c community] [-p port] [-i file] [-s file]\n", - "\t-H: This page\n", - "\t-h: Hostname for SNMP query\n", - "\t-c: Community for SNMP query\n", - "\t-p: Port for SNMP query\n", - "\t-i: ID config file\n", - "\t-s: Config file with additional site specific commands\n"; - if (!$options_ref->{H}) { +%options = ( + "Help" => \$Help, + "hostname" => \$deprecated, + "community" => \$community, + "port" => \$port, + "idfile" => \$idfile, + "sitefile" => \$sitefile + ); +Getopt::Long::Configure("no_ignore_case", "permute"); +GetOptions(\%options, "-Help|?", "-hostname", "-community=s", "-port=i", "-idfile=s", "-sitefile=s"); + +if($Help == 1 || $#ARGV != 0) { + print STDERR "Usage: $0 [-H] hostname [-c community] [-p port] [-i file] [-s file]\n", + "\tRequired parameters:\n", + "\t\thostname: Hostname for SNMP query\n", + "\n", + "\tOptional parameters:\n", + "\t\t-H|--Help: This page\n", + "\t\t-c|--community: Community for SNMP query (Defaults to \"public\")\n", + "\t\t-p|--port: Port for SNMP query (Defaults to port 161)\n", + "\t\t-i|--idfile: ID config file\n", + "\t\t-s|--sitefile: Site config file\n"; + if ($Help != 1) { exit 1; } exit 0; } -$hostname = $options_ref->{h}; -if(defined($options_ref->{c})) { - $community = $options_ref->{c}; -} -if(defined($options_ref->{p})) { - $snmp_port = $options_ref->{p}; -} -if(defined($options_ref->{i})) { - $idfile = $options_ref->{i}; -} -if(defined($options_ref->{s})) { - $sitefile = $options_ref->{s}; -} - - -$config = CHIRP::CHIRP::GenConfig($hostname, $community, $snmp_port, $idfile, $sitefile); +$hostname = $ARGV[0]; +$config = CHIRP::CHIRP::GenConfig($hostname, $community, $port, $idfile, $sitefile); if(!defined($config)) { - print STDERR "ERROR: Failed to generate configuration via $community@$hostname:$snmp_port\n"; + print STDERR "ERROR: Failed to generate configuration via $community@$hostname:$port\n"; exit 2; } diff -urN chirp-0.5/chirpid.pl chirp-0.6pre1/chirpid.pl --- chirp-0.5/chirpid.pl Wed Dec 31 18:00:00 1969 +++ chirp-0.6pre1/chirpid.pl Mon Jul 24 00:27:35 2000 @@ -0,0 +1,72 @@ +#!/usr/bin/perl -w +# -*- perl -*- + + +use strict; + +package CHIRPId; + + +my($installRoot); + +BEGIN { + $installRoot = (($0 =~ m:^(.*/):)[0] || './') . '.'; +} + + +use Getopt::Long; + +use lib "$installRoot"; +use lib::Identify; + + +my(%options); +my($Help) = 0; +my($deprecated); +my($hostname) = ""; +my($community) = "public"; +my($port) = "161"; +my($idfile) = "id.cfg"; +my($deviceTable); + + +%options = ( + "Help" => \$Help, + "hostname" => \$deprecated, + "community" => \$community, + "port" => \$port, + "idfile" => \$idfile + ); +Getopt::Long::Configure("no_ignore_case", "permute"); +GetOptions(\%options, "-Help|?", "-hostname", "-community=s", "-port=i", "-idfile=s"); +if($Help == 1 || $#ARGV != 0) { + print STDERR "Usage: $0 [-H] hostname [-c community] [-p port] [-i file]\n", + "\tRequired parameters:\n", + "\t\thostname: Hostname for SNMP query\n", + "\n", + "\tOptional parameters:\n", + "\t\t-H|--Help: This page\n", + "\t\t-c|--community: Community for SNMP query (Defaults to \"public\")\n", + "\t\t-p|--port: Port for SNMP query (Defaults to port 161)\n", + "\t\t-i|--idfile: ID config file\n"; + if ($Help != 1) { + exit 1; + } + exit 0; +} + + +$hostname = $ARGV[0]; +$deviceTable = CHIRP::Identify::Identify($hostname, $community, $port, $idfile); +if(!defined($deviceTable)) { + print STDERR "ERROR: Failed to identify $community@$hostname:$port\n"; + exit 2; +} +if(!defined($deviceTable->{name})) { + print STDERR "ERROR: Matched device does not seem to have a name. Weird\n"; + exit 2; +} + +print $deviceTable->{name} . "\n"; + +exit 0; diff -urN chirp-0.5/chirptree.pl chirp-0.6pre1/chirptree.pl --- chirp-0.5/chirptree.pl Thu Apr 27 17:31:56 2000 +++ chirp-0.6pre1/chirptree.pl Mon Jul 24 01:08:07 2000 @@ -3,56 +3,85 @@ use strict; -package CHIRPList; + +package CHIRPTree; + + +my($installRoot); + +BEGIN { + $installRoot = (($0 =~ m:^(.*/):)[0] || './') . '.'; +} use File::Path; -use Getopt::Std; +use Getopt::Long; + +use lib "$installRoot"; +use lib::CHIRP; +use lib::Lowercase; +use lib::Parse; +use lib::WriteConfig; -### Site Specific ### -#Specifies the root of the cricket config tree to place new devices -my($ROOT_DIR)= "/home/cricket/cricket-config"; -my($CHIRP) = "./chirp.pl"; -my($COMPILE) = "/home/cricket/cricket/compile"; - -##################### - -my($options_ref) = {}; - -getopts('Hf:i:q', $options_ref); -if($options_ref->{H} || !$options_ref->{f} || $#ARGV != -1) { - print STDERR "Usage: $0 [-H] -f filename [-i file] [-q]\n", - "\t-H: This page\n", - "\t-f: Filename for Devices\n", - "\t\tFormat of file is:\n", - "\t\tSUBTREE:DEVICE_NAME:HOSTNAME:SNMP_COMMUNITY:SNMP_PORT:SITE_FILE:COMMENT\n", - "\t-i: ID config file \n", - "\t-q: quiet mode\n"; - if (!$options_ref->{H}) { +my(%options); +my($Help) = 0; +my($deprecated); +my($readstdin); +my($devicefile); +my($basedir); +my($idfile) = "id.cfg"; +my($quiet) = 0; +my($hostname); +my($community); +my($port); +my($sitefile); +my($config); +my($SAVE_STDOUT); + + +%options = ( + "Help" => \$Help, + "" => \$readstdin, + "filename" => \$deprecated, + "idfile" => \$idfile, + "quiet" => \$quiet + ); +Getopt::Long::Configure("no_ignore_case", "permute"); +GetOptions(\%options, "-Help|?", "-", "-file", "-idfile=s", "-quiet"); + +if($Help == 1 || (!defined($readstdin) && $#ARGV != 1) || (defined($readstdin) && $#ARGV != 0)) { + print STDERR "Usage: $0 [-H] filename basedir [-i file] [-q]\n", + "\tRequired parameters:\n", + "\t\tfilename: File with device list (Use - for stdin)\n", + "\t\t Format of file is:\n", + "\t\t SUBTREE:DEVICE_NAME:HOSTNAME:SNMP_COMMUNITY:SNMP_PORT:SITE_FILE:COMMENT\n", + "\t\tbasedir: Base directory for cricket config files\n", + "\n", + "\tOptional parameters:\n", + "\t\t-H|--Help: This page\n", + "\t\t-i|--idfile: ID config file \n", + "\t\t-q|--quiet: Quiet mode\n"; + if ($Help != 1) { exit 1; } exit 0; } -my($devicefile); -my($idfile); -my($quiet) = 0; -if(defined($options_ref->{f})) { - $devicefile = $options_ref->{f}; -} -if(defined($options_ref->{i})) { - $idfile = $options_ref->{i}; -} -if(defined($options_ref->{q})) { - $quiet = 1; + +if(defined($readstdin)) { + $devicefile = ""; + $basedir = $ARGV[0]; + open(CONFIGFILE, "<&STDIN"); +} else { + $devicefile = $ARGV[0]; + $basedir = $ARGV[1]; + open(CONFIGFILE, "<$devicefile") || (print STDERR "ERROR: Unable to open $devicefile\n"); } my($linenumber) = 0; -open(CONFIGFILE, "< $devicefile") || (print STDERR "ERROR: Unable to open $devicefile\n"); - while() { $linenumber++; @@ -83,34 +112,47 @@ } if(!$quiet) { - print "Creating $ROOT_DIR/$SUBTREE/$DEVICE/Targets\n"; + print "Creating $basedir/$SUBTREE/$DEVICE/Targets\n"; } - my($CallCommand) = $CHIRP . " -h $HOSTNAME"; - - if(defined($COMMUNITY) && $COMMUNITY !~ /^$/) { - $CallCommand .= " -c $COMMUNITY"; + $hostname = $HOSTNAME; + $community = "public"; + if(defined($COMMUNITY) && $COMMUNITY !~ /^\s*$/) { + $community = $COMMUNITY; } - if(defined($SNMP_PORT) && $SNMP_PORT !~ /^$/) { - $CallCommand .= " -p $SNMP_PORT"; + $port = "161"; + if(defined($SNMP_PORT) && $SNMP_PORT !~ /^\s*$/) { + $port = $SNMP_PORT; } - if(defined($SITE_FILE) && $SITE_FILE !~ /^$/) { - $CallCommand .= " -s $SITE_FILE"; + $sitefile = undef; + if(defined($SITE_FILE) && $SITE_FILE !~ /^\s*$/) { + $sitefile = $SITE_FILE; } - if(defined($idfile) && $idfile !~ /^$/) { - $CallCommand .= " -i $idfile"; + + + $config = CHIRP::CHIRP::GenConfig($hostname, $community, $port, $idfile, $sitefile); + if(!defined($config)) { + print STDERR "ERROR: Failed to generate configuration via $community@$hostname:$port\n"; + exit 2; } - my($TARGET_DIR) = $ROOT_DIR . "/" . $SUBTREE . "/" . $DEVICE; + + my($TARGET_DIR) = $basedir . "/" . $SUBTREE . "/" . $DEVICE; File::Path::mkpath($TARGET_DIR, 0, 0775); - $CallCommand .= " > $TARGET_DIR/Targets"; + open(SAVE_STDOUT, ">&STDOUT"); + open(STDOUT, ">$TARGET_DIR/Targets") || (print STDERR "ERROR: Unable to open $TARGET_DIR/Targets\n"); - system($CallCommand); + if(CHIRP::WriteConfig::WriteConfig($config) != 0) { + print STDERR "ERROR: Failed to write configuration\n"; + exit 2; + } + + close(STDOUT); + open(STDOUT, ">&SAVE_STDOUT"); + close(SAVE_STDOUT); } close(CONFIGFILE); - -system($COMPILE); exit 0; diff -urN chirp-0.5/devices chirp-0.6pre1/devices --- chirp-0.5/devices Wed Apr 26 17:55:40 2000 +++ chirp-0.6pre1/devices Wed Dec 31 18:00:00 1969 @@ -1,10 +0,0 @@ -Test1:Device1:144.92.152.3:public:161:./samples/1min_site.cfg:This is my comment -Test1/Test2:Device2:144.92.152.3:public:161:./samples/1min_site.cfg:This is my comment -Test3::144.92.152.3:public:161:./samples/1min_site.cfg:This is my comment -:Device4:144.92.152.3:public:161:./samples/1min_site.cfg:This is my comment -Test5:Device5::public:161:./samples/1min_site.cfg:This is my comment -Test6:Device6:144.92.152.3:public:161:./samples/1min_site.cfg:This is my comment -Test7:Device7:144.92.152.3::161:./samples/1min_site.cfg:This is my comment -Test8:Device8:144.92.152.3:public:::This is my comment -Test9:Device9:144.92.152.3:public:161:./samples/1min_site.cfg: -Test10:Device10:144.92.152.3 diff -urN chirp-0.5/id.cfg chirp-0.6pre1/id.cfg --- chirp-0.5/id.cfg Fri Apr 28 16:15:54 2000 +++ chirp-0.6pre1/id.cfg Mon Jul 24 01:25:08 2000 @@ -1,4 +1,5 @@ OID SysDescr .1.3.6.1.2.1.1.1.0 +OID SysObjectID .1.3.6.1.2.1.1.2.0 OID CiscoChassisID .1.3.6.1.4.1.9.3.6.1.0 Device --default-- @@ -13,7 +14,7 @@ Package = "CHIRP::Cisco::Catalyst" Vendor = "Cisco" Model = "Catalyst 1900" - Match = "OID0 & OID1" + Match = "OID0" OID0 = "snmp://%snmp%/SysDescr=Cisco Systems Catalyst 1900" Device Cisco_Cat5000 @@ -150,12 +151,21 @@ Match = "OID0" OID0 = "snmp://%snmp%/SysDescr=Sysname: OS/390" +Device UCD_UCD + Module = "lib::UCD::UCD" + Package = "CHIRP::UCD::UCD" + Vendor = "University of California, Davis" + Model = "Various" + Match = "OID0" + OID0 = "snmp://%snmp%/sysObjectID=1.3.6.1.4.1.2021.250" + Device Unknown_Unknown Module = "lib::Unknown::Unknown" Package = "CHIRP::Unknown::Unknown" Vendor = "Unknown" Model = "Unknown" - Match = "" + Match = "OID0" + OID0 = "snmp://%snmp%/SysDescr=." Device None_None Module = "lib::None::None" diff -urN chirp-0.5/lib/Cisco/Catalyst.pm chirp-0.6pre1/lib/Cisco/Catalyst.pm --- chirp-0.5/lib/Cisco/Catalyst.pm Wed Apr 26 15:03:13 2000 +++ chirp-0.6pre1/lib/Cisco/Catalyst.pm Sat Jul 22 04:56:09 2000 @@ -5,8 +5,7 @@ package CHIRP::Cisco::Catalyst; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; sub GenConfig { @@ -158,7 +157,7 @@ #Get Maping of Inst, Mod, Port, Name # # .cisco.workgroup.stack.portGrp.portTable.portEntry.portModuleIndex -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.11")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.11")){ my($oid, $value) = split(/:/, $row, 2); my ($mod, $port) = split(/\./, $oid); $ifPort->{$oid}->{Inst} = $value; @@ -184,13 +183,13 @@ #Get Port Descr # # .cisco.workgroup.stack.portGrp.portTable.portEntry.portType -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.5")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.5")){ my($oid, $value) = split(/:/, $row, 2); $ifPort->{$oid}->{Descr} = $value_hwPortType->{$value}->{Descr}; } #Check for set description #.iso.org.dod.internet.private.enterprises.cisco.workgroup.stack.portGrp.portTable.portEntry.portName -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.4")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.4.1.9.5.1.4.1.1.4")){ my($oid, $value) = split(/:/, $row, 2); if ($value !~ /^$/){ $ifPort->{$oid}->{Descr} = $ifPort->{$oid}->{Descr} . " -> ". $value; @@ -200,7 +199,7 @@ #Get Mod Descr # .cisco.workgroup.stack.moduleGrp.moduleTable.moduleEntry.moduleModel -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.4.1.9.5.1.3.1.1.17")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.4.1.9.5.1.3.1.1.17")){ my($oid, $value) = split(/:/, $row, 2); $ifMod->{$oid}->{Name} = "Module_" . $oid; $ifMod->{$oid}->{Descr} = $value; @@ -216,12 +215,12 @@ my $ModEntPhysicalDescr = {}; -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.2")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.2")){ my($oid, $value) = split(/:/, $row, 2); $ModEntPhysicalDescr->{$oid} = $value; } -foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.7")){ +foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.7")){ my($oid, $value) = split(/:/, $row, 2); if(defined($ifMod->{$value})) { $ifMod->{$value}->{Descr} .= " - " . $ModEntPhysicalDescr->{$oid}; @@ -230,7 +229,7 @@ ########################################## #Get Chassis Info # .cisco.workgroup.stack.chassisGrp.chassisModel -my ($ChassisModel) = snmpUtils::get($snmp, ".1.3.6.1.4.1.9.5.1.2.16.0"); +my ($ChassisModel) = SNMP::get($snmp, ".1.3.6.1.4.1.9.5.1.2.16.0"); my($DirectoryName) = "Cisco Catalyst, " . $ChassisModel; my($DefaultType) = "Catalyst-Switch-Port"; diff -urN chirp-0.5/lib/Fore/ASX.pm chirp-0.6pre1/lib/Fore/ASX.pm --- chirp-0.5/lib/Fore/ASX.pm Wed Apr 26 15:03:23 2000 +++ chirp-0.6pre1/lib/Fore/ASX.pm Sat Jul 22 04:53:40 2000 @@ -5,8 +5,7 @@ package CHIRP::Fore::ASX; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; # Most of this was created by referencing ftp://ftp.fore.com/pub/snmp/mibs/atm_switch @@ -243,11 +242,11 @@ # Get System SysDescr - my($sysDescr) = snmpUtils::get($snmp, "$oid_sysDescr.0"); + my($sysDescr) = SNMP::get($snmp, "$oid_sysDescr.0"); $device->{SysDescr} = $sysDescr; # Get Boards, Modules, Ports, Insts - foreach $row (snmpUtils::walk($snmp, "$oid_hwPortGlobalIndex")) { + foreach $row (SNMP::walk($snmp, "$oid_hwPortGlobalIndex")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -256,7 +255,7 @@ } # Get Module Name - foreach $row (snmpUtils::walk($snmp, "$oid_moduleName")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleName")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -264,7 +263,7 @@ } # Get Module Speed - foreach $row (snmpUtils::walk($snmp, "$oid_moduleSpeed")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleSpeed")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -272,7 +271,7 @@ } # Get Module Version - foreach $row (snmpUtils::walk($snmp, "$oid_moduleVersion")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleVersion")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -280,7 +279,7 @@ } # Get Module Hardware Major Rev - foreach $row (snmpUtils::walk($snmp, "$oid_moduleHwMajorRev")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleHwMajorRev")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -288,7 +287,7 @@ } # Get Module Hardware Minor Rev - foreach $row (snmpUtils::walk($snmp, "$oid_moduleHwMinorRev")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleHwMinorRev")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -296,7 +295,7 @@ } # Get Module Product Number - foreach $row (snmpUtils::walk($snmp, "$oid_moduleProductNumber")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleProductNumber")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -304,7 +303,7 @@ } # Get Module Serial Number - foreach $row (snmpUtils::walk($snmp, "$oid_moduleSerialNumber")) { + foreach $row (SNMP::walk($snmp, "$oid_moduleSerialNumber")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -312,7 +311,7 @@ } # Get Port Names - foreach $row (snmpUtils::walk($snmp, "$oid_hwPortName")) { + foreach $row (SNMP::walk($snmp, "$oid_hwPortName")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); @@ -322,7 +321,7 @@ } # Get Port Model Number and Name - foreach $row (snmpUtils::walk($snmp, "$oid_hwPortModel")) { + foreach $row (SNMP::walk($snmp, "$oid_hwPortModel")) { my($oid, $value) = split(/:/, $row); my($board, $module, $port) = split(/\./, $oid); diff -urN chirp-0.5/lib/HP/4000m.pm chirp-0.6pre1/lib/HP/4000m.pm --- chirp-0.5/lib/HP/4000m.pm Wed Apr 26 16:59:48 2000 +++ chirp-0.6pre1/lib/HP/4000m.pm Sat Jul 22 04:55:08 2000 @@ -5,8 +5,7 @@ package CHIRP::HP::4000m; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; sub GenConfig { @@ -27,7 +26,7 @@ ############################ #Get Mapping of Port to Inst # - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.3.2.1.2")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.3.2.1.2")){ my($oid, $value) = split(/:/, $row, 2); my($mapID) = ($oid =~ /([^\.]+)\./); my($ifOID) = ($value =~ /.*\.([^\.]+)/); @@ -37,7 +36,7 @@ #Build Module Map List #Get Card ContainedIn info # - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.4")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.4")){ my($oid, $value) = split(/:/, $row, 2); if (defined($ifPort->{$oid})) { $ifPort->{$oid}->{ContainedIn} = $value; @@ -49,7 +48,7 @@ ############################# #Get Descriptions # - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.2")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.2")){ my($oid, $value) = split(/:/, $row, 2); if (defined($ifPort->{$oid})) { $ifPort->{$oid}->{Descr} = $value; @@ -61,7 +60,7 @@ ############################# #Get Names # - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.7")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.7")){ my($oid, $value) = split(/:/, $row, 2); if (defined($ifPort->{$oid})) { # Pull out "Port " from name @@ -77,7 +76,7 @@ ############################## #Get PortList Names # - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.4")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.47.1.1.1.1.4")){ my($oid, $value) = split(/:/, $row, 2); if (defined($ifPort->{$oid})) { $ifMod->{$value}->{portList} = "" unless defined($ifMod->{$value}->{portList}); diff -urN chirp-0.5/lib/HP/AdvanceStack.pm chirp-0.6pre1/lib/HP/AdvanceStack.pm --- chirp-0.5/lib/HP/AdvanceStack.pm Wed Apr 26 17:00:56 2000 +++ chirp-0.6pre1/lib/HP/AdvanceStack.pm Sat Jul 22 04:55:38 2000 @@ -5,8 +5,8 @@ package CHIRP::HP::AdvanceStack; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; + sub GenConfig { my($hostname, $snmp_community, $snmp_port) = @_; @@ -24,7 +24,7 @@ # .rptrGroupEntry.rptrGroupDescr # .1.3.6.1.2.1.22.1.2.1.1.2 - my($Descr) = (split(/:/,(snmpUtils::getnext($snmp, ".1.3.6.1.2.1.22.1.2.1.1.2"))[0],2))[1]; + my($Descr) = (split(/:/,(SNMP::getnext($snmp, ".1.3.6.1.2.1.22.1.2.1.1.2"))[0],2))[1]; # ################################################# @@ -37,7 +37,7 @@ # .rptrPortTable.rptrPortEntry.rptrPortIndex # .1.3.6.1.2.1.22.1.3.1.1.2 - foreach my $row (snmpUtils::walk($snmp, ".1.3.6.1.2.1.22.1.3.1.1.2")){ + foreach my $row (SNMP::walk($snmp, ".1.3.6.1.2.1.22.1.3.1.1.2")){ my($oid, $value) = split(/:/, $row, 2); $ifPort->{$value}->{Inst} = $oid; } diff -urN chirp-0.5/lib/IBM/OS390.pm chirp-0.6pre1/lib/IBM/OS390.pm --- chirp-0.5/lib/IBM/OS390.pm Wed Apr 26 15:03:37 2000 +++ chirp-0.6pre1/lib/IBM/OS390.pm Sat Jul 22 04:54:42 2000 @@ -5,8 +5,7 @@ package CHIRP::IBM::OS390; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; my $oid_iso = ".1"; # .1 my $oid_org = "$oid_iso.3"; # .1.3 @@ -111,7 +110,7 @@ my $interface = {}; - foreach my $row (snmpUtils::walk($snmp, "$oid_ifDescr")) { + foreach my $row (SNMP::walk($snmp, "$oid_ifDescr")) { my($oid, $value) = split(/:/, $row); $interface->{$oid}->{Descr} = $value; diff -urN chirp-0.5/lib/Identify.pm chirp-0.6pre1/lib/Identify.pm --- chirp-0.5/lib/Identify.pm Wed Apr 26 15:01:38 2000 +++ chirp-0.6pre1/lib/Identify.pm Sun Jul 23 23:59:52 2000 @@ -5,12 +5,12 @@ package CHIRP::Identify; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; use lib::Parse; use lib::Lowercase; my($snmpCache) = {}; +my($snmpHostReachable) = 1; sub Identify { @@ -19,16 +19,22 @@ $snmp_port = '161' unless defined($snmp_port); $idfile = "id.cfg" unless defined($idfile); + # Clear the cache! Important! + $snmpCache = {}; + $snmpHostReachable = 1; + my($snmp) = "$community\@$hostname:$snmp_port"; my($snmp_cache) = {}; my($config) = {}; my($deviceTable) = {}; + my(@order) = (); CHIRP::Parse::GenConfig(\$config, $idfile); CHIRP::Lowercase::LowercaseConfig(\$config); + $deviceTable->{name} = ""; $deviceTable->{vendor} = "Unknown"; $deviceTable->{model} = "Unknown"; $deviceTable->{module} = "lib::Unknown::Unknown"; @@ -46,15 +52,18 @@ my($saveDeviceTable) = $deviceTable; - my(@order) = (); if(defined($config->{"device"}->{"--order--"})) { @order = split(/\s*,\s*/, $config->{"device"}->{"--order--"}); + } else { + @order = (keys % {$config->{"device"}}); } foreach my $device (@order) { next if($device =~ /--default--/); my($tmpDeviceTable) = $saveDeviceTable; + $tmpDeviceTable->{name} = $device; + foreach my $tag (keys % {$config->{"device"}->{$device}}) { $tmpDeviceTable->{$tag} = $config->{"device"}->{$device}->{$tag}; $tmpDeviceTable->{$tag} =~ s/^"//; @@ -85,6 +94,9 @@ } } + if(!defined($deviceTable->{name})) { + $deviceTable->{name} = ""; + } if(!defined($deviceTable->{vendor})) { $deviceTable->{vendor} = "Unknown"; } @@ -127,20 +139,25 @@ print STDERR "ERROR: Device \"$device\" has an invalid match tag: >$match<\n"; } elsif (defined($snmpCache->{lc($oid)})) { $snmpValue = $snmpCache->{lc($oid)}; - } else { - ($snmpValue) = snmpUtils::get($snmp, $oid); + } elsif ($snmpHostReachable != 0) { +# if($snmpHostReachable == 1) { +# if(HostReallyReachable) { +# $snmpHostReachable = 2; +# } +# } + ($snmpValue) = SNMP::get($snmp, $oid); if(defined($snmpValue)) { $snmpCache->{lc($oid)} = $snmpValue; } else { $snmpCache->{lc($oid)} = ""; } + } else { + $snmpValue = undef; } if(defined($snmpValue)) { if($snmpValue =~ /$value/) { return 1; } - } else { - print STDERR "WARNING: Unable to retrieve oid >$oid< from $hostname\n"; } } else { print STDERR "ERROR: Device \"$device\" has an invalid match tag: >$match<\n"; diff -urN chirp-0.5/lib/None/None.pm chirp-0.6pre1/lib/None/None.pm --- chirp-0.5/lib/None/None.pm Wed Apr 26 15:03:43 2000 +++ chirp-0.6pre1/lib/None/None.pm Sat Jul 22 04:53:24 2000 @@ -5,8 +5,7 @@ package CHIRP::None::None; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; sub GenConfig { diff -urN chirp-0.5/lib/SNMP.pm chirp-0.6pre1/lib/SNMP.pm --- chirp-0.5/lib/SNMP.pm Wed Dec 31 18:00:00 1969 +++ chirp-0.6pre1/lib/SNMP.pm Sat Jul 22 04:49:48 2000 @@ -0,0 +1,40 @@ +# -*- perl -*- + + +use strict; + +package SNMP; + +use SNMP_Session; +use SNMP_util; + + +# this funky wrapper is because SNMP_Session throws exceptions with +# warn(), which we need to catch, instead of letting them run +# roughshod over Cricket's output. + +sub _do { + my($subref, @args) = @_; + my(@res); + + eval { + local($SIG{'__WARN__'}) = sub { die($_[0]); }; + @res = &{$subref}(@args); + }; + + return @res; +} + +sub get { + _do(\&snmpget, @_); +} + +sub getnext { + _do(\&snmpgetnext, @_); +} + +sub walk { + _do(\&snmpwalk, @_); +} + +1; diff -urN chirp-0.5/lib/Template/Template.pm chirp-0.6pre1/lib/Template/Template.pm --- chirp-0.5/lib/Template/Template.pm Wed Apr 26 15:03:51 2000 +++ chirp-0.6pre1/lib/Template/Template.pm Sat Jul 22 04:54:12 2000 @@ -5,8 +5,7 @@ package CHIRP::Template::Template; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; my $oid_MyInOID = ".1.3.6.1.2.1.2.2.1.10"; diff -urN chirp-0.5/lib/UCD/README chirp-0.6pre1/lib/UCD/README --- chirp-0.5/lib/UCD/README Wed Dec 31 18:00:00 1969 +++ chirp-0.6pre1/lib/UCD/README Wed Jul 19 01:24:43 2000 @@ -0,0 +1,109 @@ +NAME + CHIRP::UCD::UCD - a CHIRP driver for hosts running the UCD-SNMP agent. + +DESCRIPTION + CHIRP::UCD::UCD is a driver for the CHIRP utility, that generates + Cricket configuration files. + + The driver is specifically written to extract as much useful information + as possible from hosts that are running the UCD-SNMP agent. + + The driver tries very hard to be flexible and intelligent about which + parts of the MIB that is supported in the particular instance of the + UCD-SNMP agent. For instance, if the HOST-RESOURCES-MIB is compiled into + the agent, this is detected by the driver, and additional targets are + output to the resulting configuration file. + + The resulting configuration file will include the following sections, + depending on the support in the MIB: + + hr_System - number of system processes and users + + This target is only generated, when the HOST-RESOURCES-MIB is included + in the ucd-snmp agent. + + This section is not fully implemented yet. + + ucd_System - CPU, Memory and Load + + This target lists the CPU utilisation, Memory utilisation and Average + Load of the host. + + On the CPU page, the user and system utilisation is shown. + + On the Memory page, the amount of swap space is shown, together with the + available and used RAM. + + On the Load page, the 5 and 15 minutes load averages are shown. + + interface - octets, unicast packets and errors + + This section lists each network interface, and includes the input/output + octets, unicast packets, and errors on each interface. + + Each target in this section is named 'intf_' and then the interface + name, e.g. 'intf_fxp0'. + + hr_Storage - Storage utilisation + + The targets in this section are only generated, when the + HOST-RESOURCES-MIB is included in the ucd-snmp agent. + + Each page show the size of the storage, and the amount that is + allocated. + + Each target in this section is named 'stor_' and then the mount point, + e.g. 'stor_var'. + + ucd_Storage - Storage utilisation + + The targets in this section are only generated, when individual 'disk + PATH' entries have been entered into the agent's configuration file. + + This section is not properly implemented yet. + +INSTALLATION + Put the UCD.pm script in $CHIRP/lib/UCD/UCP.pm. + + Add these lines to the $CHIRP/id.cfg file: + + Device UCD_UCD + Module = "lib::UCD::UCD" + Package = "CHIRP::UCD::UCD" + Vendor = "University of California, Davis" + Model = "Various" + Match = "OID0" + OID0 = "snmp://%snmp%/sysObjectID=1.3.6.1.4.1.2021.250" + + There is one hardcoded path in UCD.pm, that you might need to fix up: + the path for the Cricket libraries in the 'use lib'-statement below. + +SEE ALSO + Cricket contribs (including CHIRP): + http://www.gnac.com/techinfo/cricket_contrib/index.html + + Cricket: http://cricket.sourceforge.net + + UCD-SNMP: http://ucd-snmp.ucdavis.edu + +BUGS + Probably. Patches are welcome. + +CREDITS + CHIRP is written by Tom Honermann and Scott Feldmann + for the University of Wisconsin Hospital & + Clinics. + + Cricket is written by Jeff Allen of WebTV. + +COPYRIGHT + Copyright (c) 2000 Lars Thegler. All rights reserved. + + Redistribution and use, with or without modification, are permitted + provided that the above copyright notice is retained. + +AUTHOR + Lars Thegler + + Contributions from Scott Feldmann . + diff -urN chirp-0.5/lib/UCD/UCD.pm chirp-0.6pre1/lib/UCD/UCD.pm --- chirp-0.5/lib/UCD/UCD.pm Wed Dec 31 18:00:00 1969 +++ chirp-0.6pre1/lib/UCD/UCD.pm Sat Jul 22 03:06:00 2000 @@ -0,0 +1,1100 @@ + +# $Id: UCD.pm,v 1.6 2000/06/12 15:28:21 lth Exp $ + +=head1 NAME + +CHIRP::UCD::UCD - a CHIRP driver for hosts running the UCD-SNMP +agent. + +=head1 DESCRIPTION + +CHIRP::UCD::UCD is a driver for the CHIRP utility, that generates +Cricket configuration files. + +The driver is specifically written to extract as much useful +information as possible from hosts that are running the UCD-SNMP +agent. + +The driver tries very hard to be flexible and intelligent about which +parts of the MIB that is supported in the particular instance of the +UCD-SNMP agent. For instance, if the HOST-RESOURCES-MIB is compiled +into the agent, this is detected by the driver, and additional targets +are output to the resulting configuration file. + +The resulting configuration file will include the following sections, +depending on the support in the MIB: + +=head2 hr_System - number of system processes and users + +This target is only generated, when the HOST-RESOURCES-MIB is included +in the ucd-snmp agent. + +This section is not fully implemented yet. + +=head2 ucd_System - CPU, Memory and Load + +This target lists the CPU utilisation, Memory utilisation and Average +Load of the host. + +On the CPU page, the user and system utilisation is shown. + +On the Memory page, the amount of swap space is shown, together with +the available and used RAM. + +On the Load page, the 5 and 15 minutes load averages are shown. + +=head2 interface - octets, unicast packets and errors + +This section lists each network interface, and includes the +input/output octets, unicast packets, and errors on each interface. + +Each target in this section is named 'intf_' and then the interface +name, e.g. 'intf_fxp0'. + +=head2 hr_Storage - Storage utilisation + +The targets in this section are only generated, when the +HOST-RESOURCES-MIB is included in the ucd-snmp agent. + +Each page show the size of the storage, and the amount that is +allocated. + +Each target in this section is named 'stor_' and then the mount point, +e.g. 'stor_var'. + +=head2 ucd_Storage - Storage utilisation + +The targets in this section are only generated, when individual 'disk +PATH' entries have been entered into the agent's configuration file. + +This section is not properly implemented yet. + +=head1 INSTALLATION + +Put the UCD.pm script in $CHIRP/lib/UCD/UCP.pm. + +Add these lines to the $CHIRP/id.cfg file: + + Device UCD_UCD + Module = "lib::UCD::UCD" + Package = "CHIRP::UCD::UCD" + Vendor = "University of California, Davis" + Model = "Various" + Match = "OID0" + OID0 = "snmp://%snmp%/sysObjectID=1.3.6.1.4.1.2021.250" + +There is one hardcoded path in UCD.pm, that you might need to fix up: the path for the Cricket libraries in the 'use lib'-statement below. + +=head1 SEE ALSO + +Cricket contribs (including CHIRP): http://www.gnac.com/techinfo/cricket_contrib/index.html + +Cricket: http://cricket.sourceforge.net + +UCD-SNMP: http://ucd-snmp.ucdavis.edu + +=head1 BUGS + +Probably. Patches are welcome. + +=head1 CREDITS + +CHIRP is written by Tom Honermann and Scott +Feldmann for the University of Wisconsin +Hospital & Clinics. + +Cricket is written by Jeff Allen of WebTV. + +=head1 COPYRIGHT + +Copyright (c) 2000 Lars Thegler. All rights reserved. + +Redistribution and use, with or without modification, are permitted +provided that the above copyright notice is retained. + +=head1 AUTHOR + +Lars Thegler + +Contributions from Scott Feldmann . + +=cut + +use strict; +$| = 1; + +package CHIRP::UCD::UCD; + +use lib "/usr/local/cricket/lib"; +use SNMP_util (); + +my $DEBUG = 0; # set this to 1 to log all SNMP traffic + +sub wrap { + # ignore the warnings that SNMP_util may yield + my($name, $func, @argv) = @_; + my @res; + my @err; + { + local($SIG{'__WARN__'}) = sub { @err = @_; }; + @res = &{$func}(@argv); + } + if ($DEBUG) { + printf "#%s(%s) = (%s)%s\n", + $name, + join(', ', map {"'$_'"} @argv), + join(', ', map {defined $_ ? "'$_'" : "undef"} @res), + @err ? map {" [$_]"} join(', ', map {s/\n//; $_} @err) : ""; + } + if (@err) { + return; + } else { + return @res; + } +} + +sub get { + wrap('get', \&SNMP_util::snmpget, @_); +} + +sub walk { + wrap('walk', \&SNMP_util::snmpwalk, @_); +} + +sub GenConfig { + my($hostname, $snmp_community, $snmp_port, $options) = @_; + + $snmp_community = 'public' unless defined($snmp_community); + $snmp_port = '161' unless defined($snmp_port); + + my($snmp) = "$snmp_community\@$hostname:$snmp_port"; + my($config) = {}; + + my $oid_sysName = '.1.3.6.1.2.1.1.5.0'; + my $oid_hrSystem = '.1.3.6.1.2.1.25.1'; + + ## + # Get the system name + # + my ($sysName) = get($snmp, $oid_sysName); + + ## + # Determine whether the Host Resources MIB is available + # + my $hr_available = 0; + if (walk($snmp, $oid_hrSystem)) { + $hr_available = 1; + } + + ## + # OIDs + # + + $config->{oid}->{ifInOctets} = '.1.3.6.1.2.1.2.2.1.10'; + $config->{oid}->{ifInUcastPkts} = '.1.3.6.1.2.1.2.2.1.11'; + $config->{oid}->{ifInErrors} = '.1.3.6.1.2.1.2.2.1.14'; + $config->{oid}->{ifOutOctets} = '.1.3.6.1.2.1.2.2.1.16'; + $config->{oid}->{ifOutUcastPkts} = '.1.3.6.1.2.1.2.2.1.17'; + $config->{oid}->{ifOutErrors} = '.1.3.6.1.2.1.2.2.1.20'; + + if ($hr_available) { + # Host Resources System Group + $config->{oid}->{hrSystemNumUsers} = '.1.3.6.1.2.1.25.1.5.0'; + $config->{oid}->{hrSystemProcesses} = '.1.3.6.1.2.1.25.1.6'; + $config->{oid}->{hrStorageSize} = '.1.3.6.1.2.1.25.2.3.1.5'; + $config->{oid}->{hrStorageUsed} = '.1.3.6.1.2.1.25.2.3.1.6'; + } + + # Memory stats + $config->{oid}->{ucd_memAvailSwap} = '.1.3.6.1.4.1.2021.4.4.0'; + $config->{oid}->{ucd_memAvailReal} = '.1.3.6.1.4.1.2021.4.6.0'; + $config->{oid}->{ucd_memTotalFree} = '.1.3.6.1.4.1.2021.4.11.0'; + + # Disk stats + $config->{oid}->{ucd_dskTotal} = '.1.3.6.1.4.1.2021.9.1.6'; + $config->{oid}->{ucd_dskAvail} = '.1.3.6.1.4.1.2021.9.1.7'; + $config->{oid}->{ucd_dskUsed} = '.1.3.6.1.4.1.2021.9.1.8'; + $config->{oid}->{ucd_dskPercent} = '.1.3.6.1.4.1.2021.9.1.9'; + $config->{oid}->{ucd_dskPercentNode} = '.1.3.6.1.4.1.2021.9.1.10'; + + # Load averages + $config->{oid}->{ucd_load5min} = '.1.3.6.1.4.1.2021.10.1.3.2'; + $config->{oid}->{ucd_load15min} = '.1.3.6.1.4.1.2021.10.1.3.3'; + + # CPU Stats + $config->{oid}->{ucd_ssCpuUser} = '.1.3.6.1.4.1.2021.11.9.0'; + $config->{oid}->{ucd_ssCpuSystem} = '.1.3.6.1.4.1.2021.11.10.0'; + + ## + # DataSources + # + + if ($hr_available) { + + # Host Resources system stuff + + $config->{datasource}->{hrSystemNumUsers} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/hrSystemNumUsers", + 'desc' => "The number of user sessions for which this host is storing state information. A session is a collection of processes requiring a single act of user authentication and possibly subject to collective job control.", + }; + + $config->{datasource}->{hrSystemProcesses} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/hrSystemProcesses", + 'desc' => "The number of process contexts currently loaded or running on this system.", + }; + + $config->{datasource}->{hrStorageSize} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/hrStorageSize.%inst%", + 'desc' => "The size of the storage represented by this entry.", + }; + + $config->{datasource}->{hrStorageUsed} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/hrStorageUsed.%inst%", + 'desc' => "The amount of the storage represented by this entry that is allocated.", + }; + } + + # Memory stats + + $config->{datasource}->{ucd_memAvailSwap} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_memAvailSwap", + 'desc' => "Available Swap Space on the host.", + }; + + $config->{datasource}->{ucd_memAvailReal} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_memAvailReal", + 'desc' => "Available Real/Physical Memory Space on the host.", + }; + + $config->{datasource}->{ucd_memTotalFree} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_memTotalFree", + 'desc' => "Total Available Memory on the host.", + }; + + # Disk stats + + $config->{datasource}->{ucd_dskTotal} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_dskTotal.%inst%", + 'desc' => "Total size of the disk/partion.", + }; + + $config->{datasource}->{ucd_dskAvail} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_dskAvail.%inst%", + 'desc' => "Available space on the disk.", + }; + + $config->{datasource}->{ucd_dskUsed} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_dskUsed.%inst%", + 'desc' => "Used space on the disk.", + }; + + $config->{datasource}->{ucd_dskPercent} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_dskPercent.%inst%", + 'desc' => "Percentage of space used on disk.", + }; + + $config->{datasource}->{ucd_dskPercentNode} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_dskPercentNode.%inst%", + 'desc' => "Percentage of inodes used on disk.", + }; + + # Load averages + + $config->{datasource}->{ucd_load5min} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_load5min", + 'desc' => "The 5 minute load average.", + }; + + $config->{datasource}->{ucd_load15min} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_load15min", + 'desc' => "The 15 minute load average.", + }; + + # CPU Stats + + $config->{datasource}->{ucd_ssCpuUser} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_ssCpuUser", + 'desc' => "percentages of user CPU time.", + }; + + $config->{datasource}->{ucd_ssCpuSystem} = + { + 'rrd-ds-type' => 'GAUGE', + 'ds-source' => "snmp://%snmp%/ucd_ssCpuSystem", + 'desc' => "percentages of system CPU time.", + }; + + # Interfaces stats + + $config->{datasource}->{ifInOctets} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifInOctets.%inst%', + 'desc' => "The total number of octets received on the interface, including framing characters.", + }; + + $config->{datasource}->{ifOutOctets} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifOutOctets.%inst%', + 'desc' => "The total number of octets transmitted out of the interface, including framing characters.", + }; + + $config->{datasource}->{ifInUcastPkts} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifInUcastPkts.%inst%', + 'desc' => "The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were not addressed to a multicast or broadcast address at this sub-layer.", + }; + + $config->{datasource}->{ifOutUcastPkts} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifOutUcastPkts.%inst%', + 'desc' => "The total number of packets that higher-level protocols requested be transmitted, and which were not addressed to a multicast or broadcast address at this sub-layer, including those that were discarded or not sent.", + }; + + $config->{datasource}->{ifInErrors} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifInErrors.%inst%', + 'desc' => 'For packet-oriented interfaces, the number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol. For character-oriented or fixed-length interfaces, the number of inbound transmission units that contained errors preventing them from being deliverable to a higher-layer protocol.', + }; + + $config->{datasource}->{ifOutErrors} = + { + 'rrd-ds-type' => 'COUNTER', + 'ds-source' => 'snmp://%snmp%/ifOutErrors.%inst%', + 'desc' => "For packet-oriented interfaces, the number of outbound packets that could not be transmitted because of errors. For character-oriented or fixed-length interfaces, the number of outbound transmission units that could not be transmitted because of errors.", + }; + + + ## + # TargetTypes + # + + if ($hr_available) { + + $config->{targettype}->{hr_System} = + { + 'ds' => "hrSystemProcesses, hrSystemNumUsers", + 'view' => "Processes: hrSystemProcesses, Users: hrSystemNumUsers", + }; + + $config->{targettype}->{hr_Storage} = + { + 'ds' => "hrStorageSize, hrStorageUsed", + 'view' => "Storage: hrStorageSize hrStorageUsed", + }; + } + + $config->{targettype}->{ucd_System} = + { + 'ds' => "ucd_ssCpuUser, ucd_ssCpuSystem, ". + "ucd_memAvailSwap, ucd_memAvailReal, ucd_memTotalFree, ". + "ucd_load5min, ucd_load15min", + 'view' => "CPU: ucd_ssCpuUser ucd_ssCpuSystem, ". + "Memory: ucd_memAvailSwap ucd_memAvailReal ucd_memTotalFree, ". + "Load: ucd_load5min ucd_load15min", + }; + + $config->{targettype}->{ucd_Storage}= + { + 'ds' => "ucd_dskTotal, ucd_dskAvail, ucd_dskUsed, ucd_dskPercent, ucd_dskPercentNode", + 'view' => "Storage: ucd_dskTotal ucd_dskAvail ucd_dskUsed, ". + "Percent: ucd_dskPercent ucd_dskPercentNode", + }; + + $config->{targettype}->{standard_interface} = + { + 'ds' => "ifInOctets, ifOutOctets, ". + "ifInErrors, ifOutErrors, ". + "ifInUcastPkts, ifOutUcastPkts", + 'view' => "Octets: ifInOctets ifOutOctets, ". + "UcastPkts: ifInUcastPkts ifOutUcastPkts, ". + "Errors: ifInErrors ifOutErrors", + }; + + ## + # Graphs + # + + $config->{graph}->{"--default--"}->{"y-max"} = 'undef'; + + if ($hr_available) { + + $config->{graph}->{hrSystemNumUsers} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => 'Users', + 'units' => 'Users', + 'legend' => '# of Users', + 'precision' => 'integer', + }; + + $config->{graph}->{hrSystemProcesses} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => 'Processes', + 'units' => 'Processes', + 'legend' => '# of system processes', + 'precision' => 'integer', + }; + + $config->{graph}->{hrStorageSize} = { + 'color' => 'blue', + 'y-axis' => "Bytes used", + 'units' => "Bytes", + 'legend' => "Bytes of space available", + 'bytes' => 'true', + 'scale' => '%units%', + 'y-min' => '%min-size%', + 'y-max' => '%max-size%', + }; + + $config->{graph}->{hrStorageUsed} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => "Bytes used", + 'units' => "Bytes", + 'legend' => "Bytes of space used", + 'bytes' => 'true', + 'scale' => '%units%', + 'y-min' => '%min-size%', + 'y-max' => '%max-size%', + }; + } + + $config->{graph}->{ucd_memAvailSwap} = { + 'legend' => "Available swap space", + 'scale' => '1024,*', + 'bytes' => 'true', + 'units' => 'Bytes', + }; + + $config->{graph}->{ucd_memAvailReal} = { + 'legend' => "Used RAM", + 'scale' => '1024,*', + 'bytes' => 'true', + 'units' => 'Bytes', + }; + + $config->{graph}->{ucd_memTotalFree} = { + 'legend' => "Available RAM", + 'scale' => '1024,*', + 'bytes' => 'true', + 'units' => 'Bytes', + }; + + $config->{graph}->{ucd_dskTotal} = { + 'color' => 'blue', + 'y-axis' => "Bytes", + 'legend' => "Bytes Total", + 'bytes' => 'true', + 'y-max' => '%max-size%', + 'y-min' => '0', + 'scale' => '1024,*', + }; + + $config->{graph}->{ucd_dskAvail} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => "Bytes", + 'legend' => "Bytes of space free", + 'bytes' => 'true', + 'y-max' => '%max-size%', + 'y-min' => '0', + 'scale' => '1024,*', + }; + + $config->{graph}->{ucd_dskUsed} = { + 'color' => 'red', + 'draw-as' => 'AREA', + 'y-axis' => "Bytes", + 'legend' => "Bytes of space used", + 'bytes' => 'true', + 'y-max' => '%max-size%', + 'y-min' => '0', + 'scale' => '1024,*', + }; + + $config->{graph}->{ucd_dskPercent} = { + 'color' => 'blue', + 'draw-as' => 'AREA', + 'y-axis' => "%", + 'units' => "%", + 'legend' => "Percent of space used", + }; + + $config->{graph}->{ucd_dskPercentNode} = { + 'color' => 'blue', + 'draw-as' => 'AREA', + 'y-axis' => "%", + 'units' => "%", + 'legend' => "Percent of inodes used", + }; + + $config->{graph}->{ucd_load5min} = { + 'legend' => "5 minute load average", + 'si-units' => 'false', + }; + + $config->{graph}->{ucd_load15min} = { + 'legend' => "15 minute load average", + 'si-units' => 'false', + }; + + $config->{graph}->{ucd_ssCpuUser} = { + 'legend' => "CPU user time", + 'y-axis' => "Percent", + 'units' => "%", + }; + + $config->{graph}->{ucd_ssCpuSystem} = { + 'legend' => "CPU system time", + 'y-axis' => "Percent", + 'units' => "%", + }; + + $config->{graph}->{ifInOctets} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'legend' => "Average bits in", + 'y-axis' => "bits per second", + 'units' => "bits/sec", + 'scale' => '8,*', + 'bytes' => 'true', + }; + + $config->{graph}->{ifOutOctets} = { + 'color' => 'blue', + 'legend' => "Average bits out", + 'y-axis' => "bits per second", + 'units' => "bits/sec", + 'scale' => '8,*', + 'bytes' => 'true', + }; + + $config->{graph}->{ifInUcastPkts} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => "packets per second", + 'units' => "pkt/sec", + 'legend' => "Average num Packets In", + }; + + $config->{graph}->{ifOutUcastPkts} = { + 'color' => 'blue', + 'y-axis' => "packets per second", + 'units' => "pkt/sec", + 'legend' => "Average num Packets Out", + }; + + $config->{graph}->{ifInErrors} = { + 'color' => 'dark-green', + 'draw-as' => 'AREA', + 'y-axis' => "errors per second", + 'units' => "err/sec", + 'legend' => "Average Errors In", + }; + + $config->{graph}->{ifOutErrors} = { + 'color' => 'blue', + 'y-axis' => "errors per second", + 'units' => "err/sec", + 'legend' => "Average Errors Out", + }; + + + ## + # Targets + # + + $config->{target}->{"--default--"}->{"snmp-host"} = "$hostname"; + $config->{target}->{"--default--"}->{"snmp-community"} = "$snmp_community"; + $config->{target}->{"--default--"}->{"snmp-port"} = "$snmp_port"; + $config->{target}->{"--default--"}->{"snmp"} = "%snmp-community%@%snmp-host%:%snmp-port%"; + $config->{target}->{"--default--"}->{"directory-desc"} = $sysName; + $config->{target}->{"--default--"}->{"short-desc"} = '""'; + $config->{target}->{"--default--"}->{"long-desc"} = "%short-desc%"; + + if ($hr_available) { + + $config->{target}->{hr_System} = { + 'target-type' => 'hr_System', + 'short-desc' => "# of system processes and users", + }; + + } + + $config->{target}->{ucd_System} = { + 'target-type' => 'ucd_System', + 'short-desc' => "CPU, Memory, and Load", + }; + + ## + # Get interface mapping + # + my $oid_ifDescr = '.1.3.6.1.2.1.2.2.1.2'; + my $oid_ifType = '.1.3.6.1.2.1.2.2.1.3'; + my $oid_ifMtu = '.1.3.6.1.2.1.2.2.1.4'; + my $oid_ifSpeed = '.1.3.6.1.2.1.2.2.1.5'; + my $oid_ifPhysAddress = '.1.3.6.1.2.1.2.2.1.6'; + my $oid_ifAdminStatus = '.1.3.6.1.2.1.2.2.1.7'; + my $oid_ifOperStatus = '.1.3.6.1.2.1.2.2.1.8'; + my $oid_ipAdEntIfIndex = '.1.3.6.1.2.1.4.20.1.2'; + + # ifType mapping, according to IANAifType-MIB + my @ifType; + while () { + s/--.*//; # remove all comments + if (/\s*(.*)\((\d+)\)/) { + $ifType[$2] = $1; + } + } + my $interface = {}; + foreach my $row (walk($snmp, $oid_ifDescr)){ + my($index, $ifDescr) = split /:/, $row; + $interface->{$index}->{ifDescr} = $ifDescr; + } + foreach my $index (keys %$interface) { + for (get($snmp, "$oid_ifType.$index")) { + $interface->{$index}->{ifType} = + sprintf "%s(%d)", + (defined $ifType[$_]) ? $ifType[$_] : 'Unknown', + $_; + } + ($interface->{$index}->{ifMtu}) = get($snmp, "$oid_ifMtu.$index"); + ($interface->{$index}->{ifSpeed}) = get($snmp, "$oid_ifSpeed.$index"); + if (my @addr = get($snmp, "$oid_ifPhysAddress.$index")) { + $interface->{$index}->{ifPhysAddress} = + join (':', + map { sprintf "%02x", $_ } + unpack("C*", $addr[0]) + ); + } + } + foreach my $row (walk($snmp, $oid_ipAdEntIfIndex)) { + print "#ipAdEntIfIndex: $row\n" if $DEBUG; + my($ipaddr, $index) = split /:/, $row; + $interface->{$index}->{ipAddr} = $ipaddr; + } + + if ($DEBUG) { + use Data::Dumper; + print map {"#$_\n"} split /\n/, Data::Dumper->Dump([$interface], ['*interface']); + } + + foreach my $index (keys %$interface) { + + # easy way to get rid of boring 'virtual' interfaces + next unless $interface->{$index}->{ifSpeed}; + + my $shortdesc = $interface->{$index}->{ifDescr}; + my $desc; + + $desc .= "ifType$interface->{$index}->{ifType}"; + $desc .= "ifMtu$interface->{$index}->{ifMtu} octets"; + + { + my($value, $prefix) = si_unit($interface->{$index}->{ifSpeed}); + $desc .= "ifSpeed${value} ${prefix}bits per second"; + } + + if ($interface->{$index}->{ifPhysAddress}) { + $desc .= "ifPhysAddress$interface->{$index}->{ifPhysAddress}"; + } + + if ($interface->{$index}->{ipAddr}) { + $desc .= "ipAddr$interface->{$index}->{ipAddr}"; + $shortdesc .= " $interface->{$index}->{ipAddr}"; + } + + $config->{target}->{'intf_' . $interface->{$index}->{ifDescr}} = + { + 'target-type' => 'standard_interface', + 'inst' => "map(interface-name)", + 'interface-name' => $interface->{$index}->{ifDescr}, + 'short-desc' => $shortdesc, + 'long-desc' => "$desc
", + }; + } + + + ## + # Get storage mapping + # + my $oid_hrStorageType = '.1.3.6.1.2.1.25.2.3.1.2'; + my $oid_hrStorageDescr = '.1.3.6.1.2.1.25.2.3.1.3'; + my $oid_hrStorageAllocationUnits = '.1.3.6.1.2.1.25.2.3.1.4'; + my $oid_hrStorageSize = '.1.3.6.1.2.1.25.2.3.1.5'; + my $oid_hrStorageUsed = '.1.3.6.1.2.1.25.2.3.1.6'; + my $oid_hrFSRemoteMountPoint = '.1.3.6.1.2.1.25.3.8.1.3'; + my $oid_hrFSType = '.1.3.6.1.2.1.25.3.8.1.4'; + my $oid_hrFSAccess = '.1.3.6.1.2.1.25.3.8.1.5'; + my $oid_hrFSBootable = '.1.3.6.1.2.1.25.3.8.1.6'; + my $oid_hrFSStorageIndex = '.1.3.6.1.2.1.25.3.8.1.7'; + + my $storage = {}; + foreach my $row (walk($snmp, $oid_hrStorageType)){ + my($inst, $hrStorageType) = split /:/, $row; + $storage->{$inst}->{hrStorageType} = $hrStorageType; + } + foreach my $row (walk($snmp, $oid_hrFSStorageIndex)) { + my($inst, $hrFSStorageIndex) = split /:/, $row; + $storage->{$hrFSStorageIndex}->{hrFSIndex} = $inst; + } + foreach my $inst (keys %$storage) { + ($storage->{$inst}->{hrStorageDescr}) = get($snmp, "$oid_hrStorageDescr.$inst"); + ($storage->{$inst}->{hrStorageAllocationUnits}) = get($snmp, "$oid_hrStorageAllocationUnits.$inst"); + ($storage->{$inst}->{hrStorageSize}) = get($snmp, "$oid_hrStorageSize.$inst"); + ($storage->{$inst}->{hrStorageUsed}) = get($snmp, "$oid_hrStorageUsed.$inst"); + + if (exists $storage->{$inst}->{hrFSIndex}) { + my $fsinst = $storage->{$inst}->{hrFSIndex}; + ($storage->{$inst}->{hrFSRemoteMountPoint}) = get($snmp, "$oid_hrFSRemoteMountPoint.$fsinst"); + ($storage->{$inst}->{hrFSType}) = get($snmp, "$oid_hrFSType.$fsinst"); + ($storage->{$inst}->{hrFSAccess}) = get($snmp, "$oid_hrFSAccess.$fsinst"); + ($storage->{$inst}->{hrFSBootable}) = get($snmp, "$oid_hrFSBootable.$fsinst"); + } + } + + if ($DEBUG) { + use Data::Dumper; + print map {"#$_\n"} split /\n/, Data::Dumper->Dump([$storage], ['*storage']); + } + + foreach my $inst (keys %$storage) { + # remote filesystems are monitored on the file server, not here + next if $storage->{$inst}->{hrFSRemoteMountPoint}; + + $storage->{$inst}->{hrStorageDescr} =~ s|"||g; + my $target = $storage->{$inst}->{hrStorageDescr}; + if ($target eq '/') { $target = 'root' } + for ($target) { + s|^/||; # strip leading slash + s|\s+|_|g; # replace whitespace with an underscore + s|/|_|g; # replace slash with an underscore + } + + my $maxsize = $storage->{$inst}->{hrStorageAllocationUnits} * $storage->{$inst}->{hrStorageSize}; + + my $desc = ''; + if ($storage->{$inst}->{hrStorageType}) { + $desc .= sprintf "hrStorageType%s", + hrStorageTypes($storage->{$inst}->{hrStorageType}); + } + if ($storage->{$inst}->{hrFSType}) { + $desc .= sprintf "hrFSType%s", + hrFSTypes($storage->{$inst}->{hrFSType}); + } + if ($storage->{$inst}->{hrFSAccess}) { + $desc .= sprintf "hrFSAccess%s", + { '1' => 'readWrite(1)', + '2' => 'readOnly(2)', + }->{$storage->{$inst}->{hrFSAccess}}; + } + if ($storage->{$inst}->{hrFSBootable}) { + $desc .= sprintf "hrFSBootable%s", + { '1' => 'true(1)', + '2' => 'false(2)', + }->{$storage->{$inst}->{hrFSBootable}}; + } + + $config->{target}->{'stor_' . $target} = + { + 'target-type' => 'hr_Storage', + 'inst' => $inst, + 'short-desc' => "Bytes used on $storage->{$inst}->{hrStorageDescr}", + 'long-desc' => "$desc
", + 'max-size' => $maxsize, + 'storage' => $target, + 'units' => "$storage->{$inst}->{hrStorageAllocationUnits},*", + 'bytes' => 'true', + }; + + } + + return $config; +} + +1; + + +sub si_unit { + my($value, $bytes) = @_; + return ($value, '') if ($value == 0); + + my(@symbol) = ('a', 'f', 'p', 'n', 'µ', 'milli', + '', + 'k', 'M', 'G', 'T', 'P', 'E'); + my($symbcenter) = 6; + my($digits) = int(log(abs($value))/log(10) / 3); + + my($magfact); + if ($bytes) { + $magfact = 2 ** ($digits * 10); + } else { + $magfact = 10 ** ($digits * 3.0); + } + + if ((($digits + $symbcenter) > 0) && + (($digits + $symbcenter) <= $#symbol)) { + return ($value/$magfact, $symbol[$digits + $symbcenter]); + } else { + return ($value, ''); + } +} + + +sub hrStorageTypes { + my $oid = shift; + return "bad oid" unless $oid =~ m/^1\.3\.6\.1\.2\.1\.25\.2\.1\.(\d+)$/; + my $index = $1; + my $str = + { + 1 => 'Other', + 2 => 'Ram', + 3 => 'VirtualMemory', + 4 => 'FixedDisk', + 5 => 'RemovableDisk', + 6 => 'FloppyDisk', + 7 => 'CompactDisc', + 8 => 'RamDisk', + 9 => 'FlashMemory', + 10 => 'NetworkDisk', + }->{$index} || "unknown"; + return $str . "($index)"; +} + + +sub hrFSTypes { + my $oid = shift; + return "bad oid" unless $oid =~ m/^1\.3\.6\.1\.2\.1\.25\.3\.9\.(\d+)$/; + my $index = $1; + my $str = + { + 1 => 'Other', + 2 => 'Unknown', + 3 => 'BerkeleyFFS', + 4 => 'Sys5FS', + 5 => 'Fat', + 6 => 'HPFS', + 7 => 'HFS', + 8 => 'MFS', + 9 => 'NTFS', + 10 => 'VNode', + 11 => 'Journaled', + 12 => 'iso9660', + 13 => 'RockRidge', + 14 => 'NFS', + 15 => 'Netware', + 16 => 'AFS', + 17 => 'DFS', + 18 => 'Appleshare', + 19 => 'RFS', + 20 => 'DGCFS', + 21 => 'BFS', + 22 => 'FAT32', + 23 => 'LinuxExt2', + }->{$index} || "unknown"; + return $str . "($index)"; +} + + +# ifType mapping, from IANAifType-MIB, August 31, 1999 + +__DATA__ + other(1), -- none of the following + regular1822(2), + hdh1822(3), + ddnX25(4), + rfc877x25(5), + ethernetCsmacd(6), + iso88023Csmacd(7), + iso88024TokenBus(8), + iso88025TokenRing(9), + iso88026Man(10), + starLan(11), + proteon10Mbit(12), + proteon80Mbit(13), + hyperchannel(14), + fddi(15), + lapb(16), + sdlc(17), + ds1(18), -- DS1-MIB + e1(19), -- Obsolete see DS1-MIB + basicISDN(20), + primaryISDN(21), + propPointToPointSerial(22), -- proprietary serial + ppp(23), + softwareLoopback(24), + eon(25), -- CLNP over IP + ethernet3Mbit(26), + nsip(27), -- XNS over IP + slip(28), -- generic SLIP + ultra(29), -- ULTRA technologies + ds3(30), -- DS3-MIB + sip(31), -- SMDS, coffee + frameRelay(32), -- DTE only. + rs232(33), + para(34), -- parallel-port + arcnet(35), -- arcnet + arcnetPlus(36), -- arcnet plus + atm(37), -- ATM cells + miox25(38), + sonet(39), -- SONET or SDH + x25ple(40), + iso88022llc(41), + localTalk(42), + smdsDxi(43), + frameRelayService(44), -- FRNETSERV-MIB + v35(45), + hssi(46), + hippi(47), + modem(48), -- Generic modem + aal5(49), -- AAL5 over ATM + sonetPath(50), + sonetVT(51), + smdsIcip(52), -- SMDS InterCarrier Interface + propVirtual(53), -- proprietary virtual/internal + propMultiplexor(54),-- proprietary multiplexing + ieee80212(55), -- 100BaseVG + fibreChannel(56), -- Fibre Channel + hippiInterface(57), -- HIPPI interfaces + frameRelayInterconnect(58), -- Obsolete use either + -- frameRelay(32) or + -- frameRelayService(44). + aflane8023(59), -- ATM Emulated LAN for 802.3 + aflane8025(60), -- ATM Emulated LAN for 802.5 + cctEmul(61), -- ATM Emulated circuit + fastEther(62), -- Fast Ethernet (100BaseT) + isdn(63), -- ISDN and X.25 + v11(64), -- CCITT V.11/X.21 + v36(65), -- CCITT V.36 + g703at64k(66), -- CCITT G703 at 64Kbps + g703at2mb(67), -- Obsolete see DS1-MIB + qllc(68), -- SNA QLLC + fastEtherFX(69), -- Fast Ethernet (100BaseFX) + channel(70), -- channel + ieee80211(71), -- radio spread spectrum + ibm370parChan(72), -- IBM System 360/370 OEMI Channel + escon(73), -- IBM Enterprise Systems Connection + dlsw(74), -- Data Link Switching + isdns(75), -- ISDN S/T interface + isdnu(76), -- ISDN U interface + lapd(77), -- Link Access Protocol D + ipSwitch(78), -- IP Switching Objects + rsrb(79), -- Remote Source Route Bridging + atmLogical(80), -- ATM Logical Port + ds0(81), -- Digital Signal Level 0 + ds0Bundle(82), -- group of ds0s on the same ds1 + bsc(83), -- Bisynchronous Protocol + async(84), -- Asynchronous Protocol + cnr(85), -- Combat Net Radio + iso88025Dtr(86), -- ISO 802.5r DTR + eplrs(87), -- Ext Pos Loc Report Sys + arap(88), -- Appletalk Remote Access Protocol + propCnls(89), -- Proprietary Connectionless Protocol + hostPad(90), -- CCITT-ITU X.29 PAD Protocol + termPad(91), -- CCITT-ITU X.3 PAD Facility + frameRelayMPI(92), -- Multiproto Interconnect over FR + x213(93), -- CCITT-ITU X213 + adsl(94), -- Asymmetric Digital Subscriber Loop + radsl(95), -- Rate-Adapt. Digital Subscriber Loop + sdsl(96), -- Symmetric Digital Subscriber Loop + vdsl(97), -- Very H-Speed Digital Subscrib. Loop + iso88025CRFPInt(98), -- ISO 802.5 CRFP + myrinet(99), -- Myricom Myrinet + voiceEM(100), -- voice recEive and transMit + voiceFXO(101), -- voice Foreign Exchange Office + voiceFXS(102), -- voice Foreign Exchange Station + voiceEncap(103), -- voice encapsulation + voiceOverIp(104), -- voice over IP encapsulation + atmDxi(105), -- ATM DXI + atmFuni(106), -- ATM FUNI + atmIma (107), -- ATM IMA + pppMultilinkBundle(108), -- PPP Multilink Bundle + ipOverCdlc (109), -- IBM ipOverCdlc + ipOverClaw (110), -- IBM Common Link Access to Workstn + stackToStack (111), -- IBM stackToStack + virtualIpAddress (112), -- IBM VIPA + mpc (113), -- IBM multi-protocol channel support + ipOverAtm (114), -- IBM ipOverAtm + iso88025Fiber (115), -- ISO 802.5j Fiber Token Ring + tdlc (116), -- IBM twinaxial data link control + gigabitEthernet (117), -- Gigabit Ethernet + hdlc (118), -- HDLC + lapf (119), -- LAP F + v37 (120), -- V.37 + x25mlp (121), -- Multi-Link Protocol + x25huntGroup (122), -- X25 Hunt Group + trasnpHdlc (123), -- Transp HDLC + interleave (124), -- Interleave channel + fast (125), -- Fast channel + ip (126), -- IP (for APPN HPR in IP networks) + docsCableMaclayer (127), -- CATV Mac Layer + docsCableDownstream (128), -- CATV Downstream interface + docsCableUpstream (129), -- CATV Upstream interface + a12MppSwitch (130), -- Avalon Parallel Processor + tunnel (131), -- Encapsulation interface + coffee (132), -- coffee pot + ces (133), -- Circuit Emulation Service + atmSubInterface (134), -- ATM Sub Interface + l2vlan (135), -- Layer 2 Virtual LAN using 802.1Q + l3ipvlan (136), -- Layer 3 Virtual LAN using IP + l3ipxvlan (137), -- Layer 3 Virtual LAN using IPX + digitalPowerline (138), -- IP over Power Lines + mediaMailOverIp (139), -- Multimedia Mail over IP + dtm (140), -- Dynamic syncronous Transfer Mode + dcn (141), -- Data Communications Network + ipForward (142), -- IP Forwarding Interface + msdsl (143), -- Multi-rate Symmetric DSL + ieee1394 (144), -- IEEE1394 High Performance Serial Bus + if-gsn (145), -- HIPPI-6400 + dvbRccMacLayer (146), -- DVB-RCC MAC Layer + dvbRccDownstream (147), -- DVB-RCC Downstream Channel + dvbRccUpstream (148), -- DVB-RCC Upstream Channel + atmVirtual (149), -- ATM Virtual Interface + mplsTunnel (150), -- MPLS Tunnel Virtual Interface + srp (151), -- Spatial Reuse Protocol + voiceOverAtm (152), -- Voice Over ATM + voiceOverFrameRelay (153), -- Voice Over Frame Relay + idsl (154), -- Digital Subscriber Loop over ISDN + compositeLink (155), -- Avici Composite Link Interface + ss7SigLink (156), -- SS7 Signaling Link + propWirelessP2P (157), -- Prop. P2P wireless interface + frForward (158), -- Frame Forward Interface + rfc1483 (159), -- Multiprotocol over ATM AAL5 + usb (160), -- USB Interface + ieee8023adLag(161) -- IEEE 802.3ad Link Aggregate diff -urN chirp-0.5/lib/Unknown/Unknown.pm chirp-0.6pre1/lib/Unknown/Unknown.pm --- chirp-0.5/lib/Unknown/Unknown.pm Wed Apr 26 15:03:57 2000 +++ chirp-0.6pre1/lib/Unknown/Unknown.pm Sat Jul 22 04:50:51 2000 @@ -5,8 +5,7 @@ package CHIRP::Unknown::Unknown; -use lib "/usr/local/cricket/lib"; -use snmpUtils; +use lib::SNMP; sub GenConfig { diff -urN chirp-0.5/lib/WriteConfig.pm chirp-0.6pre1/lib/WriteConfig.pm --- chirp-0.5/lib/WriteConfig.pm Wed Apr 26 15:01:55 2000 +++ chirp-0.6pre1/lib/WriteConfig.pm Sat Jul 22 03:07:42 2000 @@ -87,10 +87,10 @@ print $dict . "\t" . lc($item) . "\n"; foreach my $tag (sort keys % {$config->{$dict}->{$item}}) { # HACK HACK HACK - To deal with Cricket not correctly lowercasing in some circumstances - if ($dict =~ /^target$/ && lc($tag) =~ /^targets$/) { - print "\t" . lc($tag) . "\t= " . lc($config->{$dict}->{$item}->{$tag}) . "\n"; + if (($dict =~ /^target$/) && ($tag =~ /^targets$/)) { + print "\t" . lc($tag) . "\t= " . WriteValue(lc($config->{$dict}->{$item}->{$tag})) . "\n"; } else { - print "\t" . lc($tag) . "\t= " . $config->{$dict}->{$item}->{$tag} . "\n"; + print "\t" . lc($tag) . "\t= " . WriteValue($config->{$dict}->{$item}->{$tag}) . "\n"; } } print "\n"; @@ -112,6 +112,25 @@ } return 0; +} + +sub WriteValue { + my($txt) = @_; + + # Return if value is not defined + return undef if (!defined($txt)); + + # Return if value is already double quoted + return $txt if ($txt =~ /^\s*".*"\s*$/); + + # Return if value is already single quoted + return $txt if ($txt =~ /^\s*'.*'\s*$/); + + # Return quoted if the value contains a space + return qq("$txt") if ($txt =~ /\s/); + + # Return the value + return $txt; } 1; diff -urN chirp-0.5/samples/devicelist chirp-0.6pre1/samples/devicelist --- chirp-0.5/samples/devicelist Wed Apr 26 18:05:27 2000 +++ chirp-0.6pre1/samples/devicelist Wed Jul 19 02:17:14 2000 @@ -1,4 +1,4 @@ -# This is a sample device list file suitable for use with chirplist.pl. +# This is a sample device list file suitable for use with chirptree.pl. # Format: Each line should contain the following separated by colons ":" # Subdir The subdirectory to create under the config root. # Device Name A name for the device