Solved

nagios notification

Posted on 2013-12-19
8
356 Views
Last Modified: 2013-12-20
I have problem Mail notification in nagios 3(debian Linux).but my Postfix mail works because if i make a test like
mail -v it@domain.com then comes mail

hier is my configurations:

###contact.cfg
define contact{
        contact_name                    myname
        alias                           myname
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           it@mydomain.com
        }


define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin, it
        }


###command.cfg
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: http://nagios/nagios/cgi-bin/status.cgi?host=$HOSTNAME$&style=detail\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/local/nagios/libexec/eventhandlers/sendsms $CONTACTPAGER$ "NAGIOS $NOTIFICATIONTYPE$ $DATE$ $TIME$ $HOSTNAME$ Service: $SERVICEOUTPUT$"
        }

###nagios.cfg


# NOTIFICATION LOGGING OPTION
# If you don't want notifications to be logged, set this value to 0.
# If notifications should be logged, set the value to 1.

log_notifications=1
0
Comment
Question by:apollo-13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 

Author Comment

by:apollo-13
ID: 39731231
i found something mails sended root@localhost . how can i change?
0
 
LVL 7

Expert Comment

by:Beneford
ID: 39731248
Do you have

contact_groups admins

in your host/service definitions?

You also need to have the contacts you want to receive the email defined in the group referred to in contact_groups, so

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin, it, admins
        }
0
 

Author Comment

by:apollo-13
ID: 39731257
No   contact_groups admins .how can i do that?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Beneford
ID: 39731262
In your definitions of hosts and services, you indicate who should be notified by including the line:

contact_groups admins

so (eg):
define host{
       host_name    MyRouter
       address          192.168.1.1
       contact_groups admins
       }

This contact_groups refers to one or more contactgroup definitions (the one you have shown above is called 'admins')
The contactgroup collects the contacts, and these contacts are notified when a notifiable event takes place.
0
 

Author Comment

by:apollo-13
ID: 39731293
I have so :

#######PC19 TEST PING #######

define host{
      use            windows-server
      host_name       PC19
      alias                       Remote Windows Host
      address             x.x.x.x ip
      contact_groups       admins
     icon_image           internet_device.png
       statusmap_image      internet_device.gd2

}

define service{

      use                  generic-service
      host_name            PC19
      service_description      Explorer
      check_command            check_nt!PROCSTATE! -d SHOWALL -l Explorer.exe

      }
0
 

Author Comment

by:apollo-13
ID: 39731307
i do not undesrtand something. I have in two diffrent place contact.cfg ,which one do i need to use?
/etc/nagios3/objects/contacts.cfg
/etc/nagios3/conf.d/contactsnagios2.cfg
0
 

Author Comment

by:apollo-13
ID: 39731310
mails still come to mail  root [root@mydomain.com].But i definied my mail address.
0
 
LVL 7

Accepted Solution

by:
Beneford earned 500 total points
ID: 39731442
You need to trace the configuration - do you have the web UI running?

At the bottom, select: configuration and then select Contact Groups, and Contacts and check it's what you were expecting?
Then look at Hosts and see that the Contacts/Groups is right.

This config is what is actually running - you should be able to trace the .cfg files.

The file /etc/nagios/nagios.cfg indicates which .cfg files are used:
cfg_file= <-- this line is probably repeated for individual files
cfg_dir= <-- this is a directory - all .cfg files here will be loaded.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux SFTP 8 80
Samba 4, Users Permission, 5 68
python - find anything after $ question. 9 52
Windows 10 linux VM 18 43
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question