亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 關(guān)于日志審查 [打印本頁]

作者: 豬鼻插蔥    時間: 2010-09-19 15:03
標題: 關(guān)于日志審查
我想做一個關(guān)于查詢?nèi)罩局性谝欢螘r間內(nèi)是否存在某一個字符串的工作 具體的日志形勢如下
Sep 19 09:39:19 localhost kernel: imklog 3.22.1, log source = /proc/kmsg started.
Sep 19 09:39:19 localhost rsyslogd: [origin software="rsyslogd" swVersion="3.22.1" x-pid="1565" x-info="http://www.rsyslog.com"] (re)start
Sep 19 09:47:36 localhost firefox: gethostby*.getanswer: asked for "vod.lzu.edu.cn.localdomain", got "wx.redirect.local"
Sep 19 09:47:36 localhost firefox: gethostby*.getanswer: asked for "vod.lzu.edu.cn", got "wx.redirect.local"
Sep 19 11:47:51 localhost kernel: npviewer.bin[7338] general protection ip:116f57c sp:bfddc9c0 error:0 in libflashplayer.so[dfd000+994000]
Sep 19 11:48:10 localhost firefox: gethostby*.getanswer: asked for "vod.lzu.edu.cn", got "wx.redirect.local"
Sep 19 11:49:25 localhost firefox: gethostby*.getanswer: asked for "vod.lzu.edu.cn", got "wx.redirect.local"
Sep 19 11:49:25 localhost firefox: gethostby*.getanswer: asked for "vod.lzu.edu.cn", got "wx.redirect.local"
Sep 19 12:28:35 localhost kernel: npviewer.bin[15863] general protection ip:116f57c sp:bfd1c2c0 error:0 in libflashplayer.so[dfd000+994000]


主要是需要指定處理的日志,開始和結(jié)束的時間,指定的字符串,檢查這段時間內(nèi)的日志中是否存在某一個指定的字符串,返回值為真或者假就可以。我是新手,不清楚怎么處理時間這段,各位能幫忙的就麻煩您幫個忙。
作者: 珞水的大叔    時間: 2010-09-19 16:45
發(fā)一段偽代碼:
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;


  4. sub checktime(){
  5.     #用這個函數(shù)來檢查時間是否在范圍內(nèi),如果是、返回1,如果不是返回0
  6.     #具體比較因為需求不太明朗,這里留空,請自行補充,呵呵
  7. }

  8. my $flag = 'false';
  9. open FH,"< 日志文件路徑";
  10. while(<FH>){
  11.     my $line = $_;
  12.     if($line =~ /^(.+?:\d\d:\d\d)/){
  13.         my $result = &checktime($1);  #這里$1里存放的就是時間,如:Sep 19 12:28:35
  14.         if($result > 0 && $line =~ /關(guān)鍵字/){
  15.             $flag = 'true';
  16.             next;
  17.         }
  18.     }
  19. }
  20. close FH;
  21. return $flag;
復制代碼

作者: 豬鼻插蔥    時間: 2010-09-20 09:09
{:3_200:}謝謝指點




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2