Attempting to build a configuration template that will take into account a location(Core Site) and a OID to determine what configuration to apply and I'm having a couple of issues. The nesting seems to work for the ones labelled '3Com 4400'. I can select multiple devices of this type on various core sites and it figures the correct script to use with each one. Outside of that however, none of the other devices by OID are working(3Com 45xx, Extreme, Cisco, Juniper). When those devices are selected it returns each one with 'No Script' and if then I tell it go ahead and execute it shows Could not connect to x.x.x.x, most likely because there is nothing to do I believe. Could someone read over the logic and see if I'm missing something?
Also several of the core sites checks could be condensed, I just can't seem to figure out how to do it. Switches within a core site point to the same trap host. For example:
- 10.20.1.249 - Core A and Core B
- 10.20.1.248 - Core C, Core D, Core E, and Core F
- 10.20.1.247 - Core G, Core H, and Core I
So is it possible to condense this down from this aspect:
- IF ( @ContextNode.CoreSite startsWith 'Core A' OR 'Core B' )
/*
.CHANGE_TEMPLATE_DESCRIPTION
This change script adds the SNMP trap target host.
.PLATFORM_DESCRIPTION
This change script adds the SNMP trap target host.
.PARAMETER_LABEL @ContextNode
NCM Node
.PARAMETER_DESCRIPTION @ContextNode
The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.*/
script addTarget ( NCM.Nodes @ContextNode )
{foreach ( @node in @ContextNode )
{
IF ( @ContextNode.CoreSite startsWith 'Core A' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.249
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.249 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.249 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.249 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.249
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core B' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.249
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.249 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.249 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.249 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.249
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core C' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.248
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.248 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.248 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.248 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.248
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core D' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.248
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.248 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.248 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.248 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.248
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core E' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.248
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.248 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.248 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.248 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.248
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core F' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.248
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.248 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.248 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.248 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.248
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core G' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.247
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.247 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.247 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.247 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.247
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core H' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.247
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.247 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.247 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.247 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.247
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
IF ( @ContextNode.CoreSite startsWith 'Core I' )
// 3Com 44xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.10.27.4.1.2.4' )
CLI
{
system management snmp trap create monitor 10.20.1.247
}
// 3Com 45xx Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.43.1.16.4.3' )
CLI
{
system
snmp-agent target-host trap address udp-domain 10.20.1.247 params securityname snmp
quit
save flash:/3comoscfg.cfg
y
y
}
// Extreme Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.1916.2' )
CLI
{
configure snmp add trapreceiver 10.20.1.247 community snmp
save
yes
}
// Cisco Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.9.1' )
CLI
{
config t
snmp-server host 10.20.1.247 snmp
end
wr mem
}
// Juniper Device
IF ( @ContextNode.SystemOID == '1.3.6.1.4.1.2636.1.1.1.2' )
CLI
{
config
set snmp trap-group snmp_trap categories link
set snmp trap-group snmp_trap targets 10.20.1.247
set ethernet-switching-options mac-notification notification-interval 5
commit-and-quit
exit
}
}
}