Cacti 0.8 Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – defining a data template

The hrSystemProcesses MIB provides information on the current number of running processes on a system supporting the host resource MIB. This MIB is a collection of system-specific data such as logged in users, disk space, installed software packages, and other valuable information which can be retrieved using SNMP.

  1. Log on to your Cacti system and go to Templates | Data Templates.
  2. Click on the Add link at the top-right of the list. This will open a new page where you can define your data template.
  3. Enter Host-Resource-Mib: Running Processes in the Name field.
  4. Enter |host_description| - Running Processes as the Name for the data source. The |host_description| text is a special Cacti variable which will be replaced with the actual host description of the device where this data template will be added. You can find a list of these Cacti variables at the following link: http://docs.cacti.net/manual:087:6_reference.variables#variables.
  5. Select Get SNMP Data as the Data Input Method.
  6. Deselect the Hourly (1 Minute Average) RRA, as the polling interval will be 5 minutes anyway and breaking this down to a 1 minute average does not provide more details.
    Time for action – defining a data template
  7. Enter runProcesses as the Internal Data Source Name of the Data Source Item.
  8. Enter 1000 as the Maximum Value. There should never be 1000 processes running at the same time.
  9. The Data Source Type should be Gauge, as this is what the snmpwalk example from above returns.
  10. Keep everything else to the default values and click on Create.
    Time for action – defining a data template
  11. You're not done yet. Clicking on the Create button should have added some additional fields to the end of the page. Here you can add the SNMP-specific Custom Data.
  12. As you are going to retrieve the active processes, enter .1.3.6.1.2.1.25.1.6.0 as the OID.
    Time for action – defining a data template
  13. Click on the Save button and you're done.

What just happened?

You just created your first SNMP-based data template. SNMP-based data templates are the most common templates used within Cacti. In the example you used the hrSystemProcesses MIB to template a Get SNMP data input method in order to get the actual running processes on a system. You also defined a Maximum Value so Cacti knows the range of values which the returned data is allowed to fall within.

Tip

Always define a good maximum value

If the value is defined as 0, the SNMP poller will always fail with an error message of WARNING: Result from SNMP not valid. Partial Result: U, so make sure to set a good maximum value.

This basic example can be adapted to create a data template for any kind of SNMP. A good webpage to find SNMP OIDs/MIBs to poll is the www.mibdepot.com site. The site provides free information on almost any SNMP data that can be queried.

Have a go hero – template for currently established TCP connections

Let's assume that you have a server with performance issues. Maybe users are unable to connect to it at a specific time of the day. Wouldn't it be good to have some data on the server which will provide some valuable information for further troubleshooting or even letting us identify a problem before the users are aware of it? In this special case, we want to know the number of currently established TCP connections on a system to identify a possible build up of connections to a point where no more connections can be created. What does the data template for this look like? A small hint: Look for the TCP-MIB.

Solution: Take the data template example and duplicate it. Go to Templates | Data Templates and select it. From the drop-down box at the bottom select Duplicate and then Go. In the following page, enter TCP-MIB: Established TCP Connections as the title then click on Continue. Edit the template again and change the name fields to fit the new data. Enter tcpCurrEstab as the Internal Data Source Name and use .1.3.6.1.2.1.6.9.0 as the OID. Click on Save and you're done.