Skip to content

Commit

Permalink
graphing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
avleen committed Apr 8, 2012
1 parent 3538cb5 commit cfac1c4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
45 changes: 45 additions & 0 deletions htdocs/cgi-bin/make_registrations_graph.sh
@@ -0,0 +1,45 @@
#!/bin/bash

SQL="select count(*), date_trunc('day', to_timestamp(create_date)) as create_dated from user_registration group by create_dated order by create_dated;"
result=$( echo ${SQL} | psql -qtU postgres -d tornadowatch | awk '{ print $1, $3 }' | grep 2012 )
start=$( echo "${result}" | head -n1 | awk '{print $2}' )
end=$( echo "${result}" | tail -n1 | awk '{print $2}' )
echo "${result}" > /tmp/reg.dat
cat > /tmp/reg.plt<<EOF
set terminal png size 600,400
set xdata time
set timefmt "%Y-%m-%d"
set format x "%m/%d"
set output "/www/silverwraith.com/canonical/tw.silverwraith.com/htdocs/user_registrations_daily.png"
# time range must be in same format as data file
set xrange ["${start}":"${end}"]
#set yrange [0:50]
set grid
set xlabel "Date\\nTime"
set ylabel "Users"
set title "User registrations"
set key left box
plot "/tmp/reg.dat" using 2:1 index 0 title "User registrations" with lines
EOF
cat /tmp/reg.plt | gnuplot

SQL="select count(*), date_part('hour', to_timestamp(create_date)) as create_dated from user_registration group by create_dated order by create_dated;"
result=$( echo ${SQL} | psql -qtU postgres -d tornadowatch | awk '{ print $1, $3 }' | grep "[0-9]" )
echo "${result}" > /tmp/reg.dat
cat > /tmp/reg.plt<<EOF
set terminal png size 600,400
set xdata time
set timefmt "%H"
set format x "%H"
set output "/www/silverwraith.com/canonical/tw.silverwraith.com/htdocs/user_registrations_hourly.png"
# time range must be in same format as data file
set xrange ["0":"23"]
#set yrange [0:50]
set grid
set xlabel "Hour of day"
set ylabel "Users"
set title "User registrations"
set key left box
plot "/tmp/reg.dat" using 2:1 index 0 title "User registrations" with lines
EOF
cat /tmp/reg.plt | gnuplot
13 changes: 13 additions & 0 deletions htdocs/plot-registrations.conf
@@ -0,0 +1,13 @@
set terminal png size 1200,800
set xdata time
set timefmt "%s"
set output "/www/silverwraith.com/canonical/tw.silverwraith.com/htdocs/load.png"
# time range must be in same format as data file
#set xrange ["1331601802":"1332375229"
set yrange [0:50]
set grid
set xlabel "Date\\nTime"
set ylabel "Users"
set title "User registrations"
set key left box
plot "load.dat" using 1:2 index 0 title "ahost" with lines

0 comments on commit cfac1c4

Please sign in to comment.