mirror of
https://github.com/ShaYmez/HBmonitor.git
synced 2024-11-27 02:09:09 -05:00
Add files via upload
Switch to HBmonitor3
This commit is contained in:
parent
3cc9686388
commit
50616e3513
53
README.md
Normal file
53
README.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# hbmonitor3
|
||||||
|
Python 3 implementation of N0MJS HBmonitor for HBlink
|
||||||
|
|
||||||
|
***This software is VERY, VERY, VERY new!***
|
||||||
|
|
||||||
|
Since Python 3 is the way of the future, I'm updating the HBmonitor code from Python 2 to Python 3.
|
||||||
|
|
||||||
|
__THIS SOFTWARE IS WORKING__, hopefully...
|
||||||
|
|
||||||
|
Questions, comments, and complaints can be forwarded to the DVSwitch group at [DVSwitch - HBlink Subgroup](https://dvswitch.groups.io/g/HBlink/topics)
|
||||||
|
|
||||||
|
If you would like to contribute to this effort, please submit updated code as a PR to this repository.
|
||||||
|
|
||||||
|
***73, KC1AWV***
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Modified version by SP2ONG 2019
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Socket-Based Reporting for HBlink**
|
||||||
|
|
||||||
|
Over the years, the biggest request recevied for HBlink (other than call-routing/bridging tools) has been web-based diagnostics and/or statistics for the program.
|
||||||
|
|
||||||
|
I strongly disagree with including the amount of overhead this would require inside HBlink -- which still runs nicely on very modest resources. That it does this, and is in Python is a point of pride for me... Just let me have this one, ok? What I have done is added some hooks to HBlink, which will be expanded over time, whereby it listens on a TCP socket and provides the raw data necessary for a "web dashboard", or really any external logging or statistics gathering program.
|
||||||
|
|
||||||
|
HBmonitor is my take on a "web dashboard" for HBlink.
|
||||||
|
|
||||||
|
***THIS SOFTWARE IS VERY, VERY NEW***
|
||||||
|
|
||||||
|
Right now, I'm just getting into how this should work, what does work well, what does not... and I am NOT a web applications programmer, so yeah, that javascript stuff is gonna look bad. Know what you're doing? Help me!
|
||||||
|
|
||||||
|
It has now reached a point where folks who know what they're doing can probably make it work reasonably well, so I'm opening up the project to the public.
|
||||||
|
|
||||||
|
***GOALS OF THE PROJECT***
|
||||||
|
|
||||||
|
Some things I'm going to stick to pretty closely. Here they are:
|
||||||
|
|
||||||
|
+ HBmonitor be one process that includes a webserver
|
||||||
|
+ Websockets are used for pushing data to the browser - no long-polling, etc.
|
||||||
|
+ Does not provide data that's easily misunderstood
|
||||||
|
|
||||||
|
***0x49 DE N0MJS***
|
||||||
|
|
||||||
|
Copyright (C) 2013-2018 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
25
config_SAMPLE.py
Normal file
25
config_SAMPLE.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
REPORT_NAME = 'Dashboard local of DMR Network' # Name of the monitored HBlink system
|
||||||
|
CONFIG_INC = True # Include HBlink stats
|
||||||
|
LASTHEARD_INC = True # Include Lastheard (10)
|
||||||
|
HOMEBREW_INC = Ture # Include Homebrew Peers
|
||||||
|
BRIDGES_INC = True # Include Bridge stats (confbrige.py)
|
||||||
|
HBLINK_IP = '127.0.0.1' # HBlink's IP Address
|
||||||
|
HBLINK_PORT = 4321 # HBlink's TCP reporting socket
|
||||||
|
FREQUENCY = 10 # Frequency to push updates to web clients
|
||||||
|
WEB_SERVER_PORT = 8080 # Has to be above 1024 if you're not running as root
|
||||||
|
CLIENT_TIMEOUT = 0 # Clients are timed out after this many seconds, 0 to disable
|
||||||
|
|
||||||
|
# Files and stuff for loading alias files for mapping numbers to names
|
||||||
|
PATH = './' # MUST END IN '/'
|
||||||
|
PEER_FILE = 'peer_ids.json' # Will auto-download from DMR-MARC
|
||||||
|
SUBSCRIBER_FILE = 'subscriber_ids.json' # Will auto-download from DMR-MARC
|
||||||
|
TGID_FILE = 'talkgroup_ids.json' # User provided, should be in "integer TGID, TGID name" format
|
||||||
|
LOCAL_SUB_FILE = 'local_subscriber_ids.json' # User provided (optional, leave '' if you don't use it), follow the format of DMR-MARC
|
||||||
|
LOCAL_PEER_FILE = 'local_peer_ids.json' # User provided (optional, leave '' if you don't use it), follow the format of DMR-MARC
|
||||||
|
FILE_RELOAD = 7 # Number of days before we reload DMR-MARC database files
|
||||||
|
PEER_URL = 'https://www.radioid.net/static/rptrs.json'
|
||||||
|
SUBSCRIBER_URL = 'https://www.radioid.net/static/users.json'
|
||||||
|
|
||||||
|
# Settings for log files
|
||||||
|
LOG_PATH = './log/' # MUST END IN '/'
|
||||||
|
LOG_NAME = 'hbmon.log'
|
363
index_template.html
Normal file
363
index_template.html
Normal file
@ -0,0 +1,363 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>HBLink monitor</title>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var sock = null;
|
||||||
|
|
||||||
|
window.onload = function() {
|
||||||
|
var wsuri;
|
||||||
|
|
||||||
|
hblink_table = document.getElementById('hblink');
|
||||||
|
confbridge_table = document.getElementById('bridge');
|
||||||
|
|
||||||
|
wsuri = "ws://" + window.location.hostname + ":9000";
|
||||||
|
|
||||||
|
|
||||||
|
if ("WebSocket" in window) {
|
||||||
|
sock = new WebSocket(wsuri);
|
||||||
|
} else if ("MozWebSocket" in window) {
|
||||||
|
sock = new MozWebSocket(wsuri);
|
||||||
|
} else {
|
||||||
|
log("Browser does not support WebSocket!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sock) {
|
||||||
|
sock.onopen = function() {
|
||||||
|
log("Connected to " + wsuri);
|
||||||
|
}
|
||||||
|
sock.onclose = function(e) {
|
||||||
|
log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')");
|
||||||
|
hblink_table.innerHTML = "";
|
||||||
|
confbridge_table.innerHTML = "";
|
||||||
|
sock = null;
|
||||||
|
}
|
||||||
|
sock.onmessage = function(e) {
|
||||||
|
var opcode = e.data.slice(0,1);
|
||||||
|
var message = e.data.slice(1);
|
||||||
|
if (opcode == "d") {
|
||||||
|
hblink(message);
|
||||||
|
} else if (opcode == "b") {
|
||||||
|
confbridge(message);
|
||||||
|
} else if (opcode == "l") {
|
||||||
|
log(message);
|
||||||
|
} else if (opcode == "q") {
|
||||||
|
log(message);
|
||||||
|
hblink_table.innerHTML = "";
|
||||||
|
confbridge_table.innerHTML = "";
|
||||||
|
} else {
|
||||||
|
log("Unknown Message Received: " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function hblink(_msg) {
|
||||||
|
hblink_table.innerHTML = _msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
function confbridge(_msg) {
|
||||||
|
confbridge_table.innerHTML = _msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
function log(_msg) {
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
a:link {
|
||||||
|
color: brown;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* visited link */
|
||||||
|
a:visited {
|
||||||
|
color: brown;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mouse over link */
|
||||||
|
a:hover {
|
||||||
|
color: hotpink;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/* selected link */
|
||||||
|
a:active {
|
||||||
|
color: brown;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.tooltip {
|
||||||
|
position: relative;
|
||||||
|
opacity: 1;
|
||||||
|
display: inline-block;
|
||||||
|
border-bottom: 1px dotted black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip .tooltiptext {
|
||||||
|
visibility: hidden;
|
||||||
|
width: 260px;
|
||||||
|
background-color: #6E6E6E;
|
||||||
|
box-shadow: 4px 4px 6px #800000;
|
||||||
|
color: #FFFFFF;
|
||||||
|
text-align: left;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 8px 0;
|
||||||
|
left: 100%
|
||||||
|
opacity: 1;
|
||||||
|
/* Position the tooltip */
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip:hover .tooltiptext {
|
||||||
|
right: 100%
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
background-color: #aa6103;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0px 8px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.link {background-color: #a66300;}
|
||||||
|
.link:hover {background-color: #3e8e41;}
|
||||||
|
|
||||||
|
.dropbtn {
|
||||||
|
background-color: #aa6103;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0px 8px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The container <div> - needed to position the dropdown content */
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dropdown Content (Hidden by Default) */
|
||||||
|
.dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
min-width: 140px;
|
||||||
|
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Links inside the dropdown */
|
||||||
|
.dropdown-content a {
|
||||||
|
color: black;
|
||||||
|
padding: 6px 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change color of dropdown links on hover */
|
||||||
|
.dropdown-content a:hover {background-color: #ddd;}
|
||||||
|
|
||||||
|
/* Show the dropdown menu on hover */
|
||||||
|
.dropdown:hover .dropdown-content {display: block;}
|
||||||
|
|
||||||
|
/* Change the background color of the dropdown button when the dropdown content is shown */
|
||||||
|
.dropdown:hover .dropbtn {background-color: #3e8e41;}
|
||||||
|
table, td, th {border: .5px solid black; padding: 2px; border-collapse: collapse; text-align:center;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="background-color: #EEEEEE;font: 10pt arial, sans-serif;">
|
||||||
|
<center><div style="width:1250px; text-align: center; margin-top:5px;">
|
||||||
|
<a target='_blank' href=https://hblink.pl><img src="data:image/png;base64,
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAASsAAABACAYAAABC4FGZAAANW3pUWHRSYXcgcHJvZmlsZSB0eXBl
|
||||||
|
IGV4aWYAAHjarZlplhs5DoT/8xRzBO7LcUgAfG9uMMefDymVl7Ldbc90qV2pSqWYIAKICGQH+8+/
|
||||||
|
b/gXP6XNGGobs6/eIz911ZU3b2Z8/eznd4r1+f385PN+l74/H+r7OzFzqnAsrz9nf583zmeuz+/z
|
||||||
|
8jqmzfn2zULL3h+c7z/Y74XyfN/gff7jRiW9bhDfC4f9Xqjk953fIZ7XtmJfc3y7BXlff9+fP2ng
|
||||||
|
X/BftYzcW0+j8rvmOEZfvJ851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8Mzrn0T21Zj6kcdzRfCtvkGgegefAxBHOeOs
|
||||||
|
/hSWJiuo4wpew36cgC2n7sJ4Sqywnpse+0ujiEiufZetatVSnifGSAzj5BpqbEFYser6B7QiTTtR
|
||||||
|
6iLuw+NvKeakQx1gYOlhdWQhZUTYiLKXVxkny2mwuWId7F3/dEh9KjdQRS+GE+PHNmcszRTyXXyO
|
||||||
|
xmW1FSpL/jxFl/CgLkFjS/lRk+Vlc6VnWtwAehdTtBqjS/jE5ortBuZXJV1GBT5Po5yI8Bsa+BEF
|
||||||
|
7OBz7FY0PYVyBJdilBkIszB8SoxTuZaPRezcOytW+SRY/0oxR3E9AX6IAD61YMWqx5A8bboPAVDD
|
||||||
|
KnGYKTMbB10sVqy6MX/bfFJqlAr6cCkRTkaI5GLUSW2h5/mTCkGI6wE2mwQPB+azed065NxzO/Xw
|
||||||
|
3B4tVh1qlIfxXclhm83172grHmkjLu3Csu2ue2ivzLQb4snnNtid5fSlF6vDyehsvpuLe9YOGhuH
|
||||||
|
U2Ek5W/qKzWO9GPftZPKtDvv4VB52tG8zVU8+dr2vkg55eqhekTx//JAHDJIlwA6AAAAAElFTkSu"/></a>
|
||||||
|
</div>
|
||||||
|
<div style="width: 1100px;">
|
||||||
|
<p style="text-align:center;"><span style="color:#000;font-size: 17px; font-weight:bold;"><<<system_name>>></span></p>
|
||||||
|
<p style="text-align:center;"><<<timeout_warning>>></p>
|
||||||
|
<!-- Buttons HTML code
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="dropbtn">Others HBLink</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<a target='_blank' href="#">HBLink 1</a>
|
||||||
|
<a target='_blank' href="#">HBLink 2</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="dropbtn">Reflectors</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<a target='_blank' href="#">YSF Reflector</a>
|
||||||
|
<a target='_blank' href="#">XLX950</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target='_blank' href="#/log.php"><button class="button link">Lastheard</button></a>
|
||||||
|
|
||||||
|
-->
|
||||||
|
<noscript>You must enable JavaScript</noscript>
|
||||||
|
<p id="hblink"></p>
|
||||||
|
<p id="bridge"></p>
|
||||||
|
</div>
|
||||||
|
<!-- LOG monitor
|
||||||
|
<fieldset style="width: 1200px; margin-left:0px;margin-right:0px;font-size:14px;border-top-left-radius: 10px; border-top-right-radius: 10px;border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;"><legend><b><font color="brown"> .: Call Log Window :. </font></b></legend>
|
||||||
|
<pre id="log" style="height: 20em; text-align: left; overflow-y: scroll; font-size:13px; background-color: #000000; color:#00fd2c;"></pre>
|
||||||
|
</fieldset></center>
|
||||||
|
-->
|
||||||
|
<p style="text-align: center;"><span style="text-align: center;">
|
||||||
|
Copyright (c) 2016, 2017, 2018, 2019<br>The Regents of the K0USY Group. All rights reserved.<br>Modified by SP2ONG 2019.<br><br></span>
|
||||||
|
<!-- THIS COPYRIGHT NOTICE MUST BE DISPLAYED AS A CONDITION OF THE LICENCE GRANT FOR THIS SOFTWARE. ALL DERIVATEIVES WORKS MUST CARRY THIS NOTICE -->
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
install.sh
Normal file
6
install.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# Install the required support programs
|
||||||
|
apt-get install python3 python3-pip python3-dev libffi-dev libssl-dev -y
|
||||||
|
pip3 install setuptools wheel
|
||||||
|
pip3 install -r requirements.txt
|
33
local_peer_ids.json
Normal file
33
local_peer_ids.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{"rptrs":[
|
||||||
|
{"locator":"2603154",
|
||||||
|
"id":"2603154",
|
||||||
|
"callsign":"SP3KFQ",
|
||||||
|
"city":"Chojnice",
|
||||||
|
"state":"Pomorskie",
|
||||||
|
"country":"Polska",
|
||||||
|
"frequency":"440.58750",
|
||||||
|
"color_code":2,
|
||||||
|
"offset":"+5.000",
|
||||||
|
"assigned":"Peer",
|
||||||
|
"ts_linked":"TS1 TS2",
|
||||||
|
"trustee":"SP2KFQ",
|
||||||
|
"map_info":"",
|
||||||
|
"map":0,
|
||||||
|
"ipsc_network":"HBLink"},
|
||||||
|
{"locator":"260312201",
|
||||||
|
"id":"260312201",
|
||||||
|
"callsign":"SP3PMK",
|
||||||
|
"city":"Torun",
|
||||||
|
"state":"Pomorskie",
|
||||||
|
"country":"Polska",
|
||||||
|
"frequency":"438.5175",
|
||||||
|
"color_code":2,
|
||||||
|
"offset":"+5.000",
|
||||||
|
"assigned":"Peer",
|
||||||
|
"ts_linked":"TS1 TS2",
|
||||||
|
"trustee":"SP3KFQ",
|
||||||
|
"map_info":"",
|
||||||
|
"map":0,
|
||||||
|
"ipsc_network":"HBLink"}
|
||||||
|
|
||||||
|
]}
|
25
local_subscriber_ids.json
Normal file
25
local_subscriber_ids.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"count": 2,
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"callsign": "N0CALL",
|
||||||
|
"city": "",
|
||||||
|
"country": "",
|
||||||
|
"fname": "N0CALL",
|
||||||
|
"id": 1234567,
|
||||||
|
"remarks": "",
|
||||||
|
"state": "",
|
||||||
|
"surname": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"callsign": "SP2ABC",
|
||||||
|
"city": "",
|
||||||
|
"country": "",
|
||||||
|
"fname": "Jan",
|
||||||
|
"id": 26032254,
|
||||||
|
"remarks": "",
|
||||||
|
"state": "",
|
||||||
|
"surname": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
785
monitor.py
Normal file
785
monitor.py
Normal file
@ -0,0 +1,785 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Python 3 port by Steve Miller, KC1AWV <smiller@kc1awv.net>
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
# Standard modules
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import csv
|
||||||
|
from itertools import islice
|
||||||
|
|
||||||
|
# Twisted modules
|
||||||
|
from twisted.internet.protocol import ReconnectingClientFactory, Protocol
|
||||||
|
from twisted.protocols.basic import NetstringReceiver
|
||||||
|
from twisted.internet import reactor, task
|
||||||
|
from twisted.web.server import Site
|
||||||
|
from twisted.web.resource import Resource
|
||||||
|
|
||||||
|
# Autobahn provides websocket service under Twisted
|
||||||
|
from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
|
||||||
|
|
||||||
|
# Specific functions to import from standard modules
|
||||||
|
from time import time, strftime, localtime
|
||||||
|
from pickle import loads
|
||||||
|
from binascii import b2a_hex as h
|
||||||
|
from os.path import getmtime
|
||||||
|
from collections import deque
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
# Web templating environment
|
||||||
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
|
|
||||||
|
# Utilities from K0USY Group sister project
|
||||||
|
from dmr_utils3.utils import int_id, get_alias, try_download, mk_full_id_dict, bytes_4
|
||||||
|
|
||||||
|
# Configuration variables and constants
|
||||||
|
from config import *
|
||||||
|
|
||||||
|
# SP2ONG - Increase the value if HBlink link break occurs
|
||||||
|
#NetstringReceiver.MAX_LENGTH = 500000
|
||||||
|
|
||||||
|
# Opcodes for reporting protocol to HBlink
|
||||||
|
OPCODE = {
|
||||||
|
'CONFIG_REQ': '\x00',
|
||||||
|
'CONFIG_SND': '\x01',
|
||||||
|
'BRIDGE_REQ': '\x02',
|
||||||
|
'BRIDGE_SND': '\x03',
|
||||||
|
'CONFIG_UPD': '\x04',
|
||||||
|
'BRIDGE_UPD': '\x05',
|
||||||
|
'LINK_EVENT': '\x06',
|
||||||
|
'BRDG_EVENT': '\x07',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Global Variables:
|
||||||
|
CONFIG = {}
|
||||||
|
CTABLE = {'MASTERS': {}, 'PEERS': {}, 'OPENBRIDGES': {}}
|
||||||
|
BRIDGES = {}
|
||||||
|
BTABLE = {}
|
||||||
|
BTABLE['BRIDGES'] = {}
|
||||||
|
BRIDGES_RX = ''
|
||||||
|
CONFIG_RX = ''
|
||||||
|
LOGBUF = deque(100*[''], 100)
|
||||||
|
RED = 'ff6347'
|
||||||
|
BLACK = '000000'
|
||||||
|
GREEN = '90EE90'
|
||||||
|
GREEN2 = '008000'
|
||||||
|
BLUE = '0000ff'
|
||||||
|
ORANGE = 'ff8000'
|
||||||
|
WHITE = 'ffffff'
|
||||||
|
WHITE2 = 'f9f9f9f9'
|
||||||
|
YELLOW = 'fffccd'
|
||||||
|
|
||||||
|
# For importing HTML templates
|
||||||
|
def get_template(_file):
|
||||||
|
with open(_file, 'r') as html:
|
||||||
|
return html.read()
|
||||||
|
|
||||||
|
# Alias string processor
|
||||||
|
def alias_string(_id, _dict):
|
||||||
|
alias = get_alias(_id, _dict, 'CALLSIGN', 'CITY', 'STATE')
|
||||||
|
if type(alias) == list:
|
||||||
|
for x,item in enumerate(alias):
|
||||||
|
if item == None:
|
||||||
|
alias.pop(x)
|
||||||
|
return ', '.join(alias)
|
||||||
|
else:
|
||||||
|
return alias
|
||||||
|
|
||||||
|
def alias_short(_id, _dict):
|
||||||
|
alias = get_alias(_id, _dict, 'CALLSIGN', 'NAME')
|
||||||
|
if type(alias) == list:
|
||||||
|
for x,item in enumerate(alias):
|
||||||
|
if item == None:
|
||||||
|
alias.pop(x)
|
||||||
|
return ', '.join(alias)
|
||||||
|
else:
|
||||||
|
return str(alias)
|
||||||
|
|
||||||
|
def alias_call(_id, _dict):
|
||||||
|
alias = get_alias(_id, _dict, 'CALLSIGN')
|
||||||
|
if type(alias) == list:
|
||||||
|
for x,item in enumerate(alias):
|
||||||
|
if item == None:
|
||||||
|
alias.pop(x)
|
||||||
|
return ', '.join(alias)
|
||||||
|
else:
|
||||||
|
return str(alias)
|
||||||
|
|
||||||
|
def alias_tgid(_id, _dict):
|
||||||
|
alias = get_alias(_id, _dict, 'NAME')
|
||||||
|
if type(alias) == list:
|
||||||
|
return str(alias[0])
|
||||||
|
else:
|
||||||
|
return str(alias)
|
||||||
|
|
||||||
|
# Return friendly elapsed time from time in seconds.
|
||||||
|
def since(_time):
|
||||||
|
now = int(time())
|
||||||
|
_time = now - int(_time)
|
||||||
|
seconds = _time % 60
|
||||||
|
minutes = int(_time/60) % 60
|
||||||
|
hours = int(_time/60/60) % 24
|
||||||
|
days = int(_time/60/60/24)
|
||||||
|
if days:
|
||||||
|
return '{}d {}h'.format(days, hours)
|
||||||
|
elif hours:
|
||||||
|
return '{}h {}m'.format(hours, minutes)
|
||||||
|
elif minutes:
|
||||||
|
return '{}m {}s'.format(minutes, seconds)
|
||||||
|
else:
|
||||||
|
return '{}s'.format(seconds)
|
||||||
|
|
||||||
|
|
||||||
|
def add_hb_peer(_peer_conf, _ctable_loc, _peer):
|
||||||
|
_ctable_loc[int_id(_peer)] = {}
|
||||||
|
_ctable_peer = _ctable_loc[int_id(_peer)]
|
||||||
|
|
||||||
|
# if the Frequency is 000.xxx assume it's not an RF peer, otherwise format the text fields
|
||||||
|
# (9 char, but we are just software) see https://wiki.brandmeister.network/index.php/Homebrew/example/php2
|
||||||
|
|
||||||
|
if _peer_conf['TX_FREQ'][:3].decode('utf-8') == '000' or _peer_conf['RX_FREQ'][:3].decode('utf-8') == '000':
|
||||||
|
_ctable_peer['TX_FREQ'] = 'N/A'
|
||||||
|
_ctable_peer['RX_FREQ'] = 'N/A'
|
||||||
|
else:
|
||||||
|
_ctable_peer['TX_FREQ'] = _peer_conf['TX_FREQ'][:3].decode('utf-8') + '.' + _peer_conf['TX_FREQ'][3:7].decode('utf-8') + ' MHz'
|
||||||
|
_ctable_peer['RX_FREQ'] = _peer_conf['RX_FREQ'][:3].decode('utf-8') + '.' + _peer_conf['RX_FREQ'][3:7].decode('utf-8') + ' MHz'
|
||||||
|
|
||||||
|
# timeslots are kinda complicated too. 0 = none, 1 or 2 mean that one slot, 3 is both, and anythign else it considered DMO
|
||||||
|
# Slots (0, 1=1, 2=2, 1&2=3 Duplex, 4=Simplex) see https://wiki.brandmeister.network/index.php/Homebrew/example/php2
|
||||||
|
|
||||||
|
if (_peer_conf['SLOTS'].decode('utf-8') == '0'):
|
||||||
|
_ctable_peer['SLOTS'] = 'NONE'
|
||||||
|
elif (_peer_conf['SLOTS'].decode('utf-8') == '1' or _peer_conf['SLOTS'].decode('utf-8') == '2'):
|
||||||
|
_ctable_peer['SLOTS'] = _peer_conf['SLOTS'].decode('utf-8')
|
||||||
|
elif (_peer_conf['SLOTS'].decode('utf-8') == '3'):
|
||||||
|
_ctable_peer['SLOTS'] = 'Duplex'
|
||||||
|
else:
|
||||||
|
_ctable_peer['SLOTS'] = 'Simplex'
|
||||||
|
|
||||||
|
# Simple translation items
|
||||||
|
_ctable_peer['SOFTWARE_ID'] = _peer_conf['SOFTWARE_ID'].decode('utf-8').strip()
|
||||||
|
_ctable_peer['PACKAGE_ID'] = _peer_conf['PACKAGE_ID'].decode('utf-8').strip()
|
||||||
|
_ctable_peer['COLORCODE'] = _peer_conf['COLORCODE'].decode('utf-8')
|
||||||
|
_ctable_peer['CALLSIGN'] = _peer_conf['CALLSIGN'].decode('utf-8')
|
||||||
|
_ctable_peer['LOCATION'] = _peer_conf['LOCATION'].decode('utf-8')
|
||||||
|
_ctable_peer['CONNECTION'] = _peer_conf['CONNECTION']
|
||||||
|
_ctable_peer['CONNECTED'] = since(_peer_conf['CONNECTED'])
|
||||||
|
_ctable_peer['IP'] = _peer_conf['IP']
|
||||||
|
_ctable_peer['PORT'] = _peer_conf['PORT']
|
||||||
|
#_ctable_peer['LAST_PING'] = _peer_conf['LAST_PING']
|
||||||
|
|
||||||
|
# SLOT 1&2 - for real-time montior: make the structure for later use
|
||||||
|
for ts in range(1,3):
|
||||||
|
_ctable_peer[ts]= {}
|
||||||
|
_ctable_peer[ts]['COLOR'] = ''
|
||||||
|
_ctable_peer[ts]['BGCOLOR'] = ''
|
||||||
|
_ctable_peer[ts]['TS'] = ''
|
||||||
|
_ctable_peer[ts]['TYPE'] = ''
|
||||||
|
_ctable_peer[ts]['SUB'] = ''
|
||||||
|
_ctable_peer[ts]['SRC'] = ''
|
||||||
|
_ctable_peer[ts]['DEST'] = ''
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# Build the HBlink connections table
|
||||||
|
#
|
||||||
|
|
||||||
|
def build_hblink_table(_config, _stats_table):
|
||||||
|
for _hbp, _hbp_data in list(_config.items()):
|
||||||
|
if _hbp_data['ENABLED'] == True:
|
||||||
|
|
||||||
|
# Process Master Systems
|
||||||
|
if _hbp_data['MODE'] == 'MASTER':
|
||||||
|
_stats_table['MASTERS'][_hbp] = {}
|
||||||
|
if _hbp_data['REPEAT']:
|
||||||
|
_stats_table['MASTERS'][_hbp]['REPEAT'] = "repeat"
|
||||||
|
else:
|
||||||
|
_stats_table['MASTERS'][_hbp]['REPEAT'] = "isolate"
|
||||||
|
_stats_table['MASTERS'][_hbp]['PEERS'] = {}
|
||||||
|
for _peer in _hbp_data['PEERS']:
|
||||||
|
add_hb_peer(_hbp_data['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer)
|
||||||
|
|
||||||
|
# Proccess Peer Systems
|
||||||
|
elif (_hbp_data['MODE'] == 'XLXPEER' or _hbp_data['MODE'] == 'PEER') and HOMEBREW_INC:
|
||||||
|
_stats_table['PEERS'][_hbp] = {}
|
||||||
|
_stats_table['PEERS'][_hbp]['MODE'] = _hbp_data['MODE']
|
||||||
|
_stats_table['PEERS'][_hbp]['CALLSIGN'] = _hbp_data['CALLSIGN'].decode('utf-8')
|
||||||
|
_stats_table['PEERS'][_hbp]['LOCATION'] = _hbp_data['LOCATION'].decode('utf-8')
|
||||||
|
_stats_table['PEERS'][_hbp]['RADIO_ID'] = int_id(_hbp_data['RADIO_ID'])
|
||||||
|
_stats_table['PEERS'][_hbp]['MASTER_IP'] = _hbp_data['MASTER_IP']
|
||||||
|
_stats_table['PEERS'][_hbp]['MASTER_PORT'] = _hbp_data['MASTER_PORT']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS'] = {}
|
||||||
|
if _stats_table['PEERS'][_hbp]['MODE'] == 'XLXPEER':
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _hbp_data['XLXSTATS']['CONNECTION']
|
||||||
|
if _hbp_data['XLXSTATS']['CONNECTION'] == "YES":
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_hbp_data['XLXSTATS']['CONNECTED'])
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = "-- --"
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _hbp_data['XLXSTATS']['PINGS_SENT']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _hbp_data['XLXSTATS']['PINGS_ACKD']
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _hbp_data['STATS']['CONNECTION']
|
||||||
|
if _hbp_data['STATS']['CONNECTION'] == "YES":
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_hbp_data['STATS']['CONNECTED'])
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = "-- --"
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _hbp_data['STATS']['PINGS_SENT']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _hbp_data['STATS']['PINGS_ACKD']
|
||||||
|
if _hbp_data['SLOTS'].decode('utf-8') == 0:
|
||||||
|
_stats_table['PEERS'][_hbp]['SLOTS'] = 'NONE'
|
||||||
|
elif _hbp_data['SLOTS'].decode('utf-8') == '1' or _hbp_data['SLOTS'].decode('utf-8') == '2':
|
||||||
|
_stats_table['PEERS'][_hbp]['SLOTS'] = _hbp_data['SLOTS'].decode('utf-8')
|
||||||
|
elif _hbp_data['SLOTS'].decode('utf-8') == '3':
|
||||||
|
_stats_table['PEERS'][_hbp]['SLOTS'] = '1&2'
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['SLOTS'] = 'DMO'
|
||||||
|
# SLOT 1&2 - for real-time montior: make the structure for later use
|
||||||
|
|
||||||
|
for ts in range(1,3):
|
||||||
|
_stats_table['PEERS'][_hbp][ts]= {}
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['COLOR'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['BGCOLOR'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['TS'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['TYPE'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['SUB'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['SRC'] = ''
|
||||||
|
_stats_table['PEERS'][_hbp][ts]['DEST'] = ''
|
||||||
|
|
||||||
|
|
||||||
|
# Process OpenBridge systems
|
||||||
|
elif _hbp_data['MODE'] == 'OPENBRIDGE':
|
||||||
|
_stats_table['OPENBRIDGES'][_hbp] = {}
|
||||||
|
_stats_table['OPENBRIDGES'][_hbp]['NETWORK_ID'] = int_id(_hbp_data['NETWORK_ID'])
|
||||||
|
_stats_table['OPENBRIDGES'][_hbp]['TARGET_IP'] = _hbp_data['TARGET_IP']
|
||||||
|
_stats_table['OPENBRIDGES'][_hbp]['TARGET_PORT'] = _hbp_data['TARGET_PORT']
|
||||||
|
_stats_table['OPENBRIDGES'][_hbp]['STREAMS'] = {}
|
||||||
|
|
||||||
|
#return(_stats_table)
|
||||||
|
|
||||||
|
def update_hblink_table(_config, _stats_table):
|
||||||
|
# Is there a system in HBlink's config monitor doesn't know about?
|
||||||
|
for _hbp in _config:
|
||||||
|
if _config[_hbp]['MODE'] == 'MASTER':
|
||||||
|
for _peer in _config[_hbp]['PEERS']:
|
||||||
|
if int_id(_peer) not in _stats_table['MASTERS'][_hbp]['PEERS'] and _config[_hbp]['PEERS'][_peer]['CONNECTION'] == 'YES':
|
||||||
|
logger.info('Adding peer to CTABLE that has registerred: %s', int_id(_peer))
|
||||||
|
add_hb_peer(_config[_hbp]['PEERS'][_peer], _stats_table['MASTERS'][_hbp]['PEERS'], _peer)
|
||||||
|
|
||||||
|
# Is there a system in monitor that's been removed from HBlink's config?
|
||||||
|
for _hbp in _stats_table['MASTERS']:
|
||||||
|
remove_list = []
|
||||||
|
if _config[_hbp]['MODE'] == 'MASTER':
|
||||||
|
for _peer in _stats_table['MASTERS'][_hbp]['PEERS']:
|
||||||
|
if bytes_4(_peer) not in _config[_hbp]['PEERS']:
|
||||||
|
remove_list.append(_peer)
|
||||||
|
|
||||||
|
for _peer in remove_list:
|
||||||
|
logger.info('Deleting stats peer not in hblink config: %s', _peer)
|
||||||
|
del (_stats_table['MASTERS'][_hbp]['PEERS'][_peer])
|
||||||
|
|
||||||
|
# Update connection time
|
||||||
|
for _hbp in _stats_table['MASTERS']:
|
||||||
|
for _peer in _stats_table['MASTERS'][_hbp]['PEERS']:
|
||||||
|
if bytes_4(_peer) in _config[_hbp]['PEERS']:
|
||||||
|
_stats_table['MASTERS'][_hbp]['PEERS'][_peer]['CONNECTED'] = since(_config[_hbp]['PEERS'][bytes_4(_peer)]['CONNECTED'])
|
||||||
|
|
||||||
|
for _hbp in _stats_table['PEERS']:
|
||||||
|
if _stats_table['PEERS'][_hbp]['MODE'] == 'XLXPEER':
|
||||||
|
if _config[_hbp]['XLXSTATS']['CONNECTION'] == "YES":
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_config[_hbp]['XLXSTATS']['CONNECTED'])
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = "-- --"
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _config[_hbp]['XLXSTATS']['CONNECTION']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _config[_hbp]['XLXSTATS']['PINGS_SENT']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _config[_hbp]['XLXSTATS']['PINGS_ACKD']
|
||||||
|
else:
|
||||||
|
if _config[_hbp]['STATS']['CONNECTION'] == "YES":
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = since(_config[_hbp]['STATS']['CONNECTED'])
|
||||||
|
else:
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTED'] = "-- --"
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['CONNECTION'] = _config[_hbp]['STATS']['CONNECTION']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_SENT'] = _config[_hbp]['STATS']['PINGS_SENT']
|
||||||
|
_stats_table['PEERS'][_hbp]['STATS']['PINGS_ACKD'] = _config[_hbp]['STATS']['PINGS_ACKD']
|
||||||
|
|
||||||
|
build_stats()
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# CONFBRIDGE TABLE FUNCTIONS
|
||||||
|
#
|
||||||
|
|
||||||
|
def build_bridge_table(_bridges):
|
||||||
|
_stats_table = {}
|
||||||
|
_now = time()
|
||||||
|
_cnow = strftime('%Y-%m-%d %H:%M:%S', localtime(_now))
|
||||||
|
|
||||||
|
for _bridge, _bridge_data in list(_bridges.items()):
|
||||||
|
_stats_table[_bridge] = {}
|
||||||
|
|
||||||
|
for system in _bridges[_bridge]:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']] = {}
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TS'] = system['TS']
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TGID'] = int_id(system['TGID'])
|
||||||
|
|
||||||
|
if system['TO_TYPE'] == 'ON' or system['TO_TYPE'] == 'OFF':
|
||||||
|
if system['TIMER'] - _now > 0:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['EXP_TIME'] = int(system['TIMER'] - _now)
|
||||||
|
else:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['EXP_TIME'] = 'Expired'
|
||||||
|
if system['TO_TYPE'] == 'ON':
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TO_ACTION'] = 'Disconnect'
|
||||||
|
else:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TO_ACTION'] = 'Connect'
|
||||||
|
else:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['EXP_TIME'] = 'N/A'
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TO_ACTION'] = 'None'
|
||||||
|
|
||||||
|
if system['ACTIVE'] == True:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Connected'
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['COLOR'] = BLACK
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = GREEN
|
||||||
|
elif system['ACTIVE'] == False:
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['ACTIVE'] = 'Disconnected'
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['COLOR'] = WHITE
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['BGCOLOR'] = RED
|
||||||
|
|
||||||
|
for i in range(len(system['ON'])):
|
||||||
|
system['ON'][i] = str(int_id(system['ON'][i]))
|
||||||
|
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TRIG_ON'] = ', '.join(system['ON'])
|
||||||
|
|
||||||
|
for i in range(len(system['OFF'])):
|
||||||
|
system['OFF'][i] = str(int_id(system['OFF'][i]))
|
||||||
|
|
||||||
|
_stats_table[_bridge][system['SYSTEM']]['TRIG_OFF'] = ', '.join(system['OFF'])
|
||||||
|
return _stats_table
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# BUILD HBlink AND CONFBRIDGE TABLES FROM CONFIG/BRIDGES DICTS
|
||||||
|
# THIS CURRENTLY IS A TIMED CALL
|
||||||
|
#
|
||||||
|
|
||||||
|
build_time = time()
|
||||||
|
def build_stats():
|
||||||
|
global build_time
|
||||||
|
now = time()
|
||||||
|
if True: #now > build_time + 1:
|
||||||
|
if CONFIG:
|
||||||
|
table = 'd' + dtemplate.render(_table=CTABLE)
|
||||||
|
dashboard_server.broadcast(table)
|
||||||
|
if BRIDGES:
|
||||||
|
table = 'b' + btemplate.render(_table=BTABLE['BRIDGES'])
|
||||||
|
dashboard_server.broadcast(table)
|
||||||
|
build_time = now
|
||||||
|
|
||||||
|
|
||||||
|
def timeout_clients():
|
||||||
|
now = time()
|
||||||
|
try:
|
||||||
|
for client in dashboard_server.clients:
|
||||||
|
if dashboard_server.clients[client] + CLIENT_TIMEOUT < now:
|
||||||
|
logger.info('TIMEOUT: disconnecting client %s', dashboard_server.clients[client])
|
||||||
|
try:
|
||||||
|
dashboard.sendClose(client)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('Exception caught parsing client timeout %s', e)
|
||||||
|
except:
|
||||||
|
logger.info('CLIENT TIMEOUT: List does not exist, skipping. If this message persists, contact the developer')
|
||||||
|
|
||||||
|
|
||||||
|
def rts_update(p):
|
||||||
|
callType = p[0]
|
||||||
|
action = p[1]
|
||||||
|
trx = p[2]
|
||||||
|
system = p[3]
|
||||||
|
streamId = p[4]
|
||||||
|
sourcePeer = int(p[5])
|
||||||
|
sourceSub = int(p[6])
|
||||||
|
timeSlot = int(p[7])
|
||||||
|
destination = int(p[8])
|
||||||
|
|
||||||
|
if system in CTABLE['MASTERS']:
|
||||||
|
for peer in CTABLE['MASTERS'][system]['PEERS']:
|
||||||
|
if sourcePeer == peer:
|
||||||
|
bgcolor = RED
|
||||||
|
color = WHITE
|
||||||
|
else:
|
||||||
|
bgcolor = GREEN
|
||||||
|
color = BLACK
|
||||||
|
|
||||||
|
if action == 'START':
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = True
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = color
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['BGCOLOR'] = bgcolor
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TYPE'] = callType
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SUB'] = '{} ({})'.format(alias_short(sourceSub, subscriber_ids), sourceSub)
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SRC'] = peer
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['DEST'] = '{} ({})'.format(alias_tgid(destination,talkgroup_ids),destination)
|
||||||
|
if action == 'END':
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TS'] = False
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['COLOR'] = BLACK
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['BGCOLOR'] = WHITE2
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['TYPE'] = ''
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SUB'] = ''
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['SRC'] = ''
|
||||||
|
CTABLE['MASTERS'][system]['PEERS'][peer][timeSlot]['DEST'] = ''
|
||||||
|
|
||||||
|
if system in CTABLE['OPENBRIDGES']:
|
||||||
|
CTABLE['OPENBRIDGES'][system]['TRX'] = trx
|
||||||
|
if trx == 'RX':
|
||||||
|
CTABLE['OPENBRIDGES'][system]['COLOR'] = GREEN2
|
||||||
|
else:
|
||||||
|
CTABLE['OPENBRIDGES'][system]['COLOR'] = RED
|
||||||
|
if action == 'START':
|
||||||
|
CTABLE['OPENBRIDGES'][system]['STREAMS'][streamId] = (trx, alias_call(sourceSub, subscriber_ids),'TG{}'.format(destination))
|
||||||
|
if action == 'END':
|
||||||
|
if streamId in CTABLE['OPENBRIDGES'][system]['STREAMS']:
|
||||||
|
del CTABLE['OPENBRIDGES'][system]['STREAMS'][streamId]
|
||||||
|
|
||||||
|
if system in CTABLE['PEERS']:
|
||||||
|
bgcolor = GREEN
|
||||||
|
if trx == 'RX':
|
||||||
|
bgcolor = RED
|
||||||
|
color = WHITE
|
||||||
|
else:
|
||||||
|
bgcolor = GREEN
|
||||||
|
color = BLACK
|
||||||
|
|
||||||
|
if action == 'START':
|
||||||
|
if destination == 9 and sourcePeer == 2602122:
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['TS'] = False
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['COLOR'] = BLACK
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['BGCOLOR'] = WHITE2
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['TYPE'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SUB'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SRC'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['DEST'] = ''
|
||||||
|
else:
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['TS'] = True
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['COLOR'] = color
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['BGCOLOR'] = bgcolor
|
||||||
|
# CTABLE['PEERS'][system][timeSlot]['TYPE'] = callType[6:]
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SUB'] = '{} ({})'.format(alias_short(sourceSub, subscriber_ids), sourceSub)
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SRC'] = sourcePeer
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['DEST'] = '{} ({})'.format(alias_tgid(destination,talkgroup_ids),destination)
|
||||||
|
if action == 'END':
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['TS'] = False
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['COLOR'] = BLACK
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['BGCOLOR'] = WHITE2
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['TYPE'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SUB'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['SRC'] = ''
|
||||||
|
CTABLE['PEERS'][system][timeSlot]['DEST'] = ''
|
||||||
|
|
||||||
|
build_stats()
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# PROCESS INCOMING MESSAGES AND TAKE THE CORRECT ACTION DEPENING ON
|
||||||
|
# THE OPCODE
|
||||||
|
#
|
||||||
|
|
||||||
|
def process_message(_bmessage):
|
||||||
|
global CTABLE, CONFIG, BRIDGES, CONFIG_RX, BRIDGES_RX
|
||||||
|
_message = _bmessage.decode('utf-8', 'ignore')
|
||||||
|
opcode = _message[:1]
|
||||||
|
_now = strftime('%Y-%m-%d %H:%M:%S %Z', localtime(time()))
|
||||||
|
|
||||||
|
if opcode == OPCODE['CONFIG_SND']:
|
||||||
|
logging.debug('got CONFIG_SND opcode')
|
||||||
|
CONFIG = load_dictionary(_bmessage)
|
||||||
|
CONFIG_RX = strftime('%Y-%m-%d %H:%M:%S', localtime(time()))
|
||||||
|
if CTABLE['MASTERS']:
|
||||||
|
update_hblink_table(CONFIG, CTABLE)
|
||||||
|
else:
|
||||||
|
build_hblink_table(CONFIG, CTABLE)
|
||||||
|
|
||||||
|
elif opcode == OPCODE['BRIDGE_SND']:
|
||||||
|
logging.debug('got BRIDGE_SND opcode')
|
||||||
|
BRIDGES = load_dictionary(_bmessage)
|
||||||
|
BRIDGES_RX = strftime('%Y-%m-%d %H:%M:%S', localtime(time()))
|
||||||
|
if BRIDGES_INC:
|
||||||
|
BTABLE['BRIDGES'] = build_bridge_table(BRIDGES)
|
||||||
|
|
||||||
|
elif opcode == OPCODE['LINK_EVENT']:
|
||||||
|
logging.info('LINK_EVENT Received: {}'.format(repr(_message[1:])))
|
||||||
|
|
||||||
|
elif opcode == OPCODE['BRDG_EVENT']:
|
||||||
|
logging.info('BRIDGE EVENT: {}'.format(repr(_message[1:])))
|
||||||
|
p = _message[1:].split(",")
|
||||||
|
rts_update(p)
|
||||||
|
if p[0] == 'GROUP VOICE' and p[2] != 'TX':
|
||||||
|
if p[1] == 'END':
|
||||||
|
log_message = '{}: {} {}: SYS: {:8.8s} SRC: {:9.9s}; {:9.9s} TS: {} TGID: {:7.7s} {:17.17s} SUB: {:9.9s}; {:18.18s} Time: {}s'.format(_now[11:], p[0][6:], p[1], p[3], p[5], alias_call(int(p[5]), subscriber_ids), p[7],p[8],alias_tgid(int(p[8]),talkgroup_ids), p[6], alias_short(int(p[6]), subscriber_ids), int(float(p[9])))
|
||||||
|
# log only to file if system is NOT OpenBridge event (not logging open bridge system, name depends on your OB definitions) AND transmit time is LONGER as 2sec (make sense for very short transmits)
|
||||||
|
if LASTHEARD_INC:
|
||||||
|
if int(float(p[9]))> 2:
|
||||||
|
log_lh_message = '{},{},{},{},{},{},{},TS{},TG{},{},{},{}'.format(_now, p[9], p[0], p[1], p[3], p[5], alias_call(int(p[5]), subscriber_ids), p[7], p[8],alias_tgid(int(p[8]),talkgroup_ids),p[6], alias_short(int(p[6]), subscriber_ids))
|
||||||
|
lh_logfile = open('/opt/HBmonitor/log/lastheard.log', "a")
|
||||||
|
lh_logfile.write(log_lh_message + '\n')
|
||||||
|
lh_logfile.close()
|
||||||
|
# Lastheard in Dashboard by SP2ONG
|
||||||
|
my_list=[]
|
||||||
|
n=0
|
||||||
|
f = open("/opt/HBmonitor/templates/lastheard.html", "w")
|
||||||
|
f.write("<br><fieldset style=\"border-radius: 8px; background-color:#e0e0e0e0; text-algin: lef; margin-left:15px;margin-right:15px;font-size:14px;border-top-left-radius: 10px; border-top-right-radius: 10px;border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;\">\n")
|
||||||
|
f.write("<legend><b><font color=\"#000\"> .: Lastheard (10) :. </font></b></legend>\n")
|
||||||
|
f.write("<table style=\"width:100%; font: 10pt arial, sans-serif\">\n")
|
||||||
|
f.write("<TR style=\" height: 32px;font: 10pt arial, sans-serif; background-color:#7e6959; color:white\"><TH>Date<TH>Time<TH>Slot<TH>TG#<TH>TG Name<TH>Callsign (DMR-Id)<TH>Name<TH>Dur TX (s)<TH>Source ID<TH>System</TR>\n")
|
||||||
|
with open('/opt/HBmonitor/log/lastheard.log', 'r') as textfile:
|
||||||
|
for row in islice(reversed(list(csv.reader(textfile))),100):
|
||||||
|
duration=row[1]
|
||||||
|
dur=str(int(float(duration.strip())))
|
||||||
|
if row[10] not in my_list:
|
||||||
|
if len(row) < 13:
|
||||||
|
hline="<TR style=\"background-color:#f9f9f9f9;\"><TD>"+row[0][:10]+"<TD>"+row[0][11:16]+"<TD>"+row[7][2:]+"<TD><font color=#996633><b>"+row[8][2:]+"</b></font><TD><font color=#356244><b>"+row[9]+"</b></font><TD><font color=brown><b><a target=\"_blank\" href=https://qrz.com/db/"+row[11]+">"+row[11]+"</a></b></font><span style=\"font: 7pt arial,sans-serif\"> ("+row[10]+")</span><TD><font color=#002d62><b></b></font><TD>"+dur+"<TD>"+row[5]+"<TD>"+row[4]+"</TR>"
|
||||||
|
my_list.append(row[10])
|
||||||
|
n += 1
|
||||||
|
else:
|
||||||
|
hline="<TR style=\"background-color:#f9f9f9f9;\"><TD>"+row[0][:10]+"<TD>"+row[0][11:16]+"<TD>"+row[7][2:]+"<TD><font color=#996633><b>"+row[8][2:]+"</b></font><TD><font color=#356244><b>"+row[9]+"</b></font><TD><font color=brown><b><a target=\"_blank\" href=https://qrz.com/db/"+row[11]+">"+row[11]+"</a></b></font><span style=\"font: 7pt arial,sans-serif\"> ("+row[10]+")</span><TD><font color=#002d62><b>"+row[12]+"</b></font><TD>"+dur+"<TD>"+row[5]+"<TD>"+row[4]+"</TR>"
|
||||||
|
my_list.append(row[10])
|
||||||
|
n += 1
|
||||||
|
f.write(hline+"\n")
|
||||||
|
if n == 10:
|
||||||
|
break
|
||||||
|
f.write("</table></fieldset><br>")
|
||||||
|
f.close()
|
||||||
|
# End of Lastheard
|
||||||
|
elif p[1] == 'START':
|
||||||
|
log_message = '{}: {} {}: SYS: {:8.8s} SRC: {:9.9s}; {:9.9s} TS: {} TGID: {:7.7s} {:17.17s} SUB: {:9.9s}; {:18.18s}'.format(_now[11:], p[0][6:], p[1], p[3], p[5], alias_call(int(p[5]), subscriber_ids), p[7],p[8], alias_tgid(int(p[8]),talkgroup_ids), p[6], alias_short(int(p[6]), subscriber_ids))
|
||||||
|
elif p[1] == 'END WITHOUT MATCHING START':
|
||||||
|
log_message = '{}: {} {} on SYSTEM {:8.8s}: SRC: {:9.9s}; {:9.9s} TS: {} TGID: {:7.7s} {:17.17s} SUB: {:9.9s}; {:18.18s}'.format(_now[11:], p[0][6:], p[1], p[3], p[5], alias_call(int(p[5]), subscriber_ids), p[7], p[8],alias_tgid(int(p[8]),talkgroup_ids),p[6], alias_short(int(p[6]), subscriber_ids))
|
||||||
|
else:
|
||||||
|
log_message = '{}: UNKNOWN GROUP VOICE LOG MESSAGE'.format(_now)
|
||||||
|
|
||||||
|
dashboard_server.broadcast('l' + log_message)
|
||||||
|
LOGBUF.append(log_message)
|
||||||
|
|
||||||
|
else:
|
||||||
|
logging.debug('{}: UNKNOWN LOG MESSAGE'.format(_now))
|
||||||
|
|
||||||
|
else:
|
||||||
|
logging.debug('got unknown opcode: {}, message: {}'.format(repr(opcode), repr(_message[1:])))
|
||||||
|
|
||||||
|
def load_dictionary(_message):
|
||||||
|
data = _message[1:]
|
||||||
|
return loads(data)
|
||||||
|
logging.debug('Successfully decoded dictionary')
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# COMMUNICATION WITH THE HBlink INSTANCE
|
||||||
|
#
|
||||||
|
|
||||||
|
class report(NetstringReceiver):
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def connectionMade(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def connectionLost(self, reason):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def stringReceived(self, data):
|
||||||
|
process_message(data)
|
||||||
|
|
||||||
|
|
||||||
|
class reportClientFactory(ReconnectingClientFactory):
|
||||||
|
def __init__(self):
|
||||||
|
logging.info('reportClient object for connecting to HBlink.py created at: %s', self)
|
||||||
|
|
||||||
|
def startedConnecting(self, connector):
|
||||||
|
logging.info('Initiating Connection to Server.')
|
||||||
|
if 'dashboard_server' in locals() or 'dashboard_server' in globals():
|
||||||
|
dashboard_server.broadcast('q' + 'Connection to HBlink Established')
|
||||||
|
|
||||||
|
def buildProtocol(self, addr):
|
||||||
|
logging.info('Connected.')
|
||||||
|
logging.info('Resetting reconnection delay')
|
||||||
|
self.resetDelay()
|
||||||
|
return report()
|
||||||
|
|
||||||
|
def clientConnectionLost(self, connector, reason):
|
||||||
|
logging.info('Lost connection. Reason: %s', reason)
|
||||||
|
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
||||||
|
dashboard_server.broadcast('q' + 'Connection to HBlink Lost')
|
||||||
|
|
||||||
|
def clientConnectionFailed(self, connector, reason):
|
||||||
|
logging.info('Connection failed. Reason: %s', reason)
|
||||||
|
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# WEBSOCKET COMMUNICATION WITH THE DASHBOARD CLIENT
|
||||||
|
#
|
||||||
|
|
||||||
|
class dashboard(WebSocketServerProtocol):
|
||||||
|
|
||||||
|
def onConnect(self, request):
|
||||||
|
logging.info('Client connecting: %s', request.peer)
|
||||||
|
|
||||||
|
def onOpen(self):
|
||||||
|
logging.info('WebSocket connection open.')
|
||||||
|
self.factory.register(self)
|
||||||
|
self.sendMessage(('d' + dtemplate.render(_table=CTABLE)).encode('utf-8'))
|
||||||
|
self.sendMessage(('b' + btemplate.render(_table=BTABLE['BRIDGES'])).encode('utf-8'))
|
||||||
|
for _message in LOGBUF:
|
||||||
|
if _message:
|
||||||
|
self.sendMessage('l' + _bmessage)
|
||||||
|
|
||||||
|
def onMessage(self, payload, isBinary):
|
||||||
|
if isBinary:
|
||||||
|
logging.info('Binary message received: %s bytes', len(payload))
|
||||||
|
else:
|
||||||
|
logging.info('Text message received: %s', payload)
|
||||||
|
|
||||||
|
def connectionLost(self, reason):
|
||||||
|
WebSocketServerProtocol.connectionLost(self, reason)
|
||||||
|
self.factory.unregister(self)
|
||||||
|
|
||||||
|
def onClose(self, wasClean, code, reason):
|
||||||
|
logging.info('WebSocket connection closed: %s', reason)
|
||||||
|
|
||||||
|
class dashboardFactory(WebSocketServerFactory):
|
||||||
|
|
||||||
|
def __init__(self, url):
|
||||||
|
WebSocketServerFactory.__init__(self, url)
|
||||||
|
self.clients = {}
|
||||||
|
|
||||||
|
def register(self, client):
|
||||||
|
if client not in self.clients:
|
||||||
|
logging.info('registered client %s', client.peer)
|
||||||
|
self.clients[client] = time()
|
||||||
|
|
||||||
|
def unregister(self, client):
|
||||||
|
if client in self.clients:
|
||||||
|
logging.info('unregistered client %s', client.peer)
|
||||||
|
del self.clients[client]
|
||||||
|
|
||||||
|
def broadcast(self, msg):
|
||||||
|
logging.debug('broadcasting message to: %s', self.clients)
|
||||||
|
for c in self.clients:
|
||||||
|
c.sendMessage(msg.encode('utf8'))
|
||||||
|
logging.debug('message sent to %s', c.peer)
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# STATIC WEBSERVER
|
||||||
|
#
|
||||||
|
|
||||||
|
class web_server(Resource):
|
||||||
|
isLeaf = True
|
||||||
|
def render_GET(self, request):
|
||||||
|
logging.info('static website requested: %s', request)
|
||||||
|
return (index_html).encode('utf-8')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
filename = (LOG_PATH + LOG_NAME),
|
||||||
|
filemode='a',
|
||||||
|
format='%(asctime)s %(levelname)s %(message)s',
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
)
|
||||||
|
console = logging.StreamHandler()
|
||||||
|
console.setLevel(logging.INFO)
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
||||||
|
console.setFormatter(formatter)
|
||||||
|
logging.getLogger('').addHandler(console)
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
logging.info('monitor.py starting up')
|
||||||
|
logger.info('\n\n\tCopyright (c) 2016, 2017, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n\n\tPython 3 port:\n\t2019 Steve Miller, KC1AWV <smiller@kc1awv.net>\n\n\tModifed by:\t SP2ONG 2019\n\n')
|
||||||
|
|
||||||
|
# Download alias files
|
||||||
|
result = try_download(PATH, PEER_FILE, PEER_URL, (FILE_RELOAD * 86400))
|
||||||
|
logging.info(result)
|
||||||
|
|
||||||
|
result = try_download(PATH, SUBSCRIBER_FILE, SUBSCRIBER_URL, (FILE_RELOAD * 86400))
|
||||||
|
logging.info(result)
|
||||||
|
|
||||||
|
# Make Alias Dictionaries
|
||||||
|
peer_ids = mk_full_id_dict(PATH, PEER_FILE, 'peer')
|
||||||
|
if peer_ids:
|
||||||
|
logging.info('ID ALIAS MAPPER: peer_ids dictionary is available')
|
||||||
|
|
||||||
|
subscriber_ids = mk_full_id_dict(PATH, SUBSCRIBER_FILE, 'subscriber')
|
||||||
|
if subscriber_ids:
|
||||||
|
logging.info('ID ALIAS MAPPER: subscriber_ids dictionary is available')
|
||||||
|
|
||||||
|
talkgroup_ids = mk_full_id_dict(PATH, TGID_FILE, 'tgid')
|
||||||
|
if talkgroup_ids:
|
||||||
|
logging.info('ID ALIAS MAPPER: talkgroup_ids dictionary is available')
|
||||||
|
|
||||||
|
local_subscriber_ids = mk_full_id_dict(PATH, LOCAL_SUB_FILE, 'subscriber')
|
||||||
|
if local_subscriber_ids:
|
||||||
|
logging.info('ID ALIAS MAPPER: local_subscriber_ids added to subscriber_ids dictionary')
|
||||||
|
subscriber_ids.update(local_subscriber_ids)
|
||||||
|
|
||||||
|
local_peer_ids = mk_full_id_dict(PATH, LOCAL_PEER_FILE, 'peer')
|
||||||
|
if local_peer_ids:
|
||||||
|
logging.info('ID ALIAS MAPPER: local_peer_ids added peer_ids dictionary')
|
||||||
|
peer_ids.update(local_peer_ids)
|
||||||
|
|
||||||
|
# Jinja2 Stuff
|
||||||
|
env = Environment(
|
||||||
|
loader=PackageLoader('monitor', 'templates'),
|
||||||
|
autoescape=select_autoescape(['html', 'xml'])
|
||||||
|
)
|
||||||
|
|
||||||
|
dtemplate = env.get_template('hblink_table.html')
|
||||||
|
btemplate = env.get_template('bridge_table.html')
|
||||||
|
|
||||||
|
# Create Static Website index file
|
||||||
|
index_html = get_template(PATH + 'index_template.html')
|
||||||
|
index_html = index_html.replace('<<<system_name>>>', REPORT_NAME)
|
||||||
|
if CLIENT_TIMEOUT > 0:
|
||||||
|
index_html = index_html.replace('<<<timeout_warning>>>', 'Continuous connections not allowed. Connections time out in {} seconds'.format(CLIENT_TIMEOUT))
|
||||||
|
else:
|
||||||
|
index_html = index_html.replace('<<<timeout_warning>>>', '')
|
||||||
|
|
||||||
|
# Start update loop
|
||||||
|
update_stats = task.LoopingCall(build_stats)
|
||||||
|
update_stats.start(FREQUENCY)
|
||||||
|
|
||||||
|
# Start a timout loop
|
||||||
|
if CLIENT_TIMEOUT > 0:
|
||||||
|
timeout = task.LoopingCall(timeout_clients)
|
||||||
|
timeout.start(10)
|
||||||
|
|
||||||
|
# Connect to HBlink
|
||||||
|
reactor.connectTCP(HBLINK_IP, HBLINK_PORT, reportClientFactory())
|
||||||
|
|
||||||
|
# Create websocket server to push content to clients
|
||||||
|
dashboard_server = dashboardFactory('ws://*:9000')
|
||||||
|
dashboard_server.protocol = dashboard
|
||||||
|
reactor.listenTCP(9000, dashboard_server)
|
||||||
|
|
||||||
|
# Create static web server to push initial index.html
|
||||||
|
website = Site(web_server())
|
||||||
|
reactor.listenTCP(WEB_SERVER_PORT, website)
|
||||||
|
|
||||||
|
reactor.run()
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Twisted
|
||||||
|
dmr_utils3
|
||||||
|
bitstring
|
||||||
|
autobahn
|
||||||
|
jinja2
|
Loading…
Reference in New Issue
Block a user