pandora fms: postgresql plugin

12
Pandora FMS Administrator Manual Monitoring postgresql Server on Unix

Upload: artica-st

Post on 19-Jan-2015

127 views

Category:

Documents


3 download

DESCRIPTION

A local plugin wich monitors PostgreSQL extracting information using an external configuration file and the software already installed on the system to monitor. For more information visit the following webpage: http://pandorafms.com/index.php?sec=Library&sec2=repository&lng=en&action=view_PUI&id_PUI=552

TRANSCRIPT

Page 1: Pandora FMS: PostgreSQL Plugin

Pandora FMSAdministrator Manual

Monitoring postgresql Server on Unix

Page 2: Pandora FMS: PostgreSQL Plugin

Manual Monitoring postgresql Server Administration© Artica Soluciones Tecnológicas 2005­2012

Index1.Changelog.....................................................................................3

2.Introduction...................................................................................4

3.Requirements................................................................................53.1.Documentation that must deliver the required monitoring area...............................5

4.Compatibility Matrix ....................................................................6

5.Installation.....................................................................................76.Monitorización .............................................................................87.Configuration file..........................................................................9

Page 3: Pandora FMS: PostgreSQL Plugin

1 CHANGELOG

Date Author Change Version

19/04/12 David First Version v1r1

Page 3

Page 4: Pandora FMS: PostgreSQL Plugin

2 INTRODUCTION

The following diagram gives an idea of the interaction of pandora plugin.

This paper aims at describing the monitoring of PostgreSQL databases on Unix.

To extract the information is used:

• An external configuration file which defines all the parameters of the plugin.

•  It  uses   the software already  installed  on  the   system  for  monitoring  by   the plugin 

without having to install third party libraries or utilities.

• They perform a number of basic checks "default", but you can remove or customize.

•  It  has  an  interface  "open"  to specify  SQL queries   free  model  allowing  SQL queries 

always return a data only.

From a general point of view Pandora fms launches plugin, loading the configuration parameters from file configuracion.ini and performs a series of queries to postgres server and returns an xml monitoring, which is collected by pandora.

We can also launch this plugin from the command line:./pandora_postgres_plugin.pl -f file-config

This implementation is using a configuration file (or boot) called configuración.ini, if we throw without use file would be:./pandora_postgres_plugin.pl -u user -c password [-n basename] [-d dir_ip_server] [-p port] [-h]

For more info ./pandora_postgres_plugin.pl -h

Page 4

Page 5: Pandora FMS: PostgreSQL Plugin

3 REQUIREMENTS

The requirements to work properly this monitoring are:

• Install the Pandora FMS agent.

• To have perl installed.

•  Having a postgresql database installed on the machine where it will be monitored, with 

connectivity to the database.

• Specify the name, user, password and host of the postgresql database.

3.1.  Documentation that must deliver the required monitoring area

For proper monitoring postgresql is necessary for the technical area send some information that will be included in the configuration files. This information is:

• Username, password, host with access to the postgresql database.

•  IMPORTANT: SQL MODULES MAY MONITOR ONLY A PARAMETER THAT IS THE ONLY 

QUESTIONS MAY RETURN A DATA (A ROW AND COLUMN)

Page 5

Page 6: Pandora FMS: PostgreSQL Plugin

4 COMPATIBILITY MATRIX

The Agent compatibility matrix is as follows

Systems which have been tested • Ubuntu 12.10 con postgresql 9• OpenSuse 11.2 con postgresql 9

Systems whereshould work • Other Unix systems with postgresql 9 or 

higher.

Page 6

Page 7: Pandora FMS: PostgreSQL Plugin

5 INSTALLATION

To install this plugin must follow the following steps: 

1st. Copy and plugin configuration file in / etc / pandora / plugins / (if you have the plugin oars in 

another folder see step 2). 

2nd. Access the folder where the configuration file pandora_agent.conf (in ubuntu / etc / pandora. 

In this file we add a line 

module_plugin perl pandora_postgres_plugin.pl -f filename_config 2> /etc/pandora/plugins/error.log

In case you want to install the plugin into a separate folder will be the following line: 

module_plugin perl path/pandora_postgres_plugin.pl -f filename_config 2> /etc/pandora/plugins/erro.log

To perform this action you can use the following command: 

sudo echo "module_plugin path/pandora_postgres_plugin.pl -f filename_config 2> /etc/pandora/plugins/error.log" >> /etc/pandora/ pandora_agent.conf

Also you can install without having a configuration file, then the command is: 

module_plugin ./pandora_postgres_plugin.pl -u user -c password [-n basename] [-d dir_ip_server] [-p port] 2> error.log

3 º. Reboot the agent. 

sudo /etc/init.d/pandora_agent_daemon

We can also install the plugin if you use the configuration file, but lose some features (like creating  

your own queries).

Page 7

Page 8: Pandora FMS: PostgreSQL Plugin

6 MONITORING

The plugin monitors "default" the following:

• Connection Status   If possible the connection to the specified IP and ports.→

•  Server status

• Server port →  Only if the server is listening.

• Percentage of cpu usage 

• Percentage of memory usage 

Included in the file config.ini:

• Number of roles from the DB.

• Number of users postgres server.

• Number of active locks postgres server. 

• Space server bytes.

• Number of commits.

• Number of rollback.

• Number of active processes on the server. 

• Number of bases postgres server.

• Number tuples returned by the server. 

• Tuples in the database searched.

• Tuples inserted into the postgres server.

• Updated tuples in the postgres server.

 • Number of tuples removed postgres server.

All these modules are parameterized in the file "config.ini" that comes in the package of the plugin. These modules can be eliminated or extended for postgresql administrator.

Page 8

Page 9: Pandora FMS: PostgreSQL Plugin

7 CONFIGURATION FILE

In this file are the beginning of the plugin parameters, predefined modules and the modules we want to load user created sql.

For predefinos modules (enable / disable):

Percent cpu usage: GCPU = yes. If no boot file does not loadPercentage of use of mem: GMem = yes. If no boot file does not load

Apart from these two modules predefinos two more (but not be disabled), see list of modules.

IMPORTANT: SQL MODULES MAY MONITOR ONLY A PARAMETER THAT IS THE ONLY QUESTIONS MAY RETURN A DATA (A ROW AND COLUMN)

Below is an example of the file config.ini

#pandora_postgres_plugin.conf# # # #REQUIRED FIELDS #Name of the database on which we connect basename = david

#server address server_addr = 127.0.0.1

#server port port = 5432

#user to connect user = postgres

#password password =

################################# #Enable Predefined Modules # eg: Gcpu = yes (enabled) # Gcpu = no (disabled) # Gcpu = (disabled) ##################################

# Percentage of cpu usage Gcpu = yes

# Percentage of memory usage Gmem = yes

Page 9

Page 10: Pandora FMS: PostgreSQL Plugin

#################################################################################User Modules, allows users to create their own monitoring functions from sql query#eg : usermod# name = "user module"# description = "user module"# query := "SELECT count(*) from pg_stat_user_tables;" IMPORTANT query = is bad, query :=# type = "generic_data" (default is geneneric_data)# max_warning = This field is optional# min_warning = This field is optional# max_critical = This field is optional# min_critical = This field is optional# max = This field is optional# min = This field is optional# end ################################################################################usermodname = "Number of users from the DB"description = "Number of users Postgres server"query := "SELECT count(*) from pg_stat_activity;"min_critical = 1max_critical = 2#type = "generic_data"endusermodname = "Number of active locks the DB"description = "Number of active locks postgres server"query := "SELECT count(*) from pg_locks ;"min_warning =100max_warning = 500#type = "generic_data"endusermodname = "Number of commits"description = "Number of commit made by the server"query := "SELECT sum(xact_commit) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"max_warning = 25max = 600endusermodname = "Space server bytes"description = "Space server bytes"query := "SELECT sum(pg_database_size(datname)) FROM pg_database;"#type = "generic_data"endusermodname = "Version of the DB"description = "Version of the postgres server"

Page 10

Page 11: Pandora FMS: PostgreSQL Plugin

query := "SELECT version() ;"type = "generic_data_string"endusermodname = "Number of roles from the DB"description = "Number of postgres server roles"query := "SELECT count(*) from pg_roles ;"type = "generic_data"endusermodname = "Number of rollback"description = "Number of rollback made by the server"query := "SELECT sum(xact_rollback) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"endusermodname = "Number of active processes on the server"description = "Number of active processes on the server"query := "SELECT sum(xact_rollback) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"max = 2000type = "generic_data"endusermodname = "Number of bases in the DB"description = "Number of bases postgres server"query := "SELECT count(*) FROM pg_database;"type = "generic_data"endusermodname = "Tuples returned in the DB"description = "Number tuples returned by the server"query := "SELECT sum(tup_returned) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"endusermodname = "Tuples in the database searched "description = "Tuples sought in postgres server"query := "SELECT sum(tup_fetched) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"endusermodname = "Tuples inserted into the database"description = "Tuples inserted into the postgres server"query := "SELECT sum(tup_inserted) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"

Page 11

Page 12: Pandora FMS: PostgreSQL Plugin

endusermodname = "Updated tuples in the database"description = "Updated tuples in the postgres server"query := "SELECT sum(tup_updated) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"endusermodname = "Removed from the database tuples"description = "number of tuples removed postgres server"query := "SELECT sum(tup_deleted) FROM (pg_database AS db JOIN pg_stat_database sdb ON db.datname=sdb.datname);"type = "generic_data_inc"end

Page 12