Wednesday, 8 July 2020

Install PgBadger in Linux and set configurations


Untar the file and make a Perl file

#tar -zvxf pgbadger-4.1.tar.gz 
#cd pgbadger-4.1
#perl Makefile.PL
WARNING: META_MERGE is not a known parameter.
Checking if your kit is complete...
Looks good
'META_MERGE' is not a known MakeMaker parameter name.
Writing Makefile for pgBadger

# make
cp pgbadger blib/script/pgbadger
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/pgbadger
Manifying blib/man1/pgbadger.1
# make install
Installing /usr/share/man/man1/pgbadger.1
Installing /usr/bin/pgbadger
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/pgBadger/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
# which pgbadger
/usr/bin/pgbadger
# pgbadger -V
pgBadger version 4.1



Unzip the pgBadger file

[oracle@oracleasm1 pg]$ 
[oracle@oracleasm1 pg]$ 
[oracle@oracleasm1 pg]$ unzip pgbadger-10.2.tar.gz 
Archive:  pgbadger-10.2.tar.gz
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of pgbadger-10.2.tar.gz or
        pgbadger-10.2.tar.gz.zip, and cannot find pgbadger-10.2.tar.gz.ZIP, period.
[oracle@oracleasm1 pg]$ tar                                                                                      
tar: You must specify one of the `-Acdtrux' or `--test-label'  options
Try `tar --help' or `tar --usage' for more information.
[oracle@oracleasm1 pg]$ 
[oracle@oracleasm1 pg]$ 
[oracle@oracleasm1 pg]$ tar -zvxf pgbadger-10.2.tar.gz 
pgbadger-10.2/

pgbadger-10.2/.editorconfig
pgbadger-10.2/t/
pgbadger-10.2/t/02_basics.t
pgbadger-10.2/t/01_lint.t
pgbadger-10.2/t/03_consistency.t
pgbadger-10.2/t/fixtures/
pgbadger-10.2/t/fixtures/pgbouncer.log.gz
pgbadger-10.2/t/fixtures/light.postgres.log.bz2
pgbadger-10.2/pgbadger
pgbadger-10.2/ChangeLog
pgbadger-10.2/CONTRIBUTING.md
pgbadger-10.2/README
pgbadger-10.2/doc/
pgbadger-10.2/doc/pgBadger.pod
pgbadger-10.2/MANIFEST
pgbadger-10.2/HACKING.md
pgbadger-10.2/LICENSE
pgbadger-10.2/META.yml
pgbadger-10.2/resources/
pgbadger-10.2/resources/jquery.jqplot.css
pgbadger-10.2/resources/jqplot.pointLabels.js
pgbadger-10.2/resources/font/
pgbadger-10.2/resources/font/FontAwesome.otf
pgbadger-10.2/resources/font/fontawesome-webfont.eot
pgbadger-10.2/resources/bootstrap.css
pgbadger-10.2/resources/jquery.jqplot.js
pgbadger-10.2/resources/jqplot.canvasTextRenderer.js
pgbadger-10.2/resources/README
pgbadger-10.2/resources/patch-jquery.jqplot.js
pgbadger-10.2/resources/jqplot.dateAxisRenderer.js
pgbadger-10.2/resources/jqplot.pieRenderer.js
pgbadger-10.2/resources/underscore.js
pgbadger-10.2/resources/bean.js
pgbadger-10.2/resources/jquery.js
pgbadger-10.2/resources/jqplot.barRenderer.js
pgbadger-10.2/resources/jqplot.categoryAxisRenderer.js
pgbadger-10.2/resources/pgbadger_slide.js
pgbadger-10.2/resources/jqplot.canvasAxisTickRenderer.js
pgbadger-10.2/resources/pgbadger.css
pgbadger-10.2/resources/LICENSE
pgbadger-10.2/resources/.gitignore
pgbadger-10.2/resources/jqplot.highlighter.js
pgbadger-10.2/resources/fontawesome.css
pgbadger-10.2/resources/pgbadger.js
pgbadger-10.2/resources/jqplot.cursor.js
pgbadger-10.2/resources/bootstrap.js
pgbadger-10.2/Makefile.PL
pgbadger-10.2/tools/
pgbadger-10.2/tools/README.pgbadger_tools
pgbadger-10.2/tools/README.updt_embedded_rsc
pgbadger-10.2/tools/updt_embedded_rsc.pl
pgbadger-10.2/tools/pgbadger_tools
[oracle@oracleasm1 pg]$ 
[oracle@oracleasm1 pg]$ su - root
Password: 
[root@oracleasm1 ~]# 
[root@oracleasm1 ~]# 


[root@oracleasm1 ~]# cd /u01/pg
[root@oracleasm1 pg]# ls- ltr
-bash: ls-: command not found
[root@oracleasm1 pg]# ls -ltr
total 1248
drwxr-xr-x 6 oracle oinstall    4096 Dec 28  2018 pgbadger-10.2
drwxr-xr-x 3 oracle oinstall    4096 Jan  7 01:09 1
-rw-r--r-- 1 root   root     1268469 Feb  3 00:11 pgbadger-10.2.tar.gz
[root@oracleasm1 pg]# cd pgbadger-10.2
[root@oracleasm1 pgbadger-10.2]# ls- ltr
-bash: ls-: command not found
[root@oracleasm1 pgbadger-10.2]# ls -ltr
total 1516
drwxr-xr-x 2 oracle oinstall    4096 Dec 28  2018 tools
drwxr-xr-x 3 oracle oinstall    4096 Dec 28  2018 resources
-rw-r--r-- 1 oracle oinstall   32831 Dec 28  2018 README
-rwxr-xr-x 1 oracle oinstall 1360929 Dec 28  2018 pgbadger
-rw-r--r-- 1 oracle oinstall     250 Dec 28  2018 META.yml
-rw-r--r-- 1 oracle oinstall      81 Dec 28  2018 MANIFEST
-rw-r--r-- 1 oracle oinstall    1844 Dec 28  2018 Makefile.PL
-rw-r--r-- 1 oracle oinstall     910 Dec 28  2018 LICENSE
-rw-r--r-- 1 oracle oinstall    1487 Dec 28  2018 HACKING.md
drwxr-xr-x 2 oracle oinstall    4096 Dec 28  2018 doc
-rw-r--r-- 1 oracle oinstall     870 Dec 28  2018 CONTRIBUTING.md
-rw-r--r-- 1 oracle oinstall  106912 Dec 28  2018 ChangeLog
drwxr-xr-x 3 oracle oinstall    4096 Dec 28  2018 t
[root@oracleasm1 pgbadger-10.2]# perl Makefile.P
^C
[root@oracleasm1 pgbadger-10.2]# perl Makefile.PL


Checking if your kit is complete...
Looks good
Writing Makefile for pgBadger
[root@oracleasm1 pgbadger-10.2]# 
[root@oracleasm1 pgbadger-10.2]# 
[root@oracleasm1 pgbadger-10.2]# make
cp pgbadger blib/script/pgbadger
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pgbadger
echo "=head1 SYNOPSIS" > doc/synopsis.pod
./pgbadger --help >> doc/synopsis.pod
echo "=head1 DESCRIPTION" >> doc/synopsis.pod
sed -i.bak 's/ +$//g' doc/synopsis.pod
rm doc/synopsis.pod.bak
sed -i.bak '/^=head1 SYNOPSIS/,/^=head1 DESCRIPTION/d' doc/pgBadger.pod
sed -i.bak '4r doc/synopsis.pod' doc/pgBadger.pod
rm doc/pgBadger.pod.bak
Manifying blib/man1/pgbadger.1p
rm doc/synopsis.pod
[root@oracleasm1 pgbadger-10.2]# make install
echo "=head1 SYNOPSIS" > doc/synopsis.pod
./pgbadger --help >> doc/synopsis.pod
echo "=head1 DESCRIPTION" >> doc/synopsis.pod
sed -i.bak 's/ +$//g' doc/synopsis.pod
rm doc/synopsis.pod.bak
sed -i.bak '/^=head1 SYNOPSIS/,/^=head1 DESCRIPTION/d' doc/pgBadger.pod
sed -i.bak '4r doc/synopsis.pod' doc/pgBadger.pod
rm doc/pgBadger.pod.bak
Manifying blib/man1/pgbadger.1p
Installing /usr/local/share/man/man1/pgbadger.1p
Installing /usr/local/bin/pgbadger
Appending installation info to /usr/lib/perl5/perllocal.pod
rm doc/synopsis.pod

[root@oracleasm1 pgbadger-10.2]# pgbadger -V
pgBadger version 10.2
[root@oracleasm1 pgbadger-10.2]# 



You will have to adjust your PostgreSQL configuration file to give pgbadger the information it needs. 
1.  set the "log_line_prefix" setting:

log_line_prefix = '%t [%p]: [%l-1] '

2. enable the "log_min_duration_statement".  
(Make sure that the "log_statement" is set to "none") This setting causes PostgreSQL to log all statements which run for longer than the given value in milliseconds, where a value of 0 will log everything.

3. enable logging of checkpoints, locks and more for appropriate log analysis:

log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0

You do not need to restart PostgreSQL to make the changes take effect, 
The above parameters can be set via command line

4. Reload the config
select pg_reload_conf();


How to read the report

 

The report has the following sections:

  • Overall statistics
  • Hourly statistics
  • Queries by type (query type statistics)
  • Sessions per database
  • Sessions per user (session statistics by user)
  • Sessions per host (session statistics by connection source host)
  • Connections per database
  • Connections per user
  • Connections per host (connection statistics by connection source host)
  • Slowest queries
  • Queries that took up the most time (N) (query ranking with long total execution time)
  • Most frequent queries (N)
  • Slowest queries (N) (Query ranking with long average execution time)
  • Most frequent events (N)
  • Logs per type (server log type statistics)

Since the content of the report is diverse, when you read the report, you need an "axis" to read it. Here are some examples:

  If you are looking for a prominently slow query,  check Slowest queries. It will show you the queries that were running the slowest.

Slowest queries include statistics with and without (N), but here we are looking at statistics without (N). -Look at Slowest queries (N)



No comments:

Post a Comment