Custom Script: VCS configuration checker
Created: 17 Aug 2011 | Updated: 06 Sep 2011
The following Perl script checks the configuraion of a VCS cluster against a set of default values defined in the script. Feel free to modify this script to suit your particular needs.
Best Regards,
-Seann
#!/usr/bin/perl
#
# chkvcs
# Written by Seann Herdejurgen
#
# This script checks for inconsistencies in a VCS configuration.
# Edit the default values for your environment in the %attributes hash.
#
use Sys::Hostname;
use strict;
if ( ! -d "/opt/VRTSvcs/bin" ) {
print STDERR "VCS is not installed on this system\n";
exit 1;
}
my (%config);
my %attributes=(
haclus=>{
ClusterOwner=>'vcsalerts@symantec.com',
HacliUserLevel=>'COMMANDROOT',
ReadOnly=>1,
UseFence=>'SCSI3',
},
hasys=>{
Capacity=>500,
EngineRestarted=>0,
Frozen=>0,
LicenseType=>'PERMANENT',
TFrozen=>0,
},
hagrp=>{
AutoDisabled=>0,
AutoStart=>1,
Enabled=>1,
FaultPropagation=>1,
PreOnline=>1,
Probed=>1,
TriggerResFault=>1,
TriggerResStateChange=>1,
},
hares=>{
CFSMount=>{
Critical=>0,
},
CFSMount=>{
MountOpt=>'rw|rw,nomtime',
},
CVMCluster=>{
CVMTransport=>'gab',
CVMTimeout=>200,
},
CVMVolDg=>{
Critical=>0,
CVMActivation=>'sw',
},
CVMVxConfigd=>{
Critical=>0,
CVMVxconfigdArgs=>'syslog',
},
DiskGroup=>{
PanicSystemOnDGLoss=>0,
StartVolumes=>0,
StopVolumes=>1,
},
Db2udb=>{
AgentDebug=>0,
Critical=>1,
UseDB2start=>1,
},
IP=>{
ArpDelay=>1,
IfconfigTwice=>0,
},
Mount=>{
FSType=>'vxfs',
FsckOpt=>'-y',
},
Netlsnr=>{
AgentDebug=>0,
Critical=>1,
Home=>'/u01/app/oracle/product/10.2.0.4/db_1|/u01/app/oracle/product/11.1.0.7/db_1|/u01/app/oracle/product/11.2.0.2/db_1',
LsnrPwd=>'',
Owner=>'oracle',
},
Oracle=>{
AgentDebug=>0,
Critical=>1,
Home=>'/u01/app/oracle/product/10.2.0.4/db_1|/u01/app/oracle/product/11.1.0.7/db_1|/u01/app/oracle/product/11.2.0.2/db_1',
Owner=>'oracle',
},
Volume=>{
Critical=>1,
},
WebLogic=>{
ResLogLevel=>'INFO',
SecondLevelMonitor=>0,
},
WebSphere=>{
ResLogLevel=>'INFO',
SecondLevelMonitor=>0,
ServerType=>'DeploymentManager|NodeAgent|ApplicationServer',
},
WebSphereMQ6=>{
Critical=>1,
CommandServer=>1,
MonitorListener=>1,
MQUser=>'mqm',
MQVer=>'7.0',
ResLogLevel=>'INFO',
SecondLevelMonitor=>3,
},
},
hatype=>{
Application=>{
RestartLimit=>1,
},
CFSMount=>{
FaultOnMonitorTimeouts=>5,
MonitorInterval=>180,
NumThreads=>10,
},
CVMCluster=>{
OnlineRetryLimit=>5,
},
CVMVolDg=>{
FaultOnMonitorTimeouts=>5,
MonitorInterval=>180,
NumThreads=>1,
RestartLimit=>1,
},
CVMVxconfigd=>{
FaultOnMonitorTimeouts=>5,
MonitorInterval=>180,
},
DiskGroup=>{
NumThreads=>1,
},
Mount=>{
NumThreads=>10,
},
Netlsnr=>{
RestartLimit=>1,
},
Volume=>{
NumThreads=>1,
},
WebLogic=>{
AgentFile=>'/opt/VRTSvcs/bin/Script50Agent',
MonitorInterval=>90,
MonitorTimeout=>60,
OfflineTimeout=>300,
OnlineTimeout=>900,
RestartLimit=>1,
ToleranceLimit=>0,
},
WebSphere=>{
AgentFile=>'/opt/VRTSvcs/bin/Script50Agent',
MonitorInterval=>90,
MonitorTimeout=>60,
OfflineTimeout=>300,
OnlineTimeout=>900,
OnlineWaitLimit=>2,
RestartLimit=>1,
ToleranceLimit=>0,
},
WebSphereMQ6=>{
AgentFile=>'/opt/VRTSvcs/bin/Script50Agent',
MonitorInterval=>180,
RestartLimit=>1,
},
},
);
# Get VCS configuration
for my $command (keys %attributes) {
my $fields=0;
foreach my $line (split /\n/,`/opt/VRTSvcs/bin/$command -display`) {
next if ($line =~ /^#$/);
if ($line =~ /^#/) { $fields=split /\s+/,$line; next; }
my (@fields)=split /\s+/,$line,$fields;
my $value=pop @fields;
my $key=pop @fields;
my $href=\%config;
foreach my $field ($command,@fields) {
$href->{$field}||={};
$href=$href->{$field};
}
$href->{$key}=$value;
}
}
my $host=hostname;
my $nodes=keys %{$config{hasys}};
# Check cluster attributes
foreach my $attr (keys %{$attributes{haclus}}) {
next if ( $nodes eq 1 && $attr eq 'UseFence' );
next if ( $config{haclus}{$attr} eq $attributes{haclus}{$attr} );
print "Cluster attribute $attr is $config{haclus}{$attr} (expected $attributes{haclus}{$attr})\n";
}
# Check system attributes
foreach my $attr (keys %{$attributes{hasys}}) {
next if ( $config{hasys}{$host}{$attr} eq $attributes{hasys}{$attr} );
print "System attribute $attr is $config{hasys}{$host}{$attr} (expected $attributes{hasys}{$attr})\n";
}
# Check group attributes
foreach my $group (keys %{$config{hagrp}}) {
foreach my $attr (keys %{$attributes{hagrp}}) {
if (exists $config{hagrp}{$group}{State}{$host}) {
my $value=$config{hagrp}{$group}{$attr}{$host};
$value=$config{hagrp}{$group}{$attr}{global} if ($value eq '');
next if ( $value eq $attributes{hagrp}{$attr} );
print "$group group attribute $attr is $value (expected $attributes{hagrp}{$attr})\n";
}
}
}
# Check resource attributes
foreach my $res (keys %{$config{hares}}) {
my $type=$config{hares}{$res}{Type}{global};
foreach my $attr (keys %{$attributes{hares}{$type}}) {
my $value=$config{hares}{$res}{$attr}{$host};
$value=$config{hares}{$res}{$attr}{global} if ($value eq '');
next if ( $value =~ /$attributes{hares}{$type}{$attr}/ );
print "$res resource attribute $attr is $value (expected $attributes{hares}{$type}{$attr})\n";
}
}
# Check type attributes
foreach my $type (keys %{$config{hatype}}) {
foreach my $attr (keys %{$attributes{hatype}{$type}}) {
next if ( $config{hatype}{$type}{$attr} eq $attributes{hatype}{$type}{$attr});
print "$type type attribute $attr is $config{hatype}{$type}{$attr} (expected $attributes{hatype}{$type}{$attr})\n";
}
}
exit; Download Filed Under: