check-mirrors check-mirrors.py, 1.26, 1.27 return-mirrorlist.py, 1.12, 1.13
Michael Patrick McGrath (mmcgrath)
fedora-extras-commits at redhat.com
Fri Aug 4 20:03:52 UTC 2006
Author: mmcgrath
Update of /cvs/fedora/check-mirrors
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv28474
Modified Files:
check-mirrors.py return-mirrorlist.py
Log Message:
Added basic statistical information like uptime.
Index: check-mirrors.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/check-mirrors.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- check-mirrors.py 3 Aug 2006 02:48:11 -0000 1.26
+++ check-mirrors.py 4 Aug 2006 20:03:49 -0000 1.27
@@ -110,18 +110,18 @@
def goodmirror(self, repo, arch, country, url):
""" Update or insert a good mirror """
- if self.run("update mirrors set failures='0', lastgood=DATETIME('now') where url='%s' and repo='%s' and arch='%s';" % (url, repo, arch)):
+ if self.run("update mirrors set successes=(select successes from mirrors where url='%s' and repo='%s' and arch='%s')+1, valid=1, lastgood=DATETIME('now') where url='%s' and repo='%s' and arch='%s';" % (url, repo, arch, url, repo, arch)):
return True
- elif self.run("insert into mirrors (repo, arch, country, url, failures, lastgood) VALUES ('%s', '%s', '%s', '%s', 0, DATETIME('now'));" % (repo, arch, country, url)):
+ elif self.run("insert into mirrors (repo, arch, country, url, successes, valid, lastgood) VALUES ('%s', '%s', '%s', '%s', 1, 1, DATETIME('now'));" % (repo, arch, country, url)):
return True
else:
return False
def badmirror(self, repo, arch, country, url):
""" Update or insert a bad mirror """
- if self.run("update mirrors set failures=(select failures from mirrors where url='%s')+1 where url='%s' and repo='%s' and arch='%s';" % (url, url, repo, arch)):
+ if self.run("update mirrors set failures=(select failures from mirrors where url='%s' and repo='%s' and arch='%s')+1, valid=0 where url='%s' and repo='%s' and arch='%s';" % (url, repo, arch, url, repo, arch)):
return True
- elif self.run("insert into mirrors (repo, arch, country, url, failures, lastgood) VALUES ('%s', '%s', '%s', '%s', 1, '0');" % (repo, arch, country, url)):
+ elif self.run("insert into mirrors (repo, arch, country, url, failures, valid, lastgood) VALUES ('%s', '%s', '%s', '%s', 1, 0, '0');" % (repo, arch, country, url)):
return True
else:
return True
@@ -136,7 +136,7 @@
sys.exit(2)
return False
else:
- self.run('CREATE TABLE mirrors (m_id INTEGER PRIMARY KEY, repo varchar(30), arch varchar(8), country varchar(2), url text, failures integer, lastgood date);')
+ self.run('CREATE TABLE mirrors (m_id INTEGER PRIMARY KEY, repo varchar(30), arch varchar(8), country varchar(2), url text, failures integer default 0, successes integer default 0, valid integer, lastgood date);')
if runno == 0:
self.initdb(1)
else:
Index: return-mirrorlist.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/return-mirrorlist.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- return-mirrorlist.py 3 Aug 2006 02:48:11 -0000 1.12
+++ return-mirrorlist.py 4 Aug 2006 20:03:49 -0000 1.13
@@ -73,7 +73,7 @@
else:
countrysql = "and country='%s'" % country
try:
- self.dbcursor.execute('SELECT url FROM mirrors where failures=0 and repo="%s" and arch="%s" %s;' % (repo, arch, countrysql))
+ self.dbcursor.execute('SELECT url FROM mirrors where valid=1 and repo="%s" and arch="%s" %s;' % (repo, arch, countrysql))
except sqlite.Error, err:
print "%s" % err
@@ -95,6 +95,23 @@
self.printMirrors(repo, arch, 'global')
else:
return True
+
+ def printStats(self):
+ try:
+ self.dbcursor.execute('SELECT * FROM mirrors;')
+ except sqlite.Error, err:
+ print "%s" % err
+
+ for row in self.dbcursor.fetchall():
+ totalChecks = row[5] + row[6] * 1.0
+ good = 0.0
+ good = (row[5] / totalChecks * 1.0) * 100
+ print '# %s' % row[4]
+ print '# Country: %s' % row[3]
+ print '# Last Good: %s' % row[8]
+ print '# uptime: %i%%' % good
+ print '# -----------------------------------'
+ return True
def close(self):
@@ -215,7 +232,9 @@
print '# repo = %s country = %s arch = %s ' % (repo, country, arch)
DB.printMirrors(repo, arch, country)
-
+ if form.has_key('stats'):
+ DB.printStats()
+
# fo = open(return_file, 'r')
# for line in fo.readlines():
# line = line.replace('\n', '')
More information about the fedora-extras-commits
mailing list