Toon posts:

Nagios Monitoring Service

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Hallo,

Ik heb een nagios server staan, maar het lukt me niet om een mailke te laten sturen als er een service uit gaat.

Ubuntu 14.04
Nagios 4.0.8
Postfix (Een e-mail versturen met postfix gaat zonder probleem)
Maar ik krijg nagios niet geconfigureerd dat hij een mailke stuurt als een service uitvalt.

Instellingen:

Contact.cfg:
# 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

email **KNIP** ; <<***** 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
}
Localhost.cfg
# 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 generic-service ; Name of service template to use
host_name localhost
service_description SSH
contact_groups admins
check_command check_ssh
notifications_enabled 1
}
Templates.cfgg
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
Commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Wat zie ik over het hoofd?

Groetjes
Christiaan

[ Voor 0% gewijzigd door rens-br op 20-09-2023 14:17 ]


Acties:
  • 0 Henk 'm!

  • Mr_x007
  • Registratie: Oktober 2001
  • Laatst online: 17:14
Ik zie nergens in je config opgegeven dat het command notify-service-by-email aan een contact gekoppeld is.
voeg in de contact.cfg onder je email adres en boven de sluitende } de volgende regels toe:
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
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

email christiaan.keyers@gmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
}
Ik heb het aangepast, maar ik krijg niks binnen als ik een custum service notification verstuur.

Acties:
  • 0 Henk 'm!

  • Mr_x007
  • Registratie: Oktober 2001
  • Laatst online: 17:14
Zie je wel wat in je maillog voorbij komen? je mailt naar gmail, dus zou ook wel eens in je spamfilter terecht kunnen komen.
Test anders het volgende commando ook even:
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: Custom\n\nService: TEST\nHost: TEST\nAddress: TEST\nState: Down\n\nDate/Time: nu :) \n\nAdditional Info:\n\n Kaput\n" | /bin/mail -s "** Custom Service Alert: Test/Test is Down **" christiaan.keyers@gmail.com

Als de mail dan wel binnen komt wordt die niet goed door Nagios getriggert, anders kan het zijn dat hij ergens wordt tegengehouden.

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ik heb het anders gedaan,
Ik heb een php aangemaakt met een voorgeschreven mailke.

En als hij dan uitvalt gebruikt hij het commando php /var/www/email.php
en dan stuurt hij mij een mailke.
Dit werkt wel :)

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
@Mr_x007
Uw commando werkt niet, kan de service niet herstarten.
Pagina: 1