Hi lnickt,
I am getting the error here:
E:\Temp\inyrohs>perl outage_nodes_updated.pl on
Can't locate Path/Tiny.pm in @INC (@INC contains: E:/apps/Perl64/site/lib E:/apps/Perl64/lib .) at outage_nodes_updated.pl line 8.
BEGIN failed--compilation aborted at outage_nodes_updated.pl line 8.
#!C:\Perl\bin\perl.exe
use Win32;
use IO::Handle;
use File::Find;
use strict;
use warnings;
use File::Copy qw(copy);
use Path::Tiny qw/ path /;
use feature qw/ say /;
######################################################################
+##############
#This script is created to put the servers in unplanned outage as part
+ of the tasks#
#that are received to stop the monitoring on the servers
#due to some maintenance activity on the servers.
#
#
#
require "E:/Temp/inyrohs/omwNodeDetails.pm";
#expect values 'on|off'
my ($SEC,$MIN,$HOUR, $DAY, $MON, $YEAR)= (localtime) [0..6];
my $year=$YEAR+1900;
my $month=$MON+1;
my $day=$DAY;
my $date="$year\_$month\_$day";
my $LOG="E:/Temp/inyrohs/maintenanceMode_$date.log";
my $serverlist="E:/Temp/INYROHS/serverlist.txt";
open( MYFILE, "E:/Temp/INYROHS/serverlist.txt") or die "Can't open '$
+serverlist': $!";
my @outagenodes=path($MYFILE)->lines({chomp => 1});
#chomp(@outagenodes);
#print "@outagenodes\n";
my $maintMode=$ARGV[0];
chomp($maintMode);
open (LOG,">> $LOG") or die "Can't open $LOG file: $!\n";
printf LOG ("\nTime is %02d:%02d:%02d.\nStarting the maintenance mode
+process to turn $maintMode outages.\n\n", $HOUR, $MIN, $SEC);
#print "$date \n";
#print "starting the process \n";
#print "maintMode: $maintMode:\n";
while (<$MYFILE>){
s/\s+$//;
s/^\s+//;
next if /^$/;
if($maintMode =~ m/on/)
{
foreach my $NODES (@outagenodes)
{
my @parts=split /\./, $NODES;
my $hostname=$parts[0];
chomp($hostname);
my $fqdn = getNodeAttributes($hostname,"PrimaryNodeName");
print "$hostname\n";
#printLog("Node: $NODES, processing...\n");
#print "entered loop \n";
my $cmd="ovownodeutil.cmd -outage_node -unplanned -disable_
+heartbeat -delete_msgs -node_name $fqdn -$maintMode ";
print "$cmd\n";
`$cmd`;
print "done with command\n";
}
}
elsif($maintMode=~ m/off/)
{
foreach my $NODES (@outagenodes)
{
my @parts=split /\./, $NODES;
my $hostname=$parts[0];
chomp($hostname);
my $fqdn = getNodeAttributes($hostname,"PrimaryNodeName");
print "$hostname\n";
printLog("Node: $NODES, processing...\n");
printLog("Bringing the server $NODES out of outage.\n");
my $cmd="ovownodeutil.cmd -outage_node -unplanned -disable_
+heartbeat -delete_msgs -node_name $fqdn -$maintMode";
my $cmdresopcmona="ovdeploy -cmd \"ovc -restart opcmona\" -
+host $fqdn";
my $cmdresopcle="ovdeploy -cmd \"ovc -restart opcle\" -host
+ $fqdn";
print "$cmd\n";
`$cmd`;
print "$cmdresopcmona\n";
`$cmdresopcmona`;
print "$cmdresopcle\n";
`$cmdresopcle`;
}
}
}
my @append=();
path($file)->append(@append, {truncate =>1});
say "Done.";
sub printLog
{
my ($logLine) = @_;
chomp($logLine);
$logLine=$logLine . "\n";
print "$logLine"; print LOG "$logLine";
}
|