#!/usr/bin/perl -w #===================================================================== # # PROGRAM: mime_tester.pl # # PURPOSE: This program sends SMARTS monitoring data (as HTML link) # to email addresses. # # AUTHOR: Ron Bueler # # DATE: April 22, 2001 # # # Revision History: # # #===================================================================== # Use various Perl modules #--------------------------------------------------------------------- use strict; use diagnostics; use MIME::Entity; #===================================================================== # Flush STDOUT (i.e.; don't use buffered I/O) #--------------------------------------------------------------------- select (STDOUT); $| = 0; #===================================================================== # Define some variables #--------------------------------------------------------------------- my ($msg) = ""; my ($message) = ""; my ($plain) = ""; my ($fancy) = ""; #===================================================================== # Start of mime_tester.pl #--------------------------------------------------------------------- { &log ("Starting program $0\n"); &log ("1. Create the email, and set up the mail headers...\n"); $msg = MIME::Entity->build ( From => "smart\@pm02rg.rst.cw.net", To => "buelerra\@codenet.net", Subject => "SMART CPU Utilization Report", Type => "multipart/alternative" ); &log ("2. Create the HTML headers...\n"); $fancy = $msg->attach(Type => 'multipart/related'); &log ("3. Insert the HTML code...\n"); $fancy->attach(Type => 'text/html', Data => [qq<

PM02SM CPU Utilization Report

\n>, qq<
>, qq<
pm02sm_cpu.png
>, ]); &log ("4. Shoot the email out the door\n"); open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!"; $msg->print(\*MAIL); close MAIL; &log ("Finished program $0\n"); exit(0); } #===================================================================== # &log() subroutine #--------------------------------------------------------------------- sub log { my ($text) = @_; printf (&time_stamp() . " - " . $text); } #===================================================================== # &time_stamp() subroutine #--------------------------------------------------------------------- sub time_stamp { my ($now) = ` date +"%Y-%m-%d %H:%M:%S" `; chomp ($now); return ($now); } #===================================================================== # End of mime_tester.pl #=====================================================================