There are two possible ways to add a new indexed MIB variable toCacti. The first, and easiest, is to modify an existing SNMP query.The second, is to create a new SNMP data query from scratch. Sincemodifying an existing query is simply a subset of creating a newquery, only the second will be described. This how-to will lead you through the steps of creating acompletely new SNMP data query and integrating it into Cacti, usingthe CPU utilization of a Compaq Proliant server as an example.
有两种方法可以将MIB文件导入CACTI。首先,最容易的方法是修改一个已存在的SNMP data query。其次,是新建一个SNMPdata query。由于第一种方法:修改已创建的data query是第二种新建dataquery的一个子集,以下只介绍第二种方法。
Step 1: Create a new SNMP query XML file First we need to create an XML file to tell Cacti what informationto get and how to get it. The most difficult part of this step isdetermining the exact MIB variables to use. Proliant servers have aproprietary MIB that contains the 5 minute average CPU utilizationfor each processor. MIB variables stand for one piece of information like totaltraffic, errors, discards, multicast packets..... However, it isoften possible to have more than one source for this data (I.E. aswitch can have several hundred network interfaces). To keep theseinterfaces separate when querying a device for a single piece ofinformation, an index value is added to the end of the normal MIBvariable. This index value is used to distinguish one interfacefrom the others on all MIB variables associated with thatinterface. However, this value is not fixed. It can change any timethat the device is rebooted. Thus we must tell Cacti what MIBvariable contains the index, and then tell it what variables it canpoll, using this index, to get some useful information. In the caseof our proliant server, the index is contained at1.3.6.1.4.1.232.11.2.3.1.1.1 The actual utilization is located at.1.3.6.1.4.1.232.11.2.3.1.1.3
The following is the XML file that needs to be created for this newquery.
以下是这个xml文件需要创建的新查询
“
Get CompaqProcessors Queries a host for alist of monitorableprocessors .1.3.6.1.4.1.232.11.2.3.1.1.1
Index walk value input .1.3.6.1.4.1.232.11.2.3.1.1.1
5 MinuteUtilization walk value output .1.3.6.1.4.1.232.11.2.3.1.1.3
”
Name and description are optional fields and have no affect on theoperation of Cacti. The oid_index field should contain the MIBvariable that contains the index for this query. Anything inside of the section will be queried using the indexvalues gathered from the oid_index. There must be at least twovariables in the fields section in any data query: one to use as anindex and one gathering data to plot.
In the example above, there are two variables given in the fieldssection: cpqHoCpuUtilIndex and cpqHoCpiUtilFiveMin. The names canbe anything so long as they only contain characters from a-z andA-Z. Numbers and punctuation will cause an error. T is safe toleave method set to walk for most queries. The source value allowsyou to do some processing on the value that the query returns. Inthis simple case, we will leave this set to “value”. The Directionfield is very important. Input fields are fields that do not changeover time. These are generally things like the index value, adescription field, or a name. Input fields will be used withincacti to index the MIB mariables. Output fields are those fieldswhich can be graphed.
Once you have created your XML file, save it in the/resource/snmp_queries/ directory. We will call our filecompaq_cpu.xml. Do not use any spaces or special characters in thefile name as it may cause problems later.
Step 2: Create a Data Query in Cacti Open the Data Queries menu in Cacti and click on the add button atthe top right hand side of the screen. Fill in the fields asappropriate: Name: your name for this query Description: a description of this query… What does it do? Xml Path: The path to your query. In this example it should read“/resource/snmp_queries/compaq_cpu.xml” Data Input Method: Select the type of query. Since this is SNMP,choose Get SNMP Data (Indexed)
步骤2:在Cacti中创建一个Data Query
打开Data Queries菜单,点击右上角的add按纽,填写适合的内容
Name:查询的名称
Description:查询的描述
Xml path:文件所在路径。在本例中应该在“/resource/snmp_queries/compaq_cpu.xml”
Data Input Method:选择查询类型。因为是snmp协议,选择SNMP Data(Indexed)
The click on “Create”. This will bring up some additional fields.In the Data Input Method section, the first three options shouldalmost always all be checked and have the following values: Index Type: SNMP Field Name (Dropdown) Index Value: SNMP Field Value (From User) Output Type ID: SNMP Output Type (Dropdown)
Index Type: SNMP Field Name (Dropdown) Index Value: SNMP Field Value (From User) Output Type ID: SNMP Output Type (Dropdown)
点击保存。
Step 3: Create a Data Template Navigate to the data template screen and click on the “add” buttonat the top right hand side of the screen. In the screen thatappears fill in the fields as follows: Name (Data Templates section): the name for the data template Name (Data Source Section): The name that cacti will automaticallygenerate for all new data sources of this type. The author hasused: |host_description| CPU |query_cpqHoCpuUtilIndex|. Data Input Method: Get SNMP Data (Indexed) Internal Data Source Name: Choose a name that only usesalphanumeric characters. This is for Cacti Internal use only. Theauthor has used compaq_cpu. Minimum Value: Since this is a % utilization, 0 is the bestchoice. Maximum Value: It is impossible to have more than 100% utilization,so enter 100.
Click on Save. This will bring up yet more fields to fill in. Placea check mark next to the fields: Index Type, Index Value, andOutput Type ID and click on save.
步骤3:创建Data Template
导航至data template界面点击右上角的“add”按纽。出现以下字段: Name (Data Templates section): 数据模板的名称 Name (Data Source Section): Cacti自动为新数据源生成的名称。 The author has used:|host_description| CPU |query_cpqHoCpuUtilIndex|. sources of thistype. The author has used: |host_description| CPU|query_cpqHoCpuUtilIndex|. Data Input Method: Get SNMP Data (Indexed) Internal Data Source Name: Choose a name that only usesalphanumeric characters. 选择一个字母数字的字符名称。只在Cacti内部使用。笔者在本例中用了compaq_cpu. Minimum Value: Since this is a % utilization, 0 is the bestchoice.百分比,最佳是0 Maximum Value: It is impossible to have more than 100% utilization,so enter 100.输入100
Step 4: Create a Graph Template
Navigate to the graph template screen and click on the “add” buttonat the top right hand side of the screen. In the screen thatappears type in a name for the graph template and click on save.This will display some additional sections. Click on the add button to the right of the Graph Template Itemssection. Fill in the fields as follows:
Data Source: Select the data source that you created in theprevious step.上一步创建的data source Color: Pick something that you like.选择颜色 Graph Item Type: Since we are only graphing one item, selectAREA.只画一个数据项,选择AREA Consolidation Function: Select Average选择平均值 CDEF Function: None Value: Leave this entry blank保持为空 Gprint Type: Normal普通 Text Format: This will be displayed at the bottom of the graph.Enter something logical like “CPU”将会显示在图形的底部。输入像“CPU”这类的一些文字。 Click on save.点击保存。 You can continue adding other items to display the maximum,minimum, and current CPU utilization. However, they are notnecessary, and will not be covered here. Next click on the add button to the right of the Graph Input Items.Enter a name for the data source and place a check mark next toItem #1. This will link the data source with a graph item. Click onSave.
Step 5: Create a Host Template Open the Host Templates menu and click on the “add” button. Enter aname for the Host Template and click on save. Reopen this template.(I have not found a way to do this without having to reopen thetemplate. If anyone has any suggestions, I would love to hear them)Select the data query that you created earlier from the drop downbox under the “Associated Data Queries” section and click onadd.
步骤5:创建一个Host Template.
打开HostTemplate菜单点击"add"按纽。输入一个模板名称,保存。再打开这个模板。(我没有找到方法不用重新打开模板。如果谁有建议,我会洗耳恭听。)选择之前在“Associated Data Queries” 部分的drop down box创建的dataquery,点击保存。
Step 6: Add the Graph template to the Data Query
Open up the Data Query, scroll down to the “Associated GraphTemplates” section and then click on Add. Enter a name for thisgraph and select the graph template from the drop down window.Click on save. You should now be able to use your new MIBvariables.