Formatting text messages?

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Formatting text messages?

Postby t3dus » Sun Oct 07, 2018 12:37 pm

Is there a special way to format my sms messages from Nagios Core?

Currently if I have them text me they show up as 3 separate messages vs 1 which is super annoying so I simply don't have them going there at all which is a big issue as far as seeing alerts right away.
User avatar
t3dus
 
Posts: 111
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA

Re: Formatting text messages?

Postby mcapra » Mon Oct 08, 2018 8:18 am

It would probably depend on the specific messaging service you're using. I don't have this problem with Twilio:

2018_10_08_08_16_42_Inbox_5_Gmail.png
2018_10_08_08_16_42_Inbox_5_Gmail.png (20.57 KiB) Viewed 41 times


My implementation:
viewtopic.php?f=34&t=48698&p=252294#p252294
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3423
Joined: Thu May 05, 2016 3:54 pm

Re: Formatting text messages?

Postby t3dus » Mon Oct 08, 2018 12:34 pm

I simply have nagios core e-mailing my phone through the provided e-mail to text provided by my phone provider.

Since I currently use US Cellular it looks something like "YOURNUMBERHERE@e-mail.uscc.net" which then sends e-mails to me via text.

I'm not sure i'd be interested in using something like Twilio that costs money.

What I am asking is if there is someway to format the e-mails to be shorter within nagios config files
User avatar
t3dus
 
Posts: 111
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA

Re: Formatting text messages?

Postby ssax » Mon Oct 08, 2018 12:52 pm

If you want to shorten the message you may want to create a separate contact for SMS and then set the contacts host/service_notification_handler_commands to new commands that only sends what you want:

From the default:

Code: Select all
define command {
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

define command {
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }


To a custom command:

Code: Select all
define command {
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

define command {
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }


Unfortunately, we'd need to know where your SMS provider is splitting the messages in order to determine what to change in the custom commands but that's how you'd do it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 3218
Joined: Wed Feb 11, 2015 12:54 pm

Re: Formatting text messages?

Postby cdienger » Mon Oct 08, 2018 1:01 pm

Notification command definitions are in /usr/local/nagios/etc/objects/commands.cfg by default and these dictate the format. The notify-host-by-email andnotify-service-by-email definitions for example:

define command {

command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}


define command {

command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


Information on macros that can be used can be found at https://assets.nagios.com/downloads/nag ... olist.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
cdienger
Support Tech
 
Posts: 1885
Joined: Tue Feb 07, 2017 11:26 am


Return to Nagios Core

Who is online

Users browsing this forum: bolson and 16 guests