Accessing Raw Data for SNMP

Sources of SNMP Data

Simple Network Management Protocol (SNMP) data can be collected from the following sources:
  • HP Network Node Manager (HP NNM)
  • Round-Robin Database
In order to read the raw data from either HP NNM or rrdtool, it is necessary to run Perl scripts as part of the staging process. This means that Perl must be installed on the machine that the SAS program runs on, that is, the SAS Workspace Server, the SAS batch server, or interactive SAS.
The Perl scripts that are used by the staging code are generated as part of the code generation of the staging job. This code can be viewed and modified as necessary in the Code screen of the job.
To run these scripts in batch mode, it is necessary to set the xcmd option for the Batch server. To do so, change set USERMODS_OPTIONS= to set USERMODS_OPTIONS=XCMD.
To run these scripts from within the SAS Workspace server, it is necessary to have the SAS option XCMD turned on. By default this option is off in the Workspace server. To turn the option on, perform the following steps:
  1. Launch SAS Management Console. Log on as an administrator.
  2. Expand the Server Manager in the left panel.
  3. Expand SASITRM. Then expand SASITRM-Logical Workspace Server.
    Expanded Left Panel of SAS Management Console
    Expanded Left Panel of SAS Management Console
  4. Right-click SASITRM-Workspace Server and select Properties. The Workspace Server Properties dialog box appears.
  5. Select the Options tab and click Advanced Options.
  6. Select the Launch Properties tab to open the following dialog box.
    Launch Properties Tab of the Advanced Options Dialog Box
    Launch Properties Tab of the Advanced Options Dialog Box
  7. Select the Allow XCMD check box.
  8. Click OK to close all the open dialog boxes.
  9. Stop and then restart your object spawner service.
    Windows Specifics: To stop your object spawner service, from the Start menu, select Progamsthen selectSASthen selectSAS Configurationthen select<configuration-name>then selectObject Spawnerthen selectStop. To restart your object spawner service, from the Start menu, select Progamsthen selectSASthen selectSAS Configurationthen select<configuration-name>then selectObject Spawnerthen selectStop.
    UNIX Specifics: To stop and then restart your object spawner service, from the command line, change directories to SAS-config-dir/Lev1/SASMain/ObjectSpawner. Stop the object spawner by issuing this command: $ ./ObjectSpawner.sh stop. When you receive a confirmation that the object spawner has stopped, start it again by issuing this command: $ ./ObjectSpawner.sh start. You should receive a confirmation that the object spawner has started.
    z/OS Specifics: To stop and restart your object spawner service, stop and restart the z/OS started task associated with the object spawner. Follow the stop and restart procedures that are established at your site.

Extracting Data by Using HP NNM Tools

Versions of HP NNM that are earlier than HP NNMi 8.x provide two tools that are no longer provided with the HP NNMi 8.x and later versions of the product. However, if you have access to earlier releases of the HP NNM product, you can still use the commands that are discussed in the following section.
Versions of HP NNM that are earlier than i8.x provide two commands that enable you to extract SNMP data. The two commands are:
  • snmpCollect, which gathers SNMP data into binary files
  • snmpColDump, which reads the binary files and writes the data into ASCII files that can be processed by the SNMP staging transformation
The snmpCollect executable uses a file called snmpCol.conf to determine the metrics to collect and the devices from which to gather data.
You can create the snmpCol.conf file by using either of the following methods.
  • Use the sample UNIX script (snmpmkcf) that SAS IT Resource Management provides. The sample script is located in the sasmisc folder. It reads the snmphost and the snmpvars files, which are also located in the sasmisc folder, and creates the snmpCol.conf file.
    • The snmphost file contains a list of the device names for which SNMP data is being gathered.
    • The snmpvars file contains a list of the SNMP metrics that are to be gathered from each device. By default, the values in this list are the metrics that are in the recommended staging tables.
    Note: This method generally creates the snmpCol.conf file more quickly than using the NNM graphical user interface.
  • Use the HP NNM graphical user interface to create snmpCol.conf. The user interface prompts you to select the metrics that you want to gather and the devices about which you want to gather data. Using your responses, it then creates the snmpCol.conf file.
When the snmpCol.conf file is created, you can run the snmpCollect command to gather data. You can run the collect as often as you choose. The command collects a set of files in the location that you specify. For each metric and interface, two files are generated:
  • metricName.interface-number, that contains the raw data
  • metricName.interface-number!, that contains the information about the metrics that are collected
For example, for the metric called ifOctets, and for interface 3, the ifOctets.3 and ifOctets.3! files are generated. The SNMP staging code runs the snmpColDump command against these files to get the rawdata that is to be read and loaded into staged tables. In order to read the data, the snmpColDump executable requires both the file that contains the binary data and file that contains the information about the metrics that are collected.
Tip
The binary data files continue to accumulate until they are deleted. For best results, these data files (whose names do not end with "!") should be moved to another location before staging. The snmpCollect command then creates a new set of binary files into which the data is to be collected. The files that contain the information about the metrics (whose names end with "!") should be copied (not moved) to the other location as well. This way, the snmpCollect command can continue to use these metrics as it collects the raw data. The staging code can then read the files from the location to which they were moved or copied.

Extracting Data by Using the Round-Robin Database Tool (RRDTOOL)

The SNMP adapter can read data from a round-robin database that was created with rrdtool.
Note: The round-robin database tool, rrdtool, is a freeware package that is available for download from Tobias Oetiker. This software is widely used, often in conjunction with Tobias Oetiker's MRTG package, which is a real-time monitor of data.
The SNMP adapter reads only those round-robin databases that contain one round-robin database for each combination of the device, the network interface to which the device is connected, and the metric. The data can be gathered at any interval, and any metrics and devices can be gathered.
In order to produce the correct set of round-robin databases, SAS IT Resource Management provides a sample Perl script for data collection and storage in the round-robin database. This script, called snmpuprd.pl, is available in the sasmisc folder. The section at the top of the script enables you to specify modifications that control how the data is collected. The Perl script uses the snmphost and snmpvars files, which are located in the sasmisc folder, to determine which metrics to gather from your devices. It also uses the snmpwalk command to collect the snmp data. When you have the script set up correctly, you can use your operating system's scheduling facility to run the script at the appropriate interval.
Note: You can backload data from the rrdtool. To so, specify the Number of days to load option in the Staging Parameters property tab of the SNMP staging transformation. (This option is available only if the chosen access command is RRDTool.)

Notes about the SNMPWALK Command

The snmpwalk command is an executable that is available as part of the Net-SNMP package. This package is available as freeware that you can download from the Sourceforge.net Web site. The snmpwalk command provides an easy way to read SNMP data from specified devices.
The SNMP adapter uses snmpwalk in two places:
  • Using rrdtool: If you choose to store your rawdata using rrdtool, the script that is provided with SAS IT Resource Management uses snmpwalk to gather the data to put in the round-robin database.
  • Staging the data: The SNMP staging transformation provides the ability to collect the non-numeric data at staging time instead of at the normal regular intervals that the rest of the SNMP data is collected. This can be useful for character data that does not change frequently. If you want to collect character data and are using rrdtool to gather your rawdata, then you must collect it at staging time, because rrdtool does not store character data. If you are using HP NNM, you can set it up to gather the character data at regular intervals along with the rest of the data, or you can choose to collect it at staging time.
    If you want to use the snmpwalk method, go to the Staging Parameters tab of the SNMP transformation's property window. On the Use snmpwalk to gather character data option, select Yes. Then fill in values for the following options:
    • snmpwalk Executable: This is the path and exe file that contains the snmpwalk command.
    • HostFile for snmpwalk: This is the path and file that contains a list of the devices to poll for character data.
    • Community value for snmpwalk: This option is usually "public." Check with your SNMP administrator to ascertain the correct value for your site.
      If you choose to use snmpwalk, then a script is generated and executes when the staging code runs. This script executes the snmpwalk command in order to gather the SNMP data for specified character metrics and adds that data directly to the staged tables.

Working with the ITMS_SNMP_DeviceType Lookup Table

In order to provide better reporting, the SNMP adapter provides a SAS data table that enables you to indicate the type of device for each of the devices for which you are gathering data. This table is located by default in the SASHELP library, and contains no data. To use this table to define your device types, perform the following steps from the SAS IT Resource Management client:
  1. Locate, or create, the IT data mart that you want to use for staging SNMP data.
  2. Locate the Administrative folder. Right-click the library within that folder. (The library is called Adminnnnn, where nnnn is a random number that was generated when the IT data mart was created.)
    Select View Libname.
  3. Select the entire LIBNAME statement in the displayed box. Then right-click the LIBNAME statement and select Copy.
  4. Launch an interactive session of SAS. Use the Paste function to paste the LIBNAME statement into an Editor window.
  5. Submit the LIBNAME statement.
  6. In the Explorer window, locate the SAS data table called Itms_snmp_devicetype by drilling down into the SASHELP library.
  7. Use the Copy and Paste functions to copy this table to the Adminnnnn library.
  8. Now you can edit the table that you copied to Adminnnnn library. To do so, use VIEWTABLE to add and update rows. (To access VIEWTABLE, double-click the table in the Explorer window.)
    The value in the Device column should be the name of the device, and deviceType is the type of device.
    • The name of the device should match the device for which SNMP is gathering data. Make sure that the device names use the same case.
    • DeviceType can be any character string that helps identify the device. For example, "Router," "Switch," or "Server" would be reasonable choices for device Type.
    You can also update this table programmatically as long as the table has the device and deviceType columns.
Once this table is populated, when you run the staging code, the deviceType column in all the SNMP staging tables will have the correct value from the lookup table. If a device is not in the deviceType table, then deviceType is set to "Unknown."
If your devices are named using a convention (for example, the device type is always the first part of the name, like router_2123), you can create the deviceType value programmatically. To do so, change the expression for the deviceType column in the staged table metadata. By default, the expression for the deviceType column is: put(device, ?? $deviceType.)
You can change this to a different expression. An example is: upcase(scan(device, 1, "_"))
Or, you can use standard SAS DATA step code to create an expression. An example is:
if (device eq: "R") then 
		deviceType = "Router";
	else if (device eq: "W") then 
		deviceType = "Switch";
	else if (device eq: "S") then 
		deviceType = "Server";
	else
		deviceType = "Unknown";

Working with Management Information Base (MIB) Definitions for SNMP Staged Tables

The SAS macro %rmmb2sas enables the SNMP adapter to read Management Information Base (MIB) definitions and create the metadata for SAS IT Resource Management staged tables. This macro enables you to generate staged data from any MIBs that you have. The SAS macro is available in the SAS autocall macro library so that you can use it from any SAS session.
To use the macro, you must first create a job with an SNMP transformation in SAS IT Resource Management. To do so, perform the following steps:
  1. In the SAS IT Resource Management client, navigate to the IT Data Marts tree.
  2. Navigate to an existing IT data mart, or create a new one. (To create a new IT data mart, from the menu bar, select Newthen selectIT Resource Managementthen selectIT Data Mart. The IT Data Mart wizard opens and prompts you to enter information to specify your new IT data mart.)
  3. Create a folder in the IT data mart for your new job and tables.
  4. In the new folder, create a new job. (To create a new job, select Newthen selectJob. Then enter the information to specify your new job.)
  5. In the process flow diagram, drag the SNMP transformation from the ITRM Transformations folder of the Transformations tree and drop it onto the job.
  6. Save and close the job.
  7. Select the job in the tree and in the Basic Properties window, scroll to the Metadata ID property, and make a note of the value. This is the job ID that you need to run the macro in the next set of steps.
After the job is created, you can run the %rmmb2sas macro. To do so, perform the following steps:
  1. Invoke an interactive SAS session.
  2. Specify the parameters for the %rmmb2sas macro. For information, see Introduction to the Macros in SAS IT Resource Management.
  3. Submit the macro call to read the MIB definitions. The macro can generate a report of the staged tables that would be created from this definition, or it can create the staged table metadata.