diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-07-26 15:30:51 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-07-30 11:53:15 -0500 |
commit | 368f9c770c0eadc8a4cf4b54255ee8d51b55c95b (patch) | |
tree | 0dd911f42bea05304dd13a1b3d430aa3b1a6d07d /src/lib/Server/Reports | |
parent | bf3fe01ce7c139e1afe8b6addc8cd4c6c819c4a9 (diff) | |
download | bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.tar.gz bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.tar.bz2 bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.zip |
DBStats: Fix random mysql errors
Occasionally importing ping data would fail with "Commands out of
sync; you can't run this command now".
Improved logging and error handling for imports.
Fixed indentation error in GetCurrentEntry
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5992 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Reports')
-rwxr-xr-x | src/lib/Server/Reports/importscript.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py index 016098cc8..cdfd8079c 100755 --- a/src/lib/Server/Reports/importscript.py +++ b/src/lib/Server/Reports/importscript.py @@ -63,12 +63,9 @@ def build_reason_kwargs(r_ent): def load_stats(cdata, sdata, vlevel, logger, quick=False, location=''): - cursor = connection.cursor() clients = {} [clients.__setitem__(c.name, c) \ for c in Client.objects.all()] - #[clients.__setitem__(c['name'], c['id']) \ - # for c in Client.objects.values('name', 'id')] pingability = {} [pingability.__setitem__(n.get('name'), n.get('pingable', default='N')) \ @@ -169,16 +166,18 @@ def load_stats(cdata, sdata, vlevel, logger, quick=False, location=''): for key in pingability.keys(): if key not in clients: - #print "Ping Save Problem with client %s" % name continue - pmatch = Ping.objects.filter(client=clients[key]).order_by('-endtime') - if pmatch and pmatch[0].status == pingability[key]: - pmatch[0].endtime = datetime.now() - pmatch[0].save() - else: - Ping(client=clients[key], status=pingability[key], - starttime=datetime.now(), - endtime=datetime.now()).save() + try: + pmatch = Ping.objects.filter(client=clients[key]).order_by('-endtime')[0] + if pmatch.status == pingability[key]: + pmatch.endtime = datetime.now() + pmatch.save() + continue + except IndexError: + pass + Ping(client=clients[key], status=pingability[key], + starttime=datetime.now(), + endtime=datetime.now()).save() if vlevel > 1: logger.info("---------------PINGDATA SYNCED---------------------") |