1 | 20 | simandl | #!/bin/bash |
2 | | | # chkconfig: 12345 55 45 |
3 | | | # description: System statistics |
4 | | | |
5 | 21 | simandl | #/etc/fstab line |
6 | | | #opt /opt tmpfs rw,size=128M,nodev,mode=0755 0 0 |
7 | | | |
8 | 20 | simandl | cd "/opt/HotSaNIC" |
9 | | | |
10 | | | . ./settings |
11 | | | |
12 | | | case $1 in |
13 | | | start) |
14 | 25 | simandl | echo "Saving rrdtimer folder into start backup..." |
15 | | | /bin/mount / -o remount,rw,noatime |
16 | | | archiv=/optbackup.tgz |
17 | | | tar cfz $archiv /opt/HotSaNIC |
18 | 20 | simandl | echo "Loading rrdtimer folder..." |
19 | | | posledni=`ls -c /opt_* | head -n 1 ` |
20 | | | cd "/" |
21 | | | tar xfz $posledni |
22 | | | cd "/opt/HotSaNIC" |
23 | | | |
24 | | | echo "Starting rrdtimer..." |
25 | | | ./rrdtimer.pl Dp |
26 | | | ;; |
27 | | | stop) |
28 | 24 | simandl | ./rrdgraph save |
29 | 20 | simandl | |
30 | | | echo "Stopping rrdtimer..." |
31 | | | if [ -e "$PIDFILE" ]; then |
32 | | | PID=`cat "$PIDFILE"` |
33 | | | for nn in $PID ; do kill $nn; done |
34 | | | else |
35 | | | echo "pid-file not found, rrdtimer not running?!" |
36 | | | fi |
37 | | | ./clearall CLEAR_COUNTERS |
38 | | | ;; |
39 | 24 | simandl | save) |
40 | | | echo "Saving rrdtimer folder..." |
41 | | | /bin/mount / -o remount,rw,noatime |
42 | | | datum=`date '+%Y%m%d%H%M%S'` |
43 | | | archiv=/opt_$datum.tgz |
44 | | | tar cfz $archiv /opt/HotSaNIC |
45 | | | /bin/mount / -o remount,ro,noatime |
46 | | | ;; |
47 | 20 | simandl | status) |
48 | | | if [ -e $PIDFILE ]; then |
49 | | | echo "main process on PID `cat $PIDFILE` (according to PID-file)" |
50 | | | else |
51 | | | echo "pid-file not found, rrdtimer not running?!" |
52 | | | fi |
53 | | | ;; |
54 | | | restart) |
55 | | | ./rrdgraph stop |
56 | | | ./rrdgraph start |
57 | | | ;; |
58 | | | *) |
59 | 24 | simandl | echo "usage: rrdgraph [start|stop|status|restart|save]" |
60 | 20 | simandl | ;; |
61 | | | esac |