Take the following script to get a nice status report.
****************************************************************************
********
#!/usr/atria/bin/perl -w
# Validate pathnames given in arguments
if (@ARGV != 2) {
die "\nUsage: $0 <ccase home dir path> <result file path>\n";
}
if (-d "$ARGV[0]") {
if ($ARGV[0] =~ m"/") {
$clearlicense = "$ARGV[0]/clearlicense";
} elsif ($ARGV[0] =~ m"\\") {
$clearlicense = "$ARGV[0]\\clearlicense";
}
} else {
die "$ARGV[0] does not exist\n";
}
$licinfm = $licinfmdir = "$ARGV[1]";
$tmplicinfm = "$licinfm" . ".tmp";
if ($licinfm =~ m"/") {
$licinfmdir =~ s/[^\/]*$//;
$licinfmdir =~ s/\/$//;
} elsif ($licinfm =~ m"\\") {
$licinfmdir =~ s/[^\\]*$//;
$licinfmdir =~ s/\\$//;
}
if (!-d "$licinfmdir") {
die "$licinfmdir does not exist\n";
}
# Collect needed info from clearlicense
@licdetails = qx($clearlicense);
@hostname = grep(m"License server on host",@licdetails);
@maxdetails = grep(m"Maximum active users allowed:",@licdetails);
@actdetails = grep(m"Current active users:",@licdetails);
@dendetails = grep(m"license requests denied.$",@licdetails);
# Separate out collected info product wise
$hostname = $hostname[0];
$ccmax = $maxdetails[0];
$ccact = $actdetails[0];
$ccden = $dendetails[0];
$msmax = $maxdetails[1];
$msact = $actdetails[1];
$msden = $dendetails[1];
# Split out separated details
@hostname = split(m"\"",$hostname);
@ccmax = split(m": ",$ccmax);
@ccact = split(m": ",$ccact);
@ccden = split(/ /,$ccden);
@msmax = split(m": ",$msmax);
@msact = split(m": ",$msact);
@msden = split(/ /,$msden);
$hostname = $hostname[1];
chop($ccmax = $ccmax[1]);
chop($ccact = $ccact[1]);
$ccden = $ccden[0];
chop($msmax = $msmax[1]);
chop($msact = $msact[1]);
$msden = $msden[0];
# Make values as NA, if clearlicense command returns null
if (!@licdetails) {
$ccmax=$msmax=$ccact=$msact=$ccden=$msden="NA";
}
# Read current result file
if (-f "$licinfm") {
open (LICINFM,"$licinfm");
@licdetails = <LICINFM>;
close (LICINFM);
}
# Read current formatted time
@fmttime = &fmttime;
# Read existing result file and discard items older than two months
## Store current month info from result file
$timefmt = "$fmttime[0]" . "$fmttime[1]";
@licinfm = grep(m"^$timefmt",@licdetails);
$fmttime = "$fmttime[0]" . "$fmttime[1]" ."$fmttime[2]" . "\_$fmttime[3]" ;
$fmttime[1] = $fmttime[1] - 1;
if ($fmttime[1] eq "0") {
$fmttime[1] = $fmttime[1] + 12;
$fmttime[0] = $fmttime[0] - 1;
} elsif (($fmttime[1] < 10) && ($fmttime[1] > 0)) {
$fmttime[1] = "0" . "$fmttime[1]";
}
## Store previous month info from result file
$timefmt = "$fmttime[0]" . "$fmttime[1]";
@last_month = grep(m"^$timefmt",@licdetails);
## Mingle both current and previous month info
push(@licinfm , @last_month);
# Store header and last two months license info into a temp result file
chop(@licinfm);
open (LICENSE_INFO,">$tmplicinfm");
print LICENSE_INFO
"-----------------------------------------------------------------------\n";
print LICENSE_INFO "\tClearCase/MultiSite license statistics of
\U$hostname\E\n";
print LICENSE_INFO
"-----------------------------------------------------------------------\n";
print LICENSE_INFO "NA: Means ClearCase/MultiSite is either not up or not
available\n\n";
foreach $line (@licinfm) {
print LICENSE_INFO "$line\n";
}
close (LICENSE_INFO);
# Save current page formats into temp variables
$saveformat = $~ ;
$savelines = $= ;
# Write current license info into temp result file
open (LICENSE_INFO,">>$tmplicinfm");
select ("LICENSE_INFO");
$ccms = "CC/MS";
$max = "max:$ccmax/$msmax";
$active = "active:$ccact/$msact";
$denied = "denied:$ccden/$msden";
$~ = "LICENSEINFO" ;
$= = 1000;
write;
close(LICENSE_INFO);
# Restore saved page formats
$~ = $saveformat ;
$= = $savelines ;
# Move temp result file to original
rename("$tmplicinfm", "$licinfm");
# Display formatter
format LICENSEINFO =
@<<<<<<<<<<<<<< @<<<<< @<<<<<<<<<<< @<<<<<<<<<<< @<<<<<<<<<<<<<<<<<
$fmttime, $ccms, $max, $active, $denied
.
# Find & Format current time
sub fmttime {
my ($time, $day, $month, $date, $time, $year, $retval);
my (%monthconv);
$time = localtime(time);
($day, $month, $date, $time, $year) = split(m"[ |\t]+", $time);
$time =~ s/:\d\d$//g;
$time =~ s/://g;
$date =~ s/^([0-9])$/0$1/;
%monthconv = ("Jan", "01", "Feb", "02", "Mar", "03", "Apr", "04", "May",
"05", "Jun", "06", "Jul", "07", "Aug", "08", "Sep", "09", "Oct", "10",
"Nov", "11", "Dec", "12");
@retval = ("$year" , "$monthconv{$month}" , "$date" , "$time");
return(@retval);
}
****************************************************************************
********
-----Original Message-----
From: owner-cciug@rational.com [mailto:owner-cciug@rational.comOn
Behalf Of ponnambalam.ma@polaris.co.in
Sent: Friday, July 27, 2001 11:18 AM
To: cciug@rational.com; langston.reek@grassvalleygroup.com
Cc: Rick.Lindal@Level3.com
Subject: [cciug] list of active users alone - clearlicense -
Dear All,
Good afternoon,
I am in need of all active user's name from the clearlicense. Can
u please help me to get the list of active users and their priority &
timeout & time in . Please help me
Attention : PERL Experts
- can u give me the regular expression for that.
Sorry for the inconvenience.
Expecting your Wishes,
Pons.
Extn: 1328
----------------------------------------------------------------------------
----Learn to Grow ------> Grow to Learn more & more. ---------------------------------------------------------------------------- ----
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This archive was generated by hypermail 2b29 : Tue Jul 31 2001 - 22:04:03 EDT