ssh update on connect + web: define unseen before offline
This commit is contained in:
parent
e02273e0ef
commit
1a7989a24e
|
@ -59,23 +59,17 @@ func NewNode(nodeOrigin *yanicRuntime.Node) *Node {
|
|||
}
|
||||
|
||||
func (n *Node) SSHUpdate(ssh *ssh.Manager, iface string, oldnode *Node) {
|
||||
if oldnode == nil {
|
||||
return
|
||||
}
|
||||
addr := n.GetAddress(iface)
|
||||
if n.Hostname != oldnode.Hostname {
|
||||
if oldnode == nil || n.Hostname != oldnode.Hostname {
|
||||
ssh.ExecuteOn(addr, fmt.Sprintf(SSHUpdateHostname, n.Hostname))
|
||||
}
|
||||
if n.Owner != oldnode.Owner {
|
||||
if oldnode == nil || n.Owner != oldnode.Owner {
|
||||
ssh.ExecuteOn(addr, fmt.Sprintf(SSHUpdateOwner, n.Owner))
|
||||
}
|
||||
if !locationEqual(&n.Location, &oldnode.Location) {
|
||||
if oldnode == nil || !locationEqual(&n.Location, &oldnode.Location) {
|
||||
ssh.ExecuteOn(addr, fmt.Sprintf(SSHUpdateLocation, n.Location.Latitude, n.Location.Longtitude))
|
||||
}
|
||||
}
|
||||
func (n *Node) SSHSet(ssh *ssh.Manager, iface string) {
|
||||
n.SSHUpdate(ssh, iface, nil)
|
||||
}
|
||||
func (n *Node) GetAddress(iface string) net.TCPAddr {
|
||||
return net.TCPAddr{IP: n.Address, Port: 22, Zone: iface}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,10 @@ func (nodes *Nodes) LearnNode(n *yanic.Node) {
|
|||
logger.Infof("new node with uptime: %s", uptime)
|
||||
|
||||
nodes.Current[node.NodeID] = node
|
||||
if lNode := nodes.List[node.NodeID]; lNode != nil {
|
||||
lNode.Address = node.Address
|
||||
go lNode.SSHUpdate(nodes.ssh, nodes.iface, node)
|
||||
}
|
||||
nodes.notify(node, false)
|
||||
}
|
||||
|
||||
|
@ -96,7 +100,7 @@ func (nodes *Nodes) Updater() {
|
|||
defer nodes.Unlock()
|
||||
for nodeid, node := range nodes.List {
|
||||
if n, ok := nodes.Current[nodeid]; ok {
|
||||
go node.SSHUpdate(nodes.ssh, nodes.iface, n)
|
||||
go n.SSHUpdate(nodes.ssh, nodes.iface, node)
|
||||
}
|
||||
}
|
||||
log.Log.Debug("updater per ssh runs")
|
||||
|
|
|
@ -45,9 +45,9 @@ const guiList = {};
|
|||
case 'ChanUtil':
|
||||
// eslint-disable-next-line id-length
|
||||
let aMax = a.statistics.wireless.map((d) =>
|
||||
d.ChanUtil
|
||||
).sort(sortNumber),
|
||||
// eslint-disable-next-line id-length
|
||||
d.ChanUtil
|
||||
).sort(sortNumber),
|
||||
// eslint-disable-next-line id-length
|
||||
bMax = b.statistics.wireless.map((d) =>
|
||||
d.ChanUtil
|
||||
).sort(sortNumber);
|
||||
|
@ -86,15 +86,17 @@ const guiList = {};
|
|||
option = domlib.newAt(tr, 'td'),
|
||||
edit = domlib.newAt(option, 'div');
|
||||
|
||||
startdate.setMinutes(startdate.getMinutes() - config.node.offline);
|
||||
if (new Date(node.lastseen) < startdate) {
|
||||
tr.classList.add('offline');
|
||||
}
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
if (!node._wireless) {
|
||||
tr.classList.add('unseen');
|
||||
} else {
|
||||
startdate.setMinutes(startdate.getMinutes() - config.node.offline);
|
||||
if (new Date(node.lastseen) < startdate) {
|
||||
tr.classList.add('offline');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastseen.innerHTML = moment(node.lastseen).fromNow(true);
|
||||
|
||||
nodeID.innerHTML = node.node_id;
|
||||
|
|
Loading…
Reference in New Issue