понедельник, 30 января 2017 г.

gnuplot Load CPU bash

#!/bin/bash

FILE="/tmp/sys_load_cpu_gnuplot_h"
echo " проверка файла..."
if [ -f $FILE ]; then
echo " файл найден..." # файл есть
MAX=(62)
TMP=`cat /tmp/sys_load_cpu_gnuplot_h | wc -l`
echo " $TMP"
if [ $TMP -ge $MAX ]; then
echo " файл 62 и более строк!" # в файле 23 и более строк
truncate -s 0 /tmp/sys_load_cpu_gnuplot_h
echo "`date +%d-%m` `date +%H:%M` `awk '{print $2}' /proc/loadavg`" >> /tmp/sys_load_cpu_gnuplot_h
# # # # # # # # # # #
gnuplot << EOP

datafile = "/tmp/sys_load_cpu_gnuplot_h"
set terminal jpeg font arial 14 size 1600,1200
set output "/var/www/html/sys_load_cpu_h.jpg"
set ytics 0.05 border rangelimited mirror
set y2tics 0.05 border nomirror
set border 3
set yrange [0:*]
set ylabel "Load CPU"
set timefmt "%d-%m %H:%M"
set xdata time
set style line 1 lc rgb 'red' lt 2 lw 2
set style data histogram
set style histogram cluster gap 1
set style fill pattern border -1
set xtics rotate by 0 rangelimited 1*300 # 1*3600
set mxtics 3 #a small tic every five minute
set format x "%d-%m\n%H:%M" #set format x was needed to format the x axis as hh:mm, not hh:mm:ss
set grid x y y2 layerdefault linecolor rgb "gray" linewidth 4.0 dashtype solid, linecolor rgb "gray" linewidth 4.0 dashtype "."
set title "Load CPU (H)" font "Times-Roman,35"
plot datafile using 1:3 title 'Load CPU (H)' with lines lw 4 lt rgb "red"

EOP
# # # # # # # # # # #
else
echo " файл менее 62 строк" # в файле менее 23 строк
echo "`date +%d-%m` `date +%H:%M` `awk '{print $2}' /proc/loadavg`" >> /tmp/sys_load_cpu_gnuplot_h
FILE1="/tmp/sys_load_cpu_gnuplot_h"
echo " проверка файла..."
if [ -f $FILE1 ]; then
# файл есть
MAX=(62)
TMP1=`cat /tmp/sys_load_cpu_gnuplot_h | wc -l`
echo " $TMP1"
if [ $TMP -ge $MAX ]; then
# более 60
echo " удаляется 1-я строчка..."
sed -i '1d' /tmp/sys_load_cpu_gnuplot_h
fi
fi

# # # # # # # # # # #
gnuplot << EOP

datafile = "/tmp/sys_load_cpu_gnuplot_h"
set terminal jpeg font arial 14 size 1600,1200
set output "/var/www/html/sys_load_cpu_h.jpg"
set ytics 0.05 border rangelimited mirror
set y2tics 0.05 border nomirror
set border 3
set yrange [0:*]
set ylabel "Load CPU"
set timefmt "%d-%m %H:%M"
set xdata time
set style line 1 lc rgb 'red' lt 2 lw 2
set style data histogram
set style histogram cluster gap 1
set style fill pattern border -1
set xtics rotate by 0 rangelimited 1*300 # 1*3600
set mxtics 3 #a small tic every five minute
set format x "%d-%m\n%H:%M" #set format x was needed to format the x axis as hh:mm, not hh:mm:ss
set grid x y y2 layerdefault linecolor rgb "gray" linewidth 4.0 dashtype solid, linecolor rgb "gray" linewidth 4.0 dashtype "."
set title "Load CPU (H)" font "Times-Roman,35"
plot datafile using 1:3 title 'Load CPU (H)' with lines lw 4 lt rgb "red"

EOP
# # # # # # #
fi
else
echo " файл не найден!!!" # файла нет
echo "`date +%d-%m` `date +%H:%M` `awk '{print $2}' /proc/loadavg`" >> /tmp/sys_load_cpu_gnuplot_h
# # # # # # # # # # #
gnuplot << EOP

datafile = "/tmp/sys_load_cpu_gnuplot_h"
set terminal jpeg font arial 14 size 1600,1200
set output "/var/www/html/sys_load_cpu_h.jpg"
set ytics 0.05 border rangelimited mirror
set y2tics 0.05 border nomirror
set border 3
set yrange [0:*]
set ylabel "Load CPU"
set timefmt "%d-%m %H:%M"
set xdata time
set style line 1 lc rgb 'red' lt 2 lw 2
set style data histogram
set style histogram cluster gap 1
set style fill pattern border -1
set xtics rotate by 0 rangelimited 1*300 # 1*3600
set mxtics 3 #a small tic every five minute
set format x "%d-%m\n%H:%M" #set format x was needed to format the x axis as hh:mm, not hh:mm:ss
set grid x y y2 layerdefault linecolor rgb "gray" linewidth 4.0 dashtype solid, linecolor rgb "gray" linewidth 4.0 dashtype "."
set title "Load CPU (H)" font "Times-Roman,35"
plot datafile using 1:3 title 'Load CPU (H)' with lines lw 4 lt rgb "red"

EOP
# # # # # # #
fi

Комментариев нет:

Отправить комментарий

h265.sh

#!/bin/bash file="../mp4" if [ -d $file ]; then         echo "  Директория существует :-) "         for i in *.mp4; do f...