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 |
- |
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 |
+ |
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 |
- |
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 |
+ |
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 |
- |
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 |
+ |