I'm a network admin, and I use perl to automate just about everything on my systems. A lot of the time, I want my scripts to email me if conditions are bad and page me if conditions are terrible. I've experiemented with a few different mechanisms and I think I'm almost ready to write a real module.

I've looked at Carp::Notify by Jim Thomason and my idea is significantly different so I don't think I'd just be rebuilding his wheel.

Here's what I want my module to do:

1)read contact info from a central file: (/etc/contacts or something like that.) This eliminates the need to update all my scripts when I or my boss gets a new pager number.

2)Control how often emails get sent: I've sent myself 1000 emails in a minute before. Don't want that happening.

3)Optionally override normal warn/die/carp/croak calls: I'd like to be able to add this module to existing scripts and have it start emailing me about the events that I DON'T anticipate.

4)Optionally handle unexpected death as well as die/croak calls: I want to be notified in every case, not just the ones I thought of. If my CGI devides by zero or doesn't compile, I want to know about it.

5)Make it so the user can do as much configuration as possible at the beginning of his/her script, leaving actual warn/carp/croak/die/whateverIcallthem calls as simple as possible. I want to make these calls a LOT so I want them to be simple.

I've already done all these bits in different places. All I need to do is get it togeather in one module. Making it portable will probably be most of the challange.

The only thing I do that isn't either straightforward or just cribbed from someone elses's module is the email limiting, so I'll mention how I do that here.

Every time I send an email, I make an md5 hash of the recipients + the subject. I then make an entry in a GDBM file with that hash pointing toward a timestamp. The timestamp is the time when I consider it OK to send the same email again. So, before the email gets sent, it checks the md5 hash above against the GDBM file to see if it's been sent before, and if it has if the ok-to-send-now-timestamp is either right now or in the past.

So, oh monks of perl, do you have any suggestions for such a module? Do you think it's a good idea? Do you think it's a bad idea, and I should go soak my head?

I'm thinking of calling it Carp::Fancy. Any suggestions on better ideas for a name would also be great.

Thanks
-Dylan (aka Pileofrogs)


In reply to RFC: Module idea: Carp + controlled email by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.