/[mon-modules]/pgsql.monitor
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /pgsql.monitor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Wed Jul 10 08:43:16 2002 UTC revision 1.3 by dpavlin, Wed Jul 10 09:26:32 2002 UTC
# Line 46  GetOptions( \%options,"port=s", "usernam Line 46  GetOptions( \%options,"port=s", "usernam
46    
47  # uncomment these two lines and provide suitable information if you don't  # uncomment these two lines and provide suitable information if you don't
48  # want to pass sensitive information on the command line  # want to pass sensitive information on the command line
49  #$options{username} ||= "username";  $options{username} ||= "postgres";
50  #$options{password} ||= "password";  $options{password} ||= "";
51    
52  $mode="Pg";  $mode="Pg";
53  if ($options{host} eq ""){  if ($options{host} eq ""){
# Line 57  if ($options{port} eq ""){ Line 57  if ($options{port} eq ""){
57    $options{"port"=>"5432"};    $options{"port"=>"5432"};
58  }    }  
59    
60  if (($options{username} eq "") || ($options{password} eq "") || ($options{database} eq "")){  if (($options{username} eq "") || (! defined $options{password}) || ($options{database} eq "")){
61  print <<EOP1;  print <<EOP1;
62  Usage:  postresql.monitor [options]  Usage:  postresql.monitor [options]
63    
# Line 70  EOP1 Line 70  EOP1
70      die();      die();
71  }  }
72    
73    my @test_db;
74    
75    foreach (@ARGV) {
76            if (m/^([^:]+):([^\@]+)\@(.+)/) {
77                    push
78                    %test[host] = $1;
79                    %test[user] = $2;
80                    %test
81                    my ($host,$user,$database) = ($1,$2,$3);
82            } else {
83                    push @failures, "Can't parse configuration: host '$_' not in host:user\@database format!";
84            }
85    }
86    
87  my( $dbh ) = DBI->connect( "DBI:$mode:dbname=$options{database};$options{host};$options{port}", $options{username}, $options{password} );  my( $dbh ) = DBI->connect( "DBI:$mode:dbname=$options{database};$options{host};$options{port}", $options{username}, $options{password} );
88  if( ! $dbh ) {  if( ! $dbh ) {
89    push( @failures, "Could not connect to $mode server $host: " . $DBI::errstr );    push( @failures, "Could not connect to $mode server $host: " . $DBI::errstr );
90    } else {
91            my $sth = $dbh -> prepare("select count(*) from pg_tables");
92  }  }
93    
94    
95    
96  if (@failures) {  if (@failures) {
97      print join (", ", @failures), "\n";      print join (", ", @failures), "\n";
98      exit 1;      exit 1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26