Skip to content
Snippets Groups Projects
Commit f2ca0653 authored by Leonard Penzer's avatar Leonard Penzer
Browse files

Einige Verbesserungen

- access.log und access.log.1 überwachen
- möglichkeit mehrere Branches zu überwachen
- Variablen besser benannt
- vergeleich des Releases mit >= anstelle von ==
- updated enthält nun Knoten aller branches
parent 525b8da0
No related branches found
No related tags found
No related merge requests found
...@@ -2,25 +2,26 @@ ...@@ -2,25 +2,26 @@
import json import json
import netaddr import netaddr
branch_to_be_checked = "nightly" branch_to_be_checked = ["nightly"]
#release_to_be_watched = "1.6+2019-09-14-g.9f827678-s.5904ca9"
release_to_be_watched = "1.7+2019-09-15-g.43e01839-s.300ff17"
def getNodesDownloadedUpdate(access,segments): def getNodesDownloadedUpdate(access,segments):
updated = [] downloaded = []
for line in access.split("\n"): for line in access.split("\n"):
ipv6 = line.split(" ")[0] ipv6 = line.split(" ")[0]
for segment in segments: for segment in segments:
if ("Wget" in line or "Gluon Autoupdater (using libuclient)" in line ) and branch_to_be_checked in line and ipv6.startswith("fd21:b4dc:4b%02i"%(segment)) and "gluon-ffs" in line: for branch in branch_to_be_checked:
if ("Wget" in line or "Gluon Autoupdater (using libuclient)" in line ) and branch in line and ipv6.startswith("fd21:b4dc:4b%02i"%(segment)) and "gluon-ffs" in line and release_to_be_watched in line:
#print(line) #print(line)
if netaddr.IPAddress(ipv6) not in updated: if netaddr.IPAddress(ipv6) not in downloaded:
updated.append(netaddr.IPAddress(ipv6)) downloaded.append(netaddr.IPAddress(ipv6))
return updated return downloaded
with open("/var/log/nginx/access.log") as fp:
access = fp.read()
with open("/home/www/html/netinfo/json/nodesdb.json") as fp: access = open("/var/log/nginx/access.log.1").read()
data = json.load(fp) access += open("/var/log/nginx/access.log").read()
data = json.load(open("/home/www/html/netinfo/json/nodesdb.json"))
...@@ -28,8 +29,8 @@ countWaiting = 0 ...@@ -28,8 +29,8 @@ countWaiting = 0
countUpdated = 0 countUpdated = 0
countOfflineAfterUpdate = 0 countOfflineAfterUpdate = 0
segmentsWatched = range(1,33) segmentsWatched = range(1,33)
updated = getNodesDownloadedUpdate(access,segmentsWatched) downloads = getNodesDownloadedUpdate(access,segmentsWatched)
release_to_be_watched = "1.6+2019-09-14-g.9f827678-s.5904ca9" updated = []
for mac in data: for mac in data:
d = data[mac] d = data[mac]
software = d["software"] software = d["software"]
...@@ -51,26 +52,31 @@ for mac in data: ...@@ -51,26 +52,31 @@ for mac in data:
else: else:
segment = 0 segment = 0
hasDownloaded = "" hasDownloaded = ""
if ipv6 in updated: if ipv6 in downloads:
hasDownloaded = "UPDATING" hasDownloaded = "UPDATING"
online = d["status"] online = d["status"]
for segmentWatched in segmentsWatched: for segmentWatched in segmentsWatched:
if segment == segmentWatched and online=="online" and branch == branch_to_be_checked and autoupdater_enabled == True: if segment == segmentWatched and release >= release_to_be_watched :
if release == release_to_be_watched: updated.append(ipv6)
if segment == segmentWatched and branch in branch_to_be_checked and autoupdater_enabled == True and release == release_to_be_watched :
countUpdated+=1 countUpdated+=1
if ipv6 not in updated: if segment == segmentWatched and online=="online" and branch in branch_to_be_checked and autoupdater_enabled == True:
if release >= release_to_be_watched:
if ipv6 not in downloads:
print ("Not expected %s %s %s %s %2i %s"%(mac,online,branch,release,segment,ipv6)) print ("Not expected %s %s %s %s %2i %s"%(mac,online,branch,release,segment,ipv6))
else: else:
print ("%s %s %s %s %2i %s %s %s"%(mac,online,branch,release,segment,ipv6,hardware_model,hasDownloaded)) print ("%s %s %s %s %2i %s %s %s"%(mac,online,branch,release,segment,ipv6,hardware_model,hasDownloaded))
countWaiting+=1 countWaiting+=1
if segment == segmentWatched and online!="online" and release != release_to_be_watched and branch == branch_to_be_checked and autoupdater_enabled == True and ipv6 in updated: if segment == segmentWatched and online!="online" and release != release_to_be_watched and branch in branch_to_be_checked and autoupdater_enabled == True and ipv6 in downloads:
print ("!!!! %s %s %s %s %2i %s %s"%(mac,online,branch,release,segment,ipv6,hasDownloaded)) print ("!!!! %s %s %s %s %2i %s %s"%(mac,online,branch,release,segment,ipv6,hasDownloaded))
countOfflineAfterUpdate+=1 countOfflineAfterUpdate+=1
print("Waiting: %i"%countWaiting) print("Waiting: %i"%countWaiting)
print("Updated: %i"%countUpdated) print("Updated: %i"%countUpdated)
print("Offline after Update: %i"%countOfflineAfterUpdate) print("Offline after Update: %i"%countOfflineAfterUpdate)
print("Downloads: %i"%(len(updated))) print("Downloads: %i"%(len(downloads)))
print("Sum: %i"%(countWaiting+countUpdated)) print("Sum: %i"%(countWaiting+countUpdated))
#for u in updated: print("Nodes with upgrade in progress:")
# print(u) for d in downloads:
if d not in updated:
print(d)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment