02-20-2008 11:07 PM
Greetings,
I have written a script to check the state of Ironport cluster nodes which some of you may find useful.
To use it you must define your cluster name, group(s) and machines associated with those groups.
$cluster_name = "ClusterName";
%group_machine = (Group1 => ['machine1.example.net','machine2.example.net'],
Group2 => ['machine3.example.net','machine4.example.net']);
Cluster ClusterName
=================
Group Group1:
Machine machine1.example.net (Serial #: 123456789-ABCDEF)
Machine machine2.example.net (Serial #: 123456789-ABCDEF)
Group Group2:
Machine machine3.example.net (Serial #: 123456789-ABCDEF)
Machine machine4.example.net (Serial #: 123456789-ABCDEF)
$ ./check_ironport_cluster.pl machine1.example.net
OK: Machines: [4/4]
Connection Issue: $error_message
Establishing Connection: $error_message
Disconnected: $error_message
CRITICAL: 0/4 machines operational
#!/usr/bin/perl
# Ironport Centralised Management Check Script
# Simon Howard
# DMZGlobal
# 19 Feb 2008
# check command-line args
if ($ARGV[0] eq "") {
print "usage: ./check_ironport_cluster.pl hostname";
exit 1;
}
# initialise check variables
$cl_check = 0; $ma_check = 0;
# define our cluster
$cluster_name = "DMZGlobal";
%group_machine = (Main_Group => ['mail1.example.net','mail2.example.net'],
Other_Group => ['mail4.example.net','mail5.example.net']);
# count number of elements in each group and number of groups
foreach $family ( keys %group_machine ) {
foreach $i ( 0 .. $#{ $group_machine{$family} } ) {
$ma_value++;
}
}
# ssh onto the Ironport and grab the cluster connection status
$hostname = $ARGV[0];
$status = `ssh $hostname \'clustermode cluster ; clusterconfig connstatus\'`;
@details = split /\n/,$status;
# check the status of the groups and machines
foreach (@details) {
if ($_ =~ /^Cluster $cluster_name$/) {
$cl_check = 1;
}
if ($_ =~ /Group (.*):/) {
$current_group = "$1";
$x = 0;
}
# ensure we are dealing with the right machines
if ($group_machine{$current_group}[$x] ne "") {
if ($_ =~ /Machine $group_machine{$current_group}[$x]/) {
# looks like somethings wrong, report accordingly
if ($_ =~ /waiting for remote/) {
print "Connection Issue: $_";
} elsif ($_ =~ /connecting/) {
print "Establishing Connection: $_";
} elsif ($_ =~ /disconnected/) {
print "Disconnected: $_";
} else {
$ma_check++;
}
$x++;
}
}
}
# Exit out if the cluster isn't even defined
if ($cl_check != 1) {
print "CRITICAL: Cluster $cluster_name not defined\n";
exit 1;
}
# Complain if machines within the cluster aren't operational
if ($ma_value != $ma_check) {
print "CRITICAL: $ma_check/$ma_value machines operational\n";
exit 1;
}
print "OK: Machines: [$ma_check/$ma_value]\n";
exit 0;
05-21-2008 09:08 PM
Greetings,
I have written a script to check the state of Ironport cluster nodes which some of you may find useful.
To use it you must define your cluster name, group(s) and machines associated with those groups.
$cluster_name = "ClusterName";
%group_machine = (Group1 => ['machine1.example.net','machine2.example.net'],
Group2 => ['machine3.example.net','machine4.example.net']);
The script works by parsing the output of clustermode cluster ; clusterconfig connstatus
Cluster ClusterName
=================
Group Group1:
Machine machine1.example.net (Serial #: 123456789-ABCDEF)
Machine machine2.example.net (Serial #: 123456789-ABCDEF)
Group Group2:
Machine machine3.example.net (Serial #: 123456789-ABCDEF)
Machine machine4.example.net (Serial #: 123456789-ABCDEF)
Once you have defined your cluster, run the script against any host within your cluster.
$ ./check_ironport_cluster.pl machine1.example.net
You will hopefully see an OK message returned
OK: Machines: [4/4]
If something is broken with your cluster, you will see one of the following error messages followed by a CRITICAL error message:
Connection Issue: $error_message
Establishing Connection: $error_message
Disconnected: $error_message
CRITICAL: 0/4 machines operational
Enjoy! :twisted:
#!/usr/bin/perl
# Ironport Centralised Management Check Script
# Simon Howard
# DMZGlobal
# 19 Feb 2008
# check command-line args
if ($ARGV[0] eq "") {
print "usage: ./check_ironport_cluster.pl hostname";
exit 1;
}
# initialise check variables
$cl_check = 0; $ma_check = 0;
# define our cluster
$cluster_name = "DMZGlobal";
%group_machine = (Main_Group => ['mail1.example.net','mail2.example.net'],
Other_Group => ['mail4.example.net','mail5.example.net']);
# count number of elements in each group and number of groups
foreach $family ( keys %group_machine ) {
foreach $i ( 0 .. $#{ $group_machine{$family} } ) {
$ma_value++;
}
}
# ssh onto the Ironport and grab the cluster connection status
$hostname = $ARGV[0];
$status = `ssh $hostname \'clustermode cluster ; clusterconfig connstatus\'`;
@details = split /\n/,$status;
# check the status of the groups and machines
foreach (@details) {
if ($_ =~ /^Cluster $cluster_name$/) {
$cl_check = 1;
}
if ($_ =~ /Group (.*):/) {
$current_group = "$1";
$x = 0;
}
# ensure we are dealing with the right machines
if ($group_machine{$current_group}[$x] ne "") {
if ($_ =~ /Machine $group_machine{$current_group}[$x]/) {
# looks like somethings wrong, report accordingly
if ($_ =~ /waiting for remote/) {
print "Connection Issue: $_";
} elsif ($_ =~ /connecting/) {
print "Establishing Connection: $_";
} elsif ($_ =~ /disconnected/) {
print "Disconnected: $_";
} else {
$ma_check++;
}
$x++;
}
}
}
# Exit out if the cluster isn't even defined
if ($cl_check != 1) {
print "CRITICAL: Cluster $cluster_name not defined\n";
exit 1;
}
# Complain if machines within the cluster aren't operational
if ($ma_value != $ma_check) {
print "CRITICAL: $ma_check/$ma_value machines operational\n";
exit 1;
}
print "OK: Machines: [$ma_check/$ma_value]\n";
exit 0;
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide