Browse code

minor revision

Gandolf authored on 07/06/2021 21:24:13
Showing 4 changed files
... ...
@@ -5,9 +5,6 @@
5 5
 # whether your local network uses a domain name server.
6 6
 #
7 7
 
8
-AGENT_NAME="[a]rednsigAgent.py"
9
-SOURCE_URL="http://localnode.local.mesh/cgi-bin/status"
10
-
11 8
 APP_PATH="/home/$USER/bin"
12 9
 LOG_PATH="/home/$USER/log"
13 10
 
... ...
@@ -15,6 +12,21 @@ LOG_PATH="/home/$USER/log"
15 12
 # in the agent script.  '60' is the default. Value is in seconds.
16 13
 POLLING_INTERVAL="60"
17 14
 
15
+
16
+if [ "$HOSTNAME" == "raspi3" ]; then
17
+  AGENT_NAME="[a]rednsigMirrorAgent.py"
18
+  SOURCE_URL="http://192.168.1.30:7368/arednsig/"
19
+elif [ "$HOSTNAME" == "redwall" ]; then
20
+  AGENT_NAME="[a]rednsigMirrorAgent.py"
21
+  SOURCE_URL="http://73.157.139.23:7361/arednsig/"
22
+elif [ "$HOSTNAME" == "ka7jlo-web" ]; then
23
+  AGENT_NAME="[a]rednsigAgent.py"
24
+  SOURCE_URL="http://ka7jlo-sw-albany-nano-m3.local.mesh/cgi-bin/status"
25
+else
26
+  echo invalid host
27
+  exit 1
28
+fi
29
+
18 30
 PROCESS_ID="$(ps x | awk -v a=$AGENT_NAME '$7 ~ a {print $1}')"
19 31
 
20 32
 if [ -n "$PROCESS_ID" ]; then
... ...
@@ -1,7 +1,16 @@
1 1
 #!/bin/bash
2
-# Stop the arednsig agent process.
2
+# Stop the radmon agent process.
3 3
 
4
-AGENT_NAME="[a]rednsigAgent.py"
4
+if [ "$HOSTNAME" == "raspi3" ]; then
5
+  AGENT_NAME="[a]rednsigMirrorAgent.py"
6
+elif [ "$HOSTNAME" == "redwall" ]; then
7
+  AGENT_NAME="[a]rednsigMirrorAgent.py"
8
+elif [ "$HOSTNAME" == "ka7jlo-web" ]; then
9
+  AGENT_NAME="[a]rednsigAgent.py"
10
+else
11
+  echo invalid host
12
+  exit 1
13
+fi
5 14
 
6 15
 PROCESS_ID="$(ps x | awk -v a=$AGENT_NAME '$7 ~ a {print $1}')"
7 16
 
8 17
old mode 100644
9 18
new mode 100755
... ...
@@ -125,8 +125,9 @@ Charts update every: <span id="period"></span> minutes
125 125
  onclick="setChartPeriod(2)">4 weeks</span></li>
126 126
 <li class="selectorElement"><span class="selectorElement"
127 127
  onclick="setChartPeriod(3)">12 months</span></li>
128
-<li class="selectorElement"><span class="selectorElement"
129
- onclick="setChartPeriod(0)">Custom…</span></li>
128
+<li id="customSelector" class="selectorElement" style="visibility:hidden;">
129
+<span  class="selectorElement"
130
+ onclick="setChartPeriod(0)">Custom...</span></li>
130 131
 </ul>
131 132
 </span>
132 133
 
... ...
@@ -177,10 +178,10 @@ www.arednmesh.org</a>.</li>
177 178
 <br>
178 179
 
179 180
 <script>
180
-
181
+"use strict";
181 182
 /* Global constants */
182 183
 
183
-var nodeDataUrl = "dynamic/nodeOnline.js";
184
+var nodeDataUrl = "dynamic/arednsigData.js";
184 185
 
185 186
 /* Global DOM objects */
186 187
 
... ...
@@ -199,6 +200,7 @@ var customChartsContainer = document.getElementById("customChartsContainer");
199 200
 var stockChartsContainer = document.getElementById("stockChartsContainer");
200 201
 var fmDateSelector = document.getElementById("fmDateSelector");
201 202
 var errorMsg = document.getElementById("errorMsg");
203
+var customSelector = document.getElementById("customSelector");
202 204
 
203 205
 /* Global objects */
204 206
 
... ...
@@ -207,9 +209,12 @@ var httpRequest = new XMLHttpRequest();
207 209
 /* Global variables */
208 210
 
209 211
 var chartPeriod = 1;
210
-var chartRefreshRate = 0; // chart refresh rate in minutes
212
+var chartUpdateInterval; // chart refresh rate in seconds
213
+var dataRequestInterval; // data request interval in seconds
211 214
 
212 215
 function main() {
216
+    httpRequest.timeout = 3000;
217
+
213 218
     /* Register call back function to process http requests */
214 219
     httpRequest.onreadystatechange = function() {
215 220
         if (httpRequest.readyState == 4 && httpRequest.status == 200) {
... ...
@@ -229,8 +234,7 @@ function main() {
229 234
 }
230 235
 
231 236
 function getNodeData() {
232
-    httpRequest.open("GET", nodeDataUrl, true);
233
-    httpRequest.timeout = 3000;
237
+    httpRequest.open("POST", nodeDataUrl, true);
234 238
     httpRequest.send();
235 239
 }
236 240
 
... ...
@@ -242,7 +246,7 @@ function setChartPeriod(n) {
242 246
     } else {
243 247
         customChartsContainer.style.display = "none";
244 248
         stockChartsContainer.style.display = "block";
245
-    getNodeCharts();   
249
+        getNodeCharts();   
246 250
     }
247 251
 }
248 252
 
... ...
@@ -267,7 +271,13 @@ function getNodeCharts() {
267 271
 
268 272
 function displayData(dataItem) {
269 273
     var timeStamp, date, time, hourminute;
270
-    var localDateObj,localTimeZone;
274
+    var localDate,localTimeZone;
275
+
276
+    // Custom charts can only be generated by the local server, i.e,
277
+    // with access to rrdtool database.
278
+    if (dataItem.serverMode == "primary") {
279
+        customSelector.style.visibility = "visible";
280
+    }
271 281
 
272 282
     timeStamp = dataItem.date;
273 283
     date = timeStamp.split(" ")[0];
... ...
@@ -282,10 +292,11 @@ function displayData(dataItem) {
282 292
     statusElmt.innerHTML = "Online";
283 293
     statusElmt.style.color = "green";
284 294
 
285
-    chartRefreshRate = dataItem.period;
286
-    periodElmt.innerHTML = chartRefreshRate / 60;
287
-    setInterval(getNodeData, 1000 * chartRefreshRate);
288
-    setInterval(getNodeCharts, 1000 * chartRefreshRate);
295
+    chartUpdateInterval = dataItem.chartUpdateInterval;
296
+    dataRequestInterval = dataItem.dataRequestInterval;
297
+    periodElmt.innerHTML = chartUpdateInterval / 60;
298
+    setInterval(getNodeData, 1000 * dataRequestInterval);
299
+    setInterval(getNodeCharts, 1000 * chartUpdateInterval);
289 300
 }
290 301
 
291 302
 function displayOfflineStatus() {
292 303
old mode 100644
293 304
new mode 100755
... ...
@@ -176,12 +176,11 @@ function createChart($chartFile, $dataItem, $label, $title, $begin,
176 176
     if ($addTrend == 0) {
177 177
         $cmd .= "LINE1:dSeries#0400ff ";
178 178
     } elseif ($addTrend == 1) {
179
-        $cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE3:smoothed#ff0000 ";
179
+        $cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE2:smoothed#006600 ";
180 180
         $cmd .= sprintf($cmdfmt, $trendWindow);
181 181
     } elseif ($addTrend == 2) {
182 182
         $cmd .= "LINE1:dSeries#0400ff ";
183
-        $cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE3:smoothed#ff0000 ";
184
-        #$cmdfmt = "CDEF:smoothed=dSeries,%s,XYZZY LINE3:smoothed#ff0000 ";
183
+        $cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE2:smoothed#006600 ";
185 184
         $cmd .=  sprintf($cmdfmt, $trendWindow);
186 185
     }
187 186