Network Change & Configuration Management

Reply
Highlighted
Accepted Solution

Trying to run Ad Hoc batch command against HP switches and it's failing.

SANDS
Techie
Posts: 2
3212     0

 

Trying to try to run cleanup on HP switches with various SNMP strings that may or may not be on all the switches.

 

So we created a bulk set of commands to be removed and are trying to run them against all of our HP switches (900 of them)

 

The basic script looks like this:

conf

no snmp-server community 1

no snmp-server community 2

no snmp-server community 3

no snmp-server community 4

wr mem

 

The problem is if the switch doesn't happen to have community 1 on it , it will respond with a message

SNMP community not found: 1.


And the script will interpret this as a failure of the script and stop running the remaining commands. The error in the log of netmri reads:

*** Not found [Last executed command: 'no snmp-server community 1' ] ***

 

How can I  get the script to ignore the HP informational message and continue running the script?

Re: Trying to run Ad Hoc batch command against HP switches and it's failing.

Adviser
Posts: 410
3213     0

Here is one that will find anything and remove it Smiley Happy

 

Script-Filter:
$vendor eq "Cisco" and $sysdescr like /IOS/

########################################################################
Action:
Config SNMP

Action-Commands:
SET: $updatemade = "no"
sh run | inc snmp-server
#snmp-server community public RO
#snmp-server community infoblox RW
#snmp-server community sifbaksh RO

Output-Triggers:
Parse Output
########################################################################
Trigger:
Parse Output

Trigger-Variables:
$snmpcom string

Trigger-Template:
snmp-server community [[$snmpcom]] (RO|RW)

Trigger-Commands: { $updatemade eq "no"}
DEBUG:config t

Trigger-Commands:
DEBUG:no snmp-server community $snmpcom
SET: $updatemade = "yes"

###########################################

Action:
Add New Community

Action-Commands:{ $updatemade eq "yes"}
DEBUG:snmp-server community infoblox RW
DEBUG:snmp-server community sifbaksh RW
DEBUG:end
DEBUG:wr mem

Action-Commands:{ $updatemade eq "no"}
DEBUG:config t
DEBUG:snmp-server community infoblox RW
DEBUG:snmp-server community sifbaksh RW
DEBUG:end
DEBUG:wr mem

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: Trying to run Ad Hoc batch command against HP switches and it's failing.

Adviser
Posts: 62
3213     0

CCS Scripting has this Wonderful Feature called "SKIPERROR" which can be used for error handling. The following is from the documentation (CCS Scripting Guide) that you can also download from support site.

 

SKIPERROR
The SKIPERROR directive turns off error handling for script attributes when an error may appear from the acted-upon device, potentially preventing further job execution. You may issue SKIPERROR: on for one part of a script, thereby disabling error handling, and re-enable error handling again by issuing a second SKIPERROR: off directive. SKIPERROR can be used in Action-Command attributes and Trigger-Command attributes.

 

Example
# Turn off error handling
SKIPERROR: on
<further script execution here>

 

# Turn error handling back on
SKIPERROR: off

Showing results for 
Search instead for 
Do you mean 

Recommended for You