Problems creating XML datasheet for Juniper M20

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
Fagao
Posts: 3
Joined: Tue Dec 23, 2003 5:40 am

Problems creating XML datasheet for Juniper M20

Post by Fagao »

I have a little problem with creating a datasheet for our Juniper M20's.

Here is the XML sheet i created:
<chassis>
<name>Get SNMP Chassis information</name>
<description>Queries a host for a list of monitorable chassis elements</description>
<oid_index>.1.3.6.1.4.1.2636.3.1.13.1.1</oid_index>
<fields>
<chIndex>
<name>ContentIndex</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2636.3.1.13.1.1</oid>
</chIndex>
<chDescription>
<name>Description</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2636.3.1.13.1.5</oid>
</chDescription>
<chTemperature>
<name>Temperature</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2636.3.1.13.1.7</oid>
</chTemperature>
<chCpuload>
<name>CPU Load</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2636.3.1.13.1.8</oid>
</chCpuload>
</fields>
</chassis>
When I do an SNMP walk of the oid_index variable I get this result:
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.1.1.0.0 = 1
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.2.1.0.0 = 2
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.2.2.0.0 = 2
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.4.1.0.0 = 4
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.4.2.0.0 = 4
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.4.3.0.0 = 4
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.4.4.0.0 = 4
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.6.1.0.0 = 6
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.7.1.0.0 = 7
enterprises.juniperMIB.jnxMibs.jnxBoxAnatomy.jnxOperatingTable.jnxOperatingEntry.jnxOperatingContentsIndex.7.2.0.0 = 7
As you can see Juniper uses not a single integer as index. Is it possible to make a change to Cacti so I can use a multiple index like x.x.x.x instead of just a single integer ?

For more detail look at http://www.ee.ethz.ch/~slist/mrtg/msg24521.html
User avatar
kwabbernoot
Cacti User
Posts: 99
Joined: Mon Oct 13, 2003 4:11 am
Location: Zottegem, Belgium

Scripting is your solution

Post by kwabbernoot »

Hi,

I think the only option here is to use a script. I had a similar problem when interrogating Compaq Server temperatures, the MIB's include an additional '0' and I wanted to have the location of the sensor displayed with its name instead of a number. I know that the last thing can be performed by adding the MIBs to the Cacti system, but I wrote the script when I started with Cacti.

You can use the scripts as a starting point for your development. I used the script "query_host_partitions.php" and its XML as a starting point for the initial development.

I use Cacti 0.8.4 on a RedHat 8.0 and Mandrake 9.1. The script was adjusted to functionality of Cacti 0.8.4.

The XML file used:

Code: Select all

<Compaq_Temp>
        <name>Get Compaq MIB Temperatures</name>
        <script_path>|path_php_binary| -q |path_cacti|/scripts/Compaq_Temp.php</script_path>
        <arg_prepend>|host_hostname| |host_snmp_community| |host_snmp_version|</arg_prepend>
        <arg_index>index</arg_index>
        <arg_query>query</arg_query>
        <arg_get>get</arg_get>
        <output_delimeter>!</output_delimeter>

        <fields>
                <TempInd>
                        <name>Index</name>
                        <direction>input</direction>
                        <query_name>index</query_name>
                </TempInd>
                <TempLoc>
                        <name>Sensor Location</name>
                        <direction>input</direction>
                        <query_name>location</query_name>
                </TempLoc>
                <TempCels>
                        <name>Actual Temperature</name>
                        <direction>output</direction>
                        <query_name>temperature</query_name>
                </TempCels>
                <TempThres>
                        <name>Temperature Threshold</name>
                        <direction>output</direction>
                        <query_name>threshold</query_name>
                </TempThres>
        </fields>
</Compaq_Temp>
The PHP script performing the check:

Code: Select all

<?php

$no_http_headers = true;
//include("../include/config.php");
//include("../include/snmp.php");
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$oids = array(
        "temperature" => ".1.3.6.1.4.1.232.6.2.6.8.1.4.0",
        "threshold" => ".1.3.6.1.4.1.232.6.2.6.8.1.5.0",
        "index" => ".1.3.6.1.4.1.232.6.2.6.8.1.2",
        "location" => ".1.3.6.1.4.1.232.6.2.6.8.1.3.0"
        );

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];
$cmd = $_SERVER["argv"][4];

if ($cmd == "index") {
        $return_arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version,  "", "", 161, 1000));

        for ($i=0;($i<sizeof($return_arr));$i++) {
//              print $return_arr[$i]["value"] . "\n";
                print $return_arr[$i] . "\n";
        }
}elseif ($cmd == "query") {
        $arg = $_SERVER["argv"][5];

        // Add ".0", Compaq OID have an addition 0 in their OID
        $arr_index = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", 161, 1000));
        $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, "", "", 161, 1000));

        for ($i=0;($i<sizeof($arr_index));$i++) {
                if ($arg == "location") {
                        $locatio = realloc($arr[$i]);
                        print $arr_index[$i] . "!" . $locatio . "\n";
                } else {
                        print $arr_index[$i] . "!" . $arr[$i] . "\n";
                }
        }
}elseif ($cmd == "get") {
        $arg = $_SERVER["argv"][5];
        $index = $_SERVER["argv"][6];

        // Add ".0", Compaq OID have an addition 0 in their OID
        print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, "", "", 161, 1000));
}

function reindex($arr) {
        $return_arr = array();

        for ($i=0;($i<sizeof($arr));$i++) {
                $return_arr[$i] = $arr[$i]["value"];
        }

        return $return_arr;
}

//Function to detect sensor location (Enums in Getif)
function realloc($locarr) {
        $compaqloc = array(
                        "Other",
                        "Unknown",
                        "System",
                        "SystemBoard",
                        "ioBoard",
                        "CPU",
                        "Memory",
                        "Storage",
                        "RemovableMedia",
                        "PowerSupply"
                        );

        for ($c=1;($c<=10);$c++) {
                if ($locarr == $c) {
                        $loc = $compaqloc[$c-1];
                }
        }

        return $loc;
}

?>
Hope this helps,
Deano
Cacti User
Posts: 101
Joined: Wed Oct 29, 2003 7:08 am
Contact:

Post by Deano »

Yep - you'll need to write a script for this sort of "double" index

I've got some examples on my site - http://www.eatworms.org.uk/cacti - the Cisco NBAR one is a reasonably similair case and was also based on one of the scripts included with Cacti.

The problem with creating something "generic" is that so many vendors treat their MIBs in different ways. Often polling the inidividual item you need later on, involves several snmpwalks for each data value polled - which can be very slow unfortunately.

Deano
Post Reply

Who is online

Users browsing this forum: anwaraahmad1 and 2 guests