Page 3 of 4

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 2:41 am
by baber
rkennedy wrote:Do you have DNS setup on your machine? This is why your notifications aren't sending properly. You could also add a manual entry to your /etc/hosts file for dsa.co.ir.

It resolves fine on my end -

Code: Select all

[root@localhost var]# nslookup dsa.co.ir
Server:         192.168.5.2
Address:        192.168.5.2#53

Non-authoritative answer:
Name:   dsa.co.ir
Address: 185.10.72.56

thanks

but i have set my mail server ip and name in /etc/hosts

but when type nslookup show

Server: 172.x.x.x
Address: 172.x.x.x

Non-authoritative answer:
*** Can't find dsa.co.ir: No answer

my hosts file :

Code: Select all

127.0.0.1   localhost
172.x.x.x    dsa.co.ir
172.x.x.x    mymailserver.com
172.x.x.x    mymailserver2.com


but in mail log file see changes attached log file see that please

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 3:50 am
by baber
another attached all of my files please see them and in previous post attached mail log file

i am realy confused what is my problem

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 8:05 am
by baber
baber wrote:another attached all of my files please see them and in previous post attached mail log file

i am realy confused what is my problem

now this is end of my maillog file


Code: Select all

Jun  3 17:29:31 lin postfix/local[5873]: 432B1713A8: to=<[email protected]>, relay=local, delay=0.08, delays=0.05/0/0/0.02, dsn=5.2.2, status=bounced (cannot update mailbox /var/mail/nagios for user nagios. error writing message: File too large)
Jun  3 17:29:31 lin postfix/qmgr[2032]: 432B1713A8: removed
Jun  3 17:29:31 lin postfix/local[5854]: 434DE713AD: to=<[email protected]>, relay=local, delay=0.08, delays=0.05/0.02/0/0, dsn=5.2.2, status=bounced (cannot update mailbox /var/mail/nagios for user nagios. error writing message: File too large)
Jun  3 17:29:31 lin postfix/qmgr[2032]: 434DE713AD: removed


now i have change Modify Postfix Mailbox Size Limit :
edit /etc/postfix/main.cf and in the end of line add

# Modify Mailbox Size Limits (Default = 50MB, 0 = unlimited, 512000000 = roughly 500MB)
mailbox_size_limit = 0

then /etc/init.d/postfix reload

and my logfile is now :

Code: Select all

Jun  3 17:40:19 lin postfix/qmgr[6287]: 614E5713A0: removed
Jun  3 17:42:16 lin postfix/pickup[6293]: 9708F71365: uid=501 from=<nagios>
Jun  3 17:42:16 lin postfix/cleanup[6508]: 9708F71365: message-id=<[email protected]>
Jun  3 17:42:16 lin postfix/qmgr[6287]: 9708F71365: from=<[email protected]>, size=723, nrcpt=1 (queue active)
Jun  3 17:42:16 lin postfix/smtp[6510]: 9708F71365: to=<[email protected]>, relay=none, delay=0.33, delays=0.25/0.07/0.01/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=dsa.co.ir type=AAAA: Host found but no data record of requested type)
Jun  3 17:42:16 lin postfix/cleanup[6508]: C6750713A0: message-id=<[email protected]>
Jun  3 17:42:16 lin postfix/bounce[6511]: 9708F71365: sender non-delivery notification: C6750713A0
Jun  3 17:42:16 lin postfix/qmgr[6287]: C6750713A0: from=<>, size=2672, nrcpt=1 (queue active)
Jun  3 17:42:16 lin postfix/qmgr[6287]: 9708F71365: removed
Jun  3 17:42:17 lin postfix/local[6513]: C6750713A0: to=<[email protected]>, relay=local, delay=0.21, delays=0.03/0.17/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)

but not send any email to me

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 2:12 pm
by rkennedy
From the Nagios machine, can you run ping dsa.co.ir?

At this point, I don't think the issue is with Nagios, or your configuration, but rather your mail settings / DNS.

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 2:13 pm
by tgriep
Can you post your /etc/hosts and your /etc/resolv.conf file so we can review them?
It still looks like there is a DNS issue on your server.

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 3:11 pm
by baber
rkennedy wrote:From the Nagios machine, can you run ping dsa.co.ir?

At this point, I don't think the issue is with Nagios, or your configuration, but rather your mail settings / DNS.

yes i can ping that

dd yu previous posts ?

did you my conig files? are ok ?

Re: How can enable notify via send email

Posted: Fri Jun 03, 2016 3:16 pm
by baber
tgriep wrote:Can you post your /etc/hosts and your /etc/resolv.conf file so we can review them?
It still looks like there is a DNS issue on your server.
i have attached resolve.conf file

host file:

Code: Select all

127.0.0.1   localhost
172.20.42.64    dsa.co.ir
172.20.42.64	middleeastbank.ir
172.20.42.60    mebank.com
 


Re: How can enable notify via send email

Posted: Mon Jun 06, 2016 4:48 pm
by tmcdonald
This ServerFault listing might be helpful:

http://serverfault.com/questions/577134 ... und/577300

Basically it boils down to your Nagios system trying to use IPv6 to communicate with your mail server. Can you try disabling IPv6 and see if this helps?

Re: How can enable notify via send email

Posted: Tue Jan 24, 2017 5:29 am
by baber
dear friend
HI

i have checked all of these on the other server:


1- add mail server with ip in host file

10.10.10.0 mail.com

now when type nslookup mail.com the result is :

;; connection timed out; no servers could be reached

2- output of ps sendmail :

Code: Select all

grep sendmail
smmsp      953     1  0 Jan21 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root     26819 12703  0 11:59 pts/1    00:00:00 grep sendmail

this is my contact file

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                          [email protected]	; <<***** 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
        }
this is server.cfg file

Code: Select all

define host{
	use		windows-server			; Inherit default values from a template
	host_name	DNS				; The name we're giving to this host
	alias		server DNS			; A longer name associated with the host
	address		10.10.10.2				; IP address of the host
	}


define service{
	use					local-service
	host_name				DNS
	service_description			Memory Usage
	check_command				check_nt!MEMUSE!-w 90 -c 95
	}


define service{
	use					local-service
	host_name				DNS
	service_description			Cpu Usage
	check_command				check_nrpe!alias_cpu
	}
and these are in template.cfg file

Code: Select all

define host{
	name			windows-server	; 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-DC ; Host groups that Windows servers should be a member of
	register		0		; DONT REGISTER THIS - ITS JUST A TEMPLATE
	}


define service{
	name				local-service 		; The name of this service template
	use				generic-service		; Inherit default values from the generic-service definition
        max_check_attempts              3			; Re-check the service up to 4 times in order to determine its final (hard) state
        normal_check_interval           5			; Check the service every 5 minutes under normal conditions
        retry_check_interval            1			; Re-check the service every minute until a hard state can be determined
        register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
	contact_groups			admins
	}

these are in command.cfg file

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 -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$
        }


and attached mail.log file

finally that server (DNS) is down and services are down but nagios don't send any email to me i am confused what is my problem ?

Re: How can enable notify via send email

Posted: Tue Jan 24, 2017 12:05 pm
by rkennedy
Based on the error message -

Code: Select all

Jan 24 13:51:11 Nagios postfix/error[17639]: 92B9B61615: to=<[email protected]>, relay=none, delay=256450, delays=256450/0.05/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=karafarinbank.ir type=MX: Host not found, try again)
It appears you need to setup DNS correctly which doesn't seem to be in place. The records do exist, but you're not resolving them. http://mxtoolbox.com/SuperTool.aspx?act ... n=toolpage