LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Nagios email not working (https://www.linuxquestions.org/questions/linux-newbie-8/nagios-email-not-working-841629/)

teppel 11-01-2010 02:54 AM

Nagios email not working
 
Sorry didnt know the rules. I will repost my problem and solution here. Although i not too sure whether is it the right solution.

My purpose of nagios is to send mail notification to localhost account user when there problem with the services or host.

I reset my whole installation of the ubuntu server and nagios again. During 2nd installation, i install postfix first instead of mailx. Because i realise when u apt-get install mailx it will automatically set the postfix configuration for u instead of guiding you through. However, when u apt-get install postfix a interface will appear on the screen.

I hope i helping more than mis-leading people here. Do feel free to correct me if there any mistakes in my solution because i am still new to nagios and ubuntu.

refer to the link below for how to setup ubuntu and nagios:
http://nagios.sourceforge.net/docs/3...rt-ubuntu.html


P.S I apologise for my mistake


postfix
Code:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = ubuntu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = cmgameacct@gmail.com, ubuntu, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

contact.cfg file
Code:

###############################################################################
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
#
# Last Modified: 05-31-2007
#
# NOTES: This config file provides you with some example contact and contact
#        group definitions that you can reference in host and service
#        definitions.
#     
#        You don't need to keep these definitions in a separate file from your
#        other object definitions.  This has been done just to make things
#        easier to understand.
#
###############################################################################



###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.

define contact{
        contact_name                    nagiosadmin                ; Short name of user
        use                                generic-contact                ; Inherit default values from generic-contact template (defined above)
        alias                          Nagios Admin                ; Full name of user
        service_notifications_enabled  1
        host_notifications_enabled      1
        service_notification_period    24x7
        host_notification_period        24x7
        service_notification_options    c,w,r
        host_notification_options      d,u,r

        email                          nagois@localhost        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }



###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name      admins
        alias                  Nagios Administrators
        members                nagiosadmin
        }

Code:

###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 05-31-2007
#
# NOTE: This config file is intended to serve as an *extremely* simple
#      example of how you can create configuration entries to monitor
#      the local (Linux) machine.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
        use                    linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name              localhost
        alias                  localhost
        address                127.0.0.1
        }

define host{
        use                    linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name              ubuntu
        alias                  localhost
        address                192.168.220.136
        }


###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup{
        hostgroup_name  linux-servers ; The name of the hostgroup
        alias          Linux Servers ; Long name of the group
        members        localhost    ; Comma separated list of hosts that belong to this group
        }



###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Define a service to "ping" the local machine

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            PING
        check_command                        check_ping!100.0,20%!500.0,60%
        }

define service{
        use                            local-service        ; Name of service template to use
        host_name                      ubunutu
        service_description            PING
        check_command                        check_ping!100.0,20%!500.0,60%
        }

# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            Root Partition
        check_command                        check_local_disk!20%!10%!/
        }



# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            Current Users
        check_command                        check_local_users!20!50
        }


# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 users.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            Total Processes
        check_command                        check_local_procs!250!400!RSZDT
        }



# Define a service to check the load on the local machine.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            Current Load
        check_command                        check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }



# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            Swap Usage
        check_command                        check_local_swap!20!10
        }



# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            SSH
        check_command                        check_ssh
        notifications_enabled                0
        }



# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
        use                            local-service        ; Name of service template to use
        host_name                      localhost
        service_description            HTTP
        check_command                        check_http
        notifications_enabled                0
        }


MensaWater 11-02-2010 12:08 PM

If you solved the problem you should repost your issue AND post your solution. That way if anyone has the same problem in the future they'll find your post.

Also go to Thread Tools and mark it as solved after you post the above. It makes it easier to zero in on your solution in a web search later.


All times are GMT -5. The time now is 06:17 PM.