Page 1 of 2
Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Feb 01, 2016 11:18 am
by brdr
Hi Nagios Support Team,
We have a requirement from our network team to combine the Port Name (Description) and Alias. Presently, when we run Network/Switch Wizard we always scan by Name. When the scan is done what's put into the Service Description is the port Alias.
Example (port 204)
IF-MIB::ifDescr.204 = STRING: Port-channel16
IF-MIB::ifAlias.204 = STRING: 20 Gbps Link to as06.bstnma01.us (this is inserted into the Service Description)
The requirement is for the Service Description to include both : 'Port-channel16 - 20 Gbps Link to as06.bstnma01.us'
Is this possible, to modify the switch wizard (./nagiosxi/html/includes/configwizards/switch/switch.inc.php) to append Alias to Descr?
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Feb 01, 2016 12:24 pm
by bwallace
You should be able apply whatever service description name you want to any particular service. Go to CCM > Services > select the service in question and on the Common Settings page you can rename description.
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Feb 01, 2016 12:35 pm
by brdr
True. But given the number of devices (approx 150) this will equate to thousands of edits to the service description (status and bandwidth) in CCM. We have to do this programmatically.
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Feb 01, 2016 5:13 pm
by ssax
Try this out and let me know how it works for you.
mrtg.zip
Please unzip the attached mrtg.template file and put it in:
Code: Select all
/usr/local/nagiosxi/html/includes/configwizards/switch/
Then:
Code: Select all
chown nagios.nagios /usr/local/nagiosxi/html/includes/configwizards/switch/mrtg.template
Then edit this file:
Code: Select all
/usr/local/nagiosxi/html/includes/configwizards/switch/switch.inc.php
Around line 50 add this code:
Code: Select all
$args[] = "--ifdesc=alias,nr";
$args[] = "--if-template=/usr/local/nagiosxi/html/includes/configwizards/switch/mrtg.template";
After this code:
So it looks like this:
Code: Select all
$args[] = "--noreversedns";
$args[] = "--ifdesc=alias,nr";
$args[] = "--if-template=/usr/local/nagiosxi/html/includes/configwizards/switch/mrtg.template";
Make sure to select "Port Name" when going through the wizard.
- EDIT: Slight Typo!

Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Feb 01, 2016 5:26 pm
by brdr
Awesome ssax, worked perfectly on 1 port. I will really test it tomorrow. Keep you posted.
Thanks alot!!!
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Tue Feb 02, 2016 10:07 am
by ssax
No problem, let me know if you run into any problems.
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Wed Feb 03, 2016 12:12 pm
by brdr
Hey ssax,
Still doing tests but came across a show stopper.
Here is the scenario:
I run Wizard for a device. I select a single port to add then Apply configuration. Ok so far. But when I look at 1000+ bandwidth checks that we have, NONE are graphing.
Here is why:
One of the ports in the Device I ran above has an alias '"Inside" Primary ASA ge3/1. Yes, double quotes. Now, when I use the mrtg.template you gave me there is this line :
$target_lines .= "SetEnv[$target_name]: MRTG_INT_IP=\"$if_ip\" MRTG_INT_DESCR=\"$if_snmp_descr - $if_snmp_alias\"\n";
Which translates in the mrtg .cfg file for this device/port as:
SetEnv[10.21.254.1_78]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="GigabitEthernet1/3/46 - "Inside" Primary ASA ge3/1"
Because of the double quotes MRTG can't run, therefore rrd files do not get updated. The work around is to go into the device's MRTG cfg file and manually remove the double quotes. This was the first device I used with your fix. I have about 130 devices to add, not sure what I'm going to find.
Manually running MRTG from the command line I get below error before removing the double quotes.
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
ERROR: CFG Error in "setenv[10.21.254.1_78]", file /etc/mrtg/conf.d/10.21.254.1.cfg line 2539: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="GigabitEthernet1/3/46 - "Inside" Primary ASA ge3/1" must be XY="dddd" AASD="kjlkj" ...
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Wed Feb 03, 2016 1:05 pm
by ssax
Try this template, it will strip out the double quotes from it.
mrtg.zip
What's cool is that it's actually just perl so you can manipulate it that way.
Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Nov 13, 2017 4:46 pm
by brdr
Hi Support Team,
I'm no longer getting ifAlias appending to ifDescr. I have't ran this network wizard in sometime (perhaps since last upgrading to 5.4.3). I have the edited switch.inc.php as ssax suggested below and have the template mrtg.template in same folder.
Any idea why while running the wizard the ifAlias is not getting appended in the service description?

Re: Network-Switch Wizard - Combine Port Name and Service
Posted: Mon Nov 13, 2017 5:48 pm
by cdienger
I wonder if something may have been overwriten. Can you attach copies of /usr/local/nagiosxi/html/includes/configwizards/switch/switch.inc.php and /usr/local/nagiosxi/html/includes/configwizards/switch/mrtg.template found on the system?