Pulling the "interface description" field dynamically

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Pulling the "interface description" field dynamically

Post by atlantic »

Hello,

When adding hosts to Nagios Host Groups, is there a way to pull the "interface description" dynamically. The devices in question are predominantly Cisco switches.

Thanks in advance,

Mark
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: Pulling the "interface description" field dynamically

Post by rdedon »

As in some type of auto-propagation if I am understanding correctly?
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

Good afternoon Rene,

Yes, that is absolutely what I was trying to ask, so yes, you are understanding the question correctly.

Thanks,

Mark
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA

Re: Pulling the "interface description" field dynamically

Post by tonyyarusso »

Could you elaborate a little on the workflow you're imagining? We have another customer who is writing their own summary page of sorts, and displaying the value returned for sysName.0 instead of the hostname stored in XI - is that similar to what you have in mind?
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

I apologize, please let me clarify the question.

In Nagios XI, under the 'Configuration' Menu, I chose 'Monitoring Wizards', and then select the 'Host Creation Tool".

I am adding network switches (Cisco) to Nagios for monitoring, so I select the "Network Switch" button. You list the switches you wish add using the tool in the following way(per instructions):

Please type or paste host addresses (IP Address or FQDN) and host names in a CSV format.

The format is <address>,<host name>
The comma is only to be used to separate the address and host name columns.

When adding a device using the Network Switch Monitoring Wizard, is there a way to pre-populate/auto-populate the interface descriptions based off of the switch interface descriptions vs the Port 1, Port 2, Port 3 values that it uses now?

I hope this help clarify things a bit.
Thanks,
Mark
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA

Re: Pulling the "interface description" field dynamically

Post by tonyyarusso »

I believe that was already implemented actually, yes. Make sure you have the latest version of the Switch Wizard, and there should be an option for that.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

Tony,

Yes, it seems that the latest version of the 'Network Switch Configuration Wizard' does pull-in the description from the switch device -- the curious thing is that it does not pick up the additional manually added description entries. I hope I stated that properly. So we are getting some of the description, which is definitely better, but not the entire description.

Mark
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: Pulling the "interface description" field dynamically

Post by rdedon »

I will see what I can find find on this for you and ask around as well tomorrow.
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

We had another user requesting similar things. Take a look at this and see if this is what you're looking for as well.
I’ve continued to tackle this and I believe I know what needs to be changed, I’m just not sure how to change it as I’m not a PHP programmer…
So here goes…
In the switch.inc.php file, toward the end of the file there is a snippet of code:
// we found the description
if(preg_match('/MRTG_INT_DESCR=/',$buf,$matches))
{
//key string
$key = 'MRTG_INT_DESCR="';
//find position of value and grab substring
$position = strpos($buf, $key) + strlen($key);
$descrip = substr( $buf, $position, (strlen($buf)) );
//strip quotes and spaces
$descrip = trim(str_replace('"', NULL, $descrip));

// save the description
$output[$port_number]["port_description"]=$descrip;
}
}//end 3rd IF


That code is looking at the output from the cfgmaker program. Here is an example of the output:

### Interface 3 >> Descr: 'GigabitEthernet1/3' | Name: 'Gi1/3' | Ip: '' | Eth: '30-72-30-30-31-36-62-61-64-32-34-38-39-63' ###
Target[10.20.1.1_GigabitEthernet1_3]: \GigabitEthernet1/3:default@10.20.1.1:
SetEnv[10.20.1.1_GigabitEthernet1_3]: MRTG_INT_IP="" MRTG_INT_DESCR="GigabitEthernet1/3"
MaxBytes[10.20.1.1_GigabitEthernet1_3]: 12500000
Title[10.20.1.1_GigabitEthernet1_3]: Traffic Analysis for GigabitEthernet1/3 -- switch22
PageTop[10.20.1.1_GigabitEthernet1_3]: <h1>Traffic Analysis for GigabitEthernet1/3 -- switch22</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>switch22 in Computer Room</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>IS Dept.</td>
</tr>
<tr>
<td>Description:</td>
<td>GigabitEthernet1/3 03 is-jtest1-pc </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>Gi1/3</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>12.5 MBytes/s</td>
</tr>
</table>
</div>


If I understand this correctly the switch.inc.php file is using the wrong “KEY” information to get the correct data that I need.

I need the KEY to be : <td>Description:</td> and have it use everything between the <td> and </td> from the next line. My problem is that I don’t know what to use to find the string position to grab the value that I need.

If you can make that change then I think this just might work…


A related note…

In step 3 of the switch wizard, your first column “Port” shows the port numbers. This information is somewhat irrelevant as it does not correlate to anything. It is never the same as the actual port numbers or vlans, etc. I think a more useful first column would be to have the Port be the Port Name using the “Description” from Step 2 Ie… Port = Gigabit Ethernet 1/3 and then the third column, Port Name, would be what I am asking for above without the Gigabit Ethernet 1/3 in front of it…

End result would be:

Port Max Speed Port Name Bandwidth Port Status
GigabitEthernet1/1 1.00 Gbps 03 is-jtest1-pc


This gives a very definitive description of the port especially when it’s being graphed…
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

Oh, and I thought I should mention, the Host Creation Tool is actually a community developed wizard, written by user Box293.