terça-feira, 5 de fevereiro de 2013

How to: Cacti



INSTALAÇÃO E CONFIGURAÇÃO DO CACTI

Executar o comando de instalação:
apt-get install -y  apache2 php5 php5-mysql php5-cli php-pear php5-suhosin php5-curl php5-gd php5-snmp snmp snmpd libapache2-mod-php5 mysql-server cacti

Na instalação do cacti, será solicitado:
1-) Configuração do mysql
Escolher a opção SIM e digitar a senha do administrador do Mysql
2-) Digite a senha para o banco do mysql, dica "cacti"
3-) Selecione o servidor WEB - padrão apache2
4-) Usando o browser de uma máquina qualquer,  que está na mesma rede, digite:
Sendo que o ip que está na url é o computador que estaá instalado o cacti

Tela 1

Clique em NEXT >>
===========================================================================

Tela 2

As configurações deverão ficar assim:


Clique em FINISH
===========================================================================

O usuário e senha padrão:
admin = senha admin
===========================================================================

Instalando o agent snmp nos computadores a serem monitorados:

Instalação no CentOS:
yum install net-snmp net-snmp-libs net-snmp-utils -y
Instalação no Debian:
apt-get install libsnmp-base libsnmp15 snmp snmpd -y

Agent SNMP em coputadores linux:
Fazer um cópia de segurança do arquivo /etc/snmp/snmpd.conf;  
Configurar o arquivo de configuração snmp para apontar para o servidor cacti, 

vi /etc/snmp/snmpd.conf
syslocation     "IDC-Laboratorio-Virtual-de-Testes"
syscontact      "debian-teste - <lion.lookline@gmail.com>"
com2sec         readonly        127.0.0.1        seguranca
com2sec         readonly        192.168.1.134    seguranca
group           rogroup v1      readonly
group           rogroup v2c     readonly
group           rogroup usm     readonly
view            all             included        .1      80
access          rogroup         ""              any     noauth  exact   all    none     none
A palavra seguranca é o grupo que tem permissão de ssh, que está configurado sshd_config.


Ressalvas, efetuando alguns testes, na plataforma CentOS:
snmpwalk -v 1 localhost -c ananke system
ou
snmpwalk -Os -c ananke -v 1 localhost | head

RESULTADO:
SNMPv2-MIB::sysDescr.0 = STRING: Linux centos-teste 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10z'
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (8235595) 22:52:35.95
SNMPv2-MIB::sysContact.0 = STRING: "centos-teste - <kleber.lookline@gmail.com>"
SNMPv2-MIB::sysName.0 = STRING: centos-teste
SNMPv2-MIB::sysLocation.0 = STRING: "IDC-Lab-Virtual"
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (4) 0:00:00.04

===========================================================================


Agent SNMP em coputadores Windows:

PASSO 1:





PASSO 2:






PASSO 3:



PASSO 4:






PASSO 5:






PASSO 6:




PASSO 7:






How to: Postfix com Gmail




Neste post vou ensinar como configurar o Postfix a enviar emails usando a conta do Gmail.
O texto em vermelho é o que o usuário deverá digitar.


1-) dentro do diretório:
cd /usr/lib/ssl/misc

2-) Executar o seguinte comando:
./CA.pl -newca

Após executar esse comando, você vai preencher os dados necessários:
CA certificate filename (or enter to create)
Making CA certificate ...
Generating a 1024 bit RSA private key
................++++++
.........................++++++
writing new private key to './demoCA/private/cakey.pem'
Enter PEM pass phrase:<SENHA>
Verifying - Enter PEM pass phrase:<SENHA>
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:BR
State or Province Name (full name) [Some-State]:Sao Paulo
Locality Name (eg, city) []: <Pressionar ENTER nao precisa preencher>
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Black Screen Linux
Organizational Unit Name (eg, section) []: <Pressionar ENTER nao precisa preencher>
Common Name (eg, YOUR name) []:lion pereira de oliveira
Email Address []:lion.lookline@gmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:<PRESSIONE-ENTER>
An optional company name []:<PRESSIONE-ENTER>
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem: <SENHA-INICIAL-DIGITADA>
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            b1:5d:90:9b:48:2a:1f:31
        Validity
            Not Before: Feb  5 12:27:07 2013 GMT
            Not After : Feb  5 12:27:07 2016 GMT
        Subject:
            countryName               = BR
            stateOrProvinceName       = Sao Paulo
            organizationName          = Black Screen Linux
            commonName                = lion pereira de oliveira
            emailAddress              = lion.lookline@gmail.com
        X509v3 extensions:
            X509v3 Subject Key Identifier:
                0D:B1:20:CF:F3:DC:49:7E:BC:0A:68:70:CA:21:F2:DE:41:19:9C:B9
            X509v3 Authority Key Identifier:
                keyid:0D:B1:20:CF:F3:DC:49:7E:BC:0A:68:70:CA:21:F2:DE:41:19:9C:B9
                DirName:/C=BR/ST=Sao Paulo/O=Black Screen Linux/CN=lion pereira de oliveira/emailAddress=lion.lookline@gmail.com
                serial:B1:5D:90:9B:48:2A:1F:31

            X509v3 Basic Constraints:
                CA:TRUE
Certificate is to be certified until Feb  5 12:27:07 2016 GMT (1095 days)

Write out database with 1 new entries
Data Base Updated

3-) Vai ser criado um diretório:
ls -lh /usr/lib/ssl/misc/
drwxr-xr-x 6 root root 4.0K Feb  5 10:49 demoCA
Executar o comando dentro do diretorio /usr/lib/ssl/misc:
openssl x509 -in demoCA/cacert.pem -days 3650 -out cacert.pem -signkey demoCA/private/cakey.pem
Digitar a senha novamente, E nao vai aparecer nenhum erro

4-) Copiar o arquivo para o diretório:
cp cacert.pem demoCA/
Executar a sintaxe com os dados preenchidos corretamente:
openssl req -new -nodes -subj '/CN=dcerouter/C=BR/ST=Sao Paulo/O=Black Screen Linux/CN=lion pereira de oliveira/emailAddress=lion.lookline@gmail.com' -keyout key.pem -out  req.pem -days 3650
Generating a 1024 bit RSA private key
..++++++
...........++++++
writing new private key to 'key.pem'

5-) Executar o comando, colocar a senha anterior e aceitar os termos do certificado e a sua instalação.
openssl ca -out cert.pem -infiles req.pem

Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem: <SENHA-INICIAL-DIGITADA>
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            b1:5d:90:9b:48:2a:1f:32
        Validity
            Not Before: Feb  5 12:37:26 2013 GMT
            Not After : Feb  5 12:37:26 2014 GMT
        Subject:
            countryName               = BR
            stateOrProvinceName       = Sao Paulo
            organizationName          = Black Screen Linux
            commonName                = dcerouter
            commonName                = lion pereira de oliveira
            emailAddress              = lion.lookline@gmail.com
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                5A:58:15:75:9C:49:B9:A9:76:38:73:D8:25:D9:A6:5E:56:11:1F:3B
            X509v3 Authority Key Identifier:
                keyid:0D:B1:20:CF:F3:DC:49:7E:BC:0A:68:70:CA:21:F2:DE:41:19:9C:B9
Certificate is to be certified until Feb  5 12:37:26 2014 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

6-) Executar a sequência de comandos:
cp demoCA/cacert.pem /etc/postfix && cp key.pem /etc/postfix && cp cert.pem /etc/postfix && chmod 644 /etc/postfix/cert.pem && chmod 644 /etc/postfix/cacert.pem && chmod 400  /etc/postfix/key.pem

7-) Executar a sequência de comandos:
apt-get install ca-certificates -y && cat /etc/ssl/certs/Equifax_Secure_CA.pem >> cacert.pem && cd /etc/postfix/

8-) Criar o arquivo, com o conteúdo:
 /etc/postfix# vi transport
# Contents of /etc/postfix/transport
 #
 # This sends mail to Gmail
 *               smtp:[smtp.gmail.com]:587
 #local mail delivered local
 dcerouter       relay:[dcerouter]

9-) Criar o arquivo generic dentro do /etc/postfix
 /etc/postfix# touch generic

10-) Criar o arquivo sasl_passwd dentro do /etc/postfix com o conteúdo:
 /etc/postfix# vi sasl_passwd
[smtp.gmail.com]:587             lion.lookline@gmail.com:<SENHA-DO-EMAIL>

11-) Executar os comando para gerar os arquivos db:
cd /etc/postfix && postmap sasl_passwd &&  postmap transport && postmap generic

12-) Executar, fazer uma cópia do arquivo main.cf e deixar ele vazio para inserir novas informações:
cp main.cf main.cf.old && > main.cf
Adicionar as linhas:
/etc/postfix#  vi main.cf
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

13-) Por fim, reinicie o postfitx.
/etc/init.d/postfix restart
--------------------------------------------------------------------------------------------------------------------------------


Ressalvas, efetuando alguns testes de envio de email:

Essa síntaxe envia email para duas pessoas, referente ao conteúdo do arquivo /etc/hosts:
mailx -s "Titulo da mensagem" drikaoliveira_sp@yahoo.com.br < /etc/hosts


Essa síntaxe envia um email com o anexo /home/lion/fotojoelma.jpeg:
echo "Aqui você coloca o texto que será o corpo do email " | mutt -s "Favor não responder SRV-LINUX" -a /home/lion/fotojoelma.jpeg -- lion.lookline@gmail.com


Essa síntaxe envia uma cópia para drika e uma cópia oculta para o email blackopensource@gmail.com, mais o anexo /home/lion/fotojoelma.jpeg:
echo "Aqui você coloca o texto que será o corpo do email " | mutt -s "Favor não responder SRV-LINUX" -a /home/lion/fotojoelma.jpeg -- lion.lookline@gmail.com , drikaoliveira_sp@yahoo.com.br -b blackopensource@gmail.com