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
4. 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
6. 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 where
should work
• Other Unix systems with postgresql 9 or
higher.
Page 6
8. 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
9. 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 load
Percentage 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
10. ################################################################################
#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
################################################################################
usermod
name = "Number of users from the DB"
description = "Number of users Postgres server"
query := "SELECT count(*) from pg_stat_activity;"
min_critical = 1
max_critical = 2
#type = "generic_data"
end
usermod
name = "Number of active locks the DB"
description = "Number of active locks postgres server"
query := "SELECT count(*) from pg_locks ;"
min_warning =100
max_warning = 500
#type = "generic_data"
end
usermod
name = "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 = 25
max = 600
end
usermod
name = "Space server bytes"
description = "Space server bytes"
query := "SELECT sum(pg_database_size(datname)) FROM pg_database;"
#type = "generic_data"
end
usermod
name = "Version of the DB"
description = "Version of the postgres server"
Page 10
11. query := "SELECT version() ;"
type = "generic_data_string"
end
usermod
name = "Number of roles from the DB"
description = "Number of postgres server roles"
query := "SELECT count(*) from pg_roles ;"
type = "generic_data"
end
usermod
name = "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"
end
usermod
name = "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 = 2000
type = "generic_data"
end
usermod
name = "Number of bases in the DB"
description = "Number of bases postgres server"
query := "SELECT count(*) FROM pg_database;"
type = "generic_data"
end
usermod
name = "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"
end
usermod
name = "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"
end
usermod
name = "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
12. end
usermod
name = "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"
end
usermod
name = "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