Translate interface index to description

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

Moderators: Developers, Moderators

Post Reply
csc8000
Posts: 9
Joined: Tue Jan 10, 2012 6:21 am

Translate interface index to description

Post by csc8000 »

Hi,

I'm writing a script which generates a top ten traffic interface list for a device in our Cacti database. I already have the list with the SNMP index. Is there a way to get the interface description from the index without making an addtinal SNMP request ?

Regards,
Christian
anthonyhurst
Posts: 11
Joined: Mon Jan 09, 2012 10:32 am
Contact:

Re: Translate interface index to description

Post by anthonyhurst »

If you're good with SQL:

Code: Select all

SELECT field_value FROM host_snmp_cache WHERE host_id='74' AND host_snmp_cache.snmp_index=3 AND field_name='ifDescr'
You may want to do something slightly different but poking around the SQL is pretty easy.
anthonyhurst
Posts: 11
Joined: Mon Jan 09, 2012 10:32 am
Contact:

Re: Translate interface index to description

Post by anthonyhurst »

If you want to use other data just do this to see all available stuff for that interface. Note that you need the hostname. (look at the host table to get the id)

Code: Select all

SELECT * FROM host_snmp_cache WHERE host_id='74' AND host_snmp_cache.snmp_index='3'
I picked random values. for this example :)
csc8000
Posts: 9
Joined: Tue Jan 10, 2012 6:21 am

Re: Translate interface index to description

Post by csc8000 »

Hi,

thank you for your response, it was a good starting point. I found out that I actually had only the local_data_id, not the SNMP id. So the complete solution for my problem is:

first SELECT with local_data_id:

SELECT local_data_id,rrd_name,rrd_path,host_id,arg1 FROM poller_item WHERE local_data_id = 3753;

(extract host_id and snmp_index from result)

second SELECT with host_id and snmp_index:

mysql> SELECT field_value FROM host_snmp_cache WHERE host_id = 61 AND field_name = 'ifAlias' AND snmp_index = 2;

Christian
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Translate interface index to description

Post by gandalf »

1st link of my sig now has updated SQL table layout, see last chapter. In case you're using MySQL designer, the required tables are provided as well
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests