How to convert UNIX epoch to date format for u se in Alerts?

Mike McClure mmcclure at pneservices.com
Thu Dec 19 01:36:36 CET 2002


Gopinath,

/usr/bin/printf "%b %s" " since '$LASTSTATECHANGE$' \nTime now is: " "`/usr/bin/perl
-e 'print scalar localtime($DATETIME$)'`" | /bin/mail -s "$NOTIFICATIONTYPE$ alert -
Host $HOSTALIAS$ is $HOSTSTATE$" $CONTACTPAGER$

You owe me five bucks if it works. :)

- Mike

> Thanks. But how do I get this conversion done within this command definition
> in checkcommands.cfg ?
> define command {
> command_name                   host-notify-manager
> command_line                   /usr/bin/printf "%b" " since
> '$LASTSTATECHANGE$' \nTime now is: $DATETIME$" | /bin/mail -s
> "$NOTIFICATIONTYPE$ alert - Host $HOSTALIAS$ is $HOSTSTATE$" $CONTACTPAGER$
> }
> -Gopinath
>
>
> -----Original Message-----
> From: Steve Burton [mailto:steve at sliderule.demon.co.uk]
> Sent: Wednesday, December 18, 2002 12:59 PM
> Cc: Nagios List
> Subject: Re: [Nagios-users] How to convert UNIX epoch to date format for u
> se in Alerts?
>
>
>
>
> Olaf Greis wrote:
>>
>> >  The only problem now is that $LASTSTATECHANGE$ is in UNIX epoch format.
>> > How does one convert this to readable format ?
>>
>> perl -e 'print scalar localtime(1234567890)' is one of the possible
> solutions.
>>
> under FreeBSD (at least) date -r <unixtimeseconds> does the same.
>
> Steve.
>
>> brdgs
>>   olaf
>>
>> -------------------------------------------------------
>> This sf.net email is sponsored by:
>> With Great Power, Comes Great Responsibility
>> Learn to use your power at OSDN's High Performance Computing Channel
>> http://hpc.devchannel.org/
>> _______________________________________________
>> Nagios-users mailing list
>> Nagios-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/nagios-users
>
> --
> Steve Burton
>
> Webmaster & Sub-optimal Coder
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
> Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
> MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
> T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
> Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
> MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
> T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
>
>


-- 
Mike McClure, CCIE # 5125, CISSP # 30232
PNE Services, Inc. -  http://www.pneservices.com
mmcclure at pneservices.com
mobile: 913-636-5590



-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/




More information about the Users mailing list