Browse code

minor revisions

Gandolf authored on 06/21/2021 21:24:25
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,89 @@
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: createArednsigRrd.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 2020 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 11 Jan 2020 by J L Owrey
28
+#
29
+import os
30
+import time
31
+import subprocess
32
+
33
+    ### DEFINE FILE LOCATIONS ###
34
+
35
+_USER = os.environ['USER']
36
+# the file that stores the data
37
+_RRD_FILE = "/home/%s/database/arednsigData.rrd" % _USER
38
+_RRD_SIZE_IN_DAYS = 370 # days
39
+_1YR_RRA_STEPS_PER_DAY = 96
40
+_DATABASE_UPDATE_INTERVAL = 60
41
+
42
+def createRrdFile():
43
+    """Create the rrd file if it does not exist.
44
+       Parameters: none
45
+       Returns: True, if successful
46
+    """
47
+
48
+    if os.path.exists(_RRD_FILE):
49
+        print "aredn node database already exists"
50
+        return True
51
+
52
+     ## Calculate database size
53
+ 
54
+    heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
55
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
56
+                    _DATABASE_UPDATE_INTERVAL)))
57
+    rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
58
+    rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
59
+       
60
+    strFmt = ("rrdtool create %s --start now-1day --step %s "
61
+              "DS:S:GAUGE:%s:U:U DS:N:GAUGE:%s:U:U DS:SNR:GAUGE:%s:U:U "
62
+              "DS:RX_MCS:GAUGE:%s:U:U DS:TX_MCS:GAUGE:%s:U:U "
63
+              "DS:RX_RATE:GAUGE:%s:U:U DS:TX_RATE:GAUGE:%s:U:U "
64
+              "RRA:LAST:0.5:1:%s RRA:LAST:0.5:%s:%s")
65
+
66
+    strCmd = strFmt % (_RRD_FILE, _DATABASE_UPDATE_INTERVAL, \
67
+                heartBeat, heartBeat, heartBeat, heartBeat,  \
68
+                heartBeat,  heartBeat, heartBeat,            \
69
+                rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
70
+
71
+    print "creating aredn node database...\n\n%s\n" % strCmd
72
+
73
+    # Spawn a sub-shell and run the command
74
+    try:
75
+        subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
76
+                                shell=True)
77
+    except subprocess.CalledProcessError, exError:
78
+        print "rrdtool create failed: %s" % (exError.output)
79
+        return False
80
+    return True
81
+##end def
82
+
83
+def main():
84
+    createRrdFile()
85
+## end def
86
+
87
+if __name__ == '__main__':
88
+    main()
89
+        
Browse code

support for Aredn FW v3.20.3.0

gandolf authored on 03/31/2020 17:37:45
Showing 1 changed files
1 1
deleted file mode 100755
... ...
@@ -1,89 +0,0 @@
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: createArednsigRrd.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 2020 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 11 Jan 2020 by J L Owrey
28
-#
29
-import os
30
-import time
31
-import subprocess
32
-
33
-    ### DEFINE FILE LOCATIONS ###
34
-
35
-_USER = os.environ['USER']
36
-# the file that stores the data
37
-_RRD_FILE = "/home/%s/database/arednsigData.rrd" % _USER
38
-_RRD_SIZE_IN_DAYS = 370 # days
39
-_1YR_RRA_STEPS_PER_DAY = 96
40
-_DATABASE_UPDATE_INTERVAL = 60
41
-
42
-def createRrdFile():
43
-    """Create the rrd file if it does not exist.
44
-       Parameters: none
45
-       Returns: True, if successful
46
-    """
47
-
48
-    if os.path.exists(_RRD_FILE):
49
-        print "aredn node database already exists"
50
-        return True
51
-
52
-     ## Calculate database size
53
- 
54
-    heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
55
-    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
56
-                    _DATABASE_UPDATE_INTERVAL)))
57
-    rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
58
-    rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
59
-       
60
-    strFmt = ("rrdtool create %s --start now-1day --step %s "
61
-              "DS:S:GAUGE:%s:U:U DS:N:GAUGE:%s:U:U DS:SNR:GAUGE:%s:U:U "
62
-              "DS:RX_MCS:GAUGE:%s:U:U DS:TX_MCS:GAUGE:%s:U:U "
63
-              "DS:RX_RATE:GAUGE:%s:U:U DS:TX_RATE:GAUGE:%s:U:U "
64
-              "RRA:LAST:0.5:1:%s RRA:LAST:0.5:%s:%s")
65
-
66
-    strCmd = strFmt % (_RRD_FILE, _DATABASE_UPDATE_INTERVAL, \
67
-                heartBeat, heartBeat, heartBeat, heartBeat,  \
68
-                heartBeat,  heartBeat, heartBeat,            \
69
-                rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
70
-
71
-    print "creating aredn node database...\n\n%s\n" % strCmd
72
-
73
-    # Spawn a sub-shell and run the command
74
-    try:
75
-        subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
76
-                                shell=True)
77
-    except subprocess.CalledProcessError, exError:
78
-        print "rrdtool create failed: %s" % (exError.output)
79
-        return False
80
-    return True
81
-##end def
82
-
83
-def main():
84
-    createRrdFile()
85
-## end def
86
-
87
-if __name__ == '__main__':
88
-    main()
89
-        
Browse code

custom charts added

gandolf authored on 01/17/2020 00:20:38
Showing 1 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 #!/usr/bin/python -u
2
-# The -u option above turns off block buffering of python output. This
3
-# assures that each error message gets individually printed to the
4
-# log file.
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.
5 4
 #
6 5
 # Module: createArednsigRrd.py
7 6
 #
... ...
@@ -27,7 +26,6 @@
27 26
 # Revision History
28 27
 #   * v10 released 11 Jan 2020 by J L Owrey
29 28
 #
30
-#2345678901234567890123456789012345678901234567890123456789012345678901234567890
31 29
 import os
32 30
 import time
33 31
 import subprocess
... ...
@@ -35,11 +33,8 @@ import subprocess
35 33
     ### DEFINE FILE LOCATIONS ###
36 34
 
37 35
 _USER = os.environ['USER']
38
-# the RRD file that stores the data
36
+# the file that stores the data
39 37
 _RRD_FILE = "/home/%s/database/arednsigData.rrd" % _USER
40
-
41
-    ### DEFINE DATABASE GRANULARITY AND TIME SPAN ###
42
-
43 38
 _RRD_SIZE_IN_DAYS = 370 # days
44 39
 _1YR_RRA_STEPS_PER_DAY = 96
45 40
 _DATABASE_UPDATE_INTERVAL = 60
... ...
@@ -49,6 +44,7 @@ def createRrdFile():
49 44
        Parameters: none
50 45
        Returns: True, if successful
51 46
     """
47
+
52 48
     if os.path.exists(_RRD_FILE):
53 49
         print "aredn node database already exists"
54 50
         return True
... ...
@@ -61,8 +57,6 @@ def createRrdFile():
61 57
     rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
62 58
     rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
63 59
        
64
-    ## Format rrdtool command to create RRD database
65
-     
66 60
     strFmt = ("rrdtool create %s --start now-1day --step %s "
67 61
               "DS:S:GAUGE:%s:U:U DS:N:GAUGE:%s:U:U DS:SNR:GAUGE:%s:U:U "
68 62
               "DS:RX_MCS:GAUGE:%s:U:U DS:TX_MCS:GAUGE:%s:U:U "
... ...
@@ -74,10 +68,9 @@ def createRrdFile():
74 68
                 heartBeat,  heartBeat, heartBeat,            \
75 69
                 rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
76 70
 
77
-    ## Run the command as a shell subprocess
78
-
79 71
     print "creating aredn node database...\n\n%s\n" % strCmd
80 72
 
73
+    # Spawn a sub-shell and run the command
81 74
     try:
82 75
         subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
83 76
                                 shell=True)
Browse code

initial release

gandolf authored on 01/13/2020 03:50:38
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,96 @@
1
+#!/usr/bin/python -u
2
+# The -u option above turns off block buffering of python output. This
3
+# assures that each error message gets individually printed to the
4
+# log file.
5
+#
6
+# Module: createArednsigRrd.py
7
+#
8
+# Description: Creates a rrdtool database for use by the weather agent to
9
+# store the data from the weather station.  The agent uses the data in the
10
+# database to generate graphic charts for display in the weather station
11
+# web page.
12
+#
13
+# Copyright 2020 Jeff Owrey
14
+#    This program is free software: you can redistribute it and/or modify
15
+#    it under the terms of the GNU General Public License as published by
16
+#    the Free Software Foundation, either version 3 of the License, or
17
+#    (at your option) any later version.
18
+#
19
+#    This program is distributed in the hope that it will be useful,
20
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+#    GNU General Public License for more details.
23
+#
24
+#    You should have received a copy of the GNU General Public License
25
+#    along with this program.  If not, see http://www.gnu.org/license.
26
+#
27
+# Revision History
28
+#   * v10 released 11 Jan 2020 by J L Owrey
29
+#
30
+#2345678901234567890123456789012345678901234567890123456789012345678901234567890
31
+import os
32
+import time
33
+import subprocess
34
+
35
+    ### DEFINE FILE LOCATIONS ###
36
+
37
+_USER = os.environ['USER']
38
+# the RRD file that stores the data
39
+_RRD_FILE = "/home/%s/database/arednsigData.rrd" % _USER
40
+
41
+    ### DEFINE DATABASE GRANULARITY AND TIME SPAN ###
42
+
43
+_RRD_SIZE_IN_DAYS = 370 # days
44
+_1YR_RRA_STEPS_PER_DAY = 96
45
+_DATABASE_UPDATE_INTERVAL = 60
46
+
47
+def createRrdFile():
48
+    """Create the rrd file if it does not exist.
49
+       Parameters: none
50
+       Returns: True, if successful
51
+    """
52
+    if os.path.exists(_RRD_FILE):
53
+        print "aredn node database already exists"
54
+        return True
55
+
56
+     ## Calculate database size
57
+ 
58
+    heartBeat = 2 * _DATABASE_UPDATE_INTERVAL
59
+    rra1yrNumPDP =  int(round(86400 / (_1YR_RRA_STEPS_PER_DAY * \
60
+                    _DATABASE_UPDATE_INTERVAL)))
61
+    rrd24hrNumRows = int(round(86400 / _DATABASE_UPDATE_INTERVAL))
62
+    rrd1yearNumRows = _1YR_RRA_STEPS_PER_DAY * _RRD_SIZE_IN_DAYS
63
+       
64
+    ## Format rrdtool command to create RRD database
65
+     
66
+    strFmt = ("rrdtool create %s --start now-1day --step %s "
67
+              "DS:S:GAUGE:%s:U:U DS:N:GAUGE:%s:U:U DS:SNR:GAUGE:%s:U:U "
68
+              "DS:RX_MCS:GAUGE:%s:U:U DS:TX_MCS:GAUGE:%s:U:U "
69
+              "DS:RX_RATE:GAUGE:%s:U:U DS:TX_RATE:GAUGE:%s:U:U "
70
+              "RRA:LAST:0.5:1:%s RRA:LAST:0.5:%s:%s")
71
+
72
+    strCmd = strFmt % (_RRD_FILE, _DATABASE_UPDATE_INTERVAL, \
73
+                heartBeat, heartBeat, heartBeat, heartBeat,  \
74
+                heartBeat,  heartBeat, heartBeat,            \
75
+                rrd24hrNumRows, rra1yrNumPDP, rrd1yearNumRows)
76
+
77
+    ## Run the command as a shell subprocess
78
+
79
+    print "creating aredn node database...\n\n%s\n" % strCmd
80
+
81
+    try:
82
+        subprocess.check_output(strCmd, stderr=subprocess.STDOUT, \
83
+                                shell=True)
84
+    except subprocess.CalledProcessError, exError:
85
+        print "rrdtool create failed: %s" % (exError.output)
86
+        return False
87
+    return True
88
+##end def
89
+
90
+def main():
91
+    createRrdFile()
92
+## end def
93
+
94
+if __name__ == '__main__':
95
+    main()
96
+