Page 1 of 2

Switch / Router Wizard - disabled interfaces?

Posted: Mon Sep 30, 2019 6:31 am
by solarmon
The Switch / Router Wizard currently seems to only detect and list interfaces that have been administratively enabled.

How can this be changed so that it will also detect and list interfaces that have been administratively disabled?

Currently the wizard also creates a service for the status of the interface - I assume this is the Operational status of the interface? Is there a way to get it to graph the Admin status of an interface?

Also, I noticed the option "Scan Interfaces" option does not seem to do anything - whether it is enabled or disabled, the interfaces seem to be scanned and listed.

Note: I have updated the wizard as per thread (to get Port Alias to work):

Switch&Router / NCPA wizards - interface name and direction
https://support.nagios.com/forum/viewto ... =6&t=55568

Re: Switch / Router Wizard - disabled interfaces?

Posted: Mon Sep 30, 2019 4:45 pm
by ssax
How can this be changed so that it will also detect and list interfaces that have been administratively disabled?
I know that it's setup to skip admin down ones by default, I'll take a look and see what's required to get those in there as well, it should be a simple fix.

The "scan interfaces" thing will always scan if no previous scan file (on the backend) exists.

If you uncheck it, it will use the previous scan file (if there is one).

You will see them in

Code: Select all

/usr/local/nagiosxi/tmp/mrtg-X.X.X.X

Re: Switch / Router Wizard - disabled interfaces?

Posted: Tue Oct 01, 2019 3:47 am
by solarmon
@ssax

Thank you.

I forgot to give a reason/example of why I would want to monitor/graph disable interfaces. This is so that we can see exactly when an disabled interface has been enabled and is being used. If there was no monitoring/graphing of it then we would not get that timeline. It also means we don't have to remember to add the interfaces manually when a disabled interface is now being used.

Re: Switch / Router Wizard - disabled interfaces?

Posted: Tue Oct 01, 2019 4:59 pm
by ssax
Please attach this file so that I can review what it has in it:

Code: Select all

/etc/mrtg/conf.d/X.X.X.X.cfg

Re: Switch / Router Wizard - disabled interfaces?

Posted: Wed Oct 02, 2019 2:40 am
by solarmon
@ssax

I assume you don't literally mean a X.X.X.X.cfg and want an actual config file that was generated?

If so, for security reasons I cannot attach one as it will contain sensitive data that is not suitable for a public forum.

What specifically do you want to see in the generated config file? The issue is not with the generated config file, the issue is that the wizard only works with administratively enabled interfaces.

Re: Switch / Router Wizard - disabled interfaces?

Posted: Thu Oct 03, 2019 5:02 pm
by ssax
Sorry, I meant PM it, you can sanitize/strip the IPs and stuff if needed but I need to see the data to determine which ones you're talking about and see how the device is returning things. And just to make sure we're still on the same page, you are talking about ADMIN DOWN ones, correct?

Are the admin down ports commented out in the config file and it's only the XI interface that isn't picking them up? That's really what I'm wondering because it should show admin down based on my testing (cfgmaker specifically I'm talking about here).

Re: Switch / Router Wizard - disabled interfaces?

Posted: Fri Oct 04, 2019 2:20 am
by solarmon
@ssax,

I checked an example config for a host in question, and you are corrected the 'admin down' interfaces are commented out - for example, the headers for the interface that is commented out shows (I've sanitised it):

Code: Select all

### Interface 8 >> Descr: '<interface name>' | Name: '<interface name>' | Ip: 'No Ip' | Eth: '<interface MAC>' ###
### The following interface is commented out because:
### * it is administratively DOWN
So it looks like it is just the wizard GUI that does not offer it for selection and creation of services.

As per my other post (https://support.nagios.com/forum/viewto ... =6&t=55820) I'm looking to customise the wizard to use check_iftraffic64 instead of check_rrdtraf, so the the MRTG element of this wizard will be redundant for me. However, I still need to get the wizard to offer the 'admin down' interfaces for selection - so this feature is still desired.

Re: Switch / Router Wizard - disabled interfaces?

Posted: Fri Oct 04, 2019 3:12 am
by solarmon
@ssax

Looked at the wizard and cfgmaker code and did some debugging.

The wizard calls cfgmaker with the following options (output has been truncated to sanitise it):

Code: Select all

/usr/bin/cfgmaker --ifdesc=alias --show-op-down --noreversedns --zero-speed '100000000'
This the command is generated by the function switch_iftraffic64_configwizard_get_cfgmaker_cmd() in the wizard.

It seems cfgmaker does support ignoring the admin and oper status of interfaces with the "--no-down" option, so I added this to the arguments array in switch_iftraffic64_configwizard_get_cfgmaker_cmd():

Code: Select all

$args[] = "--no-down";
So now the cfgmaker command is called with:

Code: Select all

/usr/bin/cfgmaker --ifdesc=alias --show-op-down --no-down --noreversedns --zero-speed '100000000'
and the wizard GUI now shows all the interfaces. So this does exactly what I want!

I think I will try to see whether I can add this as an option in the wizard GUI. I'm surprised it is not already an option!

Re: Switch / Router Wizard - disabled interfaces?

Posted: Fri Oct 04, 2019 7:16 am
by solarmon
I figured out how to add in the option to use '--no-down' or not.

In function switch_iftraffic64_configwizard_func() for the case CONFIGWIZARD_MODE_GETSTAGE1HTML I added an appropriate variable:

Code: Select all

$nodown = grab_array_var($inargs, "nodown", "on");
This will create a $_POST['nodown'] variable, and by default it is 'on'.

Further down, I added the table entry for the option in the 'Monitoring Options' section:

Code: Select all

<tr>
        <td>
            <label for="nodown">' . _("No Down") . '</label>
        </td>
        <td class="checkbox">
            <label><input name="nodown" type="checkbox" ' . is_checked($nodown) . '> ' . _("Do not look at admin or opr status of interfaces") . '</label>
        </td>
    </tr>
Then in function switch_iftraffic64_configwizard_get_cfgmaker_cmd() I added a check whether to add the option to the $args array or not:

Code: Select all

if($_POST['nodown'] == 'on') {
		$args[] = "--no-down";
	}

Re: Switch / Router Wizard - disabled interfaces?

Posted: Fri Oct 04, 2019 8:30 am
by solarmon
And to disable MRTG config file configuration creation, for now I've just commented a few function calls in various places:

Code: Select all

switch_iftraffic64_configwizard_update_mrtg();

Code: Select all

switch_iftraffic64_configwizard_add_cfg_to_mrtg($ip_address);

Code: Select all

file_put_contents("/etc/mrtg/conf.d/{$serviceargs['ip_address']}.cfg", $new_cfg_text);
This is until I figure out how to clean up the mrtg bits of code to properly.

Ideally, I'd rather this wizard for iftraffic64 be created and developed by the Nagios team and not just me hacking the existing switch/router wizard! It's a good learning exercise but I don't really want to maintain it going forwards.