Detailed installation and testing of pgwatch
An error occurred during installation, but no documentation was found online. I decided to write a detailed installation document myself.
1. Download pgwatch. Here I use Version 1.0, as shown below:
Wget http://www.cybertec.at/download/pgwatch/pgwatch-1.0.tar.gz
2. decompress and open the README file to check the installation requirements. The installation here is not described in detail.
Tar-zxvf pgwatch-1.0.tar.gz
Vim README
------------------------------------------------------------
Requirements:
-------------
You will need a handful of components to make this work:
-Apache (webserver) # Use apache as a web Server
-PHP 5 (scripting language) # php5
-Pgsql extension for PHP (see http://www.php.net/manual/en/book.pgsql.php) # postgresql php Client
-PostgreSQL 9 (to store the data we collect) # postgresql supports the lowest version of 9
-Dblink (contribution module for PostgreSQL 9) # Install dblink (not by default)
-For now we only support PostgreSQL >=9.0 databases.
Older systems cannot be monitored, however, we will
Add support for future database releases.
3. First, put the folder you just decompressed in the apache directory. (The folder permission must be set)
4. Check whether the postgresql php client is installed. If not, use yum to install it directly:
Yum installphp-pgsql.i386 (I am a 32-bit student can use yum search to search, and then restart apache)
Check whether the script (php) is installed ):
// Connecting, selecting database
$ Dbconn = pg_connect ("host = 192.168.30.200 port = 5434 dbname = lengzijian user = s password = 123456 ")
Or die ('could not connect: '. pg_last_error ());
// Specify Ming SQL query
$ Query = 'select * FROM t_user limit 10 ';
$ Result = pg_query ($ query) or die ('query failed: '. pg_last_error ());
// Printing results in HTML
Echo "<table> \ n ";
While ($ line = pg_fetch_array ($ result, null, PGSQL_ASSOC )){
Echo "\ t <tr> \ n ";
Foreach ($ line as $ col_value ){
Echo "\ t <td> $ col_value </td> \ n ";
}
Echo "\ t </tr> \ n ";
}
Echo "</table> \ n ";
// Free resultset
Pg_free_result ($ result );
// Closing connection
Pg_close ($ dbconn );
?>