From f2ca06536271045747c87c597e6e8558cafffd69 Mon Sep 17 00:00:00 2001 From: poldy79 <leonard@penzer.de> Date: Mon, 16 Sep 2019 15:05:22 +0200 Subject: [PATCH] Einige Verbesserungen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- update_checker.py | 52 ++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/update_checker.py b/update_checker.py index 990a863..c95396c 100755 --- a/update_checker.py +++ b/update_checker.py @@ -2,25 +2,26 @@ import json 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): - updated = [] + downloaded = [] for line in access.split("\n"): ipv6 = line.split(" ")[0] 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: - #print(line) - if netaddr.IPAddress(ipv6) not in updated: - updated.append(netaddr.IPAddress(ipv6)) - return updated + 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) + if netaddr.IPAddress(ipv6) not in downloaded: + downloaded.append(netaddr.IPAddress(ipv6)) + 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: - data = json.load(fp) +access = open("/var/log/nginx/access.log.1").read() +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 countUpdated = 0 countOfflineAfterUpdate = 0 segmentsWatched = range(1,33) -updated = getNodesDownloadedUpdate(access,segmentsWatched) -release_to_be_watched = "1.6+2019-09-14-g.9f827678-s.5904ca9" +downloads = getNodesDownloadedUpdate(access,segmentsWatched) +updated = [] for mac in data: d = data[mac] software = d["software"] @@ -51,26 +52,31 @@ for mac in data: else: segment = 0 hasDownloaded = "" - if ipv6 in updated: + if ipv6 in downloads: hasDownloaded = "UPDATING" online = d["status"] for segmentWatched in segmentsWatched: - if segment == segmentWatched and online=="online" and branch == branch_to_be_checked and autoupdater_enabled == True: - if release == release_to_be_watched: - countUpdated+=1 - if ipv6 not in updated: + if segment == segmentWatched and 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 + 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)) else: print ("%s %s %s %s %2i %s %s %s"%(mac,online,branch,release,segment,ipv6,hardware_model,hasDownloaded)) 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)) countOfflineAfterUpdate+=1 print("Waiting: %i"%countWaiting) print("Updated: %i"%countUpdated) print("Offline after Update: %i"%countOfflineAfterUpdate) -print("Downloads: %i"%(len(updated))) +print("Downloads: %i"%(len(downloads))) print("Sum: %i"%(countWaiting+countUpdated)) -#for u in updated: -# print(u) +print("Nodes with upgrade in progress:") +for d in downloads: + if d not in updated: + print(d) -- GitLab