place dnsq
This commit is contained in:
@@ -336,7 +336,7 @@ def log(host, m, service=None):
|
|||||||
|
|
||||||
def dnsupdatethread():
|
def dnsupdatethread():
|
||||||
while True:
|
while True:
|
||||||
name, addr = dnsQ.get()
|
name, addr = Host.dnsQ.get()
|
||||||
m = "changed address to %s" % (addr)
|
m = "changed address to %s" % (addr)
|
||||||
err = nsupdate(name, addr)
|
err = nsupdate(name, addr)
|
||||||
if err:
|
if err:
|
||||||
@@ -344,7 +344,7 @@ def dnsupdatethread():
|
|||||||
email("error: nsupdate failed", "%s: %s" % (name, m))
|
email("error: nsupdate failed", "%s: %s" % (name, m))
|
||||||
else:
|
else:
|
||||||
m += ", DNS updated."
|
m += ", DNS updated."
|
||||||
dnsQ.task_done()
|
Host.dnsQ.task_done()
|
||||||
log(name, m)
|
log(name, m)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -407,7 +407,7 @@ def readsock(sock):
|
|||||||
email("address change", "%s %s" % (host.name, res))
|
email("address change", "%s %s" % (host.name, res))
|
||||||
pushover("%s %s" % (host.name, res))
|
pushover("%s %s" % (host.name, res))
|
||||||
|
|
||||||
if conn.getstate() != Connection.up and interval > 0:
|
if conn.getstate() != Connection.up: # XXX and interval > 0:
|
||||||
lasts = conn.state
|
lasts = conn.state
|
||||||
d = conn.newstate(Connection.up, now)
|
d = conn.newstate(Connection.up, now)
|
||||||
m = "%s back after being %s for %s" % (conn.afam, lasts, dur(d))
|
m = "%s back after being %s for %s" % (conn.afam, lasts, dur(d))
|
||||||
@@ -960,7 +960,7 @@ servthread = threading.Thread(target=serv.serve_forever)
|
|||||||
servthread.daemon = True
|
servthread.daemon = True
|
||||||
servthread.start()
|
servthread.start()
|
||||||
|
|
||||||
dnsQ = Queue.Queue()
|
Host.dnsQ = Queue.Queue()
|
||||||
dnsT = threading.Thread(target=dnsupdatethread)
|
dnsT = threading.Thread(target=dnsupdatethread)
|
||||||
dnsT.daemon = True
|
dnsT.daemon = True
|
||||||
dnsT.start()
|
dnsT.start()
|
||||||
|
|||||||
+4
-3
@@ -18,6 +18,7 @@ class Connection:
|
|||||||
# map of addrs to names
|
# map of addrs to names
|
||||||
|
|
||||||
htab = {}
|
htab = {}
|
||||||
|
unknown = "unknown"
|
||||||
up = "up"
|
up = "up"
|
||||||
down = "down"
|
down = "down"
|
||||||
overdue = "overdue"
|
overdue = "overdue"
|
||||||
@@ -30,13 +31,13 @@ class Connection:
|
|||||||
self.rtts = [0]
|
self.rtts = [0]
|
||||||
self.lastbeat = time.time()
|
self.lastbeat = time.time()
|
||||||
self.statetime = self.lastbeat
|
self.statetime = self.lastbeat
|
||||||
self.state = Connection.up
|
self.state = Connection.unknown
|
||||||
|
|
||||||
if host:
|
if host:
|
||||||
r = "new addr %s" % (addr)
|
r = "new addr %s" % (addr)
|
||||||
Connection.htab[addr] = self.host.name
|
Connection.htab[addr] = self.host.name
|
||||||
if self.host.isDynDns():
|
if self.host.isDynDns():
|
||||||
dnsQ.put((self.host.name, self.addr))
|
Host.dnsQ.put((self.host.name, self.addr))
|
||||||
|
|
||||||
|
|
||||||
def statedict(self, Null=False):
|
def statedict(self, Null=False):
|
||||||
@@ -107,7 +108,7 @@ class Connection:
|
|||||||
self.addr = addr
|
self.addr = addr
|
||||||
Connection.htab[addr] = self.host.name
|
Connection.htab[addr] = self.host.name
|
||||||
if self.host.isDynDns():
|
if self.host.isDynDns():
|
||||||
dnsQ.put((self.host.name, self.addr))
|
Host.dnsQ.put((self.host.name, self.addr))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user