Solved

nagios notification

Posted on 2013-12-19
8
351 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
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é.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

760 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

16 Experts available now in Live!

Get 1:1 Help Now