UCMDB and UD Practitioners Forum (Previously CMS)
cancel

uCMDB python Script Help - SNMP_Connections_Utils.py

Highlighted
brav0
Acclaimed Contributor.

uCMDB python Script Help - SNMP_Connections_Utils.py

Experts,

 

I am a learner in HP uCMDB and I am learning to understand the python scripts used in discovery.

For one of the node discovery and mapping the details, i created one of the regular expression and has incorporated into the SNMP_connections_utils.py script. As below

 

Text which I am parsing is 

"Cisco Internetwork Operating System Software  IOS (tm) CIGESM Software (CIGESM-I6K2L2Q4-M), Version 12.1(22)EA9, RELEASE SOFTWARE (fc1) Copyright (c) 1986-2006 by cisco Systems, Inc. Compiled Fri 01-Dec-06 18:20 by weiliu"

 

I am trying to get only 2 values out of this text whcih is

GESM-I6K2L2Q4-M

12.1(22)EA9

 

THe regex used is

.*\sCIGESM\s.*\s(.*).\sVersion\s(.*).\sRELEASE.*\sCopyright\s.*

 

Now as I tried to incorporate into the script, i see that the values are not getting populated into the hostVersion and hostRelease fields.

 

I tried some print statements like below which I couldnt find in the ucmdb probe AdapterDebug log file.

I am putting the piece of code in the SNMP_connection_utils.py script here.

Please correct me if I have put it wrong in the script.

Please guide.

 

Thank you

Dev.

        elif description.find('Cisco IOS') > -1:
            buffer = re.match(r".*\sCIGESM\s.*\s(.*).\sVersion\s(.*).\sRELEASE.*\sCopyright\s.*", description)
            if buffer:
                hostVersion = buffer.group(1).strip()
                hostRelease = buffer.group(2).strip()
				
				#adding print statements:
				logger.debug("printing the output")
				logger.debug("value of hostVersion is " +hostVersion)
				logger.debug("value of hostRelease is " +hostRelease)

 

P.S. This thread has been moved from Application Perf Mgmt (BAC / BSM) Support and News Forum to CMS and Discovery Support and News Forum. - Hp Forum Moderator

 

I am Listening..
1 REPLY
Rutger
Honored Contributor.

Re: uCMDB python Script Help - SNMP_Connections_Utils.py

Can you try this one: \((\w+)-\w+-\w+\),\sVersion\s(.*),\sRELEASE

No guarantees, didn't manage to test it on a live DDMa system.