Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

Network Change & Configuration Management

Reply
Highlighted

Populate Custom Fields with content out of a collected running-config

[ Edited ]
Expert
Posts: 42
3013     0

Hello all,

 

has anyone already accomplished to populate custom fields with certain content found (via regex for instance) in a collected running-config of a network device?

 

I hope someone has a nice perl snippet for this.

 

 

Thanks

 

Markus

Highlighted

Re: Populate Custom Fields with content out of a collected running-config

Moderator
Moderator
Posts: 62
3014     0

Hi Markus,

 

Here are a couple posts that might help.  You could message Sif directly also to see if he has others.

 

https://community.infoblox.com/t5/Network-Change-Configuration/Adding-a-custom-device-field-via-the-...

 

https://community.infoblox.com/t5/Network-Change-Configuration/Adding-a-custom-device-field-via-the-...

 

Dave

@DaveSignori
Highlighted

Re: Populate Custom Fields with content out of a collected running-config

Expert
Posts: 42
3014     0

Thanks Dave,

 

I've finally found a solution. Will post a code snippet soon for all the other members with similar questions.

 

Best,

 

Markus

 

 

Highlighted

Re: Populate Custom Fields with content out of a collected running-config

Techie
Posts: 14
3014     0

This might also be of help. We use a lot of HP Procurve switches which have friendly names of 2530-48G-PoE. We know them as 2530s and the rest instantly tells us how many ports and if they are PoE or not - brilliant. However the actual model number is J9772A, with the 24 port version being J9773A. That is not as helpful and awful when reading reports.

 

If you login to the switch the only place the human readable model number is referred to is in the description string. Everywhere else it is the J number. To combat this, we added a custom field, Procurve Model then added it to the default view on almost all our information screens. A daily job runs to populate this. The description string is not in a consistent format between models so we do have to perform a number of checks.

 

# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
#	$Vendor eq "HP" or $Vendor eq "H3C"
#
# END-SCRIPT-BLOCK

# Based on example at: https://community.infoblox.com/t5/Network-Change-Configuration/Custom-Fields-in-a-CSS-script/td-p/1852
use strict;
use warnings;
use NetMRI_Easy;

# Script-Variables
our $sysdescr;		# Should pick up the SNMP description string from the switch

my $pcmodel="Unknown";

# Connect to NetMRI
my $easy = new NetMRI_Easy;
# Get the Device ID from the job engine
my $device_id = $easy->device_id;
# Retrieve the device
my $device = $easy->device;

# Output description string to debug
$easy->log_message('debug', "sysdescr is $sysdescr  **");


# Different Procurve models have slightly different device strings - which is annoying

# ProCurve J9299A Switch 2520G-24-PoE, revision J.14.54, ROM J.14.05 (/sw/code/build/walle(J_t4b))
if($sysdescr =~ /^ProCurve .* Switch (\S*), revision \S*,/) {
	$pcmodel = $1;
} elsif ($sysdescr =~ /^HP J.* (\S*) Switch, revision \S*,/) {
	# Newer models of HP "HP J9627A E2620-48-PoEP Switch, revision RA.15.05.0006, ROM RA.15.10 (/sw/code/build/xform(RA_15_05)) (Formerly ProCurve)"
	$pcmodel = $1;
} elsif ($sysdescr =~ /^HP J.* Switch (\S*), revision \S*,/) {
	# Some have the switch keyword in a different place "HP J8698A Switch E5412zl, revision K.15.07.0008, ROM K.15.28 (/ws/swbuildm/ec_rel_ftcollins_qaoff)"
	$pcmodel = $1;
} elsif ($sysdescr =~ /^HP Comware .* Version \S* .* HP (\S*) .*/) {
		# H3C switches, which are now HP
		$pcmodel = $1;
} elsif ($sysdescr =~ /^HPE Comware .* Version \S* .* HPE (\S*) .*/) {
		# More recent Comware now use HPE in their string
		$pcmodel = $1;
}

# Anything else will stick with the default, defined above

# Set the custom field
$easy->device->set_custom_field(ProcurveModel => $pcmodel);



exit(0);

We found HP Comware (A) series of switches also fail to populate the model with anything nice, so we expanded it to these switches too.

 

A note to anyone from Infoblox reading this, I REALLY like the flexability NetMRI offers for things like this. First the ability to have and populate a custom field but second to be able to do something useful like put it on the inventory summary screens etc and see it on a daily basis, is brilliant.

Showing results for 
Search instead for 
Do you mean 

Recommended for You