Code: Select all
[root@mpnagios objects]# mail ivan@mydomain.com
Subject: This is a test from Nagios
This is testing the Nagios server can send
Emails. Thanks
.
EOT
1. /usr/local/nagios/etc/objects/contacts.cfg
Code: Select all
define contact {
contact_name Alan
use generic-contact
alias Alan
email myemailhere
service_notification_period 24x7
service_notification_options w,u,c,r,f,s
service_notification_commands notify-service-by-email
host_notification_period 24x7
host_notification_options d,u,r,f,s
host_notification_commands notify-host-by-email
}
Code: Select all
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 myemailhere ; Add email here
}
Code: Select all
define host{
name svr-ome ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
Code: Select all
'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/postfix "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
4. /usr/local/nagios/etc/objects/windows.cfg
Code: Select all
define host{
use windows-server ; Inherit default values from a template
host_name svr-ome ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 172.17.20.8 ; IP address of the host
}
Code: Select all
SERVICE ALERT: Svr-ome;Disk Usage;UNKNOWN;HARD;5;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042422] SERVICE NOTIFICATION: nagiosadmin;Svr-ome;Disk Usage;UNKNOWN;notify-service-by-email;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042425] HOST ALERT: Svr-ome;DOWN;SOFT;1;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042472] SERVICE ALERT: Svr-ome;CPU Usage;UNKNOWN;HARD;5;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042475] HOST ALERT: Svr-ome;DOWN;SOFT;2;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042487] SERVICE ALERT: Svr-ome;Process Count;UNKNOWN;HARD;5;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042490] HOST ALERT: Svr-ome;DOWN;SOFT;3;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042553] HOST ALERT: Svr-ome;DOWN;SOFT;4;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042593] SERVICE ALERT: Svr-ome;Memory Usage;UNKNOWN;SOFT;1;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042596] HOST ALERT: Svr-ome;DOWN;HARD;5;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042596] HOST NOTIFICATION: nagiosadmin;Svr-ome;DOWN;notify-host-by-email;UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
[1570042596] wproc: NOTIFY job 313 from worker Core Worker 11435 is a non-check helper but exited with return code 126
[1570042596] wproc: host=Svr-ome; service=(none); contact=nagiosadmin
[1570042596] wproc: early_timeout=0; exited_ok=1; wait_status=32256; error_code=0;
[1570042596] wproc: stderr line 01: /bin/sh: /bin/mail/postfix: Not a directory
[1570042596] wproc: stderr line 02: /usr/bin/printf: write error: Broken pipe