Page 1 of 1

Nagios 4.4.6 macros $SERVICEOUTPUT$ problem

Posted: Tue Nov 19, 2024 12:27 pm
by Sidius
Just migrated to new version of nagios from old lovely 3.x nagios
All works fine but i have a problem with notification macros $SERVICEOUTPUT$ when checking port state with check_snmp and only if port is down (SNMP CRITICAL - *2*)

I'm using custom owncoded script for telegram notification
/usr/lib/nagios/plugins/telegram.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Service: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ Info:$SERVICEOUTPUT$"

Here is what nagios write on debug log

Code: Select all

[1732035790.356306] [032.2] [pid=3737799] ** Notifying contact 'Pavel'
[1732035790.356312] [032.2] [pid=3737799] Raw notification command: /usr/lib/nagios/plugins/telegram.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Service: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ Info:$SERVICEOUTPUT$"
[1732035790.356317] [032.2] [pid=3737799] Processed notification command: /usr/lib/nagios/plugins/telegram.sh 296519911 "PROBLEM Service: Somewhere OLT/6. Pinger 220V is CRITICAL Info:SNMP CRITICAL - *2*"
Here what is come to telegram

Code: Select all

PROBLEM Service: Somewhere OLT/6. Pinger 220V is CRITICAL Info:SNMP CRITICAL - systemd-private-0bbec17acdc0463492d5e5f71c04556f-apache2.service-eYHFKX systemd-private-0bbec17acdc0463492d5e5f71c04556f-systemd-logind.service-tzPUK7

But if i use /usr/lib/nagios/plugins/telegram.sh 296519911 "PROBLEM Service: Somewhere OLT/6. Pinger 220V is CRITICAL Info:SNMP CRITICAL - *2*" from console - it's send proper notification.


And this is only when SNMP CRITICAL, when SNMP OK - 1 - it's send correct notification.

What is the problem with $SERVICEOUTPUT$ ?

Re: Nagios 4.4.6 macros $SERVICEOUTPUT$ problem

Posted: Tue Nov 26, 2024 1:24 pm
by danderson
Thanks for reaching out.

That output is a little silly, *2* is basically matching against every file with a 2 in the name.

I think the solution is to edit the telegram script you are using and put quotes around wherever "$2" is used