Solved

nagios notification

Posted on 2013-12-19
8
353 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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.

773 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