Solved

nagios notification

Posted on 2013-12-19
8
352 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
  • 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
 
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now