How to make nagios send me brief and informative alerts?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

How to make nagios send me brief and informative alerts?

Post by t3dus »

How do I make nagios send me brief and informative alerts via sms? The current long winded ones get broken up into multiple messages which is super annoying because I get multiple messages regarding a single outage.

I want something like the folks talked about here

What I don't understand is if I was to add this code to commands.cfg how I get certain notifications to use that vs the long winded alert.

Code: Select all

define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%.120s" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
        }


define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%.120s" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" | /usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
        }
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by scottwilkerson »

You would just change the host_notification_commands and service_notification_commands for the contact you want to receive these to notify-host-by-sms and notify-service-by-sms


https://assets.nagios.com/downloads/nag ... ml#contact
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by t3dus »

I did that in the contacts.cfg file but it isn't sending anything to my phone via text.

Code: Select all

define contact{
        contact_name                    mattphone
        alias                           Matt
        service_notification_commands   notify-service-by-sms
        host_notification_commands      notify-host-by-sms
        email               REMOVED NUMBER FOR PRIVACY@email.uscc.net
        pager                REMOVED NUMBER FOR PRIVACY@email.uscc.net
        }
and added "mattphone" to the contact groups.

Code: Select all

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 sysadmins,gldgmail,gidalerts,bp,mattphone
        }
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by scottwilkerson »

Have you tried testing these from the command line to see if the command works?

Code: Select all

/usr/bin/printf "%.120s" "host_alias is CRITICAL" |/usr/local/bin/gnokii --sendsms 'REMOVED NUMBER FOR PRIVACY@email.uscc.net' -r
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by t3dus »

Oh I see the issue. it comes back with the error

Code: Select all

-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by scottwilkerson »

t3dus wrote:Oh I see the issue. it comes back with the error

Code: Select all

-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
I don't even know what gnokii is....

If this is a email to text notification, I would suggest setting them up like your email commands
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by t3dus »

Ok I got it working. This is what I did..

I change the command to the following

Code: Select all

define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
        }
My next question is how can I get it so it doesn't text me "S:--sendsms"
Attachments
Screenshot_20190411-130849_Messages.jpg
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by scottwilkerson »

change it to this

Code: Select all

define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail $CONTACTPAGER$
        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail $CONTACTPAGER$
        }
the -s flag is defining the subject
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by t3dus »

So I narrowed it down with your commands to where it says

Code: Select all

S: M:Host/keyword is critical
but is there a way to ditch the "S:" and "M:"
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to make nagios send me brief and informative alerts?

Post by scottwilkerson »

t3dus wrote:but is there a way to ditch the "S:" and "M:"
My guess is your mail to sms provider is adding them to the message, where:

Code: Select all

S: == Subject
M: == Message
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked