开发者

LogParser get results from last hour

I have cpu monitors constantly workning on my comp开发者_JAVA技巧uter. I would like log parser to parse results only from the last hour. does anyone know how to do that?

SELECT TO_STRING(QUANTIZE(TO_TIMESTAMP(Field1, 'mm/dd/yyyy HH:mm:ss.ll'),10 ), 'hh:mm:ss') AS Time, AVG(TO_REAL(Field2)) AS Cpu
INTO .\output\cpu.csv
FROM .\logs\*.csv   
WHERE Time >= SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-02', 'yyyy-MM-dd') )

the last line results with an error. does anyone know how can i do that? thanks!


Your WHERE clause is wrong; instead of pulling 1 hour, you're pulling 1 day.

The following worked on IIS logs:

SELECT TO_STRING(QUANTIZE(TO_TIMESTAMP(date, time),10 ), 'hh:mm:ss') AS Time
INTO asdf.csv
FROM W3SVC5\*ex*.log
WHERE TO_LOCALTIME(TO_TIMESTAMP(date, time)) >= SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-01 01:00', 'yyyy-MM-dd HH:mm') )

For your particular case you should be safe just using this bit of the WHERE clause:

SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-01 01:00', 'yyyy-MM-dd HH:mm') )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜