[resolved] Problem with string index in snmp query

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

Moderators: Developers, Moderators

Post Reply
fcoulmier
Posts: 2
Joined: Fri Jan 13, 2012 12:35 pm

[resolved] Problem with string index in snmp query

Post by fcoulmier »

Hi all,

I try to create a new data query based on "Get snmp data (Indexed)". I want to graph number of mails delivered and bounced for each main ISP (hotmail, google, ...).
Here is the 'mib' representation of my data (I've limited it to only 2 ISP, but I have 8 ISP normally):

Code: Select all

$ snmpwalk -v2c -c XXXX localhost .1.3.6.1.4.1.23925.101
iso.3.6.1.4.1.23925.101.20.1.0 = Counter32: 2
iso.3.6.1.4.1.23925.101.20.2.103.111.111.103.108.101 = STRING: "google"
iso.3.6.1.4.1.23925.101.20.2.104.111.116.109.97.105.108 = STRING: "hotmail"
iso.3.6.1.4.1.23925.101.20.3.103.111.111.103.108.101 = STRING: "Google"
iso.3.6.1.4.1.23925.101.20.3.104.111.116.109.97.105.108 = STRING: "Hotmail"
iso.3.6.1.4.1.23925.101.20.4.103.111.111.103.108.101 = STRING: "gmail.com"
iso.3.6.1.4.1.23925.101.20.4.104.111.116.109.97.105.108 = STRING: "hotmail.fr,hotmail.com,live.fr"
iso.3.6.1.4.1.23925.101.20.11.103.111.111.103.108.101 = Counter32: 5579
iso.3.6.1.4.1.23925.101.20.11.104.111.116.109.97.105.108 = Counter32: 5614
iso.3.6.1.4.1.23925.101.20.12.103.111.111.103.108.101 = Counter32: 0
iso.3.6.1.4.1.23925.101.20.12.104.111.116.109.97.105.108 = Counter32: 0

The number of indexes is represented in this OID : iso.3.6.1.4.1.23925.101.20.1.0
The indexes are in this OID : iso.3.6.1.4.1.23925.101.20.2
In this OID are we have the full name of the ISP : iso.3.6.1.4.1.23925.101.20.3
The list of domains handled by the ISP are in the OID : iso.3.6.1.4.1.23925.101.20.4
Then, the delivered and bounced are in : iso.3.6.1.4.1.23925.101.20.11 and iso.3.6.1.4.1.23925.101.20.12

Here is the xml file I've created to handle this kind of snmp data :

Code: Select all

<interface>
	<name>per status mails</name>
	<description>Get number of mails per status d,b</description>
	<oid_index>.1.3.6.1.4.1.23925.101.20.2</oid_index>
	<oid_num_indexes>.1.3.6.1.4.1.23925.101.20.1.0</oid_num_indexes>
	<index_order>ispIndex</index_order>
	<index_order_type>alphabetic</index_order_type>
	<oid_index_parse>OID/REGEXP:^.*\.23925\.101\.20\.2\.(.*)$</oid_index_parse>
	<index_title_format>|chosen_order_field|</index_title_format>
	<fields>
		<ispIndex>
			<name>Index</name>
			<source>index</source>
			<direction>input</direction>
		</ispIndex>
		<ispName>
			<name>ISP Name</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.23925.101.20.3</oid>
		</ispName>
		<ispDomains>
			<name>ISP managed domains</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.23925.101.20.4</oid>
		</ispDomains>
		<ispDelivered>
			<name>Delivered</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.4.1.23925.101.20.11</oid>
		</ispDelivered>
		<ispBounced>
			<name>Bounced</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.4.1.23925.101.20.12</oid>
		</ispBounced>
	</fields>
</interface>
Here is the output of the data query in verbose mode :

Code: Select all

+ Running data query [16].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/opt/cacti/resource/snmp_queries/pmta_per_status_mails.xml'
+ XML file parsed ok.
+ Executing SNMP get for num of indexes @ '.1.3.6.1.4.1.23925.101.20.1.0' Index Count: 2
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.23925.101.20.2' Index Count: 2
+ Index found at OID: '.1.3.6.1.4.1.23925.101.20.2.103.111.111.103.108.101' value: 'google'
+ Index found at OID: '.1.3.6.1.4.1.23925.101.20.2.104.111.116.109.97.105.108' value: 'hotmail'
+ index_parse at OID: '.1.3.6.1.4.1.23925.101.20.2.103.111.111.103.108.101' results: '103.111.111.103.108.101'
+ index_parse at OID: '.1.3.6.1.4.1.23925.101.20.2.104.111.116.109.97.105.108' results: '104.111.116.109.97.105.108'
+ Inserting index data for field 'ispIndex' [value='103.111.111.103.108.101']
+ Inserting index data for field 'ispIndex' [value='104.111.116.109.97.105.108']
+ Located input field 'ispName' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.23925.101.20.3'
+ Found item [ispName='Google'] index: .1.3.6.1.4.1.23925.101.20.3.103.111.111.103.108.101 [from value]
+ Found item [ispName='Hotmail'] index: .1.3.6.1.4.1.23925.101.20.3.104.111.116.109.97.105.108 [from value]
+ Located input field 'ispDomains' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.23925.101.20.4'
+ Found item [ispDomains='gmail.com'] index: .1.3.6.1.4.1.23925.101.20.4.103.111.111.103.108.101 [from value]
+ Found item [ispDomains='hotmail.fr,hotmail.com,live.fr'] index: .1.3.6.1.4.1.23925.101.20.4.104.111.116.109.97.105.108 [from value]
The problem I have is that 'input' fields are not shown correctly in the page "graphs_new.php" to create graphs for a host. Here is a screenshot (aas said earlier, I have 8 ISP really configured but only shown 2 of them in the previous samples) :
ScreenShot190.png
ScreenShot190.png (25.77 KiB) Viewed 921 times
Do you know what's wrong in my xml file that cause this problem ?

I've read these articles to help me in creating the xml file :
http://docs.cacti.net/howto:data_query_ ... s_a_string
http://devcentral.f5.com/Tutorials/Tech ... -Data.aspx
http://docs.cacti.net/manual:087:3a_adv ... alkthrough
http://www.cacti.net/downloads/docs/htm ... y_xml.html

Thank you for your help.
Last edited by fcoulmier on Mon Jan 16, 2012 3:43 am, edited 1 time in total.
fcoulmier
Posts: 2
Joined: Fri Jan 13, 2012 12:35 pm

Re: Problem with string index in snmp query

Post by fcoulmier »

I've found the problem.

I had to replace the <oid_index_parse> regexp like that :

old:

Code: Select all

<oid_index_parse>OID/REGEXP:^.*\.23925\.101\.20\.2.(.*)$</oid_index_parse>
new:

Code: Select all

<oid_index_parse>OID/REGEXP:^.*\.23925\.101\.20\.[0-9]+.(.*)$</oid_index_parse>
This is because of the method of detection of indexes in cacti in file lib/data_query.php:

Code: Select all

 if ($field_array["source"] == "value") {
                                for ($i=0; $i<sizeof($snmp_data); $i++) {
                                        $snmp_index = preg_replace('/' . (isset($field_array["oid_index_parse"]) ? $field_array["oid_index_parse"] : $index_parse_regexp) . '/', "\\1", $snmp_data[$i]["oid"]);

The regexp specified in <oid_index_parse> must match every OID of input fields and not only the "index" field.

Now it works better, but I have the "Index" column in the "create graphs for this host" page and i don't know how to hide it :
ScreenShot191.png
ScreenShot191.png (12.88 KiB) Viewed 916 times
Do you have an idea ?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Problem with string index in snmp query

Post by gandalf »

IMHO, you can't hide the column that serves as the index
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests