1 | 1 | simandl | #!/bin/bash |
2 | | | |
3 | | | if [ $# -lt 4 ] |
4 | | | then |
5 | | | echo "Usage: `basename $0` <time interval> <file suffix> <graph comment> [graph width]" |
6 | | | exit 1; |
7 | | | fi |
8 | | | |
9 | | | name=teplota |
10 | | | timediff=$1 |
11 | | | suffix=$2 |
12 | | | popis=$3 |
13 | | | |
14 | | | if [ $# -ge 4 ] |
15 | | | then |
16 | | | width=$4 |
17 | | | else |
18 | | | width=400 |
19 | | | fi |
20 | | | |
21 | | | #PATH=$PATH:/opt/rrdtool/bin |
22 | | | |
23 | | | datadir="/var/statistiky/system" |
24 | | | target_img_dir="/var/www/heaven/stat/img" |
25 | | | |
26 | | | cd $datadir |
27 | | | |
28 | | | now=`date +%s` |
29 | | | |
30 | | | xgridstr="" |
31 | | | if [ $timediff -gt 108000 ]; then xgridstr="--x-grid HOUR:6:DAY:1:DAY:1:86400:%d.%m."; fi |
32 | | | if [ $timediff -gt 777600 ]; then xgridstr="--x-grid DAY:1:WEEK:1:WEEK:1:86400:%d.%m."; fi |
33 | | | |
34 | | | |
35 | | | |
36 | | | function temp_prime_nekonsolidovane_hodnoty() |
37 | | | { |
38 | | | rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \ |
39 | | | DEF:hdd_avg=${name}.rrd:hdd_temp:AVERAGE \ |
40 | | | HRULE:40#000000 \ |
41 | | | LINE2:hdd_avg#202020:"HDD" \ |
42 | | | --vertical-label "Teplota [st.C]" \ |
43 | | | --height 200 \ |
44 | | | --width ${width} \ |
45 | | | ${xgridstr} \ |
46 | | | --title "${name} ${popis}" \ |
47 | | | --lower-limit 0 |
48 | | | } |
49 | | | |
50 | | | if [ true ] |
51 | | | then |
52 | | | temp_prime_nekonsolidovane_hodnoty |
53 | | | else |
54 | | | temp_prime_nekonsolidovane_hodnoty |
55 | | | fi |