View Single Post
Posts: 8 | Thanked: 3 times | Joined on Nov 2009 @ Finland
#102
Originally Posted by econan View Post
Then I used some rrdtools to chart.
And here's a script that uses gnuplot (available in extras-devel):
Code:
#!/bin/sh
# plot.sh -- for n900
# pyllyukko at maimed dot org -- 18.1.2010
[ ! -x /usr/bin/gnuplot ] && {
  echo "error: no gnuplot!" 1>&2
  exit 1
}
[ -n "${1}" ] && INFILE="${1}" || INFILE="/root/battery.log"
[ ! -f "${INFILE}" ] && {
  echo "error: input file \`${INFILE}' does not exist!" 1>&2
  exit 1
}
PIC_DIR="/home/user/MyDocs/.images"
NOW=$(date +%s)
TODATE=$(date +%Y%m%d)
# BEFORE = 24 hours ago
BEFORE=$((${NOW}-60*60*24))
gnuplot -persist <<-EOP
        set terminal png
        set output "${PIC_DIR}/battery-${TODATE}.png"
        set title "n900 battery status"
        set xdata time
        set nokey
        set timefmt "%s"
        # enable this to plot only the last 24 hours
        #set xrange ["${BEFORE}":]
        set yrange [0:]
        set xlabel "time"
        set ylabel "mAh"
        set y2label "load avg"
        set y2tics
        plot "${INFILE}" using 1:2 with lines,\
             "${INFILE}" using 1:6 axes x1y2 with lines
EOP
exit 0
To create graphs like this:
 

The Following User Says Thank You to pyllyukko For This Useful Post: