7 from monitor.util import file as fileutil
10 This utility is designed to simplify the task of parsing and generating
11 statistics for the number of packages on PlanetLab nodes.
14 def list_to_md5(strlist):
19 return digest.hexdigest()
21 def pick_some_rpms(pattern, rpmlist):
23 cpatt = re.compile(pattern)
33 from optparse import OptionParser
34 parser = OptionParser()
36 parser.set_defaults( select=None,
42 parser.add_option("", "--input", dest="input",
43 help="the input file")
44 parser.add_option("", "--pattern", dest="select",
45 help="the pattern to pull out from rpm list")
46 parser.add_option("", "--frequency", dest="frequency", action="store_true",
47 help="print the frequency of packages matched by select")
48 parser.add_option("", "--disablepackage", dest="package", action="store_false",
49 help="print the frequency of each pl package")
50 (config, args) = parser.parse_args()
51 if len(sys.argv) == 1 or config.input is None:
56 rpmlist = fileutil.getListFromFile(config.input)
58 current_packages = ['NodeManager-1.8-5.planetlab',
59 'NodeUpdate-0.5-4.planetlab', 'codemux-0.1-13.planetlab',
60 'fprobe-ulog-1.1.3-0.planetlab', 'ipod-2.2-1.planetlab',
61 'iproute-2.6.16-2.planetlab', 'iptables-1.3.8-9.planetlab',
62 'kernel-2.6.22.19-vs2.3.0.34.28.planetlab',
63 'madwifi-0.9.4-2.6.22.19.3.planetlab', 'monitor-1.0-7.planetlab',
64 'monitor-client-3.0-10.planetlab',
65 'monitor-runlevelagent-3.0-10.planetlab', 'pl_mom-2.3-1.planetlab',
66 'pl_sshd-1.0-11.planetlab', 'pyplnet-4.3-2.planetlab',
67 'util-vserver-pl-0.3-16.planetlab',
68 'vserver-planetlab-f8-i386-4.2-12.2009.05.27',
69 'vserver-systemslices-planetlab-f8-i386-4.2-12.2009.05.27',
70 'vsys-0.9-3.planetlab', 'vsys-scripts-0.95-3.planetlab']
74 all_patterns = map(lambda x: ".*" + x + ".*", [ 'NodeManager',
75 'NodeUpdate', 'codemux', 'fprobe', 'ipod',
76 'iproute', 'iptables', 'kernel', 'madwifi', 'monitor-client',
77 'monitor-runlevelagent', 'monitor', 'oombailout', 'pl_mom',
78 'pl_sshd', 'pyplnet', 'util-vserver-pl', 'vserver-planetlab-f8-i386',
79 'vserver-systemslices-planetlab-f8-i386', 'vsys-scripts', 'vsys'])
81 all_patterns = [config.select]
83 for pattern in all_patterns:
91 rpms = pick_some_rpms(pattern, rpms)
93 sum = list_to_md5(rpms)
95 return_sums[sum]['hosts'].append(host)
97 return_sums[sum] = {'hosts' : [], 'diff' : []}
98 return_sums[sum]['hosts'].append(host)
100 return_sums[sum]['diff'] = set(rpms) - set(current_packages)
103 #print "Frequency for packages that matched: %s" % pattern
105 for sum in return_sums:
106 sum_list.append((len(return_sums[sum]['hosts']), sum))
108 sum_list.sort(lambda a,b: cmp(b[0], a[0]))
110 #print sum[0], sum[1], map(lambda x: x.replace('.planetlab', ''), return_sums[sum[1]]['diff'])
111 print sum[0], sum[1], len(map(lambda x: x.replace('.planetlab', ''), return_sums[sum[1]]['diff']))
113 if __name__ == "__main__":