Script:
Add SNMP community String
Script-Description:
This script adds an SNMP community string to a cisco switch or router,
if SNMP is enabled.
Script-Filter:
$Vendor eq "Cisco"
and $Type in ["Switch", "Switch-Router", "Router"]
and $sysDescr like /IOS/
Script-Variables:
$NewCommunityString string
$RW boolean
########################################################################
Action:
Confirm SNMP
Action-Description:
Make sure SNMP is enabled on the device
Action-Commands:
SET: $snmpEnabled = "true"
show snmp
Output-Triggers:
Determine SNMP Status
SNMP Disabled
Determine RW String
Add Community String
########################################################################
Trigger:
Determine SNMP Status
Trigger-Description:
Determine whether SNMP is enabled or disabled
Trigger-Template:
// cisco devices return this string if snmp is disabled
%SNMP agent not enabled
Trigger-Commands:
SET: $snmpEnabled = "false"
########################################################################
Trigger:
Determine RW String
Trigger-Description:
Determine whether the string should be Read-Write or Read-Only
Trigger-Filter:
true
Trigger-Commands:{$RW eq "off"}
SET: $RW = "RO"
Trigger-Commands:{$RW eq "on"}
SET: $RW = "RW"
########################################################################
Trigger:
Add Community String
Trigger-Description:
Adds the given community string to the device(s)
Trigger-Filter:
$snmpEnabled eq "true"
Trigger-Commands:
//cisco commands to add string here
snmp-server community $NewCommunityString $RW
Output-Triggers:
Community String Added
########################################################################
Issue:
Community String Added
Issue-ID:
newCommunityString
Issue-Severity:
Info
Issue-Description:
Show which devices the community string was added to, and the string added
Issue-Filter:
$snmpEnabled eq "true"
Issue-Details:
Host $IPAddress
Name $Name
Community String $NewCommunityString
RW or RO $RW
########################################################################
Issue:
SNMP Disabled
Issue-ID:
snmpDisabled
Issue-Severity:
Error
Issue-Description:
SNMP is not enabled on this device
Issue-Filter:
$snmpEnable eq "false"
Issue-Details:
Host $IPAddress
Name $Name
########################################################################
Mike Griffin
Netcordia TAC
support@netcordia.com