Difference between revisions of "Pandora: Configuration emails alerts"

From Pandora FMS Wiki
Jump to: navigation, search
(Postfix Setup)
Line 47: Line 47:
 
</center>
 
</center>
  
=== Postfix Setup ===
+
=== Instalación Postfix ===
  
Assuming Postfix is already installed and everything works fine except for sending feedback to gmail, here are the steps to follow:
+
Los paquetes que debe tener instalados en el servidor de Pandora para el correcto funcionamiento del servidor postfix junto con una cuenta de GMAIL.
  
1-- Edit the  /etc/postfix/main.cf configuration file and add the following lines at the end of the file:
+
yum install postfix mailx cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib cyrus-sasl-md5 cyrus-sasl-scram cyrus-sasl-gssapi
 +
 
 +
=== Configuración Postfix ===
 +
 
 +
Asumiendo que ya tiene instalado Postfix en su servidor y todo funciona correctamente excepto el envío de mail via gmail, debe seguir estos pasos:
 +
 
 +
1-- Comprobar que tiene habilitada en su cuenta de Gmail la opción "less secure pass". Para ello puede habilitarlo en este link.(https://myaccount.google.com/lesssecureapps)
 +
 
 +
2-- Editar el fichero /etc/postfix/main.cf y añadir las siguientes líneas al final del archivo:
  
 
  relayhost = [smtp.gmail.com]:587
 
  relayhost = [smtp.gmail.com]:587
 
  smtp_sasl_auth_enable = yes
 
  smtp_sasl_auth_enable = yes
  smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
+
  smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
 +
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
 
  smtp_sasl_security_options = noanonymous
 
  smtp_sasl_security_options = noanonymous
 
  smtp_use_tls = yes
 
  smtp_use_tls = yes
  smtp_tls_CAfile = /etc/postfix/cacert.pem
+
  smtp_tls_CAfile = /etc/pki/tls/cert.pem
 +
smtp_tls_security_level = encrypt
 +
  
2-- Create the /etc/postfix/sasl/passwd file with your gmail address and password (you must create the “sasl” directory and then create the password file in there).
+
3-- Crear el archivo /etc/postfix/sasl_passwd con su dirección de gmail y contraseña.
  
To create the “sasl” directory:
+
nano /etc/postfix/sasl_passwd
  
mkdir /etc/postfix/sasl
+
Añade la siguiente linea en el fichero con su propia dirección de gmail y contraseña:
 
 
To create the password file:
 
 
 
nano /etc/postfix/sasl/passwd
 
 
 
Paste the line below with your own gmail address and password inserted:
 
  
 
  [smtp.gmail.com]:587 [email protected]:PASSWORD
 
  [smtp.gmail.com]:587 [email protected]:PASSWORD
  
Protect the password file accordingly:
+
Protegerlo adecuadamente:
 
 
chmod 600 /etc/postfix/sasl/passwd
 
 
 
This will allow only root users to access the file.
 
 
 
3-- Transform /etc/postfix/sasl/passwd into a hash type indexed file.  This will create a lookup table via postmap:
 
 
 
postmap /etc/postfix/sasl/passwd
 
 
 
Issuing this command will create a passwd.db file in the /etc/postfix/sasl/ directory.
 
 
 
4-- Now to install the Gmail and Equifax certificates. Pre-built Pandora FMS ISOs and VMware virtual images do not have these certificates included by default. If you have the certificates installed, then you can skip this part.
 
 
 
To install the Gmail certificate, follow these steps:
 
 
 
Google’s SSL cert is signed by Equifax – so first we need to fetch that.
 
Move to “tls” directory:
 
cd /etc/pki/tls/
 
  
We need to download the Equifax certificate.
+
  chmod 600 /etc/postfix/sasl_passwd
  sudo wget -O Equifax_Secure_Certificate_Authority.pem https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.cer
+
chown postfix:postfix /etc/postfix/sasl_passwd
  
Add the permissions to the downloaded file:
+
4-- Creamos el archivo /etc/postfix/tls_policy con la siguiente información:
chmod 644 Equifax_Secure_Certificate_Authority.pem
 
  
We also need to request the signature for the certificate:
+
  nano /etc/postfix/tls_policy
  openssl x509 -in Equifax_Secure_Certificate_Authority.pem -fingerprint -subject -issuer -serial -hash -noout
 
  
Next install the Gmail certificate. For this you we need the c_rehash util, so install its package:
+
[smtp.gmail.com]:587 encrypt
yum install openssl-perl
 
  
If you don't have this packet in any repositories, follow these additional steps to resolve this problem:
+
Protegerlo adecuadamente:
  sudo su
 
  nano /etc/yum.repos.d/extra_repos.repo
 
  In the #percona repository I changed the baseurl line to:  http://repo.percona.com/centos/6/os/x86_64/
 
  ^O to write the edited file
 
  ^x to exit
 
  After returning to root terminal, enter "yum install openssl-perl" and accept the defaults
 
  
Next we need to actually acquire the certificate for Gmail. Use OpenSSL to do this:
+
  chmod 600 /etc/postfix/tls_policy
  openssl s_client -connect pop.gmail.com:995 -showcerts
+
  chown postfix:postfix /etc/postfix/tls_policy
  
The output should contain the required lines for the certificate and we need to copy them to /etc/pki/tls/gmail.pem file. In order to do this, create the file:
 
nano /etc/pki/tls/gmail.pem
 
  
and paste these lines into the gmail.pem file:
+
5-- Transformamos /etc/postfix/sasl_passwd y /etc/postfix/tls_policy a un fichero indexado de tipo hash mediante la instrucción:
-----BEGIN CERTIFICATE-----
 
MIIDWjCCAsOgAwIBAgIKYgy3qQADAAAJ5zANBgkqhkiG9w0BAQUFADBGMQswCQYD
 
VQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZR29vZ2xlIElu
 
dGVybmV0IEF1dGhvcml0eTAeFw0wOTA3MTcxNzE2NTVaFw0xMDA3MTcxNzI2NTVa
 
MGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1N
 
b3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRYwFAYDVQQDEw1wb3Au
 
Z21haWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTHqjJfnRXdpmZ
 
4iP/WNCpvzX4N97bEZ3rvS4aDYey/DJetKZqp9DK1Ie4/C5j8M1aakwiTNA/eHS/
 
wNWVgQx8+HxproYKUeeYj3shYKEkHGfrRYBcyCxc7Gd6NSGaaYru3Z7nJ+STIPUJ
 
E1N35JAwcjjdITVI2O4LckAL4b7GkwIDAQABo4IBLDCCASgwHQYDVR0OBBYEFIln
 
0T5I8Mw6cqhtUS4pyMGYRxOTMB8GA1UdIwQYMBaAFL/AMOv1QxE+Z7qekfv8atrj
 
axIkMFsGA1UdHwRUMFIwUKBOoEyGSmh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vR29v
 
Z2xlSW50ZXJuZXRBdXRob3JpdHkvR29vZ2xlSW50ZXJuZXRBdXRob3JpdHkuY3Js
 
MGYGCCsGAQUFBwEBBFowWDBWBggrBgEFBQcwAoZKaHR0cDovL3d3dy5nc3RhdGlj
 
LmNvbS9Hb29nbGVJbnRlcm5ldEF1dGhvcml0eS9Hb29nbGVJbnRlcm5ldEF1dGhv
 
cml0eS5jcnQwIQYJKwYBBAGCNxQCBBQeEgBXAGUAYgBTAGUAcgB2AGUAcjANBgkq
 
hkiG9w0BAQUFAAOBgQCEGIebkDpktdjtzMiTTmEiN7e4vc73hEI4K0jYKyY0Wn5N
 
dc44AXTfIWOzsikwb886PCUSevGs9rcw2/kaHdPaBSuGrzSCf8ODQqTC3odry3lo
 
PtZGr6nf/81F5UW71+bE1iWOQlJ5/olWOr2SlqYla1iOmosEctD/GyoFnDh+BA==
 
-----END CERTIFICATE-----
 
  
Next, run the c_rehash util:
+
  postmap /etc/postfix/sasl_passwd && postmap /etc/postfix/tls_policy
  cd /etc/pki/tls
 
and
 
c_rehash .
 
  
Finally, we can test it using:
+
Lo que creará el fichero /etc/postfix/sasl_passwd.db y /etc/postfix/tls_policy.db
openssl s_client -connect pop.gmail.com:995 -CApath /etc/pki/tls
 
  
The important point is to verify the return code:0 (ok), and get the final OK Gpop ready.  If you get them you should be able to connect to Gmail.
 
  
Now let’s create the Equifax_secure_CA.pem file:
+
6-- Finalmente, reiniciamos postfix para aplicar los cambios, así:
nano /etc/ssl/certs/Equifax_Secure_CA.pem
 
 
 
Paste the following certification lines:
 
-----BEGIN CERTIFICATE-----
 
MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV
 
UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy
 
dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1
 
MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx
 
dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B
 
AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f
 
BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A
 
cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC
 
AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ
 
MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm
 
aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw
 
ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj
 
IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF
 
MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
 
A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
 
7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
 
1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
 
-----END CERTIFICATE-----
 
 
 
Save and exit.
 
 
 
In order to add the Equifax certificating authority (which certifies emails from Gmail) into the certificate file that Postfix uses, run the following command on a root-enabled console:
 
cat /etc/ssl/certs/Equifax_Secure_CA.pem > /etc/postfix/cacert.pem
 
 
 
5 - Finally, restart Postfix to apply the changes made:
 
  
 
  /etc/init.d/postfix restart
 
  /etc/init.d/postfix restart
  
6 - You can verify the performance by opening two consoles. Execute the following command in one console to monitor the behavior of the e-mails:
+
7-- Podemos comprobar el funcionamiento abriendo dos consolas. En una ejecutaremos el siguiente comando para monitorear el comportamiento del correo:
  
  tail -f /var/log/mail.log
+
  tail -f /var/log/maillog
  
You can send an email through the other one:
+
Y en la otra enviaremos un correo:
  
  echo "Email test" | mail your-email-address@gmail.com
+
  echo "Prueba correo" | mail prueba@gmail.com
  
You also may need to change the settings under your gmail account (under the “devices” tab) to receive the e-mail. You can also turn on access for less secure apps and read more about it from here:
+
Si los pasos anteriores han tenido éxito, en la otra consola deberíamos ver algo como ésto:
https://www.google.com/settings/security/lesssecureapps
 
 
 
If you have done everything correctly, something like this should appear on the other console:
 
  
 
  Dec 18 18:33:40 OKComputer postfix/pickup[10945]: 75D4A243BD: uid=0 from=
 
  Dec 18 18:33:40 OKComputer postfix/pickup[10945]: 75D4A243BD: uid=0 from=
Line 204: Line 123:
 
  Dec 18 18:33:44 OKComputer postfix/qmgr[10946]: 75D4A243BD: removed
 
  Dec 18 18:33:44 OKComputer postfix/qmgr[10946]: 75D4A243BD: removed
  
If the result is similar to the above, Pandora is properly configured and linked to the Postfix server, and will send mails as expected.
+
Si el resultado es el anterior, Pandora apuntará al servidor Postfix para mandar los correos y serán enviados sin problemas.
 
 
 
 
  
 
[[Category:Pandora FMS]]
 
[[Category:Pandora FMS]]

Revision as of 08:08, 13 May 2019

1 Quick email setup guide for alerts on Pandora FMS

1.1 Email configuration using a Gmail account

In order to configure Pandora FMS to send alerts via Gmail, Pandora and Postfix must be configured this way:

1.1.1 Pandora Configuration

In order to properly configure your email delivery with a Gmail account, all the fields must have the following comments in the Pandora FMS server configuration file (/etc/pandora/pandora_server.conf) except the mta_address field, which will be configured with the IP server or localhost (where the postfix server is installed).

If Postfix is installed on the same server as Pandora FMS, the configuration in the pandora_server.conf file should look like this:

mta_address localhost 
#mta_port 25
#mta_user [email protected]
#mta_pass mypassword
#mta_auth LOGIN
#mta_from Pandora FMS <[email protected]>


Let's look briefly at how to configure an alert on the Pandora FMS console.

1.1.1.1 Action Setup

To set the mail recipient, use the 'mail action to XXX' so you can add an email recipient to which all the mail alerts will be sent.

GMAIL1.png

1.1.1.2 Alert setup

In this case, the module configuration has been generated in the module configuration> Alerts file, a new alert with the module like the one that can be seen on the screenshot below.

GMAIL2.png

Once the alert is triggered, you can see how the alert reaches the e-mail address assigned to the action:

GMAIL3.png

GMAIL4.png

1.1.2 Instalación Postfix

Los paquetes que debe tener instalados en el servidor de Pandora para el correcto funcionamiento del servidor postfix junto con una cuenta de GMAIL.

yum install postfix mailx cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib cyrus-sasl-md5 cyrus-sasl-scram cyrus-sasl-gssapi

1.1.3 Configuración Postfix

Asumiendo que ya tiene instalado Postfix en su servidor y todo funciona correctamente excepto el envío de mail via gmail, debe seguir estos pasos:

1-- Comprobar que tiene habilitada en su cuenta de Gmail la opción "less secure pass". Para ello puede habilitarlo en este link.(https://myaccount.google.com/lesssecureapps)

2-- Editar el fichero /etc/postfix/main.cf y añadir las siguientes líneas al final del archivo:

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/pki/tls/cert.pem
smtp_tls_security_level = encrypt

3-- Crear el archivo /etc/postfix/sasl_passwd con su dirección de gmail y contraseña.

nano /etc/postfix/sasl_passwd

Añade la siguiente linea en el fichero con su propia dirección de gmail y contraseña:

[smtp.gmail.com]:587 [email protected]:PASSWORD

Protegerlo adecuadamente:

chmod 600 /etc/postfix/sasl_passwd
chown postfix:postfix /etc/postfix/sasl_passwd

4-- Creamos el archivo /etc/postfix/tls_policy con la siguiente información:

nano /etc/postfix/tls_policy
[smtp.gmail.com]:587 encrypt

Protegerlo adecuadamente:

chmod 600 /etc/postfix/tls_policy
chown postfix:postfix /etc/postfix/tls_policy


5-- Transformamos /etc/postfix/sasl_passwd y /etc/postfix/tls_policy a un fichero indexado de tipo hash mediante la instrucción:

postmap /etc/postfix/sasl_passwd && postmap /etc/postfix/tls_policy

Lo que creará el fichero /etc/postfix/sasl_passwd.db y /etc/postfix/tls_policy.db


6-- Finalmente, reiniciamos postfix para aplicar los cambios, así:

/etc/init.d/postfix restart

7-- Podemos comprobar el funcionamiento abriendo dos consolas. En una ejecutaremos el siguiente comando para monitorear el comportamiento del correo:

tail -f /var/log/maillog

Y en la otra enviaremos un correo:

echo "Prueba correo" | mail [email protected]

Si los pasos anteriores han tenido éxito, en la otra consola deberíamos ver algo como ésto:

Dec 18 18:33:40 OKComputer postfix/pickup[10945]: 75D4A243BD: uid=0 from=
Dec 18 18:33:40 OKComputer postfix/cleanup[10951]: 75D4A243BD: message-id=
Dec 18 18:33:40 OKComputer postfix/qmgr[10946]: 75D4A243BD: from=, size=403, nrcpt=1 (queue active)
Dec 18 18:33:44 OKComputer postfix/smtp[10953]: 75D4A243BD: [email protected], relay=smtp.gmail.com[74.125.93.109]:587, delay=3.7,  delays=0.15/0.14/1.8/1.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1324249500 eb5sm36008464qab.10)
Dec 18 18:33:44 OKComputer postfix/qmgr[10946]: 75D4A243BD: removed

Si el resultado es el anterior, Pandora apuntará al servidor Postfix para mandar los correos y serán enviados sin problemas.