<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@01C31552.A1011490">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:HyphenationZone>21</w:HyphenationZone>
<w:EnvelopeVis/>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:AvantGarde;
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
p
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
pre
{margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Times New Roman";}
span.EstiloCorreo17
{mso-style-type:personal-compose;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:windowtext;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tabla normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=ES link=blue vlink=purple style='tab-interval:35.4pt'>
<div class=Section1>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;mso-ansi-language:EN-GB'>How can I convert the
timestamp values in the log file to a friendlier format?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;mso-ansi-language:EN-GB'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;mso-ansi-language:EN-GB'>Description:<o:p></o:p></span></font></p>
<p><font size=3 face="Times New Roman"><span lang=EN-GB style='font-size:12.0pt;
mso-ansi-language:EN-GB'>User would like to view the raw log files with
human-readable timestamps. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;mso-ansi-language:EN-GB'> <br>
Solution:<o:p></o:p></span></font></p>
<p><font size=3 face="Times New Roman"><span lang=EN-GB style='font-size:12.0pt;
mso-ansi-language:EN-GB'>The following <span class=SpellE>Perl</span> script
will print out the contents of a <span class=SpellE>Nagios</span> log file with
a human-readable time format: <o:p></o:p></span></font></p>
<pre><span class=GramE><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;mso-ansi-language:EN-GB'>#!/</span></font></span><span
class=SpellE><span lang=EN-GB style='mso-ansi-language:EN-GB'>usr/bin/perl</span></span><span
lang=EN-GB style='mso-ansi-language:EN-GB'><o:p></o:p></span></pre><pre><span
class=GramE><font size=2 face="Courier New"><span lang=EN-GB style='font-size:
10.0pt;mso-ansi-language:EN-GB'>use</span></font></span><span lang=EN-GB
style='mso-ansi-language:EN-GB'> <span class=SpellE>Time::Local</span>;<o:p></o:p></span></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><o:p> </o:p></span></font></pre><pre><span class=GramE><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'>if</span></font></span><span lang=EN-GB style='mso-ansi-language:EN-GB'> (!@ARGV[0]) {<o:p></o:p></span></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span><span class=GramE>print</span> "Usage: $0 <nagios-logfile>\n";<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span><span class=GramE>print</span> "\n";<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span><span class=GramE>print</span> "prints the specified <span
class=SpellE>Nagios-logfile</span> with timestamps\n";<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span><span class=GramE>print</span> "converted to human readable time\n";<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'>}<o:p></o:p></span></font></pre><pre><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;mso-ansi-language:EN-GB'><o:p> </o:p></span></font></pre><pre><span
class=GramE><font size=2 face="Courier New"><span lang=EN-GB style='font-size:
10.0pt;mso-ansi-language:EN-GB'>open(</span></font></span><span lang=EN-GB
style='mso-ansi-language:EN-GB'>LOG,@ARGV[0]);<o:p></o:p></span></pre><pre><span
class=GramE><font size=2 face="Courier New"><span lang=EN-GB style='font-size:
10.0pt;mso-ansi-language:EN-GB'>while</span></font></span><span lang=EN-GB
style='mso-ansi-language:EN-GB'> (! <span class=SpellE>eof</span>(LOG)) {<o:p></o:p></span></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span>$line <span class=GramE>= <log>;</span><o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span>($part1, $part2) = <span
class=GramE>split(</span>/\s+/, $line, 2);<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span>$part1 =~ s/<span class=GramE>\[</span>//;<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span>$part1 =~ s/\]//;<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;mso-ansi-language:
EN-GB'><span style='mso-spacerun:yes'> </span>print "[", scalar <span
class=SpellE><span class=GramE>localtime</span></span><span class=GramE>(</span>$part1), "] $part2";<o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>};<o:p></o:p></span></font></pre><pre><span
class=SpellE><span class=GramE><font size=2 face="Courier New"><span
style='font-size:10.0pt'>close</span></font></span></span><span class=GramE>(</span>LOG);<o:p></o:p></pre>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'></log></nagios-logfile> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><span class=GramE><font size=3 face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;mso-ansi-language:EN-GB'>ok</span></font></span><span
lang=EN-GB style='mso-ansi-language:EN-GB'>, is there any way <span
class=SpellE>nagios</span> do it for me directly? Or should I execute this
script from command line???</span><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face=AvantGarde><span style='font-size:8.0pt;
mso-bidi-font-size:10.0pt;font-family:AvantGarde;mso-no-proof:yes'>_____________________________________________________________________________________________________________________<i
style='mso-bidi-font-style:normal'><font color=teal><span style='color:teal;
font-style:italic;mso-bidi-font-style:normal'> </span></font></i><br>
Mediafusión España, S.A. ®<br>
Aviso legal: <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-align:justify'><font size=1 face=AvantGarde><span
style='font-size:8.0pt;mso-bidi-font-size:10.0pt;font-family:AvantGarde;
mso-no-proof:yes'>Este mensaje electrónico está dirigido únicamente a la(s)
dirección(es) indicadas anteriormente; el carácter confidencial, personal e
intransferible del mismo está protegido legalmente. Cualquier revelación, uso o
reenvío no autorizado, completo o en parte, está prohibido. <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-align:justify'><font size=1 face=AvantGarde><span
style='font-size:8.0pt;mso-bidi-font-size:10.0pt;font-family:AvantGarde;
mso-no-proof:yes'>Si ha recibido este mensaje por equivocación, notifíquelo
inmediatamente a la persona que lo ha enviado y borre el mensaje original junto
con sus ficheros anexos sin leerlo ni grabarlo, total o parcialmente. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face=AvantGarde><span style='font-size:8.0pt;
mso-bidi-font-size:10.0pt;font-family:AvantGarde;mso-no-proof:yes'>Gracias<font
color=teal><span style='color:teal'>.</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>