1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# |
# |
3 |
# $Id$ |
# Monitor multiple postgresql databases on different hosts |
4 |
# $Revision$ |
# |
5 |
# $Author$ |
# Dobrica Pavlinusic <dpavlin@rot13.org> |
6 |
# |
# http://www.rot13.org/~dpavlin/sysadm.html |
7 |
#Usage: postresql.monitor [options] |
# |
8 |
# |
# Based on postgresql.monitor 1.3 |
9 |
# --database=<Databasename> indicates the database to which is connected |
# by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
10 |
# --username=<Username> DB-User which is used to connect to the DB |
# it's not limited to singe host and/or singe database. |
11 |
# --password=<Password> DB-Password which is used to connect to the DB |
# |
12 |
# --host=<Databasehost> Host of the Database (optional,default=localhost) |
# Usage: pgsql.monitor username[:password]@host/database ... |
|
# --port=<Portnumber> Port on which you want to connect (optional,default=5432) |
|
13 |
# |
# |
14 |
# a monitor to determine if a PostgreSQL database server is operational |
# a monitor to determine if a PostgreSQL database server is operational |
15 |
# |
# |
16 |
# Rather than use tcp.monitor to ensure that your SQL server is responding |
# Rather than use tcp.monitor to ensure that your SQL server is responding |
17 |
# on the proper port, this attempts to connect to and list the databases |
# on the proper port, this attempts to connect to and count all tables |
18 |
# on a given database server. |
# in given database on given server. |
19 |
# |
# |
20 |
# This monitor requires the perl5 DBI, DBD::mSQL and DBD::mysql modules, |
# You can use this monitor along with fping+args which also knows how to |
21 |
|
# ping hosts in that user@host/dabase format. |
22 |
|
# |
23 |
|
# This monitor requires the perl5 DBI, DBD::Pg modules, |
24 |
# available from CPAN (http://www.cpan.org) |
# available from CPAN (http://www.cpan.org) |
25 |
# |
# |
26 |
# Copyright (C) 2001, CubIT IT Solutions |
# Copyright (C) 2001, CubIT IT Solutions |
27 |
# Written by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
# Written by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
28 |
|
# Copyright (C) 2002, Dobrica Pavlinusic <dpavlin@rot13.org> |
29 |
# |
# |
30 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
31 |
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
43 |
# |
# |
44 |
|
|
45 |
use DBI; |
use DBI; |
|
use Getopt::Long; |
|
46 |
use strict; |
use strict; |
47 |
|
|
|
my %options; |
|
|
|
|
48 |
if (! @ARGV) { |
if (! @ARGV) { |
49 |
print <<EOP1; |
print <<EOP1; |
50 |
Usage: postresql.monitor username[:password]\@host/database ... |
Usage: postresql.monitor username[:password]\@host/database ... |