Network-Switch Wizard - Combine Port Name and Service

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Network-Switch Wizard - Combine Port Name and Service

Post 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?
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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.
Be sure to check out the Knowledgebase for helpful articles and solutions!
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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:

Code: Select all

    $args[] = "--noreversedns";
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! :)
You do not have the required permissions to view the files attached to this post.
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post by brdr »

Awesome ssax, worked perfectly on 1 port. I will really test it tomorrow. Keep you posted.

Thanks alot!!!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post by ssax »

No problem, let me know if you run into any problems.
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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" ...
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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.
You do not have the required permissions to view the files attached to this post.
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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?

:?
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Network-Switch Wizard - Combine Port Name and Service

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked