lunedì 27 luglio 2009

MONITORARE LA RETE CON XYMON, L'EREDE DI BIG BROTHER

Xymon è la versione di System Monitoring derivata da Big Brother. Installeremo la versione server su una macchina Linux mentre il client è installabile sia in ambiente linux che microsoft windows.
In questo documento avremo a che fare sia con il Xymon-Server che con il Xymon-Client.
Stabiliamo che:
1)Xymon-Server(hostname: SRV-Monitor) 192.168.0.77
2)Xymon-Client 192.168.0.10

Creiamo sia sul server che sul client l'utenza Xymon dandogli come home /home/xymon
Per cominciare installeremo Xymon partendo con il suo download dal sito ufficiale (http://www.xymon.com/).

Xymon-Server: /home/xymon# wget http://freefr.dl.sourceforge.net/sourceforge/hobbitmon/xymon-4.2.3.tar.gz


Unzippiamo e estraiamo i pacchetti :

Xymon-Server:/home/xymon#tar zxvf xymon-4.2.3.tar.gz

Entriamo nella directory estratta:

Xymon-Server:/home/xymon#cd xymon-4.2.3

CONFIGURAZIONE

Xymon ha bisogno delle librerie RRD e PCRE, installiamole:

Xymon-Server:/home/xymon/xymon-4.2.3# apt-get install librrd2-dev librrd2
Xymon-Server:/home/xymon/xymon-4.2.3# apt-get install libpcre3 libpcre3-dev

Se non lo si è ancora fatto occorre anche il necessario per compilare:
Xymon-Server:/home/xymon/xymon-4.2.3# apt-get install make gcc g++

Xymon-Server:/usr/src/xymon-4.2.3# apt-get install make gcc g++

Poi si lancia la configurazione:

Xymon-Server:/home/xymon/xymon-4.2.3# ./configure

Lasciate tutte le indicazioni di default salvo le seguenti configurazioni:

Il gruppo utilizzato da Apache:

What group-ID does your webserver use nobody ?
www-data

L'hostname che sarà utilizzato da Xymon per il monitoraggio del server (potete lasciare l'indicazione di default):
What is the name of this host SRV-Monitor ?

L'IP che sarà utilizzato da Xymon per il monitoraggio del server locale:
What is the IP-address of this host 127.0.0.1 ?
192.168.0.77

INSTALLAZIONE

Ora possiamo compilare:
Xymon-Server:/home/xymon/xymon-4.2.3# make

Poi installare:
Xymon-Server:/home/xymon/xymon-4.2.3# make install


Occorre modificare la configurazione di Apache.
La configurazione Apache per Xymon si trova in /home/xymon/xymon-4.2.3/server/etc/hobbit-apache.conf. Per metterla in atto potete creare un nuovo VirtualHost nel quale mettere il contenuto del file o sostituire il contenuto del default (000-defaut).

Xymon-Server:/home/xymon/xymon-4.2.3# cp /home/xymon/xymon-4.2.3/server/etc/hobbit-apache.conf /etc/apache2/sites-enabled/000-default

Riavviate Apache

Xymon-Server:/home/xymon/xymon-4.2.3# /etc/init.d/apache2 restart

Avviate Xymon come segue:
Xymon-Server:/home/xymon/xymon-4.2.3# su - xymon -c "/home/xymon/xymon-4.2.3/server/bin/hobbit.sh start"

Xymon è ora visibile attraverso l'URL: http://192.168.0.77/xymon/

Per lanciare il client locale:
Xymon-Server:/home/xymon/xymon-4.2.3# /home/xymon/xymon-4.2.3/client/runclient.sh start


Se volete che la home page sia protetta da password:
Xymon-Server:/home/xymon/xymon-4.2.3# htpasswd -bc /home/xymon/xymon-4.2.3/server/etc/hobbitpasswd username password

- INSTALLAZIONE DEL CLIENT Xymon

Il server Xymon utilizza la porta 1984 per ricevere i dati dei clients, occorrerà quindi assicurarsi che la porta non sia impegnata da altri servizi. Sul nostro nuovo Xymon-Client, si scaricherà lo stesso pacchetto usato precedentemente:

Xymon-Client:/home/xymon# wget http://freefr.dl.sourceforge.net/sourceforge/hobbitmon/xymon-4.2.3.tar.gz

Estraiamo i pacchetti :
Xymon-Client:/home/xymon# tar zxvf xymon-4.2.3.tar.gz

Entriamo nella dir di xymon:
Xymon-Client:/home/xymon# cd xymon-4.2.3

Installiamo ciò che serve per compilare:
Xymon-Client:/home/xymon# apt-get install make gcc g++

Lanciamo la configurazione del client:
Xymon-Client:/home/xymon# ./configure.client

Una prima questione è posta, potete scegliere "server", per centralizzare sul server certe configurazioni o "client" per porli sul client locale:
Server side client configuration, or client side server ?
server

Poi rispondiamo alle altre domande:
Configuriamo l'installazione:
Accettiamo le risposte di default tranne alcune particolari.

Configuriamo l'IP del Xymon-Server:

What is the IP-address of your Xymon server 127.0.0.1 ?
192.168.0.77

La configurazione è terminata. Però la compilazione potrebbe impiantarsi con il seguente messaggio:
"/home/xymon/xymon-4.2.3/lib/timefunc.c:55: undefined reference to `clock_gettime'"

Per regolare il problema editate il MakeFile e aggiungete queste linee prima di "include build/Makefile.Linux" :


# clock_gettime() settings 
LIBRTDEF = -lrt


Ora si può compilare tutto:
Xymon-Client:/home/xymon/xymon-4.2.3# make

Poi installare:
Xymon-Client:/home/xymon/xymon-4.2.3# make install

Avviamo il nostro client Xymon :
Xymon-Client:/home/xymon/xymon-4.2.3# /home/xymon/xymon-4.2.3/client/runclient.sh start

Perchè le informazioni provenienti dal client siano utilizzate e pubblicate dal server editate su Xymon-server il file /home/xymon/xymon-4.2.3/server/etc/bb-hosts e aggiungete una nuova linea contenente l'IP del client seguito dal suo hostname
192.168.0.10 Xymon-Client


- INSTALLARE IL CLIENT BBWIN
Cos'è BBWin ?

BBWin è un client open source per pemettere le comunicazioni tra Windows e Xymon
Usare BBWin con Xymon in modalità centralizzata

Per usare la modalità centralizzata di BBWin per Xymon devi avere la versione BBWin 0.12 o successiva
Per abilitare la modalità centralizzata in BBWin 0.12 scrivi queste linee nel tuo file bbwin.cfg:

Esempio di hobbit-clients.cfg per l'uso di Windows

HOST=%win.* #Your windows hosts 
LOAD 80 90 # Load threholds are in %
DISK D 50 55 # Can be harddrive or mount points
DISK InetPub 30 35
MEMPHYS 90 101
MEMSWAP 90 95
MEMACT 90 97
PORT "LOCAL=%([.:]80)$" state=LISTENING TEXT=http
PROC BBWin.exe 1 1
PROC svchost.exe 3 4
LOG %.* %.*error.* COLOR=yellow
SVC MSSQLSERVER startup=automatic status=started
Per altri esempi guarda la pagina man hobbit-clients.cfg
FAQ
Con alcuni servers, alcuni test come svcs, ports, uptime e who appaiono in purple mentre altri sono verdi?
La modalità centralizzata invia un file (Client data) con tutte le informazioni dentro.
Cambia il file hobbitserver.cfg in questo modo:
MAXMSG_DATA="5242880"
MAXMSG_CLIENT="5242880"
MAXMSG_STATUS="5242880"

venerdì 24 luglio 2009

Linux - Installare apache 2.2 con supporto ssl, mod_rewrite, php e webdav

Scaricate httpd-2.2 dal sito www.apache.org e php dal sito www.php.net.

In questa guida si fa riferimento alle seguenti versioni:

A) httpd-2.2.9

B) php-5.2.6

Il tutto verrà installato nella dir /usr/local

Scompattare httpd-2.2.9.tar in /usr/local:

#cd /usr/local

#tar -xvf httpd-2.2.9.tar

Creiamo la dir /usr/local/apache:

#mkdir /usr/local/apache

Stariamo php-5.2.6.tar dentro /usr/local/apache:

#cd /usr/local/apache

#tar -xxvf php-5.2.6.tar

Fatto questo nella dir /usr/local/apache bisogna creare il link simbolico php che punta la dir php-5.2.6:

#ln -s /usr/local/apache/php-5.2.6 php

Spostiamoci in /usr/local/httpd-2.2.9 eseguire i seguenti comandi:
#./buildconf
#./configure --prefix=/usr/local/apache --with-mpm=prefork --enable-mods-shared=all --enable-modules=all --enable-authn-anon -enable-usertrack --enable-proxy --enable-ssl --enable-http --enable-dav --enable-info --enable-cgi --enable-dav-fs --enable-dav-lock --enable-speling --enable-rewrite --enable-so
#make
#make install

Ora andiamo nella dir /usr/local/php e lanciamo i seguenti comandi:

#cd /usr/local/php

#./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql --prefix=/usr/local/apache/php --with-config-file-path=/usr/local/apache/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm
#make
#make install
#libtool --finish /usr/local/apache/php-5.2.6/libs
#cp -p php.ini-recommended /usr/local/apache3/php/php.ini

Aggiungi queste direttive in /usr/local/apache/conf/httpd.conf (se già ci sono verifica la loro correttezza):

LoadModule php5_module modules/libphp5.so
AddHandler php5-script php

Aggiungi index.php alla tua riga DirectoryIndex :


DirectoryIndex index.html index.php

Inoltre, nello stesso file httpd.conf non dimenticare di aggiungere anche:

AddType text/html php

AddType application/x-httpd-php-source phps

Dentro il file httpd.conf inoltre verificare i moduli che vengono caricati dai vari LoadModule e controllare che le voci relative a mod_ssl, mod_dav, mod_dav_fs, mod_rewrite, mod_usertrack siano scommentate
Esempio di un mod_ssl correttamente caricato:

LoadModule ssl_module modules/mod_ssl.so

Ora configuriamo apache2 sempre attraverso il file httpd.conf
. Modifichiamo i Listen:

Listen INDIRIZZOIP:80

Listen INDIRIZZOIP:443

Scriviamo il ServerName nel file /usr/local/apache/conf/httpd.conf :

ServerName www.MIOSERVER.it

Scommentare gli Include necessari nel file /usr/local/apache3/conf/httpd.conf :

# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf


# Multi-language error messages

#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include conf/extra/httpd-autoindex.conf

# Language settings
Include conf/extra/httpd-languages.conf

# User home directories
Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
Include conf/extra/httpd-dav.conf

Editiamo il file /usr/local/apache/conf/extra/httpd-ssl.conf
Editare il parametro Listen:
Listen INDIRIZZOIP:443

Generiamo il certificato ssl con il comando openssl:
openssl req -new -x509 -days 9999 -keyout /usr/local/apache/conf/server.key -out /usr/local/apache3/conf/server.crt
Generating a 1024 bit RSA private key
....++++++
.++++++
writing new private key to '/usr/local/apache3/conf/server.key'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:



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:IT
State or Province Name (full name) Some-State:Mi
Locality Name (eg, city) :Milano
Organization Name (eg, company) Internet Widgits Pty Ltd:MIAAZIENDA Srl
Organizational Unit Name (eg, section) :MIAAZIENDA Team
Common Name (eg, YOUR name) :www.MIOSERVER.it
Email Address :indirizzodiposta@miodominio.it

Se, come me, la odiate potete togliere la pass phrase dal certificato ssl:

#cp /usr/local/apache/conf/server.key /usr/local/apache/conf/server.key.bak
#openssl rsa -in /usr/local/apache/conf/server.key.bak -out /usr/local/apache/conf/server.key

Verificare il corretto path dei file .key e crt appena creati nel file /usr/local/apache/conf/extra/httpd-ssl.conf (eventualmente correggete il path)
Ora editiamo il file /usr/local/apache/conf/extra/httpd-vhosts.conf
Nel nostro esempio conterrà:


ServerAdmin indirizzodiposta@miodominio.it
DocumentRoot "/usr/local/apache/htdocs"
ServerName www.MIOSERVER.it
ErrorLog "logs/www.MIOSERVER.it-error_log"
CustomLog "logs/www.MIOSERVER.it-access_log" combined env=!dontlog
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

RewriteEngine on
RewriteLog logs/www.MIOSERVER.it.rewrite.txt
RewriteLogLevel 4

Editiamo il file /usr/local/apache/conf/extra/httpd-ssl.conf
Nel nostro esempio va editata la seguente parte:


# General setup for the virtual host
DocumentRoot "/usr/local/apache/htdocs"
ServerName www.MIOSERVER.it
ServerAdmin indirizzodiposta@miodominio.it
ErrorLog "/usr/local/apache/logs/www.MIOSERVER.it-443-error_log"
TransferLog "/usr/local/apache/logs/www.MIOSERVER.it-443-access_log"
RewriteEngine on
RewriteLog logs/www.MIOSERVER.rewrite.txt
RewriteLogLevel 0



Editiamo il file /usr/local/apache/conf/extra/httpd-dav.conf

IL CONTENUTO DEL FILE DOVRA' ESSERE ESATTAMENTE QUESTO A PARTE IL PATH DEI FILES DavLockDB E AuthUserFile che vanno adattati a seconda del caso:

#
# Distributed authoring and versioning (WebDAV)
#
# Required modules: mod_dav, mod_dav_fs, mod_setenvif, mod_alias
# mod_auth_digest, mod_authn_file
#

# The following example gives DAV write access to a directory called
# "uploads" under the ServerRoot directory.
#
# The User/Group specified in httpd.conf needs to have write permissions
# on the directory where the DavLockDB is placed and on any directory where
# "Dav On" is specified.

DavLockDB /usr/local/apache/var/DavLock

Alias /webdav /usr/local/webdav


SSLRequireSSL
DAV On
Order Allow,Deny
Allow from all

AuthType Basic
AuthName "WebDAV Restricted"
AuthUserFile "/usr/local/apache/webdavuser"
Require user webdav



#
# The following directives disable redirects on non-GET requests for
# a directory that does not include the trailing slash. This fixes a
# problem with several clients that do not appropriately handle
# redirects for folders with DAV methods.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully


Creare la dir /usr/local/webdav e settarne i permessi:

#mkdir
/usr/local/webdav
#chown -R daemon:staff /usr/local/webdav
#chmod -R 744
/usr/local/webdav

Creare l'utenza webdav:

#cd /usr/local/apache/bin
#./htpasswd -c /usr/local/apache/webdavuser webdav

Creare la dir /usr/local/apache/var e settare i permessi:

#mkdir /usr/local/apache/var
#chmod -R 744 /usr/local/apache/var
#chown -R daemon:staff /usr/local/apache/var

Ora possiamo startare apache:

#/usr/local/apache/bin/apachectl start

Verifichiamo Apache via web:

http://www.MIOSERVER.it
https://www.MIOSERVER.it

Verifichiamo webdav lanciando konqueror e scrivendo la seguente URL:
webdavs://www.MIOSERVER.it/webdav
AUTENTICARSI CON L'UTENTE WEBDAV E PROVARE A CREARE DIRECTORY DI TEST

Verifichiamo php creando nella dir /usr/local/apache/htdocs il file testphp.php dentro al quale scriviamo:



// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

Con il nostro browser apriamo la seguente pagina:

http://www.MIOSERVER.it/testphp.php

Se visualizzeremo correttamente le proprietà della nostra versione di php abbiamo terminato l'installazione del nostro server apache.

lunedì 20 luglio 2009

Questo Blog....

finalmente on line, se riuscirò ad avere tempo raccoglierò in questo spazio esperienze di lavoro e di vita...una piccola goccia nell'oceano di internet...