Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2007, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 as published by 8 # the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 14 __doc__='''UpdateCheck 15 16 ''' 17 18 import Globals 19 import transaction 20 import Products.ZenUtils.Version 21 from Products.ZenUtils.Version import Version 22 from Products.ZenEvents import Event 23 from Products.ZenEvents.ZenEventClasses import Status_Update 24 import urllib 25 import string 26 import time 27 28 URL = 'http://update.zenoss.org/cgi-bin/version' 29 30 DAY_SECONDS = 60*60*24 31 HOUR_SECONDS = 60*60 32 3840120 121 if __name__ == "__main__": 122 from Products.ZenUtils import ZCmdBase 125 zendmd = zendmd() 126 uc = UpdateCheck() 127 uc.getUpdate = lambda *args: parseVersion('0.24.0') 128 uc.check(zendmd.dmd, zendmd.dmd.ZenEventManager, manual=True) 129 transaction.commit() 13042 available = None 43 args = {} 44 if dmd.uuid is None: 45 import commands 46 dmd.uuid = commands.getoutput('uuidgen') 47 args['sk'] = dmd.uuid 48 args['ac'] = (manual and '0') or '1' 49 args['zv'] = dmd.About.getZenossVersion().long() 50 args['pv'] = dmd.About.getPythonVersion().long() 51 args['mv'] = dmd.About.getMySQLVersion().long() 52 args['os'] = dmd.About.getOSVersion().long() 53 args['osv'] = dmd.About.getOSVersion().full() 54 #args['rv'] = Products.ZenUtils.Version.getZenossRevision() 55 args['rv'] = 'bad bad bad' 56 args['up'] = time.time() - dmd.getPhysicalRoot().Control_Panel.process_start 57 58 # If they have not opted-out and this is not a manual check then 59 # gather usage numbers and include in request 60 if not manual and dmd.reportMetricsOptIn: 61 args['nd'] = dmd.Devices.countDevices() 62 args['nu'] = len(dmd.ZenUsers.objectIds()) 63 args['nm'] = dmd.Events.countInstances() 64 args['ne'] = dmd.ZenEventManager.countEventsSince( 65 time.time() - 24 * 60 * 60) 66 numProducts = 0 67 manufacturers = dmd.Manufacturers.objectValues(spec='Manufacturer') 68 for m in manufacturers: 69 numProducts += m.products.countObjects() 70 args['np'] = numProducts 71 args['nr'] = dmd.Reports.countReports() 72 args['nt'] = dmd.Devices.rrdTemplates.countObjects() 73 args['ns'] = dmd.Systems.countChildren() 74 args['ng'] = dmd.Groups.countChildren() 75 args['nl'] = dmd.Locations.countChildren() 76 77 query = urllib.urlencode(args.items()) 78 for line in urllib.urlopen(URL + '?' + query): 79 # skip blank lines and http gunk 80 if line.strip() and line[0] not in '<' + string.whitespace: 81 try: 82 available = parseVersion(line.strip()) 83 break 84 except ValueError: 85 pass 86 return available8789 "call home with version information" 90 if not manual: 91 if time.time() - dmd.lastVersionCheck < DAY_SECONDS \ 92 or time.time() - dmd.lastVersionCheckAttempt < 2 * HOUR_SECONDS: 93 return 94 if not dmd.versionCheckOptIn: 95 return 96 now = long(time.time()) 97 dmd.lastVersionCheckAttempt = now 98 try: 99 available = self.getUpdate(dmd, manual) 100 except IOError: 101 available = None 102 if not isinstance(available, Version): 103 # We did not successfully get a version, don't continue 104 return 105 dmd.availableVersion = available.short() 106 dmd.lastVersionCheck = now 107 availableVersion = parseVersion(dmd.availableVersion) 108 if (availableVersion is None 109 or dmd.About.getZenossVersion() < availableVersion): 110 if availableVersion != available: 111 import socket 112 summary = ('A new version of Zenoss (%s) has been released' % 113 available.short()) 114 zem.sendEvent(Event.Event(device=socket.getfqdn(), 115 eventClass=Status_Update, 116 severity=Event.Info, 117 summary=summary)) 118 119 return True
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:26 2007 | http://epydoc.sourceforge.net |