#!/usr/bin/perl

#
# Scan_Hour - Does hourly (more or less) checks on all workstations, looking
#             for CPU hogs.
#
# Created by: Ted Stefanik <ted@evi.com>
#             February, 1991
#
# Copyright 1991 by Ted Stefanik and Expert Views, Inc.  All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.
#
# This code is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY.  Ted Stefanik and Expert Views, Inc. disclaim all warranties with
# regard to this software, including all implied warranties of merchantability
# and fitness, and in no event shall be liable for any special, indirect or
# consequential damages or any damages whatsoever resulting from loss of use,
# data or profits arising out of or in connection with the use or performance
# of this software.
#


#
# First, set up our manifest constants
#
@Systems =   ("sys1", "sys2", "sys3", "sys4", "sys5", "sys6", "sys7");
@AlertList = ("ted", "ned");
$Master = "/usr/local/lib/perl";

#
# Next, read in the current system status
#
foreach $sys (@Systems)
{
   if (open(Ps, "rsh $sys -n $Master/Scan_PS $Master |"))
   {
      @systat = <Ps>;
      close(Ps);
   }
   else
   {
      @systat = "**** Can't run scan_ps on $sys ****";
   }

   if ($#systat != -1)
   {
      push(@results,
      "***************************** On $sys: *****************************\n",
      @systat,
      "********************************************************************\n",
      "\n\n");
   }
}

if ($#results != -1)
{
   open(MH, "| /usr/ucb/mail @AlertList");
   print MH "~sOink Alert!\n";
   print MH @results;
}
