SNM Configuration and Operation Guide
- Prerequisites and Tools
- Configuring SNM (Win32 and Linux)
- Setup - snm.cgi
- Setup - Configuration File
- Setup - Target File
- Setup - Graph File
- How to configure Modules in SNM
- How Alerts in SNM work
- How Attribute Discovery works
- How SNM works
- Starting SNM
An understanding of xml, ip networking and snmp is assumed.
- Editing Tool:
Komodo is used to develop SNM, hence is recommended if you do not already have a preferred editor. - snmp Query Tool:
Getif for Win32 or net-snmp for Linux are recommended for the snmp querying of devices to assist in determining OIDs, etc.
Up to four files may require modification:
- <web directory>/snm.cgi
- Configuration File (eg. <config directory>/config.xml)
- Target File (eg. <config directory>/targets.xml)
- Graph File (eg. <config directory>/graph.xml)
When making changes to the Configuration or Target files, SNM will need to be restarted
to activate the changes.
SNM does not need to be restarted for changes to Graph files, just a refresh of
the web browser.
Below are details of all configuration attributes, including descriptions, limitations and examples. Each attribute is also identified as optional or mandatory. If you are new to SNM, this may seem daunting. To assist in overcoming this it is recommended to:
- Start with a minimal configuration of a few devices by removing or commenting out
optional components
<!-- an example of xml comments -->
An example of prefixing "no_" to comment out: no_font="C:\WINNT\Fonts\verdana.ttf" - Within a console (dos or unix command line), use the test (-t) mode when first executing SNM
- If test mode is successful, execute SNM in normal mode
- Modify config.xml, targets.xml and graphs.xml as appropriate and restart SNM as necessary. In some circumstances .rrd file may need to be deleted (SNM will create new files for you). If there are difficulties, use verbose (-v) mode and logging to assist diagnosis
- Upon the initial configuration stabilizing, commence expanding the targets, graphs and options as required
Setup - snm.cgi
- When using Apache 2 in a Win32 environment, line 1 in snm.cgi may require
modification:
- Example for Linux and Win32/IIS: line 1: #!/usr/bin/perl -w
- Example for Win32/Apache2: line 1: #!c:/perl/bin/perl.exe -w
so that the first line of snm.cgi points to the Perl executable
- Line 27 and 28 in snm.cgi may require modification:
- For Win32: line 27: my $cfgfile_win32 = "C:\\Program Files\\snm\\config.xml";
- For Linux: line 28: my $cfgfile_linux = "/etc/opt/snm/config.xml";
Where: $cfgfile_xxxxx = The full path of the location of the configuration file
Note: For Win32, use \\ for directories instead of \.
Setup - Configuration File : <config directory>/config.xml
The configuration file, is a XML file with the following properties (refer to config.xml as an example):
<opt>
<language language="en" />
<config directory="C:\Program Files\snm" />
<app directory="C:\Program Files\snm" />
<web directory="C:\Inetpub\wwwroot\snm" />
<log file="C:\Inetpub\wwwroot\snm\snm.log" purge="7" />
<alerts>
<mail server="192.168.1.50" from="snm@example.com" />
<alert id="syslog" syslogserver="mysyslogserver" syslogseverity="alert"/>
<alert id="email" mailto="snm@example.com" />
<alert id="logandmail" mailto="snm@example.com;admin@example.com"
syslogserver="mysyslogserver" syslogseverity="warning"/>
</alerts>
<attributes frequency="24" />
<default frequency="300" timeout="3" />
<ping module="internal" />
<snmp port="161" retries="2" />
<image format="PNG" width="520" height="120"/>
<graph font="C:\WINNT\Fonts\Verdana.ttf" font_color="555555" tab="30" />
<rrdstep timeout="2" />
<!-- <nix_mgt user="snm" group="snm" PID_path="/var/run/snm.pid"/> -->
</opt>
<language> | |
---|---|
language= (mandatory) |
the language to present SNM in.
For Win32 users using a non-English language in SNM, the command prompt window will
not display extended characters ( e.g. in 8859-1 ) properly. This is a problem with
Windows console and not Perl or SNM. To create additional languages, refer to: How to.... |
<config> | |
directory= (mandatory) |
the full path to a directory, where the configuration files are located. The four
configuration files are: config.xml, targets.xml, graphs.xml
and discover.xml.
|
<app> | |
directory= (mandatory) |
the full path to a directory, where the application files are located. Subdirectories
lib and lang will be created in this directory.
|
<web> | |
directory= (mandatory) |
the full path to a writeable directory, where the cgi and htmt template files are
located. Subdirectories rrd, graphs and lang will be
created in this directory.
|
<log> | |
file= (recommended) |
the full path to the log file
|
purge= (optional) |
The number of days before log file entries are purged.
|
<alerts> | |
<alerts> - <mail> | |
server= (optional) |
the SMTP e-mail server that alerts are sent to.
|
from= (optional) |
the e-mail address the alerts are sent from.
|
username= (optional) |
the username to authenticate against the SMTP e-mail server
|
password= (optional) |
the password to authenticate against the SMTP e-mail server
|
<alerts> - <alert>s | |
id= (mandatory) |
the name of the alert:
|
mailto= (optional) |
the e-mail address the alerts are sent to.
|
syslogserver= (optional) |
the IP address or name of the syslog server
|
syslogseverity= (optional) |
the severity of the syslog message (align with rfc 3164)
|
<attributes> How Attribute Discovery works | |
in_file= (optional) |
the full path to the attributes file
|
out_file= (optional) |
the file name of the attributes output file. This file will be created in each
target directory the attributes are discovered.
|
frequency= (optional) |
The number of hours between each attribute discovery.
|
<default> | |
frequency= (optional) |
the default frequency (in seconds) that data will be fed into RRD
|
timeout= (optional) |
the period (in seconds) to wait for a response to a query
|
<ping> | |
method= (optional) |
use the internal (perl) ping library or the external (operating system) ping file
For Linux/Unix only: Using an external ping (e.g. /bin/ping) allows snm to be run as a non-root user |
<snmp> | |
port= (optional) |
the snmp agents UDP port
|
retries= (optional) |
The number of times the snmp agent on the target will be queried for data
|
<image> | |
format= (optional) |
the image format. You may choose:
|
width= (optional) |
the WIDTH of the graphic (in pixels):
|
height= (optional) |
the HEIGHT of the graphic (in pixels):
|
<graph> | |
font= (optional) |
the font path and file name used to create the graphs
|
back_color= (optional) |
the RRBBGG color to be presented by the graph font:
SEE the wc3 web colors for more information |
canvas_color= (optional) |
the RRBBGG color to be presented by the graph font:
|
font_color= (optional) |
the RRBBGG color to be presented by the graph font:
|
tab= (optional) |
the tab width (in pixels) used to create the legend in the graphs
|
<rrdstep> | |
timeout= (optional) |
"step_timeout*frequency" is the timeout value (seconds) that without getting
data, rrdtool will plot 0 in the graphics.
|
<nix_mgt> | |
user= group= PID_path= (optional) |
For Linux/Unix only: Set the user, group and process
IDs
Note: If you have a requirement for modifying the ownership of the SNM process when
running on Linux/Unix, then <nix_mgt> will enable this. Otherwise
use of <nix_mgt> is unnecessary.
To create a PID for SNM:
Default: user, group and process IDs are not set |
Setup - Target File : <config directory>/targets.xml
Note: If the number of targets becomes too large, multiple target files can be configured, refer to: How to....
The target file is a XML format file. Additional targets should be added, one for each device required. (refer to targets.xml as an example):
<targets>
<target id="router_1" ip_address="127.0.0.1" community="public"
port="161" alert="2:email" attributes="no">
<template id="ping" ping="4" data_source_type="GAUGE" />
<template id="sysUpTime" oid="1.3.6.1.2.1.1.3.0"
data_source_type="GAUGE" frequency="900" />
<template id="ifUsage" oid="1.3.6.1.2.1.2.2.1.int" data_source_type="COUNTER">
<interface int="10.2" description="Ethernet 0 ifInOctet"
input_min="0" input_max="10e6" />
<interface int="16.2" description="Ethernet 0 ifOutOctet"
input_min="0" input_max="10e6" />
</template>
</target>
<target id="win_host" ip_address="192.168.1.100" version="2"
community="public" alert="2:syslog">
<template id="ping" ping="4" data_source_type="GAUGE" />
<template id="sysUpTime" oid="1.3.6.1.2.1.1.3.0"
data_source_type="GAUGE" frequency="900" />
<template id="ifUsage" oid="1.3.6.1.2.1.2.2.1.int" data_source_type="COUNTER">
<interface int="10.16777219" description="Ethernet 0 ifInOctet"
input_min="0" input_max="10e6" />
<interface int="16.16777219" description="Ethernet 0 ifOutOctet"
input_min="0" input_max="10e6" />
</template>
<template id="ifErrors" oid="1.3.6.1.2.1.2.2.1.int"
data_source_type="COUNTER" frequency="900">
<interface int="13.16777219" description="Ethernet 0 ifInDiscard"
input_min="0" />
<interface int="19.16777219" description="Ethernet 0 ifOutDscard"
input_min="0" />
<interface int="14.16777219" description="Ethernet 0 ifInError "
input_min="0" />
<interface int="20.16777219" description="Ethernet 0 ifOutError "
input_min="0" />
</template>
<template id="win_disk" oid="1.3.6.1.4.1.311.1.1.3.1.1.5.1.3.2.int"
data_source_type="GAUGE" frequency="3600">
<!-- Refer to the OID .1.3.6.1.4.1.311.1.1.3.1.1.5.1.1 to obtain
logical disk information. -->
<!-- If using this OID to monitor Windows 2000 disk space, remember
to initialise diskperf -y. -->
<interface int="67.58" description="Volume C" int_alert="lt:80:1" />
<interface int="68.58" description="Volume D" int_alert="lt:80:1" />
<interface int="69.58" description="Volume E" int_alert="lt:80:1" />
</template>
<template id="win_cpu" oid="1.3.6.1.2.1.25.3.3.1.2.int" data_source_type="GAUGE">
<interface int="3" description="cpu load" input_min="0" input_max="100" />
</template>
</target>
</targets>
*Note: If an interface is not configured, SNM defaults it to '0' |
|
<target> | |
---|---|
id= (mandatory) |
The name of the target
|
ip_address= (mandatory) |
The ip address or name of the target
|
version= (optional) |
The snmp version of the target.
|
community= (optional) |
The snmp read community of the target.
|
username= (optional) |
The snmp v3 (noAuthNoPriv) username of the target.
|
alert= (optional) |
|
port= (optional) |
The target's snmp agent UDP port
|
attributes= (optional) |
When <attributes> is set in the config file (e.g. config.xml),
attributes are discovered on all targets using the first <suite>
unless:
Refer to: How Attribute Discovery works |
<template> | |
id= (mandatory) |
The name of the template
|
ping= or oid= or module= (mandatory) |
The type of query ( ping, oid, or module ) and the value to query.
|
data_source_type= (recommended) |
The type of data returned from a query - refer to rrdtool documentation
|
frequency= (optional) |
The frequency this template for the target will be queried in seconds.
|
<interface> | |
int= (recommended) |
The interface or sub-interface to be measured
|
description= (optional) |
A description of the interface
|
input_max= and input_min= (recommended) |
If input_min and/or input_max are defined, any value outside the defined range will
be regarded as *UNKNOWN*.
|
int_alert= (optional) |
Set an interface alert criteria
|
Setup - Graph File : <config directory>/graphs.xml
Note: If the number of graphs becomes too large, multiple graph files can be configured, refer to: How to....
The graph file is a XML format file. Additional graphs should be added, one for each graph required. (refer to graphs.xml as an example):
<graphs>
<page menu="Site 1:power:ups-1" description="Graphs for device: APC ups-1">
<graph description="output load" vertical_label="load (%)" short_label="%"
graph_min="0" graph_max="100" k_base="1000" number_format="fixed">
<plot plot="LINE2" color="0000EE" description="output load">
[ups-1:apc_ups_load:0:MAX]</plot>
</graph>
</page>
<page menu="Site 1:networks:router_2" description="Graphs for device: router_2">
<graph description="Cisco CPU Load" vertical_label="Load (%)" short_label="%"
graph_min="0" graph_max="100" k_base="1000" number_format="fixed">
<plot plot="LINE2" color="0099cc" description="Cisco CPU load (1min)">
[router_2:cisco_cpu:57.0:MAX]</plot>
<plot plot="LINE2" color="0000ee" description="Cisco CPU load (5min)">
[router_2:cisco_cpu:58.0:MAX]</plot>
</graph>
<graph description="Network Usage" vertical_label="bit/sec" short_label="bit/s"
graph_min="0" k_base="1000">
<plot plot="AREA" color="0099cc" description="Hssi6/1/0.1-dlci212 TotalOctets"
line="95:0099cc">
[router_2:ifUsage:10.15.212:MAX],[router_2:ifUsage:16.15.212:MAX],+,8,*</plot>
<plot plot="LINE2" color="0000EE" description="Hssi6/1/0.1-dlci212 ifInOctet ">
[router_2:ifUsage:10.15.212:MAX],8,*</plot>
<plot plot="LINE2" color="006666" description="Hssi6/1/0.1-dlci212 ifOutOctet ">
[router_2:ifUsage:16.15.212:MAX],8,*</plot>
<plot>1024e3</plot>
</graph>
</page>
</graphs>
|
|
<page> | |
---|---|
menu= (mandatory) |
The page navigation path
|
description= (recommended) |
A description for the page of graphs
|
<graph> | |
description= (recommended) |
A description of the group of metrics that are being measured
|
vertical_label= (recommended) |
A description of the vertical scale units of measure:
|
short_label= (optional) |
A short description of the vertical scale units of measure:
|
comment= (optional) |
Place a comment at the bottom of the graph.
Note: The use of XML for graphs.xml restricts the use of &, ",
<, > in the comments. To print these, replace: |
graph_max= and/or graph_min= (optional) |
The upper and lower limits defined on the graph:
|
autoscale= (optional) |
By default the graph will be autoscale="normal" so that it will
adjust the y-axis to the range of the data. This may be sub optimal when you need
to graph something like 260 + 0.001 * sin(x). The autoscale=alt
(alternate) option calculates the minimum and maximum y-axis from the actual minimum
and maximum data values. The example would display slightly less than 260-0.001
to slightly more than 260+0.001
|
k_base= (optional) |
The number of units per "k":
|
number_format= (optional) |
The format of the numbers in the graph legend
Hint: It is recommended to initially use SI for all number_formats, only changing them to fixed if the output is overly complex or confusing. Where the number is always 3 digits or less, it may be appropriate to use fixed: e.g. for cpu the number is always ≤ 100, so to avoid 971.12 m% (milli-percent), use fixed i.e. 0.97 %. |
<plot> | |
<plot> |
Either an RPN expression or a number
For RPN expression
For number:
Examples:
|
plot= (recommended) |
The plot type to be presented on the graph:
|
color= (recommended) |
The RRBBGG color to be presented on the graph:
|
description= (recommended) |
A description of the plot
|
line= (optional) |
Draw a horizontal line on the graph of the AVERAGE, MAXimum or
95th percentile
|
When configuring the targets file (eg targets.xml), modules may be configured within each target. If modules are used, the following requirements apply:
- Modules must be located in SNM's \lib directory.
- The module must return a single numeric value. SNM validates this, returning UNKNOWN if invalid.
- The module is required to exit gracefully in the event of a failure.
- The module must be written in perl.
- Three optional variables are avaivable within SNM to assist module parameters:
- %ip_address% - the ip address of the target
- %interface% - the interface id of the template of the target
- %community% - the snmp community string for the target
An example is apache_hits where %ip_address% is used as a module parameter:
<metric module="Apachestats::stats( '%ip_address%', 'apache_total_hits')"
data_source_type="COUNTER" convert="60" plot="LINE2"
color="00BB00" consolidate="MAX">apache_hits</metric>
It is strongly recommended to test the module before using within SNM.
For further information, refer to: Modules
Alerts are triggered by two methods:
- <alert> - failure of the target to respond to a (ping, snmp or module) query. Configuration is only required for sending e-mail or syslog alerts.
- <int_alert> - a query result does not meet a criteria. Configuration is required to set the criteria.
Note: to e-mail/syslog a <int_alert>, an <alert> must be configured
Alerts are presented in two forms:
- On the SNM Alert web page (snm.cgi).
- All alerts are presented on the SNM Alert web page (no configuration required)
- Interface alerts are presented on the SNM Alert web page if <int_alert> is configured
- Send via e-mail and/or syslog. The sending of alerts via e-mail/syslog is optional.
To send e-mail/syslog alerts:
- Configure <mail_server> and <alert>s in the configuration file (config.xml)
- Configure <alert> in the target file (target.xml)
- Optionally configure criteria in <int_alert> in the target file (target.xml)
Attribute discovery is designed to allow the viewing of target properties that change infrequently (e.g. System Description and System Contact).
- Attribute discovery is optional.
- When activated, attribute discovery is delivered by querying of snmp properties on targets and storing the results in <web directory>\rrd\<target>\attributes.xml.
Four components comprise attribute discovery:
- Configuration file (e.g. config.xml)
If attribute discovery is required, <attributes> are configured. Refer to: Setup - Configuration File. - Discover file (e.g. discover.xml)
Within discover.xml there are suites (e.g. <suite id="">). Each target uses one or more <suite>s, by default the first suite is used, unless in <target attributes=""> is configured. Each <suite> comprises the <value>, <table> and <column> snmp oids to query. Note, the <value> oids return a single value and the <column> oids return multiple values. The file discover.xml can be modified to provide differing discovered snmp oid values (upon testing and restarting SNM). - The attributes file (e.g. <web directory>\rrd\<target>\attributes.xml)
Contains the query return values, ready for display using a web browser. - The <target attributes="">
Is configured to either select a non-default <suite>, multiple <suite>s, or to not discover the target by setting <target attributes="no">.
|
|
<suite> | |
---|---|
id= (mandatory) |
The suite identifier
|
<value> | |
oid= (mandatory) |
The snmp OID, in dotted number format, that returns a single value
|
description= (mandatory) |
A description of the Attribute/OID that is being queried
|
convert= (optional) |
Convert a returned value.
|
calculate= (optional) |
An RPN (http://en.wikipedia.org/wiki/Reverse_Polish_notation)
suffix to derive the attribute value
|
<table> | |
description= (mandatory) |
A description of the table of attributes being queried
|
<column> | |
oid= (mandatory) |
The snmp OID, in dotted number format, that returns one-to-many values
|
description= (mandatory) |
A description of the Attribute/OID that are being queried
|
convert= (optional) |
Convert a returned value.
|
calculate= (optional) |
An RPN (http://en.wikipedia.org/wiki/Reverse_Polish_notation)
suffix to derive the attribute value
|
<translate> (used by both <value> and <column>) | |
value= (mandatory) |
The value to match against return column values |
text= (mandatory) |
The replacement text if value matches a return column value |
There are two program files that comprise SNM, the server program snm.pl and the browser program snm.cgi.
- snm.pl is the server program that:
- loads then verifies the configuration and target files,
- queries targets at predetermined intervals,
- writes the data to .rrd files (creating them if they do not exist),
- creates an alert file of unsuccessful queries and criteria, and
- sends e-mail alerts.
There are two methods of running the SNM server:
- Console Mode - using the DOS or terminal console. The SNM server has no graphical interface, the method of viewing SNM server messages are via the console or the log file.
- Service Mode - When SNM server is correctly configured and has been operating in console mode without issue for a reasonable time, the SNM server can be configured to operate as a service. This eliminates the use of the console and provides for automatic start-up upon the server booting without user login or interaction.
snm.pl creates sub-directories in <web_dir>, one for each target. In each target subdirectory, one .rrd file will be produced for each template associated with that target.
- snm.cgi is a program that creates the graphs and presents them via a web
browser (Internet Explorer, Firefox, etc).
- snm.cgi is executed each time the user requests new or updated presentation of the graphs.
- New graphs are generated.
- Data is developed from snm.cgi and parsed to template files (.htmt) used to create the presentation. The output is then presented to the user using a standard web browser.
- The alert file is also queried and displayed as requested by the user.
- The most recent 100 lines of the log file are also queried and displayed as requested by the user.
Normal SNM Server Operation
For Win32 users using a non-English language in SNM, the command prompt window will
not display extended characters ( e.g. in 8859-1 ) properly. This is a problem with
Windows console and not Perl or SNM.
Assuming a console running in a window (as opposed to running full-screen) then
two things are required:
1. The default raster font used for console windows doesn't know about 8859-1 /
latin-1, so change it. Use the system menu, Properties and select "Lucida Console"
instead of "Raster Fonts".
2. Use the CHCP command to select the
1252 (Latin 1) codepage: CHCP 1252
Now re-run SNM in console mode and you should see the correct extended characters.
At the console prompt:
- Go to the directory where snm.pl resides:
Example: C:\Program Files\snm> - If starting for the first time it is recommended to run the program in test mode:
Win32 Example: C:\Program Files\snm>snm.pl -c config.xml -t, or
Linux Example: [root@host snm] perl snm.pl -c /etc/opt/snm/config.xml -t.
If any error messages are displayed after the test, attend to as appropriate. - Run the program:
Win32 Example: C:\Program Files\snm>snm.pl -c config.xml, or
Linux Example: [root@host snm] perl snm.pl -c /etc/opt/snm/config.xml. - In the console a start-up message should appear:
Example: 0000000000 main(): Loop start Day Mth 0 00:00:00 0000 - If any error messages are displayed after the start-up, attend to as appropriate.
- Only when SNM has been tested for a time, if appropriate, it can be installed as a service.
At the console prompt, to stop SNM, use Ctrl^C.
Note, it may take up to 10 seconds to stop processing.
SNM Browser Operation
To view the graphs via a web interface, go to the configured web path / cgi file
name:
Example: http://localhost/snm/snm.cgi
SNM Server Operation Options
To test and verify the correct operation of SNM, two settings have been developed.
Also, in the event of anomalies, these two methods can be used to correct the condition:
Note: It is recommended that test and verbose modes are only activated in console mode.
- Test Mode (snm.pl -c config.xml -t)
When test mode is activated, SNM will test and log itself including the configuration and target files but will not query any targets. Included is a test of RRDs (the perl RRDs shared module) to a test_x.rrd file, where the test .rrd file is created from the command rrdtool create test.rrd DS:test:GAUGE:300:U:U RRA:LAST:0.5:1:10. - Verbose Mode (snm.pl -c config.xml -v)
When verbose mode is activated, SNM will provide verbose logging of all activities to assist in verifying and identifying configuration corrections including target query anomalies.
Both test mode and verbose mode will output to console as well as to the log file (if defined in the configuration file).
SNM Server Maintenance
- The menu in the web browser provides an alert status.
- Remember to regularly review the log file if it has been defined (SNM will purge old logs automatically).