[1443094172] [29058] SERVICE ALERT: imgserver03;Root File System;UNKNOWN;SOFT;1;ERROR: hrStorageDescr Table : No response from remote host '192.168.90.64'. [1443094462] [29058] SERVICE ALERT: imgserver03;Root File System;OK;SOFT;2;Disk OK - / TOTAL: 15.748 Go USED: 19% : 3.019 Go
While I'm not that bad with reading timestamps... it takes some temporal awareness and when it's 6am and I haven't had my coffee yet, that's just too much cognitive power for me to conjure up. So I made the following script that takes info in from a pipe, looks for timestamps, and converts them over.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$fd = fopen("php://stdin", "r"); | |
while ($line=fgets($fd)) { | |
$lx=explode(" ",$line); | |
echo date("Y-m-d H:i:s",trim($lx[0],"\t ;,.][{})(^&%$#@!=-\"':<>+/")); | |
unset($lx[0]); | |
$l=implode(" ",$lx); | |
echo " ".$l; | |
} | |
fclose($fd); | |
?> |
Save that in a file, chmod the file +x, and do something like:
cat mylogfile.log|./t2d
You can stick greps and such in there too. Just as long as the timestamp doesn't get corrupted, From the above output, I get:
$ cat mylogfile.log|./t2d 2015-09-24 07:29:32 [29058] SERVICE ALERT: dsfrcimg03;Root File System;UNKNOWN;SOFT;1;ERROR: hrStorageDescr Table : No response from remote host '10.93.90.64'. 2015-09-24 07:34:22 [29058] SERVICE ALERT: dsfrcimg03;Root File System;OK;SOFT;2;Disk OK - / TOTAL: 15.748 Go USED: 19% : 3.019 Go
I've also added this script in a public Gist on github.com: https://gist.github.com/thejml/7af9f4b56ef9b11e612f
No comments:
Post a Comment