How to convert UNIX epoch to date format for u se in Alerts?
Pulyankote, Gopinath
Gopinath_Pulyankote at affymetrix.com
Thu Dec 19 19:14:15 CET 2002
Thanks Mike, I owe you the 5 bucks! Let me know how you want it sent ;)
Here is the final entry in checkcommands.cfg that worked:
# Used for escalations. Alerts have additional info on how long the host was
down.
define command {
command_name host-notify-manager
command_line /usr/bin/printf "%s %b" " Since: " "
`/usr/bin/perl -e 'print scalar localtime ($LASTSTATECHANGE$)'` " |
/bin/mail -s "$NOTIFICATIONTYPE$ alert - Host $HOSTALIAS$ is $HOSTSTATE$"
$CONTACTPAGER$
}
Thanks once again
-Gopinath
-----Original Message-----
From: Mike McClure [mailto:mmcclure at pneservices.com]
Sent: Wednesday, December 18, 2002 5:23 PM
To: Pulyankote, Gopinath
Subject: RE: [Nagios-users] How to convert UNIX epoch to date format for u
se in Alerts?
I think you are missing the backticks in there.
They mean "evaluate the statement and return it's value as a string".
"`/usr/bin/perl -e 'print scalar localtime($LASTSTATECHANGE$)'`"
> I definitely will! But it didn't work. It spit out the complete line with
> the perl command.
> What did I do wrong? BTW, I need to convert $LASTSTATECHANGE$ value to
date
> format not $DATETIME$, that is already in date format.
>
>
> define command {
> command_name host-notify-manager
> command_line /usr/bin/printf "%b %s" " Since: " "
> /usr/bin/perl -e 'print scalar localtime ($LASTSTATECHANGE$)' " "\nTime
now
> is: $DATETIME$" | /bin/mail -s "$NOTIFICATIONTYPE$ alert - Host
$HOSTALIAS$
> is $HOSTSTATE$" $CONTACTPAGER$
> }
>
> -----Original Message-----
> From: Mike McClure [mailto:mmcclure at pneservices.com]
> Sent: Wednesday, December 18, 2002 4:37 PM
> To: Pulyankote, Gopinath
> Cc: 'Steve Burton'; Nagios List
> Subject: RE: [Nagios-users] How to convert UNIX epoch to date format for u
> se in Alerts?
>
>
> 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
>
>
--
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: Geek Gift Procrastinating?
Get the perfect geek gift now! Before the Holidays pass you by.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/
More information about the Users
mailing list