Monitoraggio di sistemi con collectd: Difference between revisions

From RVM Wiki
Jump to navigation Jump to search
mNo edit summary
Line 93: Line 93:
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
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)
  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:
Vedi:
*[http://emacstragic.net/collectd-causing-rrd-illegal-attempt-to-update-using-time-errors/ Collectd causing rrd illegal attempt to update using time errors]
*[http://emacstragic.net/collectd-causing-rrd-illegal-attempt-to-update-using-time-errors/ Collectd causing rrd illegal attempt to update using time errors]


==Filecount==
==Filecount==

Revision as of 06:24, 12 June 2014

Installazione stand alone

  • Installazione pacchetti
sudo apt-get install collectd
  • Abilitazione pulgin
sudoedit /etc/collectd/collectd.conf 
  • Vedi sezione finale
  • 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

CGP

cd /var/www
sudo mkdir -p collectd
cd collectd
sudo git clone git clone https://github.com/pommi/CGP.git .

Configurazione Client

  • Installare come standalone
  • Abilitare il plugin
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>

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