Browse code

minor revision

Gandolf authored on 07/06/2021 21:30:56
Showing 1 changed files
... ...
@@ -24,16 +24,21 @@
24 24
 #    along with this program.  If not, see http://www.gnu.org/license.
25 25
 #
26 26
 # Revision History
27
-#   * v10 released 15 Sep 2015 by J L Owrey
27
+#   * v11 released 24 Jul 2018 by J L Owrey
28 28
 #
29
+# Example of rrdtool command line executed by this program:
30
+#
31
+#   rrdtool create radmonData.rrd --step 30 DS:CPM:GAUGE:60:U:U
32
+#   DS:SvperHr:GAUGE:60:U:U RRA:LAST:0.5:1:2880 RRA:LAST:0.5:30:35520
33
+#
34
+
29 35
 import os
30
-import time
31 36
 import subprocess
32 37
 
33 38
     ### DEFINE FILE LOCATIONS ###
34 39
 
35 40
 _USER = os.environ['USER']
36
-_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # the file that stores the data
41
+_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # rrd database file
37 42
 _RRD_SIZE_IN_DAYS = 370 # days
38 43
 _1YR_RRA_STEPS_PER_DAY = 96
39 44
 _DATABASE_UPDATE_INTERVAL = 30
... ...
@@ -51,7 +56,8 @@ def createRrdFile():
51 56
      ## Calculate database size
52 57
  
53 58
     heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
54
-    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * _DATABASE_UPDATE_INTERVAL)))
59
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
60
+                        _DATABASE_UPDATE_INTERVAL)))
55 61
     rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
56 62
     rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
57 63
        
... ...
@@ -69,8 +75,7 @@ def createRrdFile():
69 75
         subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
70 76
                                 shell=True)
71 77
     except subprocess.CalledProcessError, exError:
72
-        print "%s rrdtool create failed: %s" % \
73
-                            (getTimeStamp(), exError.output)
78
+        print "rrdtool create failed: %s" % (exError.output)
74 79
         return False
75 80
     return True
76 81
 ##end def
Browse code

minor revisions

Gandolf authored on 10/04/2020 05:03:10
Showing 1 changed files
... ...
@@ -9,7 +9,7 @@
9 9
 # database to generate graphic charts for display in the weather station
10 10
 # web page.
11 11
 #
12
-# Copyright 2018 Jeff Owrey
12
+# Copyright 2014 Jeff Owrey
13 13
 #    This program is free software: you can redistribute it and/or modify
14 14
 #    it under the terms of the GNU General Public License as published by
15 15
 #    the Free Software Foundation, either version 3 of the License, or
... ...
@@ -24,21 +24,16 @@
24 24
 #    along with this program.  If not, see http://www.gnu.org/license.
25 25
 #
26 26
 # Revision History
27
-#   * v11 released 24 Jul 2018 by J L Owrey
27
+#   * v10 released 15 Sep 2015 by J L Owrey
28 28
 #
29
-# Example of rrdtool command line executed by this program:
30
-#
31
-#   rrdtool create radmonData.rrd --step 30 DS:CPM:GAUGE:60:U:U
32
-#   DS:SvperHr:GAUGE:60:U:U RRA:LAST:0.5:1:2880 RRA:LAST:0.5:30:35520
33
-#
34
-
35 29
 import os
30
+import time
36 31
 import subprocess
37 32
 
38 33
     ### DEFINE FILE LOCATIONS ###
39 34
 
40 35
 _USER = os.environ['USER']
41
-_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # rrd database file
36
+_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # the file that stores the data
42 37
 _RRD_SIZE_IN_DAYS = 370 # days
43 38
 _1YR_RRA_STEPS_PER_DAY = 96
44 39
 _DATABASE_UPDATE_INTERVAL = 30
... ...
@@ -56,8 +51,7 @@ def createRrdFile():
56 51
      ## Calculate database size
57 52
  
58 53
     heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
59
-    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
60
-                        _DATABASE_UPDATE_INTERVAL)))
54
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * _DATABASE_UPDATE_INTERVAL)))
61 55
     rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
62 56
     rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
63 57
        
... ...
@@ -75,7 +69,8 @@ def createRrdFile():
75 69
         subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
76 70
                                 shell=True)
77 71
     except subprocess.CalledProcessError, exError:
78
-        print "rrdtool create failed: %s" % (exError.output)
72
+        print "%s rrdtool create failed: %s" % \
73
+                            (getTimeStamp(), exError.output)
79 74
         return False
80 75
     return True
81 76
 ##end def
Browse code

sync 2018-07-27

fractalxaos authored on 07/27/2018 19:27:41
Showing 1 changed files
... ...
@@ -9,7 +9,7 @@
9 9
 # database to generate graphic charts for display in the weather station
10 10
 # web page.
11 11
 #
12
-# Copyright 2014 Jeff Owrey
12
+# Copyright 2018 Jeff Owrey
13 13
 #    This program is free software: you can redistribute it and/or modify
14 14
 #    it under the terms of the GNU General Public License as published by
15 15
 #    the Free Software Foundation, either version 3 of the License, or
Browse code

revisions 2018-07-24

fractalxaos authored on 07/24/2018 19:19:53
Showing 1 changed files
1 1
old mode 100644
2 2
new mode 100755
... ...
@@ -24,16 +24,21 @@
24 24
 #    along with this program.  If not, see http://www.gnu.org/license.
25 25
 #
26 26
 # Revision History
27
-#   * v10 released 15 Sep 2015 by J L Owrey
27
+#   * v11 released 24 Jul 2018 by J L Owrey
28 28
 #
29
+# Example of rrdtool command line executed by this program:
30
+#
31
+#   rrdtool create radmonData.rrd --step 30 DS:CPM:GAUGE:60:U:U
32
+#   DS:SvperHr:GAUGE:60:U:U RRA:LAST:0.5:1:2880 RRA:LAST:0.5:30:35520
33
+#
34
+
29 35
 import os
30
-import time
31 36
 import subprocess
32 37
 
33 38
     ### DEFINE FILE LOCATIONS ###
34 39
 
35 40
 _USER = os.environ['USER']
36
-_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # the file that stores the data
41
+_RRD_FILE = "/home/%s/database/radmonData.rrd" % _USER  # rrd database file
37 42
 _RRD_SIZE_IN_DAYS = 370 # days
38 43
 _1YR_RRA_STEPS_PER_DAY = 96
39 44
 _DATABASE_UPDATE_INTERVAL = 30
... ...
@@ -51,7 +56,8 @@ def createRrdFile():
51 56
      ## Calculate database size
52 57
  
53 58
     heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
54
-    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * _DATABASE_UPDATE_INTERVAL)))
59
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
60
+                        _DATABASE_UPDATE_INTERVAL)))
55 61
     rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
56 62
     rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
57 63
        
... ...
@@ -69,8 +75,7 @@ def createRrdFile():
69 75
         subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
70 76
                                 shell=True)
71 77
     except subprocess.CalledProcessError, exError:
72
-        print "%s rrdtool create failed: %s" % \
73
-                            (getTimeStamp(), exError.output)
78
+        print "rrdtool create failed: %s" % (exError.output)
74 79
         return False
75 80
     return True
76 81
 ##end def
Browse code

revisions

Jeff Owrey authored on 02/09/2016 05:20:52
Showing 1 changed files
... ...
@@ -57,7 +57,7 @@ def createRrdFile():
57 57
        
58 58
     strFmt = ("rrdtool create %s --step %s "
59 59
                "DS:CPM:GAUGE:%s:U:U DS:SvperHr:GAUGE:%s:U:U "
60
-               "RRA:AVERAGE:0.5:1:%s RRA:AVERAGE:0.5:%s:%s")
60
+               "RRA:LAST:0.5:1:%s RRA:LAST:0.5:%s:%s")
61 61
 
62 62
     strCmd = strFmt % (_RRD_FILE, _DATABASE_UPDATE_INTERVAL, \
63 63
                 heartBeat, heartBeat, rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
Browse code

revisions

Jeff Owrey authored on 02/09/2016 04:57:21
Showing 1 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
 
Browse code

bug fix 20151227

Jeff Owrey authored on 12/28/2015 02:58:35
Showing 1 changed files
... ...
@@ -32,7 +32,7 @@ import subprocess
32 32
 
33 33
     ### DEFINE FILE LOCATIONS ###
34 34
 
35
-_RRD_FILE = "/home/pi/database/radmonData.rrd"  # the file that stores the data
35
+_RRD_FILE = "/home/{user}/database/radmonData.rrd"  # the file that stores the data
36 36
 _RRD_SIZE_IN_DAYS = 370 # days
37 37
 _DATABASE_UPDATE_INTERVAL = 30
38 38
 
Browse code

first release

Jeff Owrey authored on 09/25/2015 03:44:17
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,84 @@
1
+#!/usr/bin/python -u
2
+## The -u option above turns off block buffering of python output. This assures
3
+## that each error message gets individually printed to the log file.
4
+#
5
+# Module: createRadmonRrd.py
6
+#
7
+# Description: Creates a rrdtool database for use by the weather agent to
8
+# store the data from the weather station.  The agent uses the data in the
9
+# database to generate graphic charts for display in the weather station
10
+# web page.
11
+#
12
+# Copyright 2014 Jeff Owrey
13
+#    This program is free software: you can redistribute it and/or modify
14
+#    it under the terms of the GNU General Public License as published by
15
+#    the Free Software Foundation, either version 3 of the License, or
16
+#    (at your option) any later version.
17
+#
18
+#    This program is distributed in the hope that it will be useful,
19
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+#    GNU General Public License for more details.
22
+#
23
+#    You should have received a copy of the GNU General Public License
24
+#    along with this program.  If not, see http://www.gnu.org/license.
25
+#
26
+# Revision History
27
+#   * v10 released 15 Sep 2015 by J L Owrey
28
+#
29
+import os
30
+import time
31
+import subprocess
32
+
33
+    ### DEFINE FILE LOCATIONS ###
34
+
35
+_RRD_FILE = "/home/pi/database/radmonData.rrd"  # the file that stores the data
36
+_RRD_SIZE_IN_DAYS = 370 # days
37
+_DATABASE_UPDATE_INTERVAL = 30
38
+
39
+def createRrdFile():
40
+    """Create the rrd file if it does not exist.
41
+       Parameters: none
42
+       Returns: True, if successful
43
+    """
44
+
45
+    if os.path.exists(_RRD_FILE):
46
+        print "rrdtool radiation database file already exists"
47
+        return True
48
+
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))
57
+       
58
+    strFmt = ("rrdtool create %s --start %s --step %s "
59
+               "DS:CPM:GAUGE:%s:U:U DS:SvperHr:GAUGE:%s:U:U "
60
+               "RRA:AVERAGE:0.5:1:%s RRA:AVERAGE:0.5:%s:%s")
61
+
62
+    strCmd = strFmt % (_RRD_FILE, rrdfileStartTime, dbUpdateInterval, \
63
+                heartBeat, heartBeat, rrd24hrRows, rrd1yearSteps, rrd1yearRows)
64
+
65
+    print "creating rrdtool radiation database...\n\n%s\n" % strCmd
66
+
67
+    # Spawn a sub-shell and run the command
68
+    try:
69
+        subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
70
+                                shell=True)
71
+    except subprocess.CalledProcessError, exError:
72
+        print "%s rrdtool create failed: %s" % \
73
+                            (getTimeStamp(), exError.output)
74
+        return False
75
+    return True
76
+##end def
77
+
78
+def main():
79
+    createRrdFile()
80
+## end def
81
+
82
+if __name__ == '__main__':
83
+    main()
84
+