Skip to content

Commit 76927e1

Browse files
author
unknown
committed
readme update
1 parent 0eceb9d commit 76927e1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PostreSQL-Monitor
22
This is a simple script that aims to be able to diagnose heavy SQL queries and show them in an easy to understand manner
33

4-
## What does it do ?
4+
# What does it do ?
55
This script was designed to be either used as a command line or for a slack / discord bot and can also write to a file<br/>
66
The script will display queries that :
77
- are the most used
@@ -11,7 +11,7 @@ The script will display queries that :
1111
- returned the most rows on average
1212
For each of these criteria, the 10 queries that had the biggest result are displayed
1313

14-
## How to use
14+
# How to use
1515
First, the database needs to be configured in order to allow the monitoring. This can be done at the following link : <a href='https://gist.github.com/troyk/4462899'>https://gist.github.com/troyk/4462899</a>
1616

1717
Next, the script uses the following library to connect to the database and requires it to work : `psycopg2`
@@ -52,9 +52,20 @@ It will display just the queries for `mostUsed`, `longestTimeOnAverage` and `mos
5252

5353
**Note** : the queries that are used by this program are not displayed by default. See the configurations variables to display them
5454

55-
## Configuration
55+
# Configuration
5656

57-
## Troubleshooting
57+
The following class instance variables are used to configure the monitor to your needs :
58+
`useIgnore` ( boolean ) is used to determine if queries possessing the substrings in the `ignore` variable should be ignored or not<br/>
59+
`ignore` ( string array ) this array of strings / substrings is used to exclude queries from the displayed query list<br/>
60+
By default, the following are ignored : "pg_stat_statements", "pg_catalog", "ALTER TABLE", "TRUNCATE TABLE" and "CREATE TABLE"<br/>
61+
`writeOnConsole` ( boolean ) to allow ( True ) or forbid ( False ) the monitor to output on the console<br/>
62+
`writeToFile` ( boolean ) to allow ( True ) or forbid ( False ) the monitor to output on a file<br/>
63+
`filename` ( string ) is the file name that is used by the monitor ( will be overwritten )<br/>
64+
`truncatedQuerySize` ( integer ) is used to shorted the query lengths. It is mostly used for long queries or small terminals
65+
`indentBeforeQuery` and `indentBeforeCalls` ( integer ) are used to insert blank spaces and try to get all the data displayed as neatly as possible <br/>
66+
`displayUsedQueries` ( boolean ) is used to display the queries that the program is using to gather the displayed data
67+
68+
# Troubleshooting
5869
**Important** : the script will only show everything *from the moment the postgresql options are enabled* ***and*** *the server restarted*. Anything prior will not be shown as the database was not
5970
saving the required data
6071

@@ -66,7 +77,7 @@ Should this script not work, please make sure that :
6677
Should it still not work, please set the console display ( `writeOnConsole` ) to True in order to see any other possible errors<br/>
6778
Details on the working of this table here : https://www.postgresql.org/docs/9.6/static/pgstatstatements.html
6879

69-
## Example :
80+
# Example :
7081
The following output was obtained with the following instruction : `"dbname=test_database user=user password=my-password host=127.0.0.1 port=5432" all 10`<br />
7182
Note : some queries can be very long, this is why the query id is displayed. This allows the output to not be cluttered with very long queries and allow you to display the important queries using the id directly
7283
<br />

0 commit comments

Comments
 (0)