[Pacemaker] small Script for comparing two cluster nodes

Koch, Sebastian Sebastian.Koch at netzwerk.de
Thu Jun 24 08:29:11 EDT 2010


Hi,

i wrote a small script that compares the output of a supplied command on two clusternodes. I used it for comparing packagelists, configs and so on. Mybe some of you find it userful. It's quick and dirty and there is no error handling, so please don't blame me ;-)

Use it like this: ./clustercompare "cat /etc/hosts"

-----------------------------------------------------------------------------------------------------------------
#!/bin/sh
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Written by: Sebastian Koch, sebastian.koch at netzwerk.de
# Use this script to compare to cluster nodes which should be identical
# by passing a command as argument and running it on the remote node.
# The command will always be executed on the remote node, the script
# tries to examine the current by hostname.
#
# IMPORTANT:    You need to set the ip's of the nodes. The Nodes must have
#               hostname like foo-node1 and bar-node2. If not change it below
#               in the if condition to fit your naming conventions.
#
# Example: ./clustercompare.sh "dpkg -l"
#
# If there is no output, the diff found no differnces
# @param: $1    -       command that should be executed on the Remote Node
#
# This is just a quick and dirty little helper so please don't blame me ;-)
#
USER=root
COMMAND=$1;
NODE1=10.1.1.10;
NODE2=10.1.1.11;
THISHOST=`uname -n`;
if [[ $THISHOST =~ 'node2' ]]; then
        LOCAL=$NODE2;
        REMOTE=$NODE1;
else
        LOCAL=$NODE1;
        REMOTE=$NODE2;
fi
echo "LOCAL $LOCAL REMOTE $REMOTE"
$COMMAND > /tmp/"$LOCAL"_compare && ssh "$USER"@"$REMOTE" $COMMAND > /tmp/"$REMOTE"_compare && diff /tmp/"$LOCAL"_compare /tmp/"$REMOTE"_compare
echo "I executed the command: $COMMAND on $NODE and $NODE2 with $USER, if you saw nothing than the output of the command was identical. Bye ...";
-----------------------------------------------------------------------------------------------------------------

Sebastian Koch
                                                        


More information about the Pacemaker mailing list