I've implemented Nagios 3.5.1 on one node to monitor basic metrics coming from Ganglia gmetad and gmond clients to Nagios via ganglia-nagios-bridge.py script.
Currently, I'm having issues with alerts, as e-mails do not get sent out, even when I can see alerts being logged in the Nagios web UI. One suspicion I have is that there are 2 missing missing files, /var/spool/mail/nagios and /var/mail/nagios. I would like to find out why these 2 files are missing, and what I can do to work around this.
The following is my contacts.cfg file:
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 brazelton.w.mann#hpe.com ; <<***** 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
}
I've validated I can use the mail command to send e-mails to this address. Operations system: Red Hat Enterprise Linux 6.6.
Commands run to install nagios and dependent components:
yum install httpd
yum install mailx
yum install nagios
yum install nagios-www
yum install nagios-plugins-all
yum install nagios-plugins-nrpe
yum install php
First please check if you're able to send e-mail from operating system by following command:
echo test | mail -s 'test mail' yourmail#mailservice.com
If you are receiving email then probably you have problem with them mail command configuration.
Related
I have installed OrangeHrm 3.3.3 on Ubuntu 14.04 Server and now trying to configure SMTP Email.
The credentials and settings are correct. I am using same in SuiteCRM installed on CentOS 7.
The message I get
Settings Saved. Test email not sent.
I remember doing this on CentOS:
chcon -R -t httpd_sys_content_rw_t /var/www/html
setsebool httpd_can_network_connect=on
setsebool httpd_can_sendmail=on
setsebool httpd_unified=on
Is there some similar settings for Apache on Ubuntu where I can allow sendmail on the server?
I would highly appreciate your input.
Thanks in advance.
/AAN
My knowledge of perl is limited to running commands. I have managed to come up with a shell script to output the gav of a pom.xml, using xpath as follows:
xpath pom.xml '//project/artifactId/text()'
On a new machine right now, this does not work because I do not have the XPath.pm installed:
Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .)
I seem to remember installing XPath using cpan so I tried the following command, blindly:
cpan XPath
This is probably not the correct command to use, but I think that is unrelated to the issue I am facing. The command gives following error:
Going to read '/home/****/.cpan/Metadata'
Database was generated on Mon, 25 Aug 2014 00:41:02 GMT
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not connect to 'proxy:8080': IO::Socket::INET: Bad hostname 'proxy' at /usr/lib/perl5/5.14/HTTP/Tiny.pm line 139
Proxy authentication needed!
(Note: to permanently configure username and password run
o conf proxy_user your_username
o conf proxy_pass your_password
)
Username: C-c C-c
Why is HTTP::Tiny looking for host proxy? We do have a corporate proxy with hostname proxy but that is needed only when I am on corporate network or VPN, neither of which is case right now.
How do I convince HTTP::Tiny to connect directly to internet? I do not have an envvar named http_proxy or HTTP_PROXY set.
While the environment variable is used, cpan first checks its configuration.
To view: o conf http_proxy
To clear: o conf http_proxy ''
Don't forget to use o conf commit to make the change permanent.
CPAN uses HTTP:Tiny to download info about the module you are asking for. It is lightweight so it runs fast.
Either CPAN has not been configured, or the cpan found on your path is configured to use the proxy. Determine the location of the CPAN program you are executing and proceed from there.
This msg Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .) shows that module is not installed.
If you are on windows and using a proxy setting. You can use these commands to install module from ppm or cpan. Open a command prompt and run these commands :
set http_proxy=http://xxx.xxx.xxx.x:yyyy (xxx is your system proxy and yyyy is port)
set http_proxy_user=username (login username)
set http_proxy_pass=password (login password)
To install a module from cpan type:
cpan install modulename
The error occurs because you have set http_proxy variable to direct IP, Instead, put http_proxy=http://ipaddress , then it will work
I have access to a couple of Ubuntu servers and I am trying to configure the PHP mail() command for each of these servers. However, for one of these servers, the From: header is overwritten by www-data#. I have no access to the SPF record of that hostname, so I want to configure the mail server so it doesn't overwrite the From: header.
So my question is, how do I find out which mail server is used so I can correctly configure that mail server? (Postfix, SSMTP, ...)
Thanks in advance!
To get a list of packages installed locally do this in your terminal:
dpkg --get-selections | grep -v deinstall
To save that list to a text file called packages on your desktop do this in your terminal:
dpkg --get-selections | grep -v deinstall > ~/Desktop/packages
Then search for Mailserver. I'll do my bet for Postfix, which seems to be the most used.
Credit goes here
$ dpkg -l | grep mail
rc libc-client2007e 8:2007f~dfsg-4 amd64 c-client library for mail protocols - library files
ii libmail-sendmail-perl 0.79.16-1 all Send email from a perl script
ii libmailtools-perl 2.13-1 all Manipulate email in perl programs
ii libmailutils4:amd64 1:2.99.99-1ubuntu2 amd64 GNU Mail abstraction library
ii mailutils 1:2.99.99-1ubuntu2 amd64 GNU mailutils utilities for handling mail
ii mailutils-common 1:2.99.99-1ubuntu2 all Common files for GNU mailutils
ii mime-support 3.59ubuntu1 all MIME files 'mime.types' & 'mailcap', and support programs
ii postfix 3.1.0-3ubuntu0.3 amd64 High-performance mail transport agent
Finding which server is listening on port 25 may help (expecially if you have multiple MTA installed but only one which one is running).
(sudo) netstat -tanp | grep ':25'
As Following suggested, you need to be root (sudo).
You will get the PID of the process, for example :
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 98249/master
Here I found the PID (98249 in my case), and you can get more information with ps or lsof
ps 98249
lsof -p 98249
Recently I installed msmtp on my ubuntu 12.04 server that is running the kubuntu desktop. The install of msmtp worked fine, and I can even send mail through the terminal using gmail's smtp server.
My problem is that although sending mail works through the terminal, it still doesn't work with php mail. I have tried using the php mail() function, but I never receive any email.
I have checked the apache error logs (/var/log/apache2/error.log), but they are empty.
Does anyone know how to fix this? If any further information is needed, just say so :)
Also when executing the php script, no errors appear.
The code below echos Mail Sent, but I never recieve an email:
<?
if(mail( 'noreply.njmedia#gmail.com', 'Test mail from localhost', 'Working Fine.'))
{
echo 'Mail sent';
}
else
{
echo 'Error. Please check error log.';
}
?>
For me the cause was incorrect file ownership & permissions on the msmtp config file.
When I tried to run the PHP mail-sending script from the CLI as root, it worked. However switching user to www-data and trying to run the script again (also on CLI) failed with the following messages:
msmtp: /etc/msmtprc: contains secrets and therefore must be owned by you
msmtp: /etc/msmtprc: contains secrets and therefore must have no more than user read/write permissions
Triggering the PHP script by a HTTP request to Apache (or Nginx etc) would have the same results (since msmtp would be invoked by the www-data user).
Assuming your msmtp config file is at /etc/msmtprc, these commands would fix those issues:
chown www-data:www-data /etc/msmtprc
chmod 600 /etc/msmtprc
Before making these changes please consider if these new permissions are appropriate for your circumstances (eg. are there security implications?).
The php mail module calls a system command called sendmail for sending emails. sendmail is implemented by various mail servers, e.g. postfix or exim. As I see, msmtp doesn't provide a sendmail binary. Please check, if you can execute sendmail via command line. If not, try to install postfix.
update:
I see, that msmtp-mta does provide an sendmail binary too. You can try this, if you don't want postfix.
I have installed perl in windows 7 and configured the proxy (http & ftp) as at How do I install a module? Strawberry Perl issues by Axeman, replacing proxy with my lan proxy IP and port respectively. However, when I run cpanm App::cpanminus, it returns a message for proxy authentication which has faile. Its requesting for a username.
you need to set the http_proxy environment variable in the form:
http_proxy=http://user:password#host:port/
Otherwise just use the cpan client.
Edit: 2012-08-29
If you do not have the proxy username and password, you are not getting out through that proxy regardless of the client software.