天天看点

控制台-网络管理之在Cacti系统中导入MIB信息库

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

步骤1:创建一个新的SNMP query xml 文件

首先我们需要创建一个.xml文件告诉Cacti系统要获取什么信息以及如何获取。此步骤最困难的部分是准确选定要使用的MIB变量。工业标准服务器有一个统计每个系统进程5分钟平均CPU利用率的私有MIB。MIB变量是一整套信息标准,像总流量、错误包、丢弃包、广播包等。但是,这类信息常常可能有着多个数据来源(比如,一台交换机有可能拥有几百个网络接口)。为了让这些接口在信息查询时保持各自的独立性,在普通的MIB变量的结尾加上了一个索引值。这个索引值用于区分MIB变量关联的不同接口。然而,这个值不是固定的,设备重启后值会发生改变。因此,我们必须告诉Cacti系统什么MIB变量包含这个索引,什么变量能检测、使用这个索引,然后得到一些有用的信息。在工业标准的服务器条件下,索引包含在1.3.6.1.4.1.232.11.2.3.1.1.1实际使用率位置在.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文件需要创建的新查询

<interface>

<name>Get CompaqProcessors</name>

<description>Queries a host for alist of monitorableprocessors</description>

<oid_index>.1.3.6.1.4.1.232.11.2.3.1.1.1</oid_index>

<fields>

<cpqHoCpuUtilIndex>

<name>Index</name>

<method>walk</method>

<source>value</source>

<direction>input</direction>

<oid>.1.3.6.1.4.1.232.11.2.3.1.1.1</oid>

</cpqHoCpuUtilIndex>

<cpqHoCpiUtilFiveMin>

<name>5 MinuteUtilization</name>

<method>walk</method>

<source>value</source>

<direction>output</direction>

<oid>.1.3.6.1.4.1.232.11.2.3.1.1.3</oid>

</cpqHoCpiUtilFiveMin>

</fields>

</interface>

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.

Name和description是可选项,对Cacti操作没有影响。Oid索引字段应该包含此次查询的MIB变量。任何区域内的查询将使用oid索引采集到的索引值。任何数据查询字段区域内必须包含至少两种变量:一种是使用索引另一种是采集数据去绘制。

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.

在上面的实例中,在fields字段区域中有两个变量: cpqHoCpuUtilIndex andcpqHoCpiUtilFiveMin。名字可以是任何包含大小写字母的字符。数字和标点会引起错误。 多数查询方法设置成walk返回值T是安全的。源值允许你对查询的返回值进行一些处理。在这个简单的例子中,我们设置成“value”。Direction字段是非常重要的。Input字段是不变的字段。就像索引值、description字段、或者name字段。Input字段被cacti用来索引MIB变量。Output字段关于制图的设置的字段。

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.

一旦你创建了xml文件,保存在/resource/snmp_queries/目录下。我们将调用compaq_cpu.xml。不要在name字段中使用空格或特殊字符,以免后面引起问题。

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)

Click on Save.

点击创建。进入附加字段。在Data Input Method区域,最前面的三个选项应该总是被设置为下面的值:

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:

在graph template视图的右上角点击“add”按纽。屏幕中出现graphtemplate的名称,点击保存,出现一些额外的选项。点击右边的add按纽,填写以下的字段:

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.

你可以继续增加其它项去显示最大、最小和当前CPU利用率。然而,不是必需的。这里不讨论了。

再点击右边的add按纽。输入数据源的名称,在#1项的下面设置一个检查标记。这将关联数据源和图形。点击保存。

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.

步骤6:为Data Query增加Graph template

打开Data Query,下滚到 “Associated GraphTemplates”区域,点击Add。输入图形名称,选择下拉框中的图形模板,点击保存。你现在应该可以使用新的MIB变量了。

继续阅读