Commit 21634719 authored by bnachtw's avatar bnachtw
Browse files

summarize occupancy of nodes named DELME.

parent d188c428
#! /usr/bin/perl
##############################################################################
#
# tsm-summary-delme.pl
#
# script for getting some statistics on nodes marked for deletion
# using "DELME" as name prefix
#
#
# (C) 2014 - 2018 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
##############################################################################
#
# changelog
# date version remark
# 2014-09-02 0.9 initial coding
# 2014-09-09 0.9.1 some fixes
# 2014-09-12 0.9.2 script renamed
# 2018-01-12 0.9.3 switched to common style, moved credentials arguments
#
##############################################################################
use warnings;
use strict;
use Time::Piece;
##############################################################################
##############################################################################
# F I L L I N Y O U R S E T T I N G S H E R E
##############################################################################
##############################################################################
##############################################################################
# C R E D E N T I A L S
##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
##############################################################################
# O U T P U T S E T T I N G S
##############################################################################
my $outputpath = "/TSM/Monitoring/www/Nodebackupstatus/delmesummary.html"; # output path
##############################################################################
# F U R T H E R S E T T I N G S
##############################################################################
my @serverlist = qw /tsm110 tsm112 tsm113 tsm130 tsm131 tsm180 tsm182 tsm184 tsm230 tsm231 tsm232 tsm233 tsm234 lm101 lm201 lm202/; # list of new servers
use warnings;
use strict;
use Time::Piece;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set some variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#
# # some settings for tabbed output
my $widewidth = 30;
my $midwidth = 20;
my $smallwidth = 15;
#
# # some threshold values
my $node_name;
my $num_files; # num_files for a single node
my $occupancy; # occupancy for a single node
my $grand_total_num_files = 0; # sum of num_files over all servers
my $grand_total_occupancy = 0.0; # sum of occupancy over all serversmy $node_name;
# # some loop iterators
my $server; # actual server name
my $server_name;
my @nodelist; # list of all "DELME." nodes
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
my $date = localtime->strftime ('%a %b %d %H:%M:%S %Y %Z');
#
# # new variables
my $command;
my $selectstatement;
open STATFILE, ">" . $outputpath or die "$0: cannot open output file: " . $outputpath;
printf STATFILE "<HTML>\n<HEAD>\n<TITLE>TSM Server State: %s</TITLE>\n</HEAD>\n", $date;
printf STATFILE "<BODY BGCOLOR=\"#eeeee0\">\n";
printf STATFILE "<P><FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"5\"><CENTER>\n";
printf STATFILE "TSM Server State: %s</CENTER></FONT></P>\n", $date;
printf STATFILE "<HR NOSHADE>\n";
printf STATFILE "<P><FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"5\"><CENTER>\n";
printf STATFILE "-- Occupancy of Nodes named DELME. -- </CENTER></FONT></P>\n";
printf STATFILE "<p style=\"font-family:monospace\">\n";
printf STATFILE "<HR NOSHADE>\n";
printf STATFILE "<FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"4\">\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $server (@serverlist)
{
printf STATFILE "<br>" . "\n";
printf STATFILE "Servername" . "&nbsp;" x ($smallwidth - length("Serverame") + 0);
printf STATFILE "&nbsp;" x ($widewidth - length("Nodename") + 0) . "Nodename";
printf STATFILE "&nbsp;" x ($midwidth - length("# Files") + 0) . "# Files";
printf STATFILE "&nbsp;" x ($midwidth - length("Occupancy (GB)") + 0) . "Occupancy (GB)";
printf STATFILE "\n";
printf STATFILE "<br>" . "\n";
printf STATFILE "<HR NOSHADE>\n";
$server_name = $server;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get list of nodes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
undef @nodelist;
$server_name = $server;
$selectstatement = "SELECT CAST(FLOAT(SUM(physical_mb)) / 1024 AS DEC(8,2)), SUM(num_files), node_name FROM occupancy where node_name like \'DELME%%\' GROUP BY node_name";
$command = "$dsmadmc $dsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@nodelist = split '\n' , `$command`;
foreach my $node (@nodelist)
{
if ( ( $node =~ m/^ANR/ ) or ($node =~ m/^ANS/) )
{
printf STATFILE $server_name . "&nbsp;" x ($smallwidth - length ($server_name) ) . "\n";
printf STATFILE "&nbsp;" x ($widewidth - length ("--") ) . "--" . "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ("--") ) . "--" . "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ("--") ) . "--" . "\n";
last
}
($occupancy, $num_files, $node_name) = split '\t' , $node;
printf STATFILE $server_name . "&nbsp;" x ($smallwidth - length ($server_name) ) . "\n";
printf STATFILE "&nbsp;" x ($widewidth - length ($node_name) ) . $node_name . "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ($num_files) ) . $num_files . "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ($occupancy) ) . $occupancy . "\n";
printf STATFILE "\n";
printf STATFILE "<br>" . "\n";
$grand_total_occupancy = $grand_total_occupancy + $occupancy;
$grand_total_num_files = $grand_total_num_files + $num_files;
# substitute server_name by "." if not first fs
if ( $server eq $server_name )
{
$server_name = ".";
}
} # EO while (@assocstatus)
printf STATFILE "<br>\n";
}
printf STATFILE "<HR NOSHADE>\n";
printf STATFILE "<HR NOSHADE>\n";
$grand_total_occupancy = sprintf "%.2f", $grand_total_occupancy / 1024.;
$grand_total_num_files = sprintf "%.2f", $grand_total_num_files / 1000000.;
printf STATFILE " (with files in mio, occupancy in TB):". "\n";
printf STATFILE "<br>\n";
printf STATFILE "TOTAL (All Servers):" . "&nbsp;" x ($widewidth - length ("TOTAL (All Servers):") ) . "\n";
printf STATFILE "&nbsp;" x $smallwidth. "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ($grand_total_num_files) ) . $grand_total_num_files . "\n";
printf STATFILE "&nbsp;" x ($midwidth - length ($grand_total_occupancy) ) . ($grand_total_occupancy/1.) . "\n";
printf STATFILE "<br>\n";
printf STATFILE "</FONT></P>\n";
printf STATFILE "</P>\n</BODY>\n</HTML>\n";
close STATFILE;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment