#!@@PERL@@
-#
+#
# Kill all slon instances for the current cluster
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
use Getopt::Long;
# Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE = 0;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE = 0;
$WATCHDOG_ONLY = 0;
-$ONLY_NODE = 0;
+$ONLY_NODE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE,
- "w|watchdog" => \$WATCHDOG_ONLY,
- "only-node=i" => \$ONLY_NODE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE,
+ "w|watchdog" => \$WATCHDOG_ONLY,
+ "only-node=i" => \$ONLY_NODE
+);
-my $USAGE =
-"Usage: slon_kill [--config file] [-w|--watchdog]
+my $USAGE = "Usage: slon_kill [--config file] [-w|--watchdog]
--config file Location of the slon_tools.conf file
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-print "slon_kill.pl... Killing all slon and slon_watchdog instances for the cluster $CLUSTER_NAME\n";
+print
+"slon_kill.pl... Killing all slon and slon_watchdog instances for the cluster $CLUSTER_NAME\n";
print "1. Kill slon watchdogs\n";
-$found="n";
+$found = "n";
# kill the watchdogs
-if($ONLY_NODE) {
- kill_watchdog($ONLY_NODE);
-} else {
- for my $nodenum (@NODES) {
- kill_watchdog($nodenum);
- }
+if ($ONLY_NODE) {
+ kill_watchdog($ONLY_NODE);
}
-if ($found eq 'n') {
+else {
+ for my $nodenum (@NODES) {
+ kill_watchdog($nodenum);
+ }
+}
+if ( $found eq 'n' ) {
print "No watchdogs found\n";
}
print "\n2. Kill slon processes\n";
# kill the slon daemons
- $found="n";
-
- if($ONLY_NODE) {
- kill_slon_node( $ONLY_NODE );
- } else {
- for my $nodenum (@NODES) {
- kill_slon_node( $nodenum );
- }
+ $found = "n";
+
+ if ($ONLY_NODE) {
+ kill_slon_node($ONLY_NODE);
+ }
+ else {
+ for my $nodenum (@NODES) {
+ kill_slon_node($nodenum);
+ }
}
- if ($found eq 'n') {
- print "No slon processes found\n";
+ if ( $found eq 'n' ) {
+ print "No slon processes found\n";
}
}
sub kill_watchdog($) {
- my ($nodenum) = @_;
-
- my $config_regexp = quotemeta( $CONFIG_FILE );
-
- my $command = ps_args() . "| egrep \"[s]lon_watchdog[2]? .*=$config_regexp node$nodenum \" | awk '{print \$2}' | sort -n";
-
- #print "Command:\n$command\n";
- open(PSOUT, "$command|");
-
- while ($pid = <PSOUT>) {
- chomp $pid;
- if (!($pid)) {
- print "No slon_watchdog is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
- } else {
- $found="y";
- kill 9, $pid;
- print "slon_watchdog for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
- }
- }
- close(PSOUT);
+ my ($nodenum) = @_;
+
+ my $config_regexp = quotemeta($CONFIG_FILE);
+
+ my $command = ps_args()
+ . "| egrep \"[s]lon_watchdog[2]? .*=$config_regexp node$nodenum \" | awk '{print \$2}' | sort -n";
+
+ #print "Command:\n$command\n";
+ open( PSOUT, "$command|" );
+
+ while ( $pid = <PSOUT> ) {
+ chomp $pid;
+ if ( !($pid) ) {
+ print
+"No slon_watchdog is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
+ }
+ else {
+ $found = "y";
+ kill 9, $pid;
+ print
+"slon_watchdog for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
+ }
+ }
+ close(PSOUT);
}
sub kill_slon_node($) {
- my ($nodenum) = @_;
-
- my $pid = get_pid($nodenum);
-
- #print "Command:\n$command\n";
- if (!($pid)) {
- print "No slon is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
- } else {
- $found="y";
- kill 15, $pid;
- print "slon for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
- }
+ my ($nodenum) = @_;
+
+ my $pid = get_pid($nodenum);
+
+ #print "Command:\n$command\n";
+ if ( !($pid) ) {
+ print
+ "No slon is running for the cluster $CLUSTER_NAME, node $nodenum!\n";
+ }
+ else {
+ $found = "y";
+ kill 15, $pid;
+ print
+ "slon for cluster $CLUSTER_NAME node $nodenum killed - PID [$pid]\n";
+ }
}
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
use Getopt::Long;
# Defaults
-$START_WATCHDOG = 1;
-$SLEEP_TIME = 30;
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE = 0;
+$START_WATCHDOG = 1;
+$SLEEP_TIME = 30;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE = 0;
$WATCHDOG_VERSION = 1;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "watchdog!" => \$START_WATCHDOG,
- "sleep=i" => \$SLEEP_TIME,
- "help" => \$SHOW_USAGE);
-
-my $USAGE =
-"Usage: slon_start [--config file] [--watchdog|--nowatchdog]
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "watchdog!" => \$START_WATCHDOG,
+ "sleep=i" => \$SLEEP_TIME,
+ "help" => \$SHOW_USAGE
+);
+
+my $USAGE = "Usage: slon_start [--config file] [--watchdog|--nowatchdog]
[--sleep seconds] node#
--config file Location of the slon_tools.conf file
";
-if ($SHOW_USAGE or scalar(@ARGV) != 1) {
- die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 1 ) {
+ die $USAGE;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
$node = $ARGV[0];
# Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = "node$1";
- $nodenum = $1;
-} else {
- die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = "node$1";
+ $nodenum = $1;
+}
+else {
+ die $USAGE;
}
$pid = get_pid($node);
if ($pid) {
- die "Slon is already running for the '$CLUSTER_NAME' cluster.\n";
+ die "Slon is already running for the '$CLUSTER_NAME' cluster.\n";
}
my $dsn = $DSN[$nodenum];
$pid = get_pid($node);
unless ($pid) {
- print "Slon failed to start for cluster $CLUSTER_NAME, node $node\n";
-} else {
- print "Slon successfully started for cluster $CLUSTER_NAME, node $node\n";
- print "PID [$pid]\n";
- if ($START_WATCHDOG) {
- print "Start the watchdog process as well...\n";
- if( $WATCHDOG_VERSION eq 2 ) {
- system "@@TOOLSBIN@@/slon_watchdog2 --config=$CONFIG_FILE $node $SLEEP_TIME &";
- } else {
- system "@@TOOLSBIN@@/slon_watchdog --config=$CONFIG_FILE $node $SLEEP_TIME &";
+ print "Slon failed to start for cluster $CLUSTER_NAME, node $node\n";
+}
+else {
+ print "Slon successfully started for cluster $CLUSTER_NAME, node $node\n";
+ print "PID [$pid]\n";
+ if ($START_WATCHDOG) {
+ print "Start the watchdog process as well...\n";
+ if ( $WATCHDOG_VERSION eq 2 ) {
+ system
+"@@TOOLSBIN@@/slon_watchdog2 --config=$CONFIG_FILE $node $SLEEP_TIME &";
+ }
+ else {
+ system
+"@@TOOLSBIN@@/slon_watchdog --config=$CONFIG_FILE $node $SLEEP_TIME &";
+ }
}
- }
}
use Getopt::Long;
# Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE = 0;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slon_status [--config file] node#
+my $USAGE = "Usage: slon_status [--config file] node#
--config file Location of the slon_tools.conf file
";
-if ($SHOW_USAGE or scalar(@ARGV) != 1) {
- die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 1 ) {
+ die $USAGE;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
$node = $ARGV[0];
# Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = "node$1";
- $nodenum = $1;
-} else {
- die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = "node$1";
+ $nodenum = $1;
+}
+else {
+ die $USAGE;
}
-if ( ! $DBNAME[$nodenum] ) {
- die "There is no such node.\n";
+if ( !$DBNAME[$nodenum] ) {
+ die "There is no such node.\n";
}
$pid = get_pid($node);
if ($pid) {
- die "Slon is running for the '$CLUSTER_NAME' cluster on $node.\n";
-} else {
- die "slon is not running for $node_name cluster.\n";
+ die "Slon is running for the '$CLUSTER_NAME' cluster on $node.\n";
+}
+else {
+ die "slon is not running for $node_name cluster.\n";
}
-
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
use Getopt::Long;
# Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE = 0;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE = 0;
$WATCHDOG_VERBOSE = 1;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slon_watchdog [--config file] node# sleep_seconds
+my $USAGE = "Usage: slon_watchdog [--config file] node# sleep_seconds
--config file Location of the slon_tools.conf file
";
-if ($SHOW_USAGE or scalar(@ARGV) != 2) {
- die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 2 ) {
+ die $USAGE;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-$node = $ARGV[0];
+$node = $ARGV[0];
$sleep = $ARGV[1];
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = "node$1";
- $nodenum = $1;
-} else {
- die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = "node$1";
+ $nodenum = $1;
+}
+else {
+ die $USAGE;
}
-my $logfile = "$LOGDIR/slon-watchdog.log";
+my $logfile = "$LOGDIR/slon-watchdog.log";
my $logfile_err = "$LOGDIR/slon-$CLUSTER_NAME-$node.err";
-log_to_file( $logfile , "Invoking watchdog for $CLUSTER_NAME node $nodenum , sleep time = $sleep +/- " . int($sleep/2) . " seconds");
+log_to_file( $logfile,
+"Invoking watchdog for $CLUSTER_NAME node $nodenum , sleep time = $sleep +/- "
+ . int( $sleep / 2 )
+ . " seconds" );
while (1) {
- $pid = get_pid($node);
- if (!($pid)) {
- my ($dsn, $dbname) = ($DSN[$nodenum], $DBNAME[$nodenum]);
- my $message = qq{WATCHDOG: No Slon is running for $CLUSTER_NAME node $nodenum!
+ $pid = get_pid($node);
+ if ( !($pid) ) {
+ my ( $dsn, $dbname ) = ( $DSN[$nodenum], $DBNAME[$nodenum] );
+ my $message =
+ qq{WATCHDOG: No Slon is running for $CLUSTER_NAME node $nodenum!
You ought to check the postmaster and slon for evidence of a crash!
I'm going to restart slon for $node...
};
- # log to error log as original routine
- log_to_file( $logfile_err , $message );
-
- # log to watchdog log
- log_to_file( $logfile , "No Slon running for $CLUSTER_NAME node $nodenum, restarting slon");
-
- # First, restart the node using slonik
- if ($CONFIG_FILE ne "") {
- system "(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
- } else {
- system "(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+ # log to error log as original routine
+ log_to_file( $logfile_err, $message );
+
+ # log to watchdog log
+ log_to_file( $logfile,
+ "No Slon running for $CLUSTER_NAME node $nodenum, restarting slon"
+ );
+
+ # First, restart the node using slonik
+ if ( $CONFIG_FILE ne "" ) {
+ system
+"(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+ }
+ else {
+ system
+"(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile_err 2>> $logfile_err";
+ }
+
+ # Next, restart the slon process to service the node
+ start_slon($nodenum);
+ $pid = get_pid($node);
+ log_to_file( $logfile_err,
+"WATCHDOG: Restarted slon for the $CLUSTER_NAME cluster $node, new PID $pid"
+ );
}
- # Next, restart the slon process to service the node
- start_slon($nodenum);
- $pid = get_pid($node);
- log_to_file( $logfile_err , "WATCHDOG: Restarted slon for the $CLUSTER_NAME cluster $node, new PID $pid" );
- } else {
- if ( $WATCHDOG_VERBOSE ) {
- log_to_file( $logfile , "Found slon daemon for $CLUSTER_NAME $node, PID $pid, Sleeping for $sleep +/- " . int($sleep/2) . " seconds" );
+ else {
+ if ($WATCHDOG_VERBOSE) {
+ log_to_file( $logfile,
+"Found slon daemon for $CLUSTER_NAME $node, PID $pid, Sleeping for $sleep +/- "
+ . int( $sleep / 2 )
+ . " seconds" );
+ }
}
- }
- sleep $sleep + (rand($sleep) - $sleep/2);
+ sleep $sleep + ( rand($sleep) - $sleep / 2 );
}
sub log_to_file {
- my ($logfile,$message) = @_;
- chomp $message;
- my $date = `date`;
- chomp $date;
-
- open (SLONLOG, ">>$logfile");
- print SLONLOG $date, " | ", $message, "\n";
- close SLONLOG;
+ my ( $logfile, $message ) = @_;
+ chomp $message;
+ my $date = `date`;
+ chomp $date;
+
+ open( SLONLOG, ">>$logfile" );
+ print SLONLOG $date, " | ", $message, "\n";
+ close SLONLOG;
}
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
use Getopt::Long;
# Defaults
-$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
-$SHOW_USAGE = 0;
+$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
+$SHOW_USAGE = 0;
$WATCHDOG_VERBOSE = 1;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slon_watchdog2 [--config file] node# sleep_seconds
+my $USAGE = "Usage: slon_watchdog2 [--config file] node# sleep_seconds
--config file Location of the slon_tools.conf file
";
-if ($SHOW_USAGE or scalar(@ARGV) != 2) {
- die $USAGE;
+if ( $SHOW_USAGE or scalar(@ARGV) != 2 ) {
+ die $USAGE;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
$node = $ARGV[0];
$sleep = $ARGV[1];
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = "node$1";
- $nodenum = $1;
-} else {
- die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = "node$1";
+ $nodenum = $1;
+}
+else {
+ die $USAGE;
}
my $logfile = "$LOGDIR/slon-watchdog.log";
-log_to_file( $logfile , "Invoking watchdog for $CLUSTER_NAME node $nodenum, sleep time = $sleep +/- " . int($sleep/2) . " seconds");
+log_to_file( $logfile,
+"Invoking watchdog for $CLUSTER_NAME node $nodenum, sleep time = $sleep +/- "
+ . int( $sleep / 2 )
+ . " seconds" );
# When slon daemon is just started, may not have time to start syncronization
# and the watchdog will kill the process with no mercy.
sleep $sleep;
while (1) {
- my $res = query_slony_status($nodenum); # See where the node stands
- my $eventsOK;
- if ($res =~ /^\s*t\s*\|/) {
- $eventsOK = "YES";
- if ( $WATCHDOG_VERBOSE ) {
- log_to_file( $logfile , "Query_slony_status returns true for $CLUSTER_NAME node $nodenum" );
- }
- } else {
- $res = node_is_subscribing($nodenum);
- if ($res =~ /SUBSCRIBE_SET/) {
- $eventsOK = "YES";
- } else {
- $eventsOK = "NO";
+ my $res = query_slony_status($nodenum); # See where the node stands
+ my $eventsOK;
+ if ( $res =~ /^\s*t\s*\|/ ) {
+ $eventsOK = "YES";
+ if ($WATCHDOG_VERBOSE) {
+ log_to_file( $logfile,
+"Query_slony_status returns true for $CLUSTER_NAME node $nodenum"
+ );
+ }
}
- if ( $WATCHDOG_VERBOSE ) {
- log_to_file( $logfile , "Query_slony_status returns false for $CLUSTER_NAME node $nodenum, node_is_subscribing : $eventsOK" );
+ else {
+ $res = node_is_subscribing($nodenum);
+ if ( $res =~ /SUBSCRIBE_SET/ ) {
+ $eventsOK = "YES";
+ }
+ else {
+ $eventsOK = "NO";
+ }
+ if ($WATCHDOG_VERBOSE) {
+ log_to_file( $logfile,
+"Query_slony_status returns false for $CLUSTER_NAME node $nodenum, node_is_subscribing : $eventsOK"
+ );
+ }
}
- }
- my $pid = get_pid($node); # See if the slon process is alive
- my ($restart, $kick);
- $kick = "NO"; # Initially, assume we don't need to submit a "restart node" command
- if ($pid) { # PID is alive...
- if ($eventsOK eq "YES") {
- # All is well - do nothing!
- $restart = "NO";
- } else {
- $restart = "YES";
+ my $pid = get_pid($node); # See if the slon process is alive
+ my ( $restart, $kick );
+ $kick =
+ "NO"; # Initially, assume we don't need to submit a "restart node" command
+ if ($pid) { # PID is alive...
+ if ( $eventsOK eq "YES" ) {
+
+ # All is well - do nothing!
+ $restart = "NO";
+ }
+ else {
+ $restart = "YES";
+ }
}
- } else {
- $restart = "YES";
+ else {
+ $restart = "YES";
# The message searched isn't generated as bellow anymore...
# and may be exist another better way to know if the restart of node is necessary
# $kick = "YES"; # Yup, need to tell slonik to reset this node
# }
- # Kicking allways as slon_watchdog.pl do
- $kick = "YES";
- }
-
- # If the node needs a swift kick in the "RESTART", then submit that to slonik
- if ($kick eq "YES") {
- log_to_file($logfile,"submit slonik to restart $CLUSTER_NAME node $nodenum");
- if ($CONFIG_FILE ne "") {
- system "(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
- } else {
- system "(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+ # Kicking allways as slon_watchdog.pl do
+ $kick = "YES";
+ }
+
+ # If the node needs a swift kick in the "RESTART", then submit that to slonik
+ if ( $kick eq "YES" ) {
+ log_to_file( $logfile,
+ "submit slonik to restart $CLUSTER_NAME node $nodenum" );
+ if ( $CONFIG_FILE ne "" ) {
+ system
+"(@@TOOLSBIN@@/slonik_restart_node --config=${CONFIG_FILE} $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+ }
+ else {
+ system
+"(@@TOOLSBIN@@/slonik_restart_node $node | @@SLONBINDIR@@/slonik) >> $logfile 2>> $logfile";
+ }
}
- }
- if ($restart eq "YES") {
- if ($pid) {
- log_to_file($logfile,"terminate slon daemon for $CLUSTER_NAME node $nodenum, PID $pid");
- # Kill slon until dead...
- kill 2, $pid;
- sleep 3;
- kill 15, $pid;
- sleep 3;
- # if killed with 9 the pid file isnยดt deleted and the service donยดt restart
- # kill 9, $pid;
+ if ( $restart eq "YES" ) {
+ if ($pid) {
+ log_to_file( $logfile,
+"terminate slon daemon for $CLUSTER_NAME node $nodenum, PID $pid"
+ );
+
+ # Kill slon until dead...
+ kill 2, $pid;
+ sleep 3;
+ kill 15, $pid;
+ sleep 3;
+
+ # if killed with 9 the pid file isnยดt deleted and the service donยดt restart
+ # kill 9, $pid;
+ }
+ log_to_file( $logfile, "restart slon for $CLUSTER_NAME node $nodenum" );
+ start_slon($nodenum);
}
- log_to_file($logfile,"restart slon for $CLUSTER_NAME node $nodenum");
- start_slon($nodenum);
- }
- sleep $sleep + (rand($sleep) - $sleep/2);
+ sleep $sleep + ( rand($sleep) - $sleep / 2 );
}
sub log_to_file {
- my ($logfile,$message) = @_;
- chomp $message;
- my $date = `date`;
- chomp $date;
- open (SLONLOG, ">>$logfile");
- print SLONLOG $date, "|", $message, "\n";
- close SLONLOG;
+ my ( $logfile, $message ) = @_;
+ chomp $message;
+ my $date = `date`;
+ chomp $date;
+ open( SLONLOG, ">>$logfile" );
+ print SLONLOG $date, "|", $message, "\n";
+ close SLONLOG;
}
#!@@PERL@@
-#
+#
# Author: Gurjeet Singh
use Getopt::Long;
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: add_node [--config file] node# event_node#
+my $USAGE = "Usage: add_node [--config file] node# event_node#
adds a node to the cluster.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($addnode, $current_origin) = @ARGV;
-if ($addnode =~ /^(?:node)?(\d+)$/) {
- $addnode = $1;
-} else {
- die $USAGE;
+my ( $addnode, $current_origin ) = @ARGV;
+if ( $addnode =~ /^(?:node)?(\d+)$/ ) {
+ $addnode = $1;
+}
+else {
+ die $USAGE;
}
-if ($current_origin =~ /^(?:node)?(\d+)$/) {
- $current_origin = $1;
-} else {
- die $USAGE;
+if ( $current_origin =~ /^(?:node)?(\d+)$/ ) {
+ $current_origin = $1;
+}
+else {
+ die $USAGE;
}
-my ($dbname, $dbhost) = ($DBNAME[$addnode], $HOST[$addnode]);
+my ( $dbname, $dbhost ) = ( $DBNAME[$addnode], $HOST[$addnode] );
my $slonik = '';
-$slonik .= "\n# ADD NODE\n";
+$slonik .= "\n# ADD NODE\n";
$slonik .= genheader();
$slonik .= " try {\n";
-$slonik .= " store node (id = $addnode, event node = $current_origin, comment = 'Node $addnode - $dbname\@$dbhost');\n";
+$slonik .=
+" store node (id = $addnode, event node = $current_origin, comment = 'Node $addnode - $dbname\@$dbhost');\n";
$slonik .= " } on error {\n";
$slonik .= " echo 'Failed to add node $node to cluster';\n";
$slonik .= " exit 1;\n";
$slonik .= " }\n";
# STORE PATH
-$slonik .= "\n# STORE PATHS\n";
+$slonik .= "\n# STORE PATHS\n";
foreach my $node (@NODES) {
- my $adddsn = $DSN[$addnode];
- if ($node != $addnode) { # skip the master node; it's already initialized!
- my ($dbname, $dbhost, $nodedsn) = ($DBNAME[$node], $HOST[$node], $DSN[$node]);
- $slonik .= " store path (server = $addnode, client = $node, conninfo = '$adddsn');\n";
- $slonik .= " store path (server = $node, client = $addnode, conninfo = '$nodedsn');\n";
- }
+ my $adddsn = $DSN[$addnode];
+ if ( $node != $addnode ) { # skip the master node; it's already initialized!
+ my ( $dbname, $dbhost, $nodedsn ) =
+ ( $DBNAME[$node], $HOST[$node], $DSN[$node] );
+ $slonik .=
+" store path (server = $addnode, client = $node, conninfo = '$adddsn');\n";
+ $slonik .=
+" store path (server = $node, client = $addnode, conninfo = '$nodedsn');\n";
+ }
}
$slonik .= " echo 'added node $addnode to cluster';\n";
-$slonik .= " echo 'Please start a slon replication daemon for node $addnode';\n";
-
-run_slonik_script($slonik, 'ADD NODE');
+$slonik .=
+ " echo 'Please start a slon replication daemon for node $addnode';\n";
+run_slonik_script( $slonik, 'ADD NODE' );
#!@@PERL@@
-#
+#
# Contributed by:
# Joe Kalash
# kalash@savicom.net
my $dataBasePort;
my @nodes;
my $schema = 'public';
-my $usage = "$0 -node host:database:user[:password:port] [-node ...] [-schema myschema]
+my $usage =
+ "$0 -node host:database:user[:password:port] [-node ...] [-schema myschema]
First node is assumed to be the master.
Default schema is \"public\"\n";
-&usage if(!GetOptions('node=s@'=>\@nodes, 'schema=s' => \$schema));
+&usage if ( !GetOptions( 'node=s@' => \@nodes, 'schema=s' => \$schema ) );
die "At least one node is required" if ( scalar(@nodes) < 1 );
-
-
my $nodeNumber = 1;
my $parentString;
-foreach my $node (@nodes)
-{
- my($tmpHost,$tmpDataBase,$tmpDataBaseUser,$tmpDataBasePassword,$tmpPort) =
- split(/:/,$node);
- die "Host is required" if ( !$tmpHost );
- die "database is required" if ( !$tmpDataBase );
- die "user is required" if ( !$tmpDataBaseUser );
- $tmpPort = 5432 if ( !$tmpPort );
- $host = $tmpHost if ( !$host );
- $dataBase = $tmpDataBase if ( !$dataBase );
- if ( !$dataBaseUser ) {
- $dataBaseUser = $tmpDataBaseUser;
- $dataBasePassword = $tmpDataBasePassword if ( $tmpDataBasePassword );
- $dataBasePort = $tmpPort if ( $tmpPort );
- }
- print "&add_node(host => '$tmpHost', dbname => '$tmpDataBase', port =>$tmpPort,
+foreach my $node (@nodes) {
+ my ( $tmpHost, $tmpDataBase, $tmpDataBaseUser, $tmpDataBasePassword,
+ $tmpPort )
+ = split( /:/, $node );
+ die "Host is required" if ( !$tmpHost );
+ die "database is required" if ( !$tmpDataBase );
+ die "user is required" if ( !$tmpDataBaseUser );
+ $tmpPort = 5432 if ( !$tmpPort );
+ $host = $tmpHost if ( !$host );
+ $dataBase = $tmpDataBase if ( !$dataBase );
+ if ( !$dataBaseUser ) {
+ $dataBaseUser = $tmpDataBaseUser;
+ $dataBasePassword = $tmpDataBasePassword if ($tmpDataBasePassword);
+ $dataBasePort = $tmpPort if ($tmpPort);
+ }
+ print
+ "&add_node(host => '$tmpHost', dbname => '$tmpDataBase', port =>$tmpPort,
user=>'$tmpDataBaseUser', password=>'$tmpDataBasePassword', node=>$nodeNumber $parentString);\n";
- $parentString = ', parent=>1';
- $nodeNumber++;
+ $parentString = ', parent=>1';
+ $nodeNumber++;
}
my $connectString = "dbi:Pg:dbname=$dataBase;host=$host;port=$dataBasePort";
-my $dbh = DBI->connect($connectString,$dataBaseUser,$dataBasePassword,
- {RaiseError => 0, PrintError => 0, AutoCommit => 1});
+my $dbh = DBI->connect( $connectString, $dataBaseUser, $dataBasePassword,
+ { RaiseError => 0, PrintError => 0, AutoCommit => 1 } );
die "connect: $DBI::errstr" if ( !defined($dbh) || $DBI::err );
+
# Read in all the user 'normal' tables in $schema (public by default).
-my $tableQuery = $dbh->prepare("
+my $tableQuery = $dbh->prepare( "
SELECT pg_namespace.nspname || '.' || pg_class.relname,pg_class.relkind,pg_class.relhaspkey
FROM pg_namespace,pg_class
WHERE pg_class.reltype > 0
AND pg_class.relnamespace = pg_catalog.pg_namespace.oid
AND (pg_class.relkind = 'r' OR pg_class.relkind = 'S')
-AND pg_namespace.nspname = '$schema' AND pg_namespace.oid = pg_class.relnamespace");
+AND pg_namespace.nspname = '$schema' AND pg_namespace.oid = pg_class.relnamespace"
+);
-die "prepare(tableQuery): $DBI::errstr" if ( !defined($tableQuery) || $DBI::err );
+die "prepare(tableQuery): $DBI::errstr"
+ if ( !defined($tableQuery) || $DBI::err );
die "execute(tableQuery): $DBI::errstr" if ( !$tableQuery->execute() );
-die "No objects to replicate found in schema \"$schema\"\n" if ($tableQuery->rows <= 0);
+die "No objects to replicate found in schema \"$schema\"\n"
+ if ( $tableQuery->rows <= 0 );
my @tablesWithIndexes;
my @tablesWithoutIndexes;
my @sequences;
while ( my $row = $tableQuery->fetchrow_arrayref() ) {
- my $relname = @$row[0];
- my $relkind = @$row[1];
- my $relhaspkey = @$row[2];
- push(@sequences,$relname) if ( $relkind eq 'S' );
- push(@tablesWithIndexes,$relname) if ( $relkind eq 'r' && $relhaspkey == 1 );
- push(@tablesWithoutIndexes,$relname) if ( $relkind eq 'r' && $relhaspkey == 0 );
+ my $relname = @$row[0];
+ my $relkind = @$row[1];
+ my $relhaspkey = @$row[2];
+ push( @sequences, $relname ) if ( $relkind eq 'S' );
+ push( @tablesWithIndexes, $relname )
+ if ( $relkind eq 'r' && $relhaspkey == 1 );
+ push( @tablesWithoutIndexes, $relname )
+ if ( $relkind eq 'r' && $relhaspkey == 0 );
}
$tableQuery->finish();
$dbh->disconnect();
if ( scalar(@tablesWithIndexes) >= 1 ) {
- print '@PKEYEDTABLES=(' . "\n";
- foreach my $table (sort @tablesWithIndexes) {
- print "\t\"$table\",\n";
- }
- print ");\n";
+ print '@PKEYEDTABLES=(' . "\n";
+ foreach my $table ( sort @tablesWithIndexes ) {
+ print "\t\"$table\",\n";
+ }
+ print ");\n";
}
if ( scalar(@tablesWithoutIndexes) >= 1 ) {
- my $tables = '';
- foreach my $table (sort @tablesWithoutIndexes) {
- if($tables ne '') {
- $tables.=',';
- }
- $tables.="\"$table\"";
- }
- die "The following tables had no unique index:" . $tables."\n";
+ my $tables = '';
+ foreach my $table ( sort @tablesWithoutIndexes ) {
+ if ( $tables ne '' ) {
+ $tables .= ',';
+ }
+ $tables .= "\"$table\"";
+ }
+ die "The following tables had no unique index:" . $tables . "\n";
}
if ( scalar(@sequences) >= 1 ) {
- print '@SEQUENCES=(' . "\n";
- foreach my $table (sort @sequences) {
- print "\t\"$table\",\n";
- }
- print ");\n";
+ print '@SEQUENCES=(' . "\n";
+ foreach my $table ( sort @sequences ) {
+ print "\t\"$table\",\n";
+ }
+ print ");\n";
}
exit 0;
sub usage {
- print "$usage";
- exit 0;
+ print "$usage";
+ exit 0;
}
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: create_set [--config file] set
+my $USAGE = "Usage: create_set [--config file] set
set The name or ID of the set to be created
";
-my $slonik = '';
+my $slonik = '';
if ($SHOW_USAGE) {
print $USAGE;
$SET_ID = get_set($set);
unless ($SET_ID) {
my $possible_sets = join "\n\t", keys %$SLONY_SETS;
- print "No set was found with the name provided. Possible valid names include:\n\t"
- . $possible_sets . "\n\n"
- . "New sets may be defined in your slon_tools.conf file\n\n";
+ print
+"No set was found with the name provided. Possible valid names include:\n\t"
+ . $possible_sets . "\n\n"
+ . "New sets may be defined in your slon_tools.conf file\n\n";
die $USAGE;
}
# CREATE SET
$slonik .= "\n";
$slonik .= "# CREATE SET\n";
-$slonik .= " create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID ($SET_NAME) for $CLUSTER_NAME');\n";
+$slonik .=
+" create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID ($SET_NAME) for $CLUSTER_NAME');\n";
# SET ADD TABLE
$slonik .= "\n";
foreach my $table (@PKEYEDTABLES) {
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- $slonik .= " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+ $slonik .=
+" set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
$slonik .= " full qualified name = '$table',\n";
$slonik .= " comment = 'Table $table with primary key');\n";
$slonik .= " echo 'Add primary keyed table $table';\n";
$TABLE_ID++;
}
-foreach my $table (keys %KEYEDTABLES) {
+foreach my $table ( keys %KEYEDTABLES ) {
my $key = $KEYEDTABLES{$table};
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- $slonik .= " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+ $slonik .=
+" set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
$slonik .= " full qualified name = '$table', key='$key',\n";
- $slonik .= " comment = 'Table $table with candidate primary key $key');\n";
+ $slonik .=
+" comment = 'Table $table with candidate primary key $key');\n";
$slonik .= " echo 'Add candidate primary keyed table $table';\n";
$TABLE_ID++;
}
foreach my $seq (@SEQUENCES) {
$seq = ensure_namespace($seq);
$seq = lc($seq) if $FOLD_CASE;
- $slonik .= " set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
+ $slonik .=
+" set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
$slonik .= " full qualified name = '$seq',\n";
$slonik .= " comment = 'Sequence $seq');\n";
$slonik .= " echo 'Add sequence $seq';\n";
}
$slonik .= " echo 'All tables added';\n";
-run_slonik_script($slonik, 'CREATE SET');
+run_slonik_script( $slonik, 'CREATE SET' );
### If object hasn't a namespace specified, assume it's in "public", and make it so...
sub ensure_namespace {
my ($object) = @_;
- if ($object =~ /^(.*\..*)$/) {
- # Table has a namespace specified
- } else {
- $object = "public.$object";
+ if ( $object =~ /^(.*\..*)$/ ) {
+
+ # Table has a namespace specified
+ }
+ else {
+ $object = "public.$object";
}
return $object;
}
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: drop_node [--config file] node# event_node#
+my $USAGE = "Usage: drop_node [--config file] node# event_node#
Drops a node.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($node, $event_node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = $1;
-} else {
- die $USAGE;
+my ( $node, $event_node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = $1;
+}
+else {
+ die $USAGE;
}
-if ($event_node =~ /^(?:node)?(\d+)$/) {
- $event_node = $1;
-} else {
- print "Need to specify event node!\n";
- die $USAGE;
+if ( $event_node =~ /^(?:node)?(\d+)$/ ) {
+ $event_node = $1;
+}
+else {
+ print "Need to specify event node!\n";
+ die $USAGE;
}
my $slonik = '';
$slonik .= " drop node (id = $node, event node = $event_node);\n";
$slonik .= " echo 'dropped node $node cluster';\n";
-run_slonik_script($slonik, 'DROP NODE');
+run_slonik_script( $slonik, 'DROP NODE' );
#!@@PERL@@
-#
+#
# Author: Mark Stosberg
# Based on work by: Christopher Browne
# Parts Copyright 2008 Summerault, LLC
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slonik_drop_sequence [--config file] sequence_id set
+my $USAGE = "Usage: slonik_drop_sequence [--config file] sequence_id set
sequence_id The ID of the sequence to be dropped from replication
set The name or ID of the set to drop the sequence from
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($SEQ_ID,$set) = @ARGV;
+my ( $SEQ_ID, $set ) = @ARGV;
$SET_ID = get_set($set);
-unless ($SEQ_ID && $SET_ID) {
+unless ( $SEQ_ID && $SET_ID ) {
die $USAGE;
}
$slonik .= " exit 1;\n";
$slonik .= " }\n";
-run_slonik_script($slonik, 'DROP SEQUENCE');
+run_slonik_script( $slonik, 'DROP SEQUENCE' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
my $USAGE = <<EOF
"Usage: drop_set [--config file] set#
Handle with care...
EOF
-;
+ ;
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
$slonik .= " }\n";
$slonik .= " echo 'Dropped set $set';\n";
-run_slonik_script($slonik, 'DROP SET');
+run_slonik_script( $slonik, 'DROP SET' );
#!@@PERL@@
-#
+#
# Author: Mark Stosberg
# Based on work by: Christopher Browne
# Parts Copyright 2006 Summerault, LLC
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slonik_drop_table [--config file] table_id set
+my $USAGE = "Usage: slonik_drop_table [--config file] table_id set
table_id The ID of the table to be dropped from replication
set The name or ID of the set to drop the table from
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($TABLE_ID,$set) = @ARGV;
+my ( $TABLE_ID, $set ) = @ARGV;
$SET_ID = get_set($set);
-unless ($TABLE_ID && $SET_ID) {
+unless ( $TABLE_ID && $SET_ID ) {
die $USAGE;
}
$slonik .= " exit 1;\n";
$slonik .= " }\n";
-run_slonik_script($slonik, 'DROP TABLE');
+run_slonik_script( $slonik, 'DROP TABLE' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
my $fh = undef;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE,
- "c=s" => \$SCRIPT_ARG,
- "n|node=s" => \$node);
-
-my $USAGE =
-"Usage:
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE,
+ "c=s" => \$SCRIPT_ARG,
+ "n|node=s" => \$node
+);
+
+my $USAGE = "Usage:
execute_script [options] set# full_path_to_sql_script_file
execute_script [options] -c SCRIPT set#
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($set, $file) = @ARGV;
+my ( $set, $file ) = @ARGV;
die $USAGE unless $set;
$set = get_set($set) or die "Non-existent set specified.\n";
$node = $SET_ORIGIN unless $node;
# We can either have -c SCRIPT or a filename as an argument. The
# latter takes precedence.
if ($file) {
- unless ($file =~ /^\// and -f $file) {
- print STDERR "SQL script path needs to be a full path, e.g. /tmp/my_script.sql\n\n";
- die $USAGE;
+ unless ( $file =~ /^\// and -f $file ) {
+ print STDERR
+"SQL script path needs to be a full path, e.g. /tmp/my_script.sql\n\n";
+ die $USAGE;
}
- $filename = $file
+ $filename = $file;
}
elsif ($SCRIPT_ARG) {
+
# Put the script into a file
- ($fh, $filename) = tempfile();
+ ( $fh, $filename ) = tempfile();
print $fh $SCRIPT_ARG;
close $fh;
}
else {
- print STDERR "You must include either a filename or a SQL statement on the command line to be run.\n\n";
+ print STDERR
+"You must include either a filename or a SQL statement on the command line to be run.\n\n";
die $USAGE;
}
$slonik .= " event node = $node\n";
$slonik .= " );\n";
-run_slonik_script($slonik, 'EXECUTE SCRIPT');
+run_slonik_script( $slonik, 'EXECUTE SCRIPT' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slonik_failover [--config file] dead_node backup_node
+my $USAGE = "Usage: slonik_failover [--config file] dead_node backup_node
Abandons dead_node, making backup_node the origin for all sets on
dead_node.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($node1, $node2) = @ARGV;
-if ($node1 =~ /^(?:node)?(\d+)$/) {
- $node1 = $1;
-} else {
- die $USAGE;
+my ( $node1, $node2 ) = @ARGV;
+if ( $node1 =~ /^(?:node)?(\d+)$/ ) {
+ $node1 = $1;
+}
+else {
+ die $USAGE;
}
-if ($node2 =~ /^(?:node)?(\d+)$/) {
- $node2 = $1;
-} else {
- die $USAGE;
+if ( $node2 =~ /^(?:node)?(\d+)$/ ) {
+ $node2 = $1;
+}
+else {
+ die $USAGE;
}
my $slonik = '';
$slonik .= " echo 'Failure to fail node $node1 over to $node2';\n";
$slonik .= " exit 1;\n";
$slonik .= " }\n";
-$slonik .= " echo 'Replication sets originating on $node1 failed over to $node2';\n";
+$slonik .=
+ " echo 'Replication sets originating on $node1 failed over to $node2';\n";
-run_slonik_script($slonik, 'FAILOVER');
+run_slonik_script( $slonik, 'FAILOVER' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
my $SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: init_cluster [--config file]
+my $USAGE = "Usage: init_cluster [--config file]
Generates the slonik commands necessary to create a cluster and
prepare the nodes for use. Also displays a report showing the
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
# INIT CLUSTER
-$slonik .= "\n# INIT CLUSTER\n";
-$slonik .= genheader();
-my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]);
-$slonik .= " init cluster (id = $MASTERNODE, comment = 'Node $MASTERNODE - $dbname\@$dbhost');\n";
+$slonik .= "\n# INIT CLUSTER\n";
+$slonik .= genheader();
+my ( $dbname, $dbhost ) = ( $DBNAME[$MASTERNODE], $HOST[$MASTERNODE] );
+$slonik .=
+" init cluster (id = $MASTERNODE, comment = 'Node $MASTERNODE - $dbname\@$dbhost');\n";
# STORE NODE
-$slonik .= "\n# STORE NODE\n";
+$slonik .= "\n# STORE NODE\n";
foreach my $node (@NODES) {
- if ($node != $MASTERNODE) { # skip the master node; it's already initialized!
- my ($dbname, $dbhost) = ($DBNAME[$node], $HOST[$node]);
- $slonik .= " store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
- }
+ if ( $node != $MASTERNODE )
+ { # skip the master node; it's already initialized!
+ my ( $dbname, $dbhost ) = ( $DBNAME[$node], $HOST[$node] );
+ $slonik .=
+" store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
+ }
}
-$slonik .= " echo 'Set up replication nodes';\n";
+$slonik .= " echo 'Set up replication nodes';\n";
# STORE PATH
-$slonik .= "\n# STORE PATH\n";
+$slonik .= "\n# STORE PATH\n";
-$slonik .= " echo 'Next: configure paths for each node/origin';\n";
+$slonik .= " echo 'Next: configure paths for each node/origin';\n";
foreach my $nodea (@NODES) {
- my $dsna = $DSN[$nodea];
- foreach my $nodeb (@NODES) {
- if ($nodea != $nodeb) {
- my $dsnb = $DSN[$nodeb];
- if (!$printed[$nodea][$nodeb]) {
- $slonik .= " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
- $printed[$nodea][$nodeb] = "done";
- }
- if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
- $slonik .= " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
- $printed[$nodeb][$nodea] = "done";
- }
+ my $dsna = $DSN[$nodea];
+ foreach my $nodeb (@NODES) {
+ if ( $nodea != $nodeb ) {
+ my $dsnb = $DSN[$nodeb];
+ if ( !$printed[$nodea][$nodeb] ) {
+ $slonik .=
+" store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+ $printed[$nodea][$nodeb] = "done";
+ }
+ if ( !$printed[$nodeb][$nodea] and $providerba == $nodea ) {
+ $slonik .=
+" store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+ $printed[$nodeb][$nodea] = "done";
+ }
+ }
}
- }
}
-$slonik .= " echo 'Replication nodes prepared';\n";
-$slonik .= " echo 'Please start a slon replication daemon for each node';\n";
-run_slonik_script($slonik, 'INIT CLUSTER');
+$slonik .= " echo 'Replication nodes prepared';\n";
+$slonik .= " echo 'Please start a slon replication daemon for each node';\n";
+run_slonik_script( $slonik, 'INIT CLUSTER' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: merge_sets [--config file] node# targetset# srcset#
+my $USAGE = "Usage: merge_sets [--config file] node# targetset# srcset#
Merges the contents of the second set into the first one.
When completed, the second set no longer exists.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($node, $set1, $set2) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
- # Set name is in proper form
- $node = $1;
-} else {
- print "Valid node names are node1, node2, ...\n\n";
- die $USAGE;
+my ( $node, $set1, $set2 ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+
+ # Set name is in proper form
+ $node = $1;
+}
+else {
+ print "Valid node names are node1, node2, ...\n\n";
+ die $USAGE;
}
die $USAGE unless $set1;
die $USAGE unless $set2;
$set2 = get_set($set2) or die "Non-existent set specified.\n";
-my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]);
+my ( $dbname, $dbhost ) = ( $DBNAME[$MASTERNODE], $HOST[$MASTERNODE] );
my $slonik = '';
$slonik .= genheader();
$slonik .= " merge set (id = $set1, add id = $set2, origin = $node);\n";
-$slonik .= " echo 'Replication set $set2 merged into $set1 on origin $node. Set $set2 no longer exists.';\n";
+$slonik .=
+" echo 'Replication set $set2 merged into $set1 on origin $node. Set $set2 no longer exists.';\n";
-run_slonik_script($slonik, 'MERGE SET');
+run_slonik_script( $slonik, 'MERGE SET' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: move_set [--config file] set# from_node# to_node#
+my $USAGE = "Usage: move_set [--config file] set# from_node# to_node#
Change a set's origin.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($set, $node1, $node2) = @ARGV;
+my ( $set, $node1, $node2 ) = @ARGV;
die $USAGE unless $set;
$set = get_set($set) or die "Non-existent set specified.\n";
-if ($node1 =~ /^(?:node)?(\d+)$/) {
- $node1 = $1;
-} else {
- print "Valid node names are node1, node2, ...\n\n";
- die $USAGE;
+if ( $node1 =~ /^(?:node)?(\d+)$/ ) {
+ $node1 = $1;
+}
+else {
+ print "Valid node names are node1, node2, ...\n\n";
+ die $USAGE;
}
-if ($node2 =~ /^(?:node)?(\d+)$/) {
- $node2 = $1;
-} else {
- print "Valid node names are node1, node2, ...\n\n";
- die $USAGE;
+if ( $node2 =~ /^(?:node)?(\d+)$/ ) {
+ $node2 = $1;
+}
+else {
+ print "Valid node names are node1, node2, ...\n\n";
+ die $USAGE;
}
my $slonik = '';
$slonik .= " echo 'Locking down set $set on node $node1';\n";
$slonik .= " lock set (id = $set, origin = $node1);\n";
$slonik .= " sync (id = $node1);\n";
-$slonik .= " wait for event (origin = $node1, confirmed = $node2, wait on = $node2);\n";
+$slonik .=
+ " wait for event (origin = $node1, confirmed = $node2, wait on = $node2);\n";
$slonik .= " echo 'Locked down - moving it';\n";
-$slonik .= " move set (id = $set, old origin = $node1, new origin = $node2);\n";
-$slonik .= " echo 'Replication set $set moved from node $node1 to $node2. Remember to';\n";
-$slonik .= " echo 'update your configuration file, if necessary, to note the new location';\n";
+$slonik .=
+ " move set (id = $set, old origin = $node1, new origin = $node2);\n";
+$slonik .=
+" echo 'Replication set $set moved from node $node1 to $node2. Remember to';\n";
+$slonik .=
+" echo 'update your configuration file, if necessary, to note the new location';\n";
$slonik .= " echo 'for the set.';\n";
-run_slonik_script($slonik, 'MOVE SET');
+run_slonik_script( $slonik, 'MOVE SET' );
#!@@PERL@@
-#
+#
# Author: Mark Stosberg
# Based on work by: Christopher Browne
# Parts Copyright 2006 Summerault, LLC
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: slonik_print_preamble [--config file]
+my $USAGE = "Usage: slonik_print_preamble [--config file]
print the preamble required by all slonik scripts, using the
details from the config file
my $slonik = '';
$slonik .= genheader();
-run_slonik_script($slonik, 'PRINT PREAMBLE');
+run_slonik_script( $slonik, 'PRINT PREAMBLE' );
#!/usr/bin/perl
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$ALL_NODES = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE,
- "all" => \$ALL_NODES);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE,
+ "all" => \$ALL_NODES
+);
-my $USAGE =
-"Usage: restart_node [--config file] [--all] [node# ...]
+my $USAGE = "Usage: restart_node [--config file] [--all] [node# ...]
Restart one or more nodes
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
}
else {
foreach my $node (@ARGV) {
- if ($node =~ /^(?:node)?(\d+)$/) {
- push @nodes, ($1);
- }
- else {
- die $USAGE;
- }
+ if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ push @nodes, ($1);
+ }
+ else {
+ die $USAGE;
+ }
}
}
$slonik .= " restart node $node;\n";
}
-run_slonik_script($slonik, 'RESTART NODE');
+run_slonik_script( $slonik, 'RESTART NODE' );
#!@@PERL@@
-#
+#
# Author: Steve Simms
# Copyright 2005-2009 PostgreSQL Global Development Group
my $SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: store_node [--config file] node#
+my $USAGE = "Usage: store_node [--config file] node#
Generates the slonik commands necessary to add a node to a
cluster. Also displays a report showing the relationships between
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
$node = $ARGV[0];
# Node can be passed either as "node1" or just "1"
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = $1;
-} else {
- die $USAGE;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = $1;
+}
+else {
+ die $USAGE;
}
my $slonik = '';
# STORE NODE
$slonik .= "\n# STORE NODE\n";
-my ($dbname, $dbhost) = ($DBNAME[$node], $HOST[$node]);
-$slonik .= " store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
+my ( $dbname, $dbhost ) = ( $DBNAME[$node], $HOST[$node] );
+$slonik .=
+" store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
$slonik .= " echo 'Set up replication nodes';\n";
# STORE PATH
foreach my $nodea (@NODES) {
my $dsna = $DSN[$nodea];
foreach my $nodeb (@NODES) {
- if ($nodea != $nodeb) {
- next unless ($node == $nodea or $node == $nodeb);
- my $dsnb = $DSN[$nodeb];
- if (!$printed[$nodea][$nodeb]) {
- $slonik .= " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
- $printed[$nodea][$nodeb] = "done";
- }
- if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
- $slonik .= " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
- $printed[$nodeb][$nodea] = "done";
- }
- }
+ if ( $nodea != $nodeb ) {
+ next unless ( $node == $nodea or $node == $nodeb );
+ my $dsnb = $DSN[$nodeb];
+ if ( !$printed[$nodea][$nodeb] ) {
+ $slonik .=
+" store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+ $printed[$nodea][$nodeb] = "done";
+ }
+ if ( !$printed[$nodeb][$nodea] and $providerba == $nodea ) {
+ $slonik .=
+" store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+ $printed[$nodeb][$nodea] = "done";
+ }
+ }
}
}
$slonik .= " echo 'Replication nodes prepared';\n";
$slonik .= " echo 'Please start a slon replication daemon for each node';\n";
-run_slonik_script($slonik, 'STORE NODE');
+run_slonik_script( $slonik, 'STORE NODE' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: subscribe_set [--config file] set# node#
+my $USAGE = "Usage: subscribe_set [--config file] set# node#
Begins replicating a set to the specified node.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($set, $node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = $1;
-} else {
- print "Need to specify node!\n";
- die $USAGE;
+my ( $set, $node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = $1;
+}
+else {
+ print "Need to specify node!\n";
+ die $USAGE;
}
die $USAGE unless $set;
$slonik .= genheader();
$slonik .= " \n";
-if ($DSN[$node]) {
- my $provider = $SET_ORIGIN;
- my $forward;
- if ($PARENT[$node]) {
- $provider = $PARENT[$node];
- }
- if ($NOFORWARD[$node] eq "yes") {
- $forward = "no";
- } else {
- $forward = "yes";
- }
- $slonik .= " subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
-} else {
- die "Node $node not found\n";
+if ( $DSN[$node] ) {
+ my $provider = $SET_ORIGIN;
+ my $forward;
+ if ( $PARENT[$node] ) {
+ $provider = $PARENT[$node];
+ }
+ if ( $NOFORWARD[$node] eq "yes" ) {
+ $forward = "no";
+ }
+ else {
+ $forward = "yes";
+ }
+ $slonik .=
+" subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
+}
+else {
+ die "Node $node not found\n";
}
$slonik .= " echo 'Subscribed nodes to set $set';\n";
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: uninstall_nodes [--config file]
+my $USAGE = "Usage: uninstall_nodes [--config file]
Removes Slony configuration from all nodes in a cluster.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
my $slonik = '';
$slonik .= genheader();
foreach my $node (@NODES) {
- next if $node == $MASTERNODE; # Do this one last
+ next if $node == $MASTERNODE; # Do this one last
$slonik .= " uninstall node (id=$node);\n";
}
$slonik .= " uninstall node (id=$MASTERNODE);\n";
-run_slonik_script($slonik, 'UNINSTALL NODE');
+run_slonik_script( $slonik, 'UNINSTALL NODE' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: unsubscribe_set [--config file] set# node#
+my $USAGE = "Usage: unsubscribe_set [--config file] set# node#
Stops replicating a set on the specified node.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-my ($set, $node) = @ARGV;
-if ($node =~ /^(?:node)?(\d+)$/) {
- $node = $1;
-} else {
- print "Need to specify node!\n\n";
- die $USAGE;
+my ( $set, $node ) = @ARGV;
+if ( $node =~ /^(?:node)?(\d+)$/ ) {
+ $node = $1;
+}
+else {
+ print "Need to specify node!\n\n";
+ die $USAGE;
}
die $USAGE unless $set;
$slonik .= " }\n";
$slonik .= " echo 'unsubscribed node $node from set $set';\n";
-run_slonik_script($slonik, 'UNSUBSCRIBE SET');
+run_slonik_script( $slonik, 'UNSUBSCRIBE SET' );
#!@@PERL@@
-#
+#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
-my $USAGE =
-"Usage: update_nodes [--config file]
+my $USAGE = "Usage: update_nodes [--config file]
Updates the functions on all nodes.
";
if ($SHOW_USAGE) {
- print $USAGE;
- exit 0;
+ print $USAGE;
+ exit 0;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
my $slonik = '';
$slonik .= genheader();
foreach my $node (@NODES) {
- $slonik .= " update functions (id = $node);\n";
-};
+ $slonik .= " update functions (id = $node);\n";
+}
-run_slonik_script($slonik, 'UPDATE FUNCTIONS');
+run_slonik_script( $slonik, 'UPDATE FUNCTIONS' );
$SHOW_USAGE = 0;
# Read command-line options
-GetOptions("config=s" => \$CONFIG_FILE,
- "help" => \$SHOW_USAGE);
+GetOptions(
+ "config=s" => \$CONFIG_FILE,
+ "help" => \$SHOW_USAGE
+);
my $USAGE =
-"Usage: slony_show_configuration [--config file] [node# nodeproperty]
+ "Usage: slony_show_configuration [--config file] [node# nodeproperty]
nodeproperty valid values:
host : return host
";
if ($SHOW_USAGE) {
- die $USAGE;
+ die $USAGE;
}
require '@@PERLSHAREDIR@@/slon-tools.pm';
if ( scalar(@ARGV) == 0 ) {
- print_configurations();
+ print_configurations();
-} elsif ( scalar(@ARGV) == 2 ) {
- $nodenum = $ARGV[0];
+}
+elsif ( scalar(@ARGV) == 2 ) {
+ $nodenum = $ARGV[0];
$nodeproperty = $ARGV[1];
- if ($nodenum =~ /^(?:node)?(\d+)$/) {
- $nodenum = $1;
+ if ( $nodenum =~ /^(?:node)?(\d+)$/ ) {
+ $nodenum = $1;
}
print_property_value();
-} else {
- die $USAGE;
+}
+else {
+ die $USAGE;
}
sub print_configurations {
- print "Slony Configuration\n-------------------------------------\n";
- if ($ENV{"SLONYNODES"}) {
- print "With node configuration from ", $ENV{"SLONYNODES"}, "\n";
- }
- if ($ENV{"SLONYSET"}) {
- print "With set configuration from ", $ENV{"SLONYSET"}, "\n";
- }
- print qq{
+ print "Slony Configuration\n-------------------------------------\n";
+ if ( $ENV{"SLONYNODES"} ) {
+ print "With node configuration from ", $ENV{"SLONYNODES"}, "\n";
+ }
+ if ( $ENV{"SLONYSET"} ) {
+ print "With set configuration from ", $ENV{"SLONYSET"}, "\n";
+ }
+ print qq{
Slony-I Cluster: $CLUSTER_NAME
Logs stored under $LOGDIR
Slony Binaries in: @@SLONBINDIR@@
};
- if ($APACHE_ROTATOR) {
- print "Rotating logs using Apache Rotator: $APACHE_ROTATOR\n";
- }
- print qq{
+ if ($APACHE_ROTATOR) {
+ print "Rotating logs using Apache Rotator: $APACHE_ROTATOR\n";
+ }
+ print qq{
Node information
--------------------------------
};
- for $node (@NODES) {
- printf("Node: %2d Host: %15s User: %8s Port: %4d Forwarding? %4s Parent: %2d Database: %10s\n DSN: %s\n",
- $node, $HOST[$node], $USER[$node], $PORT[$node], $NOFORWARD[$node],
- $PARENT[$node], $DBNAME[$node], $DSN[$node]);
- }
+ for $node (@NODES) {
+ printf(
+"Node: %2d Host: %15s User: %8s Port: %4d Forwarding? %4s Parent: %2d Database: %10s\n DSN: %s\n",
+ $node, $HOST[$node], $USER[$node], $PORT[$node], $NOFORWARD[$node],
+ $PARENT[$node], $DBNAME[$node], $DSN[$node] );
+ }
}
sub print_property_value {
- switch($nodeproperty) {
- # connection configs
- case "host" { print $HOST[$nodenum], "\n"; }
- case "port" { print $PORT[$nodenum], "\n"; }
- case "user" { print $USER[$nodenum], "\n"; }
- case "dbname" { print $DBNAME[$nodenum], "\n"; }
- case "dsn" { print $DSN[$nodenum], "\n"; }
- # replication configs
- case "parent" { print $PARENT[$nodenum], "\n"; }
- case "noforward" { print $NOFORWARD[$nodenum], "\n"; }
- # Misc
- case "cluster" { print $CLUSTER_NAME, "\n"; }
- # config files
- case "node-config-file" { print $CONFIG[$nodenum], "\n"; }
- case "node-config-file-quotemeta" { print quotemeta( $CONFIG[$nodenum] ), "\n"; }
- case "config-file" { print $CONFIG_FILE, "\n"; }
- case "config-file-quotemeta" { print quotemeta( $CONFIG_FILE ), "\n"; }
- else { print $USAGE; }
- }
+ switch ($nodeproperty) {
+
+ # connection configs
+ case "host" { print $HOST[$nodenum], "\n"; }
+ case "port" { print $PORT[$nodenum], "\n"; }
+ case "user" { print $USER[$nodenum], "\n"; }
+ case "dbname" { print $DBNAME[$nodenum], "\n"; }
+ case "dsn" { print $DSN[$nodenum], "\n"; }
+
+ # replication configs
+ case "parent" { print $PARENT[$nodenum], "\n"; }
+ case "noforward" { print $NOFORWARD[$nodenum], "\n"; }
+
+ # Misc
+ case "cluster" { print $CLUSTER_NAME, "\n"; }
+
+ # config files
+ case "node-config-file" { print $CONFIG[$nodenum], "\n"; }
+ case "node-config-file-quotemeta" {
+ print quotemeta( $CONFIG[$nodenum] ), "\n";
+ }
+ case "config-file" { print $CONFIG_FILE, "\n"; }
+ case "config-file-quotemeta" { print quotemeta($CONFIG_FILE), "\n"; }
+ else { print $USAGE; }
+ }
}