# # CC_GRAPH_LIC.pl # # Track and graphically display ClearCase license usage for a day # or series of days. # # Could be started as continuous "cron" (UNIX) or "at" job (Windows). # # REQUIRED: Required GIFs etc. are located here (self extracting exe): # http://www.abs-consulting.com/ftp/SCRIPTS/CC_GRAPH_LIC.exe (100k) # # # A detailed readme is located at: # http://www.abs-consulting.com/ftp/SCRIPTS/CC_GRAPH_LIC.readme.html # # ASSUMED: Must run on a machine that has access to ClearCase licenses server. # # Author: Charles W. Clarke III (ABS) # email: charles@abs-consulting.com # URL: http://www.abs-consulting.com # Date: Sept. 10, 2000 ############################################################ # History: 09/10/00 : Created for A Better Solution, Inc. # : 09/12/01 : Updated for general use # : 10/26/01 : Changed till-end-of-day to till_end_of_day # : - thanx Karl Ellison # : 11/05/01 : Changed typo in die statement # : - thanx Bill Robinson # : 01/25/02 : Initialize _history file # : - thanx Todd Minear # : 03/14/02 : Added usernames to display. # : 06/14/02 : Removed stray printf. ############################################################ ########################################## # Site data: # # You can change this data within limits # ########################################## $CLOSE_OUT_AFTER = "23.5"; # Period that signals to perform closout functions # This means run till 11:50pm then stop $UPDATE_MINUTES = 3; # From 1 to 3 - never more than 3 or you will have # to rewrite end of day code $DAYS_TO_KEEP = 120; # Must be divisible by 5 # This is for the "range" graph data only # - All daily graphs are saved until you remove # but their data is "tossed' daily #################################### ######## Data Initializaton ######## #################################### @hour_text = ( '12', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ); $self = $parent_dir = $0; $UPDATE_SECONDS = $UPDATE_MINUTES * 60; $END_OF_DAY_PAUSE = 600 + ($UPDATE_SECONDS * 2); $DENIED_GRAPH_HEIGHT = 30; ############################################################################# # There are functions that perform dirname and basename in "real" Perl, but # # this was designed to also work with ccperl distributed with ClearCase. # ############################################################################# $char = chop($parent_dir); while (($char !~ /[\\\/]/) && ($char ne "")) { $char = chop($parent_dir); } $parent_dir = ($char eq "") ? "." : $parent_dir.$char; $self .= "/"; @me = split (/[\\\/]/, $self); $self = $me[$#me]; ########################################## # Warning placed in generated html files # ########################################## $STAMP = " \n"; $STAMP .= " \n"; ######################## ######## MAIN ########---------------------------------------------------------------- ######################## chdir ($parent_dir); # Its all relative - Eienstien ?? if (! -e "data") { mkdir ("data", 0777) or die "Can't create data directory \n$!\n"; } if (! -e "web_results") { mkdir ("web_results", 0777) or die "Can't create web_results directory \n$!\n"; } $running = 1; while ($running) { ####################### # Initialze some data # ####################### %HASHED_DATA = (); @BUFF = (); ($seconds, $minutes, $hours, $day_of_month, $month, $year, $week_day, $day_of_year, $junk) = localtime (time); $month += 1; $month = ($month < 10) ? "0"."$month" : $month; $day_of_month = ($day_of_month < 10) ? "0"."$day_of_month" : $day_of_month; $year += 1900; $date = "$year"."_"."$month"."_"."$day_of_month"; $printed_date = "$month/$day_of_month/$year"; $key_minutes = int ($minutes / 10); $current_key = ($hours < 10) ? "0$hours.$key_minutes" : "$hours.$key_minutes"; $printed_hour = "$hour_text[$hours]:"; $printed_hour = ($minutes < 10) ? "$printed_hour"."0$minutes" : "$printed_hour"."$minutes"; $printed_time = ($hours < 12) ? "$printed_hour"."am" : "$printed_hour"."pm" ; $OS = "$ENV{'OS'}"; if ($OS =~ /[Ww]indows/) { $_main_html = "display_license_data.html"; $_run_duration = "run_duration.txt"; $_html_file = "web_results\\-$date.html"; $_history_html_file = "web_results\\_history.html"; $_blank_html_file = "web_results\\_blank.html"; $_selection_html_file = "web_results\\_selection.html"; $_today_html_file = "web_results\\_today.html"; $_yesterday_html_file = "web_results\\_yesterday.html"; $_today_data = "data\\_today_data.txt"; $_historical_data = "data\\_historical_data.txt"; $TRASH_CAN = "NUL"; } else { $_main_html = "display_license_data.html"; $_run_duration = "run_duration.txt"; $_html_file = "web_results/-$date.html"; $_history_html_file = "web_results/_history.html"; $_blank_html_file = "web_results/_blank.html"; $_selection_html_file = "web_results/_selection.html"; $_today_html_file = "web_results/_today.html"; $_yesterday_html_file = "web_results/_yesterday.html"; $_today_data = "data/_today_data.txt"; $_historical_data = "data/_historical_data.txt"; $TRASH_CAN = "/dev/null"; } $MAX_USED_TODAY = 0; $MAX_LIC_FOR_GRAPH = 0; $LAST_MAX_LIC_GRAPH = 0; $MAX_LIC = 0; $MAX_LIC_DENIED = 0; $LIC_DENIED = 0; $LAST_MAX = 0; $LIC_IN_USE = 0; $OK_TO_BUILD = 0; $IS_CURRENT = 0; $PAST_CURRENT = 0; $USER = ""; $USER_LIST = ""; $USER_LIST_TODAY = ""; %UNIQUE_USERS_TODAY = (); @_USER_LIST_TODAY = (); $SORTED_UNIQUE_USERS_TODAY = ""; ################################# # Create history file if needed # ################################# if (! -e $_historical_data) { open (HISTORY_CREATE, ">>$_historical_data") or die "Can't create file ($_historical_data)\n$!\n"; close (HISTORY_CREATE); } ###################################################################### # Get ClearCase license usage at this moment and store in today_data # # Store data with key for time period. # ###################################################################### open CLEARLICENSE, "clearlicense -product ClearCase 2>$TRASH_CAN |" or die "Can't execute (clearlicense) \n$!\n"; while () { $data_line = $_; if ($data_line =~ /Maximum active users allowed: (\d+)/) { $max_cc_licenses = $1; } elsif ($data_line =~ /Current active users: (\d+)/) { $cc_licenses_used = $1; } elsif ($data_line =~ /(\d+) license requests denied/) { $cc_licenses_denied = $1; } elsif ($data_line =~ /(\d+) active users bumped/) { $cc_licenses_bumped = $1; } elsif ($data_line =~ /minutes \(at /) { ($JUNK, $cc_user, $JUNK) = split (/\s+/, $data_line); $cc_user_list ="$cc_user,$cc_user_list"; } } close CLEARLICENSE; if ($cc_licenses_used == 1) { $cc_user_list = $cc_user; } $cc_overage_data = $cc_licenses_denied + $cc_licenses_bumped ; ############################# # Append to today data file # ############################# open (_TODAY_DATA, ">>$_today_data") or die "Can't open file ($_today_data)\n$!\n"; printf _TODAY_DATA "\n$current_key $max_cc_licenses $cc_licenses_used $cc_overage_data $cc_user_list"; close (_TODAY_DATA); ########################## # Build _today.html file #--------------------------------------------------------------------- ########################## ######################################## # Read the current data file for today # # and store in the expected html file. # ######################################## open (_TODAY_DATA, $_today_data) or die "Can't open file ($_today_data)\n$!\n"; @BUFF = <_TODAY_DATA>; close (_TODAY_DATA); $OK_TO_BUILD = ($#BUFF != -1) ? 1:0; foreach $_data (@BUFF) { %UNIQUE_USERS = (); @_USER_LIST = (); $cc_user_list = ""; $SORTED_UNIQUE_USERS = ""; chomp($_data); ($TIME_KEY, $MAX_LIC, $LIC_IN_USE, $LIC_DENIED, $USER_LIST) = split (/ /, $_data); @USERS = split (/\,/, $USER_LIST); foreach $USER (@USERS) { if (! exists ($UNIQUE_USERS{$USER})) { $UNIQUE_USERS{$USER} = "using..."; push (@_USER_LIST, $USER); } if (! exists ($UNIQUE_USERS_TODAY{$USER})) { $UNIQUE_USERS_TODAY{$USER} = "using..."; push (@_USER_LIST_TODAY, $USER); } } $LAST_MAX_LIC_GRAPH = $MAX_LIC; # Last read is used to initailze tomorrow if ( $MAX_LIC > $MAX_LIC_FOR_GRAPH ) { $MAX_LIC_FOR_GRAPH = $MAX_LIC; } # Upper bounds for graph if ( $LIC_DENIED > $MAX_LIC_DENIED ) { $MAX_LIC_DENIED = $LIC_DENIED; } # upper bounds for excess graph $MAX_USED_TODAY = ($LIC_IN_USE > $MAX_USED_TODAY) ? $LIC_IN_USE : $MAX_USED_TODAY; if (exists ($HASHED_DATA{$TIME_KEY})) { ########################################## # take the greater of any duplicate data # # and store just one key. # ########################################## ($ML, $LIU, $LD, $UL) = split (/ /, $HASHED_DATA{$TIME_KEY}); $MAX_LIC = ($MAX_LIC > $ML) ? $MAX_LIC : $ML ; $LIC_IN_USE = ($LIC_IN_USE > $LIU) ? $LIC_IN_USE : $LIU ; $LIC_DENIED = ($LIC_DENIED > $LIU) ? $LIC_DENIED : $LD ; @USERS = split (/\,/, $UL); foreach $USER (@USERS) { if (! exists ($UNIQUE_USERS{$USER})) { $UNIQUE_USERS{$USER} = "using..."; push (@_USER_LIST, $USER); } } } $SORTED_UNIQUE_USERS=""; foreach $USER (sort (@_USER_LIST)) { $SORTED_UNIQUE_USERS = "$USER,$SORTED_UNIQUE_USERS"; } if ( "$SORTED_UNIQUE_USERS" ne "" ) { chop ($SORTED_UNIQUE_USERS); } $HASHED_DATA{$TIME_KEY} = "$MAX_LIC $LIC_IN_USE $LIC_DENIED $SORTED_UNIQUE_USERS"; } foreach $USER (sort (@_USER_LIST_TODAY)) { $SORTED_UNIQUE_USERS_TODAY = "$USER,$SORTED_UNIQUE_USERS_TODAY"; } if ( "$SORTED_UNIQUE_USERS_TODAY" ne "" ) { chop ($SORTED_UNIQUE_USERS_TODAY); } $LAST_MAX = $MAX_LIC; # incase a piece of data is missing then blend the graph ################################################################ # Open the html file to write to and select it for all printfs # ################################################################ open (_TFILE, ">$_html_file") or open (_TFILE, ">>$_html_file") or die "Can't open file ($_html_file)\n$!\n"; select(_TFILE); printf (" \n"); printf (" \n"); printf ($STAMP); $BLOCK = <<' BLOCK_1';
BLOCK_1 printf ($BLOCK); ########################################################################### # It is critical to keep the next two lines exactly as it is because some # # insertion code depends on it later. (code reference #1) # ########################################################################### printf ("

\n"); printf ("ClearCase License usage for $printed_date @ $printed_time :

\n"); if ($OK_TO_BUILD == 0) { printf ("At the time that this web-page was built there was no data to read in ($_today_data)!\n"); } else { ############################ # Build the Header portion # ############################ printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); ########################### # Build the Graph portion # ########################### for ($I = 0; ($I < 24); $I++) { for ($J = 0; ($J < 6); $J++) { if ($I == 0) { $time_text = "12:$J"."0 am"; } elsif ($I < 12) { $time_text = "$I:$J"."0 am"; } else { $i = $I - 12; $time_text = "$i:$J"."0 pm"; } $TIME_KEY = ($I < 10) ? "0$I.$J":"$I.$J"; if (exists ($HASHED_DATA{$TIME_KEY})) { ###################################### # Read the data and assign variables # ###################################### $DATA_READ = 1; ($MAX_LIC, $LIC_IN_USE, $IGNORE, $USER_LIST) = split (/ /, $HASHED_DATA{$TIME_KEY}); $LAST_MAX = $MAX_LIC; } else { ######################################## # Extend the previous data for display # ######################################## $DATA_READ = 0; $MAX_LIC = $LAST_MAX; $LIC_IN_USE = 0; } if ($LIC_IN_USE == 0) { $USER_TEXT = ""; } elsif ("$USER_LIST" eq "") { $USER_TEXT = "by undetermined user(s)"; } else { $USER_TEXT = "by user(s): $USER_LIST"; } ######################################### # Display the data - write to html file # ######################################### if ($MAX_LIC == $MAX_LIC_FOR_GRAPH) { $display_extra = 0; $display_bar = (($LIC_IN_USE == 0) || ($DATA_READ == 0)) ? 0:1; $display_space = ($LIC_IN_USE == $MAX_LIC) ? 0:1; if ($display_bar == 1) { $bar_height= int(($LIC_IN_USE / $MAX_LIC_FOR_GRAPH) * 100); } else { $bar_height= 0; } if ($display_space == 1) { $space_height = 100 - $bar_height; } } else { $display_extra = 1; $display_bar = (($LIC_IN_USE == 0) || ($DATA_READ == 0)) ? 0:1; $display_space = (($LIC_IN_USE != $MAX_LIC) || ($DATA_READ == 0)) ? 1:0; $extra_height = int ((($MAX_LIC_FOR_GRAPH - $MAX_LIC) / $MAX_LIC_FOR_GRAPH) * 100); if ($DATA_READ) { $bar_height= int ((($LIC_IN_USE) / $MAX_LIC_FOR_GRAPH) * 100); } else { $bar_height= 0; } $space_height = 100 - $extra_height - $bar_height; $LIC_LOST = $MAX_LIC_FOR_GRAPH - $MAX_LIC ; } $AVAIL_LIC = $MAX_LIC - $LIC_IN_USE ; $GUESS = (DATA_READ) ? "" : "(Warning: -Guess- no data actually stored or read)" ; printf (" \n"); } # for $J printf (" \n"); }# for $I ############################### # Build bottom bar time index # ############################### $BLOCK = <<' BLOCK_2';
\n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf ("
$MAX_LIC_FOR_GRAPH
0
\n"); printf ("
\n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); if ("$TIME_KEY" eq "$current_key") { $gif = "../images/data_current.gif"; $IS_CURRENT = 1; } else { $gif = ($DATA_READ) ? "../images/data_yes.gif" : ($PAST_CURRENT) ? "../images/data_future.gif" : "../images/data_no.gif"; } if ($display_extra) { if ($DATA_READ) { printf (" \n"); } else { printf (" \n"); } } if ($display_space) { if ($PAST_CURRENT) { printf (" \n"); } else { if ($DATA_READ) { printf (" \n"); } else { printf (" \n"); } } } if ($display_bar) { printf (" \n"); } if ($DATA_READ) { printf (" \n"); } else { if ($PAST_CURRENT) { printf (" \n"); } else { printf (" \n"); } } if ($IS_CURRENT) { $PAST_CURRENT = 1; } printf ("
\"$LIC_LOST
\"Assumed
\"have
\"$AVAIL_LIC
\"Assumed
\"$LIC_IN_USE
\"$LIC_IN_USE
\"Have
\"No
\n"); printf ("
12a 1a 2a 3a 4a 5a 6a 7a 8a 9a 10a 11a 12p 1p 2p 3p 4p 5p 6p 7p 8p 9p 10p 11p

BLOCK_2 printf ($BLOCK); printf ($STAMP); } ########################################## # Always end the page and close the file # ########################################## printf ("
\n"); printf (" \n"); printf (" \n"); close (_TFILE); ########################## # End of today.html file #--------------------------------------------------------------------- ########################## ################################# # start of historical.html file #--------------------------------------------------------------------- ################################# ########################################### # Build the current data file for hsitory # # and store in the expected html file. # ########################################### if (-e $_historical_data) { ############################### # It exists - open and use it # ############################### open (_HISTORY_DATA, $_historical_data) or die "Can't open file ($_historical_data)\n$!\n"; @BUFF = <_HISTORY_DATA>; close (_HISTORY_DATA); $HISTORY_INIT = 0; } else { ############################################### # Init the data - file will get created later # ############################################### $HISTORY_INIT = 1; @BUFF = ("$MAX_LIC_FOR_GRAPH.0.0"); } $MAX_DAY_LIC_FOR_HISTORY = 0; $MAX_USE_LIC_FOR_HISTORY = 0; $DAYS_READ = 0; $FIRST_DAY_LIC_HISTORY = 0; $LIC_DENIED = 0; $LIC_MAX_DENIED = 0; $FIRST_SET = "no"; $OK_TO_BUILD = ($#BUFF != -1) ? 1:0; foreach $_data (@BUFF) { chomp($_data); $DAYS_READ += 1; ($MAX_DAY_LIC, $MAX_DAY_USE, $LIC_DENIED, $USERS_FOR_DAY) = split (/\./, $_data); if ( $MAX_DAY_LIC > $MAX_DAY_LIC_FOR_HISTORY) { $MAX_DAY_LIC_FOR_HISTORY = $MAX_DAY_LIC; } if ( $MAX_DAY_USE > $MAX_USE_LIC_FOR_HISTORY) { $MAX_USE_LIC_FOR_HISTORY = $MAX_DAY_USE; } if ( $LIC_DENIED > $LIC_MAX_DENIED) { $LIC_MAX_DENIED = $LIC_DENIED; } if ( "$FIRST_SET" eq "no" ) { $FIRST_DAY_LIC_HISTORY = $MAX_DAY_LIC; $FIRST_SET = "yes"; } } @BUILT_HISTORY = (); for ($I = 0; ($I < ($DAYS_TO_KEEP - $DAYS_READ)); $I++) { push (@BUILT_HISTORY, "$FIRST_DAY_LIC_HISTORY.0.0."); } foreach $_data (@BUFF) { push (@BUILT_HISTORY, $_data); } ################################################################ # Open the html file to write to and select it for all printfs # ################################################################ open (_TFILE, ">$_history_html_file") or open (_TFILE, ">>$_history_html_file") or die "Can't open file ($_history_html_file)\n$!\n"; select(_TFILE); printf (" \n"); printf (" \n"); printf ($STAMP); $BLOCK = <<' BLOCK_3';
BLOCK_3 printf ($BLOCK); if (!$HISTORY_INIT) { printf ("

ClearCase License usage for the last $DAYS_TO_KEEP days :

\n"); } else { printf ("

ClearCase License usage for the last $DAYS_TO_KEEP days : (Empty until tomorrow)

\n"); } if ($OK_TO_BUILD == 0) { printf ("At the time that this web-page was built there was no data to read in ($_historical_data)!\n"); } else { printf (" \n"); if ($LIC_MAX_DENIED != 0) { $days_back = $DAYS_TO_KEEP; printf (" \n"); printf (" \n"); printf (" \n"); foreach $_data (@BUILT_HISTORY) { chomp($_data); ($junk1, $junk2, $LIC_DENIED) = split (/\./, $_data); ######################################### # Display the data - write to html file # ######################################### $display_bar = ($LIC_DENIED == 0) ? 0 : 1 ; $bar_height= ($LIC_DENIED / $LIC_MAX_DENIED) ; # fraction of display area $bar_height= int($bar_height * $DENIED_GRAPH_HEIGHT); # Percentage of height if ($display_bar) { printf (" \n"); } else { printf (" \n"); } if ( ($days_back != DAYS_KEPT) && (($days_back - 1) % 5) == 0 ) { printf (" \n"); } $days_back -= 1; } printf (" \n"); } ############################ # Build the Header portion # ############################ printf (" \n"); printf (" \n"); printf (" \n"); ########################### # Build the Graph portion # ########################### $days_back = $DAYS_TO_KEEP; $I = 0; foreach $_data (@BUILT_HISTORY) { chomp($_data); $DATA_READ = (($DAYS_TO_KEEP - $DAYS_READ) <= $I) ? 1 : 0 ; ($MAX_DAY_LIC, $MAX_DAY_USE, $IGNORE, $USERS_FOR_DAY) = split (/\./, $_data); if ($MAX_DAY_USE == 0) { $USER_DAY_TEXT = ""; } elsif ($USERS_FOR_DAY eq "") { $USER_DAY_TEXT = "by undetermined user(s)"; } else { $USER_DAY_TEXT = "by user(s) $USERS_FOR_DAY"; } ######################################### # Display the data - write to html file # ######################################### if ($MAX_DAY_LIC == $MAX_DAY_LIC_FOR_HISTORY) { $display_extra = 0; $display_bar = ($MAX_DAY_USE == 0) ? 0:1; $display_space = ($MAX_DAY_USE == $MAX_DAY_LIC) ? 0:1; $bar_height= int(($MAX_DAY_USE / $MAX_DAY_LIC_FOR_HISTORY) * 100); $space_height = 100 - $bar_height; } else { $display_extra = 1; $display_bar = ($MAX_DAY_USE == 0) ? 0:1; $display_space = ($MAX_DAY_USE == $MAX_DAY_LIC) ? 0:1; $extra_height = int ((($MAX_DAY_LIC_FOR_HISTORY - $MAX_DAY_LIC) / $MAX_DAY_LIC_FOR_HISTORY) * 100); if ($display_space) { $bar_height= int ((($MAX_DAY_USE) / $MAX_DAY_LIC_FOR_HISTORY) * 100); $space_height = 100 - $extra_height - $bar_height; } else { $bar_height= 100 - $extra_height ; $space_height = 0; } $LIC_LOST = $MAX_DAY_LIC_FOR_HISTORY - $MAX_DAY_LIC ; } $AVAIL_LIC = $MAX_DAY_LIC - $MAX_DAY_USE ; printf (" \n"); if ( ($days_back != DAYS_KEPT) && (($days_back - 1) % 5) == 0 ) { printf (" \n"); } $days_back -= 1; $I++; } $BLOCK = <<' BLOCK_4';
\"$LIC_DENIED
\n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf (" \n"); printf ("
$MAX_DAY_LIC_FOR_HISTORY
0
\n"); printf ("
\n"); printf (" \n"); printf (" \n"); $gif = ($DATA_READ && !$HISTORY_INIT) ? "../images/data_yes.gif" : "../images/data_no.gif" ; if ($HISTORY_INIT || ! $DATA_READ) { printf (" \n"); printf (" \n"); } else { if ($display_extra) { printf (" \n"); } if ($display_space) { printf (" \n"); } if ($display_bar) { printf (" \n"); } printf (" \n"); } printf ("
\"No
\"No
\"$LIC_LOST
\"$AVAIL_LIC
\"$MAX_DAY_USE
\"$MAX_DAY_USE
\n"); printf ("
115 105 95 85 75 65 55 45 35 25 15 05

BLOCK_4 printf ($BLOCK); printf ($STAMP); } ########################################## # Always end the page and close the file # ########################################## printf ("
\n"); printf (" \n"); printf (" \n"); close (_TFILE); ############################### # End of historical.html file #--------------------------------------------------------------------- ############################### ###################################################### # Copy the specific html to the generic html as well # ###################################################### open (TODAY, ">$_today_html_file") or open (TODAY, ">>$_today_html_file") or die "Can't open file ($_today_html_file)\n$!\n"; open (BY_DATE, "<$_html_file") or die "Can't open file ($_html_file)\n$!\n"; ######################################################################## # The _today.html version automatically refreshes every UPDATE_SECONDS # ######################################################################## printf TODAY " \n" ; while () { if ($_ =~ /^ClearCase License usage/) # (code reference #1) { printf TODAY "Dynamic " ; } printf TODAY $_ ; } close (TODAY); close (BY_DATE); ############################################# # If at end of day then do more processing # # .. turn today into yesterday and initial # # today. # ############################################# if ("$current_key" eq "$CLOSE_OUT_AFTER") { open (YESTERDAY, ">$_yesterday_html_file") or open (YESTERDAY, ">>$_yesterday_html_file") or die "Can't open file ($_yesterday_html_file)\n$!\n"; open (TODAY, "<$_today_html_file") or die "Can't open file ($_today_html_file)\n$!\n"; while () { printf YESTERDAY $_ ; } close (YESTERDAY); close (TODAY); open (TODAY, ">$_today_html_file") or open (TODAY, ">>$_today_html_file") or die "Can't open file ($_today_html_file)\n$!\n"; printf TODAY " \n"; printf TODAY " \n"; printf TODAY $STAMP; printf TODAY "

No data collected yet for today...

\n"; printf TODAY " \n"; printf TODAY " \n"; close (TODAY); open (TOMORROW, ">$_today_data") or open (TOMORROW, ">>$_today_data") or die "Can't open file ($_today_data)\n$!\n"; printf TOMORROW "x.x $LAST_MAX_LIC_GRAPH 0 0"; close (TOMORROW); open (HISTORY_READ, "<$_historical_data") or die "Can't open file ($_historical_data)\n$!\n"; @historical_data = ; close (HISTORY_READ); $days_in_file = $#historical_data + 1; if ($days_in_file < $DAYS_TO_KEEP) { open (HISTORY_WRITE, ">>$_historical_data") or die "Can't open file ($_historical_data)\n$!\n"; printf HISTORY_WRITE "\n$MAX_LIC_FOR_GRAPH.$MAX_USED_TODAY.$MAX_LIC_DENIED.$SORTED_UNIQUE_USERS_TODAY"; close (HISTORY_WRITE); } else { open (HISTORY_WRITE, ">$_historical_data") or open (HISTORY_WRITE, ">>$_historical_data") or die "Can't open file ($_historical_data)\n$!\n"; for ($I = ($days_in_file - $DAYS_TO_KEEP + 1); ($I <= $#historical_data); $I++) { printf HISTORY_WRITE "$historical_data[$I]"; } printf HISTORY_WRITE "\n$MAX_LIC_FOR_GRAPH.$MAX_USED_TODAY.$MAX_LIC_DENIED.$SORTED_UNIQUE_USERS_TODAY"; close (HISTORY_WRITE); } } #################################### # Rebuild the selection.html page. # #################################### open (SELECTION, ">$_selection_html_file") or open (SELECTION, ">>$_selection_html_file") or die "Can't open file ($_selection_html_file)\n$!\n"; select (SELECTION); printf (" \n"); printf (" \n"); printf ($STAMP); $BLOCK = <<' BLOCK_5';
\n"); printf (" \n"); printf ("
Number of license that were in use and who used them... = licenses that were in use and who used them...
Number of license that were available to use... = licenses that were available to use...
Number of license that were added/removed in the period... = licenses that were added/removed in the period...
Number of license that were denied/bumped in the day... = license request that were denied/bumped in the day...
On mouse rollover for this icon displays details... = Data was stored and read...
On mouse rollover for this icon displays details... = Data was not stored and read...
On mouse rollover for this icon displays details... = Last data processed...
On mouse rollover for this icon displays details... = Future data to read...
View another date or series above: \n"); $BLOCK = <<' BLOCK_6';
View another date or series below: \n"); printf ("
\n"); printf ("
\n"); printf ("
\n"); printf ($STAMP); printf (" \n"); printf (" \n"); close (SELECTION); chdir (".."); ########################################## # Rebuild the required _blank.html page. # ########################################## if ( ! -e $_blank_html_file) { open (BLANK, ">>$_blank_html_file") or die "Can't open file ($_blank_html_file)\n$!\n"; select (BLANK); printf (" \n"); printf (" \n"); printf ($STAMP); printf (" \n"); printf (" \n"); close (BLANK); } ############################################## # Rebuild the required _yesterday.html page. # ############################################## if ( ! -e $_yesterday_html_file) { open (YESTERDAY, ">>$_yesterday_html_file") or die "Can't open file ($_yesterday_html_file)\n$!\n"; select (YESTERDAY); printf (" \n"); printf (" \n"); printf ("

Cannot look at yesterday because $self was not running then. This data will not be available until tomorrow..

\n"); printf ($STAMP); printf (" \n"); printf (" \n"); close (YESTERDAY); } ############################################## # Rebuild the required _yesterday.html page. # ############################################## if ( ! -e $_main_html) { open (MAIN_HTML, ">>$_main_html") or die "Can't open file ($_main_html)\n$!\n"; select (MAIN_HTML); printf (" \n"); printf ("A Better Solution, Inc. - ClearCase License Tracker \n"); printf ($STAMP); $BLOCK = <<' BLOCK_7'; BLOCK_7 printf ($BLOCK); printf ($STAMP); printf (" \n"); printf (" \n"); close (MAIN_HTML); } #################################### # either end or sleeep and restart # #################################### if (-e $_run_duration) { $decided = 0; open (DURATION, "<$_run_duration") or die "Can't open file ($_run_duration)\n$!\n"; while () { $duration = $_; chomp ($duration); if ($duration =~ /once/) { ############################################ # Run the one interation - prepare to stop # ############################################ $decided = 1; $running = 0; last; } elsif ($duration =~ /till_end_of_day/) { ################################################ # Keep polling/gatehring data until you have # # reached the "CLOSE_OUT" period (end-of-day). # ################################################ $decided = 1; if ("$current_key" ne "$CLOSE_OUT_AFTER") { sleep ($UPDATE_SECONDS); } else { $running = 0; } last; } elsif ($duration =~ /forever/) { ############################################ # Never stop - When the "CLOSE_OUT" period # # is reached, sleep a bit longer to avoid # # writing duplicated historical data. # ############################################ $decided = 1; if ("$current_key" ne "$CLOSE_OUT_AFTER") { sleep ($UPDATE_SECONDS); } else { sleep ($END_OF_DAY_PAUSE); } last; } } close (DURATION); if (! $decided) { ############################################ # When file is no help the default is to # # run the one interation - prepare to stop # ############################################ $running = 0; } } else { ############################################ # When file is not there the default is to # # run the one interation - prepare to stop # ############################################ $running = 0 ; } } # while (running)