I created a ‘PropertySource’ that creates a shortened ‘sysinfo’ string. It creates a new property that I called ‘short_sysinfo’. I did it for Cisco devices but it can be easily adapted to other devices.
See the example differences below.
It’s helpful for reports because it takes out the non-helpful text and redundant text that makes it too long.
It’s fairly flexible, so it can be tweaked
This is short_sysinfo…
Catalyst L3 Switch (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.2, RELEASE (fc4)
instead of…
Cisco IOS Software [Denali], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.2, RELEASE SOFTWARE (fc4) Technical Support: http://www.cisco.com/ techsupport Copyright (c) 1986-2016 by Cisco Systems, Inc. Compiled Tue 08-Nov-16 17:31 b
—————————— —————————— ————
This is the short_sysinfo…
C2900 (C2900-UNIVERSALK9-M), Version 15.4(3)M7, RELEASE (fc1)
instead of…
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.4(3)M7, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/ techsupport Copyright (c) 1986-2017 by Cisco Systems, Inc. Compiled Thu 02-Feb-17 21:48 by prod_rel_team
————————-
This is short_sysinfo…
(ucs-6100-k9-system), Version 5.0(3)N2(3.12f), RELEASE
instead of long…
Cisco NX-OS(tm) ucs, Software (ucs-6100-k9-system), Version 5.0(3)N2(3.12f), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 2/27/2017 8:00:00
=========================
If you’re curious…Below is the groovy script I wrote:
info = hostProps.get(“system.sysinfo” )
step_one = info.replaceAll(‘Technical Support: http://www.cisco.com/ techsupport‘,”) // replace the string with nothing (remove it)
step_two = step_one.replaceAll(‘SOFTWARE’ ,”) // replace the string ‘SOFTWARE ‘ with blank (remove it)
step_three = step_two.replaceAll(‘Software’ ,”)
if (info.contains(‘Copyright’)){ // to avoid errors if it doesn’t contain ‘Copyright’ in string
index_of_copyright = step_three.indexOf(‘Copyright’ ) // get position of where the string ‘Copyright’ starts
step_four = step_three.substring(0,index_ of_copyright) // grab from start to ‘Copyright’
}else{
step_four = step_three
}
if (info.contains(‘,’)){ // to avoid errors if string doesn’t contain a comma
index_of_first_comma = step_four.indexOf(‘,’) +1 // get position of first comma which is after ‘Cisco IOS Software’
step_five = step_four.substring(index_of_ first_comma) // grab from first comma to end
}else{
step_five = step_four
}
step_six = step_five.trim() // trim the leading and ending spaces if they exist
length = step_six.size()
println “short_sysinfo=” + step_six
return 0
No comments