- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Trigger Filter to match all but one or a series of ip addresses
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-06-2014 09:40 AM
I have been developing scripts that can:
- Clean up existing server hosts statements, unless they are the correct. If they are correct, bypass the next steps
- Validate the server hosts - if missing or incorrect will add
The problem I am running to is with the trigger filtering on the CLEANUP_SNMP_SERVER_HOST_TRIGGER trigger. Our 2 valid hosts are 192.168.1.1 and 192.168.2.2. I need a filter that will say: If the ip address is NOT equal to 192.168.2.2 or 192.168.1.1 and SNMP_WORD_0 is or contains network. (I used a Ruby Regex generator FYI.)
I tried to write multiple expression but either I'm not writing it correctly or I don't think NetMRI is interpreting them correctly.
Trigger-Filter:
$SNMP_HOST_0 like /\b(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\.[0-9]{1,3}\.[0-9]{1,3}\.(?:0|25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\b/ and $SNMP_WORD_0 like /network.*/
Any assistance on how to write a filter or a reg expression that would meet these conditions.
Thanks!
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#################################################
Action:
CLEAN UP - SNMP SERVER-HOSTS
Action-Description:
Check server host
Action-Timeout
60
Action-Commands:
SET: $SNMP_SVR_HOST_BYPASS_OK = "no"
sho run | inc snmp-server host
Output-Triggers:
CLEANUP_SNMP_SERVER_HOST_TRIGGER
#################################################
Action:
CHECK SNMP SERVER-HOST 192.168.1.1
Action-Description:
Check server host 192.168.1.1
Action-Timeout
60
Action-Commands:{$SNMP_SVR_HOST_BYPASS_OK = "no"}
SET: $SNMP_SVR_HOST_1_OK = "yes"
sho run | inc snmp-server host 192.168.1.1
Output-Triggers:
CHECK_SNMP_SERVER_HOST_TRIGGER_1
#################################################
Action:
FIX SNMP SERVER-HOST 192.168.1.1
Action-Description:
Add correct host 192.168.1.1
Action-Timeout
60
Action-Commands:{$SNMP_SVR_HOST_1_OK = "no"}
config term
snmp-server host 192.168.1.1 traps network
exit
SET:$NEED_TO_SAVE = "yes"
#################################################
Action:
CHECK SNMP SERVER-HOST 192.168.2.2
Action-Description:
Check server host 192.168.2.2
Action-Timeout
60
Action-Commands:{$SNMP_SVR_HOST_BYPASS_OK = "no"}
SET: $SNMP_SVR_HOST_2_OK = "yes"
sho run | inc snmp-server host 192.168.2.2
Output-Triggers:
CHECK_SNMP_SERVER_HOST_TRIGGER_2
#################################################
Action:
FIX SNMP SERVER-HOST 192.168.2.2
Action-Description:
Add correct hosts 192.168.2.2
Action-Timeout
60
Action-Commands:{$SNMP_SVR_HOST_2_OK = "no"}
config term
snmp-server host 192.168.2.2 traps network
exit
SET:$NEED_TO_SAVE = "yes"
################################################
Trigger:
CLEANUP_SNMP_SERVER_HOST_TRIGGER
Trigger-Timeout:
60
Trigger-Variables:
$SNMP_HOST_0 Ipaddress
$SNMP_WORD_0 string
Trigger-Template:
snmp-server host [[$SNMP_HOST_0]] [[$SNMP_WORD_0]]
Trigger-Filter:
$SNMP_HOST_0 like /\b(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\.[0-9]{1,3}\.[0-9]{1,3}\.(?:0|25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\b/ and $SNMP_WORD_0 like /network.*/
Trigger-Commands:
config t
no snmp-server host $SNMP_HOST_0 $SNMP_WORD_0
exit
SET: $SNMP_SVR_HOST_BYPASS_OK = "no"
########################################
Trigger:
CHECK_SNMP_SERVER_HOST_TRIGGER_1
Trigger-Timeout:
60
Trigger-Variables:
$SNMP_HOST_1 Ipaddress
$SNMP_WORD_1 string
Trigger-Template:
snmp-server host [[$SNMP_HOST_1]] [[$SNMP_WORD_1]]
Trigger-Filter:
$SNMP_HOST_1 like /192\.168\.1\.1/ and $SNMP_WORD_1 like /network.*/
Trigger-Commands:
SET: $SNMP_SVR_HOST_1_OK = "yes"
########################################
Trigger:
CHECK_SNMP_SERVER_HOST_TRIGGER_2
Trigger-Timeout:
60
Trigger-Variables:
$SNMP_HOST_2 Ipaddress
$SNMP_WORD_2 string
Trigger-Template:
snmp-server host [[$SNMP_HOST_2]] [[$SNMP_WORD_2]]
Trigger-Filter:
($SNMP_HOST_2 like /192\.168\.2\.2/) and $SNMP_WORD_2 like /network.*/
Trigger-Commands:
SET: $SNMP_SVR_HOST_2_OK = "yes"
########################################
Chris,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-10-2014 04:13 AM
Chris,
Try this :
Trigger-Filter:
$SNMP_HOST_0 like /\b(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\.[0-9]{1,3}\.[0-9]{1,3}\.(?:0|25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)\b/ and $SNMP_WORD_0 like /network.*/
Trigger-Commands: { $SNMP_HOST_0 not in [" 192.168.2.2,"192.168.1.1"] and $SNMP_WORD_0 like /network/}
config t
no snmp-server host $SNMP_HOST_0 $SNMP_WORD_0
exit
SET: $SNMP_SVR_HOST_BYPASS_OK = "no"
Twitter: https://twitter.com/sifbaksh
Sif - Thanks so much! That
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-10-2014 10:30 AM
Sif - Thanks so much! That worked!
Is there a good resource or reference material around the usage, syntax and operators for the scripting for network automation?
BTW - Great script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-10-2014 10:52 AM
BTW - Great script
Cick on the "Blue Question mark" On the left at the top additional documentaion look for CCS Guide in that list
Twitter: https://twitter.com/sifbaksh