/
message-fax-graph
executable file
·58 lines (47 loc) · 1.82 KB
/
message-fax-graph
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# message-fax-graph
# Plot graph of WriteToThem fax send creation rate.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
#
# $Id: message-fax-graph,v 1.3 2009-10-28 16:00:08 louise Exp $
GPLOT_OUTPUT="set terminal png font 'Vera.ttf' 9 size 1200,600"
EXTENSION=".png"
#GPLOT_OUTPUT="set terminal fig color big thickness 1"
#EXTENSION=".fig"
#GPLOT_OUTPUT="set terminal svg size 800 250"
#EXTENSION=".svg"
cd `dirname $0`
cd ../../
source writetothem/commonlib/shlib/deployfns
read_conf writetothem/conf/general
SOURCEO=/tmp/fyr-fax-rate-graph-data-$RANDOM$RANDOM
GPSCRIPT=/tmp/fyr-fax-rate-graph-script-$RANDOM$RANDOM
echo "select
date('1970-1-1 00:00:00'::timestamp + (created||' seconds')::interval), count(*)
from message
where state not in ('new', 'pending')
and recipient_fax is not null
group by
date('1970-1-1 00:00:00'::timestamp + (created||' seconds')::interval)
order by
date('1970-1-1 00:00:00'::timestamp + (created||' seconds')::interval)
;" | psql --host $OPTION_FYR_QUEUE_DB_HOST --port $OPTION_FYR_QUEUE_DB_PORT -A -F " " $OPTION_FYR_QUEUE_DB_NAME $OPTION_FYR_QUEUE_DB_USER | egrep -v "date|rows" >$SOURCEO
#echo "source $SOURCEO"
cat >$GPSCRIPT <<END
unset border
$GPLOT_OUTPUT
set xdata time;
set timefmt "%Y-%m-%d";
set format x "%b %Y"
unset xlabel
set ylabel "faxes created / calendar day (confirmed)"
set xtics nomirror
set ytics nomirror
n = 0
plot "$SOURCEO" using 1:2 with lines axes x1y2 lt 3 title "faxes"
# "< awk 'BEGIN { n = 0 } { n += \$2; print \$1, \$2, n; }' $SOURCE" using 1:3 with lines lt 2 title "cumulative messages created",
END
#echo "gpscript $GPSCRIPT"
export GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera
gnuplot < $GPSCRIPT > writetothem/web/fyr-live-faxes$EXTENSION