(Jari Aalto: Thanks for reporting and patching) Hi,
Hereby, I'm forwarding a patch I received on Debian Bug Tracker [0] proposing to use ISO 8601 date format on mail alerts. Please, consider it's inclusion. Cheers, [0] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=551730 Note it is based on mon 0-99-2 version. Jari Aalto wrote: > Package: mon > Version: 0.99.2-15 > Severity: wishlist > Tags: patch > > > The following patch makes the alert messages appear in ISO 8601 format. > > YYYY-MM-DD HH:MM > > MOTIVATION > > For international context, the ISO date is recommended: > > http://en.wikipedia.org/wiki/ISO_8601 > http://www.cl.cam.ac.uk/~mgk25/iso-time.html (ISO8601 by Markus Kuhn) > > For non-english people, the month names, like "Oct" are problematic. > It's not easy to remember if Oct comes before of after Sep etc. > > -- System Information: > Debian Release: squeeze/sid > APT prefers testing > APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') > Architecture: amd64 (x86_64) > > Kernel: Linux 2.6.30-2-amd64 (SMP w/2 CPU cores) > Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8) > Shell: /bin/sh linked to /bin/dash > -- Dario Minnucci (midget) <deb...@midworld.net> Phone: +34 902021030 | Fax: +34 902024417 | Support: +34 807450000 Key fingerprint = 62FF F60F CE79 9CE4 EBA8 523F FC84 1B2D 82C8 B711
>From a1a4d51e243b27c5d257db3e6efab43ab6547149 Mon Sep 17 00:00:00 2001 From: Jari Aalto <jari.aa...@cante.net> Date: Tue, 20 Oct 2009 09:02:19 +0300 Subject: [PATCH] alert.d/mail.alert: (Date, DateISO8601): new functions. Use ISO date Signed-off-by: Jari Aalto <jari.aa...@cante.net> --- alert.d/mail.alert | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/alert.d/mail.alert b/alert.d/mail.alert index 1657b4c..bbab386 100755 --- a/alert.d/mail.alert +++ b/alert.d/mail.alert @@ -29,6 +29,26 @@ $RCSID='$Id: mail.alert 1.1 Sat, 26 Aug 2000 15:22:34 -0400 trockij $'; use Getopt::Std; use Text::Wrap; +sub Date (; $) { + my ($time) = @ARG; + + $time = time unless defined $time; + my ($yyyy, $MM, $dd, $hh, $mm) = (localtime $time)[5, 4, 3, 2, 1]; + + $yyyy += 1900; + $MM++; + + $yyyy, $MM, $dd, $hh, $mm; +} + +sub DateISO8601 (; $) { + my ($time) = @ARG; + + my($yyyy, $MM, $dd, $hh, $mm) = Date $time; + + sprintf "$yyyy-%02d-%02d %02d:%02d", $MM, $dd, $hh, $mm; +} + getopts ("S:s:g:h:t:l:u"); $summary=<STDIN>; @@ -40,14 +60,17 @@ $mailaddrs = join (',', @ARGV); $ALERT = $opt_u ? "UPALERT" : "ALERT"; -$t = localtime($opt_t); -($wday,$mon,$day,$tm) = split (/\s+/, $t); +# $t = localtime($opt_t); +# ($wday,$mon,$day,$tm) = split (/\s+/, $t); +# $date = "wday $mon $day $tm"; + +$date = DateISO8601($opt_t); open (MAIL, "| /usr/sbin/sendmail -oi -t") || die "could not open pipe to mail: $!\n"; print MAIL <<EOF; To: $mailaddrs -Subject: $ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm) +Subject: $ALERT $opt_g/$opt_s: $summary ($date) X-Mailer: $0 EOF -- 1.6.4.3
signature.asc
Description: OpenPGP digital signature