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

Re: Pulling the "interface description" field dynamically

Post by atlantic »

Yes, the request you posted is exactly what I would expect.

When polling an interface, I would expect to see (for example)

GigabitEthernet1/1 as the port name and
"to server room" as a description.

Where now it would be

Port10002 as the port name and
GigabitEthernet1/1 as the description
"to server room" is dropped.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

Ok, I'll take a look at modifying the switch wizard and post it when I get the changes made.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

I don't have the hardware to let me custom define my port descriptions, so if you'd be willing to test this and let me know if it works I'd appreciate it.
You do not have the required permissions to view the files attached to this post.
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

The polling worked well. The only problem that you may want to tweak is normalize the description.

For example on the swtich I polled this is a valid descriptor.

'To->Admin Switch "

But when you reload I get this.

Error: The description string for service 'To->Admin Switch (xxxxxx) Bandwidth' on host 'swtch_test' contains one or more illegal characters.
Error: The description string for service 'To->Admin Switch (xxxxxx) Status' on host 'swtch_test' contains one or more illegal characters.

If you were to strip the invalid characters automatically that would be great.
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

Also, is there a way to "rediscover" interfaces after adding a switch? To look for newly added interfaces?
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

For example on the swtich I polled this is a valid descriptor.

'To->Admin Switch "

But when you reload I get this.

Error: The description string for service 'To->Admin Switch (xxxxxx) Bandwidth' on host 'swtch_test' contains one or more illegal characters.
Error: The description string for service 'To->Admin Switch (xxxxxx) Status' on host 'swtch_test' contains one or more illegal characters.

If you were to strip the invalid characters automatically that would be great.
Was this the descriptor you got in the form field? Stripping the meta characters shouldn't be a big deal, I just want to make sure I'm cleaning the right data. If you could even send a screenshot that would be awesome. I don't have a switch to test on that will let me add user-defined descriptions.
Also, is there a way to "rediscover" interfaces after adding a switch? To look for newly added interfaces?
Currently we don't have this feature available, although you're not the first to request it. It's something we'll probably need to put on our TODO list.
atlantic
Posts: 45
Joined: Wed Feb 02, 2011 10:38 am

Re: Pulling the "interface description" field dynamically

Post by atlantic »

in regards to the illegal characters.

Chaning line 362 (the line below) from
<input type="text" size="20" name="serviceargs[portname]['.$port_num.']" value="'.$port_name.'">

to

<input type="text" size="20" name="serviceargs[portname]['.$port_num.']" value="'.str_replace( array("<",">","(",")"), "", urldecode($port_name)).'">

seems to have done the trick for us if anyone else is interested.
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: Pulling the "interface description" field dynamically

Post by rdedon »

atlantic wrote:in regards to the illegal characters.

Changing line 362 (the line below) from
<input type="text" size="20" name="serviceargs[portname]['.$port_num.']" value="'.$port_name.'">

to

<input type="text" size="20" name="serviceargs[portname]['.$port_num.']" value="'.str_replace( array("<",">","(",")"), "", urldecode($port_name)).'">

seems to have done the trick for us if anyone else is interested.
Thank you for the input, we appreciate tips like this greatly :-)
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 »

I was digging in the switch.inc.php script a little more and the port number option you have listed may be better to use the $port_description variable there instead of the $port_number variable you use.

Actually what may be good is (if possible) to have the option of Port Number, Port Description or Both.

Here are the modifications I did to my script.

We added these lines

$short_port_description=str_replace('GigabitEthernet','GigE',$port_description);
$short_port_description=str_replace('FastEthernet','FastE',$short_port_description);

That was line 323 and 324. Which just shortens the length of the interface type.

Then modified line number 364 to read.

<input type="text" size="20" name="serviceargs[portname]['.$port_num.']" value="'.str_replace( array("<",">","(",")","&",":"), "", urldecode($short_port_description.'-'.$port_name)).'">

The end result is I am ending up with a description of the port to be something like this:

GigE2/5-To TACACS Server

So to summarize,

$port_description is a good varible to use as "Port Number"
$port_name would be good for "Port Name"
You can concantate those together and create a "Both" option.
$port _number can be dropped.

Which I feel any Networking person will agree is exactly the information they would need to see in the event of an outage.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Pulling the "interface description" field dynamically

Post by mguthrie »

At some point I'll try and take a look at making these changes, we've made multiple revisions to it based on user suggestions. The $port_number variable still needs to remain as a key identifier to locate the performance data, but I'll have to dive back into that script a bit to remember how the rest of it comes together. Thanks for the input!
Locked