针对数据 gnuplot画图 初试
把數(shù)據(jù)畫成圖,是我一直想要達到的,今日研究gnuplot,小有成就,下面我只舉一個數(shù)據(jù)制圖的例子
比如我想畫個每小時nginx日志500錯的圖
需求:開啟一個http服務(wù),比如80端口
? ? web根目錄為/var/www/html
實施:
? ?1.先針對nginx日志進行分析
? ?grep \"\ 500 access.log|wc -l >>/opt/yanchao/500.txt
? ?2.編寫gnuplot腳本為
500zhitu.sh
set terminal png truecolor
set output "500.png" ? 輸出文件為
set autoscale ? ?
set key box
set key center at 20,150 ?表示位置
set xtics 1 ? ? ? ?x軸沒個點走多少
set ytics 50 ? ? ? ?y軸沒個點走多少
set yrange [0:1000] ?y軸坐標
set ylabel "500error" ? y軸注釋
set xrange [01:24] ? x軸坐標
set xlabel "Time" ? x軸注釋
set style data lines ?選擇線型
plot "/home/yanchao/500test5" using 1 w lp lc 3 lw 2 pt 7 ps 2 title "test" ?針對于什么進行畫圖,using 1代表針對第一列進行制圖 ?后面參數(shù)請查看參考手冊
? ?3.cat 500zhitu.sh|gnuplot
? ?4.訪問圖片
想要獲得動態(tài)圖片,請修改crontab 你們懂得 我就不多說了
當然樓主給單位做的比這個復(fù)雜很多,樓主致力于用shell搭建一個全面的日志分析,動態(tài)站點
轉(zhuǎn)載于:https://blog.51cto.com/darkyin/1624491
總結(jié)
以上是生活随笔為你收集整理的针对数据 gnuplot画图 初试的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: careercup-高等难度 18.5
- 下一篇: 编写一段代码,实现在控制台输入一组数据后