Commit f290387d authored by bnachtw's avatar bnachtw
Browse files

nodecheck on v.r.m.l added, including to mark nodes with possible problems with TOFU

parent a90d8ad9
#! /usr/bin/perl
##############################################################################
#
# tsm-status-node-vrmf.pl
#
# script for getting _V_ersion._R_eleasse._M_aintainaceLevel-_F_ixpack for every node
#
#
# (C) 2018 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
##############################################################################
#
# changelog
# date version remark
# 2018-10-24 0.8 initial coding based on "tsm-status-nodebackup.pl
# 2021-03-15 0.8.1 added new colors for "non-TLS"-Versions
#
##############################################################################
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 $outbasedir = "/TSM/Monitoring/www/VRMF/"; # base path to output
my $outfile = $outbasedir."index.html";
##############################################################################
# F U R T H E R S E T T I N G S
##############################################################################
my @serverlist = qw /tsm110 tsm111 tsm112 tsm130 tsm131 tsm180 tsm182 tsm184 tsm230 tsm231 tsm232 tsm233 tsm234 tsm236 tsm237 tsm283 tsm285 tsm286/; # list of servers
#my @serverlist = qw /tsm110 tsm285/; # list of servers
use warnings;
use strict;
use Time::Piece;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set some variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# some settings for tabbed output
my $widewidth = 50;
my $smallwidth = 10;
# VRM indication EoS versions
my $eos_version = 7;
my $eos_release = 1;
my $eos_level = 0;
my $eos_vrm = sprintf "%d.%d.%02d", $eos_version, $eos_release, $eos_level;
# oldest supported SP8 client doing already TOFU
my $old_version = 8;
my $old_release = 1;
my $old_level = 5;
my $old_tofu = sprintf "%d.%d.%02d", $old_version, $old_release, $old_level;
# newest supported SP7 client working w/o TLS
my $new_version = 7;
my $new_release = 1;
my $new_level = 7;
my $new_tofu = sprintf "%d.%d.%02d", $new_version, $new_release, $new_level;
printf "NT: %s \ OT: %s \n", $new_tofu, $old_tofu;
# some loop iterators
my $server; # actual server name
my $node; # actual node name (loop iterator)
# some lists to be processed
my @nodelist; # list of all nodes on each server
# items from seletc statement
my $nodename; # actual nodename
my $nodelock; # is actual node locked?
my $elap_days; # elapsed days since last access
my $client_version; # V Version
my $client_release; # R Release
my $client_level; # M aka Maintainance-Level
my $client_sublevel; # F aka Fixpack
my $client_vrmf; # V.R.M-F combined text
my $client_vrm; # V.R.M combined text, so without fixpak
#
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 $server_name; # admin-friendly name of the actual server
my $fontcolor; # color of font for indication problems
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# global index file
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
open GIDXFILE, ">" . $outfile
or die "$0: cannot open output file: " . $outfile;
printf GIDXFILE "<HTML>\n<HEAD>\n<TITLE>Client-Software State Overview: %s</TITLE>\n</HEAD>\n", $date;
printf GIDXFILE "<BODY BGCOLOR=\"#eeeee0\">\n";
printf GIDXFILE "<P><FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"5\"><CENTER>\n";
printf GIDXFILE "Client-Software State: %s -- O V E R V I E W - -</CENTER></FONT></P>\n", $date;
printf GIDXFILE "<HR NOSHADE><P>\n";
printf GIDXFILE "<FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"4\">\n";
printf GIDXFILE "Select Server:</P><HR NOSHADE><P>\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $server (@serverlist)
{
$server_name = uc $server;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# prepare index file for each server
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
printf GIDXFILE "<FONT COLOR=\"#0000ff\" FACE=\"monospace\" SIZE=\"4\">\n";
printf GIDXFILE "<A HREF=\"./%s.html\" TARGET=\"_self\">", $server;
printf GIDXFILE "%s</A></FONT><BR>\n", $server_name;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get list of domains
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $filename = $outbasedir . $server . ".html";
open HTMLFILE, ">" . $filename
or die "$0: cannot open output file: " . $filename;
printf HTMLFILE "<HTML>\n<HEAD>\n<TITLE>Client-Software State at server $server_name: " . "%s</TITLE>\n</HEAD>\n", $date;
printf HTMLFILE "<BODY BGCOLOR=\"#eeeee0\">\n";
printf HTMLFILE "<P><FONT COLOR=\"#000000\" FACE=\"monospace\" " . "SIZE=\"5\"><CENTER>\n";
printf HTMLFILE "Client-Software State at server $server_name: %s</CENTER></FONT></P>\n", $date;
printf HTMLFILE "<p style=\"font-family:monospace\">\n";
printf HTMLFILE "<HR NOSHADE>\n";
printf HTMLFILE "<FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"4\">\n";
printf HTMLFILE "Nodename" . "&nbsp;" x ($widewidth - length("Nodename") + 1);
printf HTMLFILE "VRMF" . "&nbsp;" x ($smallwidth - length("VRMF") + 1);
printf HTMLFILE "# Days" . "&nbsp;" x ($smallwidth - length("# Days") + 1);
printf HTMLFILE "locked?" . "&nbsp;" x ($smallwidth - length("locked?") + 1);
printf HTMLFILE "<br>" . "\n";
printf HTMLFILE "</FONT></P>\n";
printf HTMLFILE "<HR NOSHADE>\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get list of nodes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
undef @nodelist;
$command = "$dsmadmc $dsmargs -se=$server \"select ".
"NODE_NAME, ".
"LOCKED, ".
"CAST(DAYS(current_date) - DAYS(LASTACC_TIME) as decimal), ".
"TRIM(CHAR(client_version)), TRIM(CHAR(client_release)), TRIM(CHAR(client_level)), TRIM(CHAR(client_sublevel)) ".
"from NODES order by NODE_NAME\" 2>/dev/null";
@nodelist = split '\n' , `$command`;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# process each node
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $node (@nodelist)
{
# check for errors on SQL request
if ( ( $node =~ /^ANR/ ) or ($node =~ m/^ANS/) )
{
last
}
# split line in subvalues
($nodename, $nodelock, $elap_days, $client_version, $client_release, $client_level, $client_sublevel) = split "\t", $node;
if ( $elap_days eq "")
{
$elap_days = "--";
}
if ( $client_version eq "")
{
$fontcolor = "#000000";
$client_vrmf = "--";
}
else
{
$client_vrmf = sprintf "%d.%d.%d-%d", $client_version, $client_release, $client_level, $client_sublevel;
$client_vrm = sprintf "%d.%d.%02d", $client_version, $client_release, $client_level;
# set font color according to legend
if ($elap_days eq "--")
{
$fontcolor="#000000";
}
elsif ( ($client_vrm gt $new_tofu) and ($client_vrm lt $old_tofu) )
{
$fontcolor="#FF00FF";
}
elsif ($client_vrm ge $eos_vrm)
{
$fontcolor="#228b22";
}
# elsif ($client_version > $eos_version )
# elsif ($client_version == $eos_version and $client_release > $eos_release)
# {
# $fontcolor="#228b22";
# }
# elsif ($client_version == $eos_version and $client_release == $eos_release and $client_level >= $eos_level)
# {
# $fontcolor="#228b22";
# }
else
{
$fontcolor="#ff0000";
}
}
# truncate name of fs and node for eqal tab spacing
if (length($nodename) > $widewidth )
{
$nodename = substr $nodename, 0, $widewidth;
}
printf HTMLFILE "<FONT COLOR=\"" . $fontcolor . "\" FACE=\"monospace\" SIZE=\"4\">";
printf HTMLFILE $nodename . "&nbsp;" x ($widewidth - length ($nodename) ) . "\n";
printf HTMLFILE $client_vrmf . "&nbsp;" x ($smallwidth - length ($client_vrmf)). "\n";
printf HTMLFILE $elap_days . "&nbsp;" x ($smallwidth - length ($elap_days)) . "\n";
printf HTMLFILE $nodelock . "&nbsp;" x ($smallwidth - length ($nodelock)) . "\n";
printf HTMLFILE "</FONT>\n";
printf HTMLFILE "<br>\n";
} # EO while (@nodelist)
printf HTMLFILE "</P>&nbsp;</P>\n";
printf HTMLFILE "<HR NOSHADE><P>\n";
printf HTMLFILE "<FONT FACE=\"monospace\" SIZE=\"5\">Legend:</FONT>\n";
printf HTMLFILE "<br>\n";
$client_vrmf = sprintf "%d.%d.%d-0", $eos_version, $eos_release, $eos_level;
printf HTMLFILE "<FONT FACE=\"monospace\" SIZE=\"4\">Oldest Version in Support\t %s</FONT>\n", $client_vrmf;
printf HTMLFILE "<br>\n";
# set font color according to legend
# "#228b22"; # green
# "#FFBF00"; # orange
# "#FF00FF"; # pink
# "#ff0000"; # red
printf HTMLFILE "<FONT COLOR=\"#228b22\" FACE=\"monospace\" SIZE=\"4\">\n";
printf HTMLFILE "Client Software in Support</FONT><BR>\n";
printf HTMLFILE "<FONT COLOR=\"#FF00FF\" FACE=\"monospace\" SIZE=\"4\">\n";
printf HTMLFILE "Client Software does not support TOFU, update to 8.1.5+</FONT><BR>\n";
printf HTMLFILE "<FONT COLOR=\"#ff0000\" FACE=\"monospace\" SIZE=\"4\">\n";
printf HTMLFILE "Client Software has reached End-Of-Support (EoS).</FONT><BR>\n";
printf HTMLFILE "<FONT COLOR=\"#000000\" FACE=\"monospace\" SIZE=\"4\">\n";
printf HTMLFILE "No information -- Maybe the Client never connected to server.</FONT><BR>\n";
printf HTMLFILE "</P>\n</BODY>\n</HTML>\n";
close HTMLFILE;
} # EO foreach $server (@serverlist)
printf GIDXFILE "</P>\n</BODY>\n</HTML>\n";
close GIDXFILE;
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