1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# |
# |
3 |
# $Id$ |
# Monitor multiple postgresql databases on different hosts |
4 |
# $Revision$ |
# |
5 |
# $Author$ |
# Based on postgresql.monitor 1.3 |
6 |
# |
# by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
7 |
#Usage: postresql.monitor [options] |
# |
8 |
# |
#Usage: postresql.monitor username[:password]\@host/database ... |
|
# --database=<Databasename> indicates the database to which is connected |
|
|
# --username=<Username> DB-User which is used to connect to the DB |
|
|
# --password=<Password> DB-Password which is used to connect to the DB |
|
|
# --host=<Databasehost> Host of the Database (optional,default=localhost) |
|
|
# --port=<Portnumber> Port on which you want to connect (optional,default=5432) |
|
9 |
# |
# |
10 |
# a monitor to determine if a PostgreSQL database server is operational |
# a monitor to determine if a PostgreSQL database server is operational |
11 |
# |
# |
12 |
# 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 |
13 |
# 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 |
14 |
# on a given database server. |
# in given database on given server. |
15 |
|
# |
16 |
|
# You can use this monitor along with fping+args which also knows how to |
17 |
|
# ping hosts in that user@host/dabase format. |
18 |
# |
# |
19 |
# This monitor requires the perl5 DBI, DBD::mSQL and DBD::mysql modules, |
# This monitor requires the perl5 DBI, DBD::mSQL and DBD::mysql modules, |
20 |
# available from CPAN (http://www.cpan.org) |
# available from CPAN (http://www.cpan.org) |
21 |
# |
# |
22 |
# Copyright (C) 2001, CubIT IT Solutions |
# Copyright (C) 2001, CubIT IT Solutions |
23 |
# Written by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
# Written by Severin Luftensteiner <severin.luftensteiner@cubit.at> |
24 |
|
# Copyright (C) 2002, Dobrica Pavlinusic <dpavlin@rot13.org> |
25 |
# |
# |
26 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
27 |
# 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 |
39 |
# |
# |
40 |
|
|
41 |
use DBI; |
use DBI; |
|
use Getopt::Long; |
|
42 |
use strict; |
use strict; |
43 |
|
|
|
my %options; |
|
|
|
|
44 |
if (! @ARGV) { |
if (! @ARGV) { |
45 |
print <<EOP1; |
print <<EOP1; |
46 |
Usage: postresql.monitor username[:password]\@host/database ... |
Usage: postresql.monitor username[:password]\@host/database ... |