Upload
affinitic
View
757
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
PgBadger
1
J Outil d’analyse en Perl pour les logs PostgreSQL J Anciennement pgFouine J Open-Source (PostgreSQL License) J Nécessite l’activation des logs dans PostgreSQL
PgBadger
2
Source à télécharger sur http://sourceforge.net/projects/pgbadger/
Commandes pour l’installation$ tar -xzf pgbadger-3.x.tar.gz$ cd pgbadger-3.x/$ perl Makefile.PL$ make && make install
Installation
3
Commande pour trouver ou se trouve le fichier postgresql.conf$ psql dbname -c ‘SHOW config_file’ | grep ‘\.conf’
Activation des logs avec une durée minimale en milliseconde (0 : tout, -1 : désactiver)log_min_duration_statement = 2log_destination = ‘stderr’
Choix du répertoire pour les logslog_directory = ‘pg_log’
Noms des fichiers de loglog_filename = ‘postgresql-%Y-%m-%d.log’
Activation des logs dans PostgreSQL
4
Activation des logs dans PostgreSQL
Eviter d’écraser les logs en cas de redémarrage de la dblog_truncate_on_rotation = off
Format minimum pour les logslog_line_prefix = ‘%t [%p]: [%l-1] ‘
Rotation des logslog_rotation_age = 1dlog_rotation_size = 10MB
Redémarrage de PostgreSQL$ pg_ctl stopwaiting for server to shut down.... doneserver stopped$ pg_ctl startserver starting
5
Activation des logs dans PostgreSQL
Exemple de log PostgreSQL2013-02-22 17:21:14 CET [95200]: [81-1] LOG: duration: 60.945 ms statement: SELECT count(1) AScount_1 FROM vacationvt.list JOIN vacationvt.list_status_view ON vacationvt.list.id = vacationvt.list_status_view.list_id WHERE vacationvt.list.isvalid = true AND vacationvt.list.prestation_min_date >= ‘2012-04-01T00:00:00’::timestamp AND vacationvt.list.prestation_max_date <= ‘2012-06-30T23:59:00’::timestamp ANDvacationvt.list.type = E’VISIT_PORCS’ AND vacationvt.list.list_type = E’FINAL’ AND vacationvt.list_status_view.status IS NOT NULL AND vacationvt.list.vt_id = E’BE00005016’ AND vacationvt.list.creation_date < ‘2012-07-27T10:01:52.549269’::timestamp
6
Exécution de l’analysepgbadger /opt/local/var/db/postgresql90/defaultdb/pg_log/postgresql-2013-02-22.log \-o 2013-02-22.html
Analyse des logs
7
Démo
8
Questions
9
J Site internet : http://dalibo.github.com/pgbadger/ J Github : https://github.com/dalibo/pgbadger J Documentation pgBadger : http://dalibo.github.com/pgbadger/documentation.html
Liens