Browse code

revisions

Jeff Owrey authored on 02/09/2016 04:57:21
Showing 2 changed files
... ...
@@ -32,8 +32,10 @@ import subprocess
32 32
 
33 33
     ### DEFINE FILE LOCATIONS ###
34 34
 
35
-_RRD_FILE = "/home/{user}/database/radmonData.rrd"  # the file that stores the data
35
+_USER = os.environ['USER']
36
+_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # the file that stores the data
36 37
 _RRD_SIZE_IN_DAYS = 370 # days
38
+_1YR_RRA_STEPS_PER_DAY = 96
37 39
 _DATABASE_UPDATE_INTERVAL = 30
38 40
 
39 41
 def createRrdFile():
... ...
@@ -46,21 +48,19 @@ def createRrdFile():
46 48
         print "rrdtool radiation database file already exists"
47 49
         return True
48 50
 
49
-    dbUpdateInterval = _DATABASE_UPDATE_INTERVAL  # rrd update step in seconds
50
-    rrd1yearSteps = 30 # steps per day for longer time periods
51
-
52
-    dataItemEpochTime = long(time.mktime(time.localtime())) 
53
-    rrdfileStartTime = dataItemEpochTime - 10
54
-    heartBeat = 2 * dbUpdateInterval
55
-    rrd24hrRows = int(86400 / dbUpdateInterval)
56
-    rrd1yearRows = int(3600 * 24 * _RRD_SIZE_IN_DAYS / (dbUpdateInterval * rrd1yearSteps))
51
+     ## Calculate database size
52
+ 
53
+    heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
54
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * _DATABASE_UPDATE_INTERVAL)))
55
+    rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
56
+    rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
57 57
        
58
-    strFmt = ("rrdtool create %s --start %s --step %s "
58
+    strFmt = ("rrdtool create %s --step %s "
59 59
                "DS:CPM:GAUGE:%s:U:U DS:SvperHr:GAUGE:%s:U:U "
60 60
                "RRA:AVERAGE:0.5:1:%s RRA:AVERAGE:0.5:%s:%s")
61 61
 
62
-    strCmd = strFmt % (_RRD_FILE, rrdfileStartTime, dbUpdateInterval, \
63
-                heartBeat, heartBeat, rrd24hrRows, rrd1yearSteps, rrd1yearRows)
62
+    strCmd = strFmt % (_RRD_FILE, _DATABASE_UPDATE_INTERVAL, \
63
+                heartBeat, heartBeat, rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
64 64
 
65 65
     print "creating rrdtool radiation database...\n\n%s\n" % strCmd
66 66
 
... ...
@@ -1,7 +1,8 @@
1 1
 #!/bin/bash
2 2
 #
3
-APP_PATH="/home/{user}/bin"
4
-LOG_PATH="/home/{user}/log"
3
+
4
+APP_PATH="/home/$USER/bin"
5
+LOG_PATH="/home/$USER/log"
5 6
 
6 7
 PROCESS_ID="$(ps x | awk '/[r]admonAgent.py/{print $1}')"
7 8
 
... ...
@@ -12,5 +13,5 @@ if [ -n "$PROCESS_ID" ]; then
12 13
 else
13 14
   printf "starting up radmon agent\n"
14 15
   cd $APP_PATH
15
-  ./radmonAgent.py -t 10 -u 'http://73.157.139.23:4371/jsdata' >> $LOG_PATH/radmonAgent.log 2>&1 &
16
+  ./radmonAgent.py -t 10 -u 'http://73.157.139.23:4371' >> $LOG_PATH/radmonAgent.log 2>&1 &
16 17
 fi