5

I just discovered 'atop'. This is a fantastic tool for identifying performance bottlenecks in Linux. It supports a long term monitoring mode, in which it logs data to a binary log.

I would like to be able to visualize these data in a graph. Is this possible? If so, how?

I cannot seem to find out what format the log is saved in. It is binary, but nothing that 'file' will detect.

1
  • +1 atopsar (which comes with atop) is a half-way there. It displays any wanted metric vs time. What remains is just to plot these time series. A general solution to this with a web interface would be cool to have. The accepted answer while great, doesn't go all the way towards a full solution. – arielf May 15 '16 at 21:18
7

A shell script to plot the three CPL load average fields from a list of atop log files.

#!/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 - idallen@idallen.ca - 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
15
  • I have just tried this, but nothing happened. I ran ./plot-atop.sh /var/log/atop/atop_20140225 And it just returned. No plot was shown. I tried with -x and the trace is as follows: + log=/var/log/atop/atop_20140225 + tmp=/tmp/atop24693 + rm -f /tmp/atop24693 + trap rm -f /tmp/atop24693 0 1 2 + atop -PCPL -r /var/log/atop/atop_20140225 + gnuplot -persist + rm -f /tmp/atop24693 – Thomas Feb 26 '14 at 13:39
  • Try these: wc /var/log/atop.log and echo $DISPLAY and atop -PCPL -r /var/log/atop.log | wc – Ian D. Allen Feb 27 '14 at 16:17
  • ~ $ wc /var/log/atop.log wc: /var/log/atop.log: No such file or directory ~ $ wc /var/log/atop/atop_20140120 10687 51924 2834046 /var/log/atop/atop_20140120 ~ $ echo $DISPLAY :0 Full properly formatted output here: paste.yt/p2863.html How do I format code in a comment? – Thomas Feb 27 '14 at 20:27
  • You need to give my script an atop log file that exists and is not empty. You click on the help button to learn how to format. – Ian D. Allen Feb 28 '14 at 21:36
  • 1
    Then the problem isn't my script; it's your gnuplot. Get that working first. – Ian D. Allen Mar 18 '14 at 8:03
0

The man pages (man atop) provide good information on how to look at the raw log files. Atop itself provides viewing facilities, with the option of generating "parseable output" which you could then use to generate a visualisation. So, just look at man atop and search for this term by entering: \PARSEABLE OUTPUT

1
  • You search in man pages using /PARSEABLE not \PARSEABLE -- see the man page for the less program or use the h or ? key to bring up the HELP screen while viewing the man page itself. – Ian D. Allen Jan 28 '14 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.