向gnuplot awk脚本添加条件 [英] adding conditions to a gnuplot awk script

查看:86
本文介绍了向gnuplot awk脚本添加条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在社区的大量帮助下,我设法使用以下脚本将 rebootlogfile.log 中的图形转换为图形

With lots of help from the community I have managed to get a graph from rebootlogfile.log into a graph using the script below

command.gpl

 set terminal png size 2000,600
    set output '/usr/src/scripts/plots/core_temp_data/output.png'


    set size ratio 0.4
    set xdata time
    set timefmt "%H:%M:%S"

    plot "<awk '{print $4, substr($0,match($0,/temp=[0-9.]+/)+5,RLENGTH-5)}' /var/log/rebootlogfile.log" using 1:2 with lines

我使用

gnuplot /usr/src/scripts/plots/core_temp_data/command.gpl

这给了我

数据是一个巨大的文件,看起来像下面的样子,但是在多天内有更多行,而不仅仅是星期六(Sat)在这里打印:

the data is a huge file which looks like below but with many more lines over multiple days not just Sat as printed here:

Sat Sep 20 18:10:02 BST 2014 -- temp=57.3'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:11:01 BST 2014 -- temp=57.3'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:12:01 BST 2014 -- temp=57.8'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:13:01 BST 2014 -- temp=57.3'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:14:02 BST 2014 -- temp=58.4'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:15:01 BST 2014 -- temp=57.8'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:16:01 BST 2014 -- temp=57.3'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:16:02 BST 2014 -- WiFi seems stuck, rebooting - message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:17:18 BST 2014 -- temp=57.3'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:18:02 BST 2014 -- temp=58.4'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:19:01 BST 2014 -- temp=58.4'C -- message from script /usr/src/scripts/wifi_test_2.sh
Sat Sep 20 18:20:01 BST 2014 -- temp=58.9'C -- message from script /usr/src/scripts/wifi_test_2.sh

  1. 如何修改awk命令以仅打印出"sun"?我已经尝试修改if语句问题1 此处,但出现语法错误.

我如何在第三列上绘制零或黑线,或用于标识"wifi似乎卡住"的东西

How can I plot on a third column a zero or a black line, or something to identify "wifi seems stuck"

这就是我(从22日星期一开始的24小时)从数据表上获取的数据:

this is what I'm after (24 hrs of Mon 22) taken from a spreadsheet chart on the data:

我在想这样的事情:

plot "<awk 'if ($1 == 'Sat') {print $4, substr($0,match($0,/temp=[0-9.]+/)+5,RLENGTH-5)}' /var/log/rebootlogfile.log" using 1:2 with points

但是当我运行它时,我会得到x range is invalid.

but when I run it I get x range is invalid.

推荐答案

感谢安德拉斯(Andyras)向我指出了正确的方向.我正在尝试对awk命令未输出的列进行grep.经过进一步的搜索,我偶然发现了 awk中的条件和宾果游戏!此命令有效!

Thanks to andyras for pointing me in the correct direction. I was trying to grep a column that wasn't being outputted from the awk command. After further searching I stumbled on conditions in awk and bingo! This command worked!

plot "<awk '/Mon/ {print $4, substr($0,match($0,/temp=[0-9.]+/)+5,RLENGTH-5)}' /var/log/rebootlogfile.log" using 1:2 with points

这篇关于向gnuplot awk脚本添加条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆