Commit 92a1e031 authored by bnachtw's avatar bnachtw
Browse files

some minor fixes, adding e-mail alerting

parent 9f6fb0f4
......@@ -28,7 +28,7 @@
# date version remark
# 2017-05-15 0.9 initial coding
# 2018-07-18 0.9.1 Apache License added
#
# 2020-10-21 0.9.2 Alerting by e-mail added
##############################################################################
use warnings;
......@@ -46,6 +46,9 @@ use Time::Piece;
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
my $mail_to ='tsm-team@gwdg.de';
my $mail_from ='tsmadm@gwdg.de';
##############################################################################
# O U T P U T S E T T I N G S
##############################################################################
......@@ -56,7 +59,7 @@ my $outputpath = "/TSM/www/Monitoring/drives_paths.html"; # output path
# F U R T H E R S E T T I N G S
##############################################################################
my @serverlist = qw /lm101 lm201 lm202/;# list of servers
my @serverlist = qw /lm101 lm201 lm202/; # list of servers
# some settings for tabbed output
my $widewidth = 25;
......@@ -92,6 +95,7 @@ my $server; # actual server name
my $drives_onl; # number of drives beeing online
my $drives_off; # number of drives beeing offline
my $drives_nn; # number of drives beeing neither on- nor offline
my $drives_nn_g = 0; # total numer of drives beeing neither on- nor -offline
my $drives_on_perc; # share of drives beein online in %
my $drivestatus; # return value of select command
......@@ -147,7 +151,6 @@ printf STATFILE "</tr>\n";
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $server (@serverlist)
{
printf STATFILE "<tr>\n";
......@@ -245,8 +248,33 @@ foreach $server (@serverlist)
printf STATFILE "\t<td> <p style=\"color:$fontcolor\"> %5.2f </p> </td>\n", $paths_on_perc;
printf STATFILE "</tr>\n";
# count number of drives beeing neither on- nor offline
$drives_nn_g = $drives_nn_g + $drives_nn;
}
printf STATFILE "</table>\n";
printf STATFILE "</P>\n</BODY>\n</HTML>\n";
close STATFILE;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# alerting using e-mails
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ($drives_nn_g > 0)
{
my $subj ="TSM: $drives_nn_g Drives failed";
my $mess ="$drives_nn_g failed";
open (MAIL, "|/usr/sbin/sendmail -t");
# Email Header
print MAIL "To: $mail_to\n";
print MAIL "From: $mail_from\n";
print MAIL "Subject: $subj\n\n";
# Email Body
print MAIL $mess;
close(MAIL);
}
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