set up email alerts using mailx

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.

Re: set up email alerts using mailx

Postby nib01 » Tue Jan 15, 2019 12:45 pm

Do you mean copy the Contact information from contact.cfg file to linuxhosts.cfg file where rancid host is?
nib01
 
Posts: 31
Joined: Tue Oct 09, 2018 9:31 am

Re: set up email alerts using mailx

Postby tgriep » Tue Jan 15, 2019 4:16 pm

No, edit the Contact Group called admin, add the contact to it in the member list.
Save and restart Nagios to apply the change.
That is much easier to do as you only have to add the contact to one place, the Contact Group.

Take a look at this link for descriptions of the Objects and how they are formatted.
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8375
Joined: Thu Oct 30, 2014 9:02 am

Re: set up email alerts using mailx

Postby mayuril » Wed Jan 16, 2019 5:41 am

This is an all-in-one command that sends email to $TO_EMAIL_ADDRESS . You need to also replace these $FROM_EMAIL_ADDRESS and $FRIENDLY_NAME variables with your email and name.

$ mailx -v -s "$EMAIL_SUBJECT" \
-S smtp=smtp://smtp.ust.hk \
-S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \
$TO_EMAIL_ADDRESS
mailx will read the email content from STDIN. Type in the email main content and input “Ctrl+d” to tell mailx you have finished the content. The mail will be sent out. You can also use pipes like:
mayuril
 
Posts: 1
Joined: Wed Jan 16, 2019 5:28 am

Re: set up email alerts using mailx

Postby tgriep » Wed Jan 16, 2019 3:56 pm

Thanks @mayuril for the help.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8375
Joined: Thu Oct 30, 2014 9:02 am

Re: set up email alerts using mailx

Postby nib01 » Tue Jan 22, 2019 5:08 pm

mayuril wrote:This is an all-in-one command that sends email to $TO_EMAIL_ADDRESS . You need to also replace these $FROM_EMAIL_ADDRESS and $FRIENDLY_NAME variables with your email and name.

$ mailx -v -s "$EMAIL_SUBJECT" \
-S smtp=smtp://smtp.ust.hk \
-S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \
$TO_EMAIL_ADDRESS
mailx will read the email content from STDIN. Type in the email main content and input “Ctrl+d” to tell mailx you have finished the content. The mail will be sent out. You can also use pipes like:


Ive tried above command to send email, see screenshot photo, and it works fine without any error.

The problem that Im facing right now is the client within linuxhosts.cfg file, I did some testing by shutting down one of the host (rancid) I expect to send an email notification to the email Ive setup within commands.cfg, but it didnt work.
Attachments
nagios_send_email_all_in_one_command.PNG
nib01
 
Posts: 31
Joined: Tue Oct 09, 2018 9:31 am

Re: set up email alerts using mailx

Postby tgriep » Wed Jan 23, 2019 10:26 am

Can you post all of the Nagios config files so we can view the settings to verify that the settings for the contact, host, services, groups are setup correctly?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8375
Joined: Thu Oct 30, 2014 9:02 am

Re: set up email alerts using mailx

Postby nib01 » Wed Jan 23, 2019 12:52 pm

Please see attached nagios config files. For the Services and Groups config file, these two config files are combined with the hosts to be monitored. Please let me know if you need additional information.
Attachments
linuxhosts.cfg
(10.36 KiB) Downloaded 115 times
contacts.cfg
(3.22 KiB) Downloaded 117 times
commands.cfg
(7.42 KiB) Downloaded 110 times
nib01
 
Posts: 31
Joined: Tue Oct 09, 2018 9:31 am

Re: set up email alerts using mailx

Postby tgriep » Wed Jan 23, 2019 5:54 pm

Can you post the config file that contains the generic-contact template and the linux-server template?
Typically, the templates have the Host and Service Notifications enabled and also the contact template but I would have to see them for sure to verify that they are set.

Another thing, can you go to the Notification Report and see if you can find the host there and is so, post the entry?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8375
Joined: Thu Oct 30, 2014 9:02 am

Re: set up email alerts using mailx

Postby nib01 » Thu Jan 24, 2019 12:56 pm

See attached generic-contact template and lnux-server template config. As far as I can see Host and Service Notifications are both enabled.

Also, Id like to verify if this free version of Nagios able to support VM instances because all of the servers that we have to monitor are mostly VMs (ProxMox VMs and VMware ESXi VMs) beside Network switch, router and firewall.
Attachments
templates.cfg
(12.49 KiB) Downloaded 116 times
nib01
 
Posts: 31
Joined: Tue Oct 09, 2018 9:31 am

Re: set up email alerts using mailx

Postby tgriep » Thu Jan 24, 2019 5:34 pm

Check the nagios.cfg file and make sure notifications are enabled. Check this setting.
Code: Select all
enable_notifications=1


Then restart the nagios service and test to see if the Notifications are working.

Can you go to the Notification Report and see if you can find the host there and post what it look like?orking.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8375
Joined: Thu Oct 30, 2014 9:02 am

PreviousNext

Return to Nagios Core

Who is online

Users browsing this forum: tgriep and 19 guests