On 12 May 98 at 8:30, Jack Killpatrick wrote:

> again. They then asked me what emails they had not received. I
> looked in my database and gave them copies of the last records in
> the table, but told them that I didn't know when sendmail stopped
> being usable, so they'd have to check the database info against the
> emails they already received to see what they hadn't received. It
> was kind of a hassle. In the first place, I wasn't aware of the
> problem, in the second place I didn't have an easy way of tracking
> the unsent emails. Note that these weren't even emails drifting
> around in cyberspace; they never even got created.

Couple of ideas.  I often now send myself an email rather than doing 
a || die -- or print_error as I would usually do or send me an email 
and print_error.  In the case of something critical such as you 
mentioned, I would suggest that 


> So, I'm looking for a way to be able to know whether an email was
> created and sent or not. Let's say sendmail doesn't even start up,
> and thus can't return an exit code, I need to know what email send

if using the 

open sendmail || warn me of problem

>From Rich:
> What you propose will tell you if sendmail returns a non-zero exit
> code immediately, but that isn't what you really need to know: you
> need to know if the mail actually got delivered.  And there's no

If you cannot open sendmail then I think you get the warning.  If you 
can open sendmail but it cannot deliver for one reason or 
other...well then there is no easy method.

Did you use the 

open || die

or just open. If you did just open then your program will continue 
regardless of what the sendmail open does.  Perl will gladly glide 
along.

> Could my script just look for _no_ exit code coming from sendmail,
> write an error to the user in html and write a record to my database
> detailing the non-send? Seems like that could work. Hmmm. At that

I am surprised that your cgi could even  start if it could not then 
send email.


> point the user on the web would get an error notice, but not me (I
> don't plan on sitting at the console). I could ask the web user to
> call Customer Service at my client and notify them of the error,
> then Customer Service could call me. Hmmm, that might work. Any
> thoughts?


As I mentioned.  I think it is always best to do a :

do this || warn me of failure

and then you email yourself and depending on the context you exit the 
program or continue. That way you can be kept abreast of how a 
program is operating.

Another thing.  You may want to consider a cron job. Set it to run on 
an hourly basis and check your system status.  Send the results to 
you via email.  I don't know what the best thing to do would be..

Off the top of my hairless head:

cheap and fairly quick:
(note I would never use backticks in any cgi program)

Another note.  I don't like the idea or running top without somehow 
quitting it (just don't know).

I hate seeing those zombies in there. I wonder if I started them or 
someone else did.  How would I know.

But I think something like the following might be interesting. You 
could even pass it to a webpage.

I have seen much more sophisticated programs that do this--but at 
iserver.com you cannot run these (last time I tried) from a 
cgi--unless you put them in your bin but then I wonder if they will 
really run.

Peter

#!/usr/local/bin/perl5

$email_tech = "webmaster\@rede.com";
$process = `ps`;
$date = `date`;
$top = `top`;

`/usr/bin/mail -s "SysCheck on $date" $email_tech  << END
$date

Process Check:

$process

----------------
Top Check:

$top

----------------

END
`;

And running this sends me this email:



Tue May 12 22:10:10 MDT 1998


Process Check:

  PID  TT  STAT      TIME COMMAND
  393  p0  S+     0:00.03 perl5 sysup.pl
  394  p0  R+     0:00.02 ps
27968  p0  Is     0:00.19 -csh (csh)
29556  p0  I      0:00.07 bash
29565  p0  I      0:00.14 -csh (tcsh)
29583  p0  S      0:00.14 bash


----------------
Top Check:

load averages:  0.03,  0.02,  0.00    22:10:11
94 processes:  4 running, 86 sleeping, 4 zombie

Memory: Real: 7688K/29M Virt: 27M/492M Free: 14M


  PID USERNAME PRI NICE  SIZE   RES STATE   TIME   WCPU    CPU COMMAND
29931 rede       2    0 4308K 4296K sleep   0:06  1.86%  1.86% bob.pl
  393 rede       2    0  596K  520K sleep   0:00  3.00%  0.15% perl5
  398 rede      28    0  240K  392K run     0:00  1.00%  0.05% top
29583 rede      10    0  692K  688K sleep   0:00  0.05%  0.05% bash
29565 rede      18    0  764K  608K sleep   0:00  0.00%  0.00% tcsh
27968 rede      18    0  224K  308K sleep   0:00  0.00%  0.00% csh
29556 rede      10    0  704K  692K sleep   0:00  0.00%  0.00% bash
29928 rede      10    0  204K  180K sleep   0:00  0.00%  0.00% sh
19018 rede       2    0  916K  348K sleep   0:00  0.00%  0.00% aftpd
24593 rede       2    0 1728K   20K sleep   0:00  0.00%  0.00% <httpd>
24503 rede       2    0 1728K   20K sleep   0:00  0.00%  0.00% <httpd>
13481 rede       2    0  920K   20K sleep   0:00  0.00%  0.00% <aftpd>



----------------




 _________________________________________________________
Peter J. Schoenster                      [EMAIL PROTECTED]
Exercise Your Brain..Read a Book       http://www.rede.com/
             Free CGI Scripts and Applications
           http://www.rede.com/samples/index.html
____________________________________________________________________
--------------------------------------------------------------------
 Join The Web Consultants Association :  Register on our web site Now
Web Consultants Web Site : http://just4u.com/webconsultants
If you lose the instructions All subscription/unsubscribing can be done
directly from our website for all our lists.
---------------------------------------------------------------------

Reply via email to