Monitoraggio di sistemi con collectd: Difference between revisions
mNo edit summary |
m →CGP |
||
| Line 52: | Line 52: | ||
sudo mkdir -p collectd | sudo mkdir -p collectd | ||
cd collectd | cd collectd | ||
sudo | sudo git clone https://github.com/pommi/CGP.git . | ||
* Loggarsi su http://servername.example.com/collectd/ | * Loggarsi su http://servername.example.com/collectd/ | ||
Revision as of 11:02, 2 March 2015
Installazione stand alone
- Installazione pacchetti
sudo apt-get install collectd
- Abilitazione plugin necessari:
sudoedit /etc/collectd/collectd.conf
- Syslog è necessario per loggare:
LoadPlugin syslog
<Plugin syslog>
LogLevel info
</Plugin>
- Rrdtool è necessario per scrivere le statistiche su disco in /var/lib/collectd/rrd/nomemacchina.example.com. Se la macchina che si sta configurando è solo client, non è necessario salvare le statistiche in locale:
LoadPlugin rrdtool
<Plugin rrdtool>
DataDir "/var/lib/collectd/rrd"
</Plugin>
- Questo è un plugin base per le statistiche CPU, non necessita di configurazione:
LoadPlugin cpu
- Vedi sezione finale per quelli che necessitano di configurazione
- Riavvio
sudo invoke-rc.d collectd restart
Installazione frontend web
PhpCollection
cd /var/www/ sudo mkdir php-collection cd php-collection/ sudo cp /usr/share/doc/collectd/examples/php-collection/* .
- Installare apache2 e php-5
- Loggarsi su http://servername.example.com/php-collection/
CGP
cd /var/www sudo mkdir -p collectd cd collectd sudo git clone https://github.com/pommi/CGP.git .
- Loggarsi su http://servername.example.com/collectd/
Configurazione Client
- Installare come standalone
- Se non si intende consultare le statistiche in locale, è possibile NON abilitare il plugin rrdtool
- LoadPlugin rrdtool
- Abilitare il plugin network, che serve ad inviare le statistiche ad un server centrale:
sudoedit /etc/collectd/collectd.conf
LoadPlugin network
<Plugin network>
# # client setup:
Server "192.168.254.101"
</Plugin>
- Riavviare
sudo invoke-rc.d collectd restart
Configurazione Server
- Installare come standalone
- Abilitare il plugin
sudoedit /etc/collectd/collectd.conf
LoadPlugin network
<Plugin network>
# # server setup:
Listen "192.168.254.101"
</Plugin>
- Riavviare
sudo invoke-rc.d collectd restart
Gestione
- Azzerare il database:
sudo invoke-rc.d collectd stop sudo rm -rf /var/lib/collectd/rrd sudo invoke-rc.d collectd start
Configurazione Plugins
Df
Mostra spazio libero ed occupato. Di default mostra tutti i filesystem montati, compresi i temporanei. Per includere solo i filesystem ext4:
#...
LoadPlugin df
#...
<Plugin df>
FSType ext4
IgnoreSelected false
</Plugin>
#...
Per un bug, se non si configura il plugin, i filesystem vengono conteggiati doppi (ad esempio rootfs o tmpfs), e il syslog viene floodato con messaggi del tipo
Aug 20 16:27:12 mythbox collectd[32167]: rrdtool plugin: rrd_update_r (/var/lib/collectd/rrd/mythbox/df-root/df_complex-free.rrd) failed: /var/lib/collectd/rrd/mythbox/df-root/df_complex-free.rrd: illegal attempt to update using time 1345444032 when last update time is 1345444032 (minimum one second step)
Attenzione che in questo modo, se vengono montati degli snapshot o filesystem, questi verranno inclusi nel conteggio. Eventualmente, usare la selezione per device, esempio:
Device "/dev/md0"
Vedi:
Filecount
Serve per mostrare la dimensione di una directory e il numero di files.
Funziona solo se configurato.
- Esempio:
<Plugin filecount> <Directory "/var/www/example.com"> Instance "WWW example.com" IncludeHidden true </Directory> </Plugin>
Nut
- Questo plugin fornisce info sull'ups collegato:
LoadPlugin nut
- Indicare il nome dell'ups come da comando:
upsc -l
<Plugin nut>
UPS "apc_backups_cs_500"
</Plugin>
Tail
Questo plugin viene usato per leggere i log. Matchando delle occorrenze si possono estrarre delle info loggate dai vari daemon.
Postfix
Questa configurazione crea delle statistiche per Postfix.
- Definire un tipo dati utilizzato nei contatori
sudoedit /etc/collectd/my_types.db
mail_counter value:COUNTER:0:65535
- Abilitare i tipi dati custom:
sudoedit /etc/collectd/collectd.conf
TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db"
- Configurare il plugin:
sudoedit /etc/collectd/collectd.conf
#...
LoadPlugin tail
#...
<Plugin "tail">
#...
<File "/var/log/mail.log">
# or: <File "/srv/rsyslog/mail.log">
Instance "postfix"
# number of connections
# (incoming)
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: connect from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-open"
</Match>
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: disconnect from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-close"
</Match>
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: lost connection after .* from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-lost"
</Match>
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: timeout after .* from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-timeout"
</Match>
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: setting up TLS connection from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-TLS-setup"
</Match>
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: [A-Za-z]+ TLS connection established from\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-in-TLS-established"
</Match>
# (outgoing)
<Match>
Regex "\\<postfix\\/smtp\\[[0-9]+\\]: setting up TLS connection to\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-out-TLS-setup"
</Match>
<Match>
Regex "\\<postfix\\/smtp\\[[0-9]+\\]: [A-Za-z]+ TLS connection established to\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "connection-out-TLS-established"
</Match>
# rejects for incoming E-mails
<Match>
Regex "\\<554 5\\.7\\.1\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "rejected"
</Match>
<Match>
Regex "\\<450 4\\.7\\.1\\>.*Helo command rejected: Host not found\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "rejected-host_not_found"
</Match>
<Match>
Regex "\\<450 4\\.7\\.1\\>.*Client host rejected: No DNS entries for your MTA, HELO and Domain\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "rejected-no_dns_entry"
</Match>
<Match>
Regex "\\<450 4\\.7\\.1\\>.*Client host rejected: Mail appeared to be SPAM or forged\\>"
DSType "CounterInc"
Type "mail_counter"
Instance "rejected-spam_or_forged"
</Match>
# status codes
<Match>
Regex "status=deferred"
DSType "CounterInc"
Type "mail_counter"
Instance "status-deferred"
</Match>
<Match>
Regex "status=forwarded"
DSType "CounterInc"
Type "mail_counter"
Instance "status-forwarded"
</Match>
<Match>
Regex "status=reject"
DSType "CounterInc"
Type "mail_counter"
Instance "status-reject"
</Match>
<Match>
Regex "status=sent"
DSType "CounterInc"
Type "mail_counter"
Instance "status-sent"
</Match>
<Match>
Regex "status=bounced"
DSType "CounterInc"
Type "mail_counter"
Instance "status-bounced"
</Match>
<Match>
Regex "status=SOFTBOUNCE"
DSType "CounterInc"
Type "mail_counter"
Instance "status-softbounce"
</Match>
# message size
<Match>
Regex "size=([0-9]*)"
DSType "CounterAdd"
Type "ipt_bytes"
Instance "size"
</Match>
# delays (see [1] for details)
# total time spent in the Postfix queue
<Match>
Regex "delay=([\.0-9]*)"
DSType "GaugeAverage"
Type "gauge"
Instance "delay"
</Match>
# time spent before the queue manager, including message transmission
<Match>
Regex "delays=([\.0-9]*)/[\.0-9]*/[\.0-9]*/[\.0-9]*"
DSType "GaugeAverage"
Type "gauge"
Instance "delay-before_queue_mgr"
</Match>
# time spent in the queue manager
<Match>
Regex "delays=[\.0-9]*/([\.0-9]*)/[\.0-9]*/[\.0-9]*"
DSType "GaugeAverage"
Type "gauge"
Instance "delay-in_queue_mgr"
</Match>
# connection setup time including DNS, HELO and TLS
<Match>
Regex "delays=[\.0-9]*/[\.0-9]*/([\.0-9]*)/[\.0-9]*"
DSType "GaugeAverage"
Type "gauge"
Instance "delay-setup_time"
</Match>
# message transmission time
<Match>
Regex "delays=[\.0-9]*/[\.0-9]*/[\.0-9]*/([\.0-9]*)"
DSType "GaugeAverage"
Type "gauge"
Instance "delay-trans_time"
</Match>
</File>
</Plugin>
Vedi:
*Plugin:Tail/Config - collectd Wiki