Forum Discussion
How to use integers or numbers in custom SNMP Traps?
Hi
I am asking this from some questions I came across.
How would you make a trap for
01010029:5: Clock advanced by <number> ticks
Is <number> the right way or should it be int or *int something?
Here we can see .* used as a wildcard of sorts for enabled or disabled
Custom SNMP trap example
A message that appears similar to the following example is logged to the /var/log/ltm file when switchboard failsafe is enabled:
`Sep 23 11:51:40 bigip1.askf5.com lacpd[27753]: 01160016:6: Switchboard Failsafe enabled`
To create a custom SNMP trap that is triggered whenever switchboard failsafe status changes are logged, add the following trap definition to the /config/user_alert.conf file:
alert SWITCHBOARD_FAILSAFE_STATUS "Switchboard Failsafe (.*)" {
snmptrap OID=".1.3.6.1.4.1.3375.2.4.0.500"
}
Thanks!
- Dario_Garrido
Noctilucent
The easiest way is to use "Clock advanced by (.*) ticks" as matching expression.
KR,
Dario.
- davidfisher
Cirrus
so .* only stands for numerics or integers or for any string?
- Hamish
Cirrocumulus
Its a regex...
. == any character
* == 0 or more of the preceding character
So .* effectively matches ANY string. Including an empty one.
See https://techdocs.f5.com/kb/en-us/products/big-ip-afm/manuals/product/dns-dos-firewall-implementations-11-6-0/6.html for details of alert configs
Also see https://www.rexegg.com/regex-quickstart.html for a regex cheat sheet.
- Dario_Garrido
Noctilucent
Actually, if you want to match an specific integer you can do something like this
https://regex101.com/r/QDdM2d/1
alert CREACION_VS "Clock advanced by [[:digit:]]* ticks" { snmptrap OID=".1.3.6.1.4.1.3375.2.4.0.300"; }
KR,
Dario.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com