Un script de shell para trazar los tres campos promedio de carga de CPL de una lista de archivos de registro superiores.
#!/bin/sh -u
# $0 [list of atop logfiles to plot]
# Plot the three CPL load average numbers from a list of atop log files.
# Uses a default atop log file if no arguments given.
# -Ian! D. Allen - [email protected] - www.idallen.com
if [ $# -eq 0 ] ; then
set -- '/var/log/atop.log'
fi
tmp=/tmp/atop$$
rm -f $tmp
trap "rm -f $tmp" 0 1 2
title=''
for log do
if [ ! -s "$log" -o ! -r "$log" ] ; then
echo 1>&2 "$0: $log: empty or unreadable - skipping"
continue
fi
atop -PCPL -r "$log" >>$tmp || exit $?
title="$title ${log##*/}"
done
if [ ! -s "$tmp" ] ; then
echo 1>&2 "$0: No files plotted"
exit 1
fi
len=${#title}
if [ $len -le 80 ] ; then
title="Three CPL load averages from atop -PCPL\n$title"
else
title="Three CPL load averages from atop -PCPL\n$(printf "%.77s..." "$title")"
fi
gnuplot -persist <<EOF
set xdata time
set timefmt '%Y/%m/%d %H:%M:%S'
set format x "%Y\n%m/%d\n%H:%M"
set grid
set title noenhanced
set title "$title"
plot \
"$tmp" using 4:8 notitle 'L1+' with points lc rgbcolor 'blue', \
"$tmp" using 4:8 title 'L1+' smooth csplines lc rgbcolor 'blue', \
"$tmp" using 4:9 notitle 'L2*' with points lc rgbcolor 'green', \
"$tmp" using 4:9 title 'L2*' smooth csplines lc rgbcolor 'green', \
"$tmp" using 4:10 notitle 'L3x'with points lc rgbcolor 'red', \
"$tmp" using 4:10 title 'L3x' smooth csplines lc rgbcolor 'red', \
;
EOF