Is there a way to process and rewrite the %alertsummary% variable (maybe copy pieces into a new variable) for sending in a text message? I would like to possibly change occurrences of Serial to S and Gigabit to G to make it short enough to be sent to a sat phone. I can do the processing, I was just hoping to see if that was even possible and where to start looking. I figure I could possibly send the contents of the variable to Perl, pull out what I need and copy into a new variable that I can use as a custom alert variable. Does what I want to do make sense? Is there a better way possibly?
I would like the final solution to be portable and survive upgrades without having to change a lot of baked in system files so this would be easy to transport across installations and make support easier.
Truncate %serviceoutput% for text notification
Truncate %serviceoutput% for text notification
Last edited by dfmco on Sun May 31, 2015 10:08 pm, edited 1 time in total.
Re: Truncate %alertsummary% for text notification
Have you tried using a custom notification host or service macros as described in this document:
https://assets.nagios.com/downloads/nag ... iables.pdf
https://assets.nagios.com/downloads/nag ... iables.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Truncate %alertsummary% for text notification
A custom notification script is your best option as the %alertsummary% macro is an XI built-in notification macro and it's code most likely resides in a protected file. Not to mention your changes to the macro would not persist through upgrades.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Truncate %serviceoutput% for text notification
So the notification variables look like they need to be hard set (like the MAC example given). Maybe I am missing something but when an SNMP trap is sent to Nagios, the %serviceoutput% variable contains the text from that trap (or so I think). So what I need is to process the text of the SNMP trap to pull out the most basic of information to send to my sat phone. The custom variable does not seem to be of value. Please let me know if I am missing something. Here is what I need to do exactly.
The %serviceoutput% in the example below contains the following text:
LINK DOWN 6 Serial 0/0/0:0 ds1 / ifIndex.6 (INTEGER32):6 ifDescr.6 (OCTETSTR):T1 0/0/0 ifType.6 (INTEGER):ds1
This text needs to be modified on the alert to look like this:
DOWN s0/0/0
I can figure out the regex or perl processing to get this done, I just need to know how to get the text in the first place to process and how to then send the processed output to a text alert.
Ideas?
The %serviceoutput% in the example below contains the following text:
LINK DOWN 6 Serial 0/0/0:0 ds1 / ifIndex.6 (INTEGER32):6 ifDescr.6 (OCTETSTR):T1 0/0/0 ifType.6 (INTEGER):ds1
This text needs to be modified on the alert to look like this:
DOWN s0/0/0
I can figure out the regex or perl processing to get this done, I just need to know how to get the text in the first place to process and how to then send the processed output to a text alert.
Ideas?
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Truncate %serviceoutput% for text notification
With SNMP Traps, EXEC lines are how the information is sent to Nagios.
EXEC are normally defined in /etc/snmp/snmptt.conf
Here is an example EXEC line:
snmptraphandling.py needs 6 arguments.
snmptraphandling.py <HOST> <SERVICE> <SEVERITY> <TIME> <PERFDATA> <DATA>
And they should be surrounded by double quotes. If you don't want to submit a value, like perfdata, you still need double quotes with no value between them.
$-* and $* are ways of expanding and printing ALL the variables. If you just want one varable, you can use $1 or $2 etc
Hence your EXEC line could look like:
Here's the snmptt documentation:
http://snmptt.sourceforge.net/docs/snmp ... ONF-FORMAT
Does this help?
EXEC are normally defined in /etc/snmp/snmptt.conf
Here is an example EXEC line:
Code: Select all
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The SNMP trap that is generated as a result of an event with the service $*"snmptraphandling.py <HOST> <SERVICE> <SEVERITY> <TIME> <PERFDATA> <DATA>
And they should be surrounded by double quotes. If you don't want to submit a value, like perfdata, you still need double quotes with no value between them.
$-* and $* are ways of expanding and printing ALL the variables. If you just want one varable, you can use $1 or $2 etc
Hence your EXEC line could look like:
Code: Select all
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "" "DOWN $1"http://snmptt.sourceforge.net/docs/snmp ... ONF-FORMAT
Does this help?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.