Additional Plugin Examples
In case you haven't seen enough.
This is a set of RUR plugins that report information about the number of available huge pages on each node. The huge page counts are reported in /proc/buddyinfo. There are two versions of the staging component: one that reports what is available and the second that reports changes during the application run.
Huge pages data plugin staging component (version A)
#
# Copyright (c) 2013 Cray Inc. All rights reserved.
#
# This is an RUR plugin that reports information about the number of available
# huge pages on each node. This is reported in /proc/buddyinfo.
#
# Each node reports its nid and the number of available pages of each size.
#
#!/usr/bin/env python
import sys, os, getopt
from rur_plugins import rur_plugin_args
def main():
apid, inputfile, outputfile, timeout, pre, post, parg =rur_plugin_args(sys.argv[1:])
if outputfile == 0:
outputfile = "/var/spool/RUR/buddyinfo."+str(apid)
if (pre==1):
zero_counters()
else:
nidf = open("/proc/cray_xt/nid", "r")
n = nidf.readlines()
nid = int(n[0])
inf = open("/proc/buddyinfo", "r")
b = inf.readlines()
sizes = dict( [( '2M' , 0 ), ('4M', 0), ('8M', 0), ('16M', 0), ('32M', 0), ('64M', 0)])
for line in b:
l = line.split()
sizes['2M'] += int(l[13])
sizes['4M'] += int(l[14])
sizes['8M'] += int(l[15])
sizes['16M'] += int(l[16])
sizes['32M'] += int(l[17])
sizes['64M'] += int(l[18])
o = open(outputfile, "w")
o.write("{6} {0} {1} {2} {3} {4} {5}".format(sizes['2M'],sizes['4M'], \
sizes['8M'], sizes['16M'], sizes['32M'], sizes['64M'], nid))
o.close()
if __name__ == "__main__":
main()
Huge pages data plugin staging component (version B)
#
# Copyright (c) 2013 Cray Inc. All rights reserved.
#
# This is an RUR plugin that reports information about the number of available
# huge pages on each node. This is reported in /proc/buddyinfo.
#
# This plugin records the number of available pages before the job is launched.
# At job completion time it reports the change
#
#!/usr/bin/env python
import sys, os, getopt
from rur_plugins import rur_plugin_args
def main():
apid, inputfile, outputfile, timeout, pre, post, parg =rur_plugin_args(sys.argv[1:])
if outputfile == 0:
outputfile = "/var/spool/RUR/buddyinfo."+str(apid)
if (pre==1):
inf = open("/proc/buddyinfo", "r")
b = inf.readlines()
sizes = dict( [( '2M' , 0 ), ('4M', 0), ('8M', 0), ('16M', 0), ('32M', 0), ('64M', 0)])
for line in b:
l = line.split()
sizes['2M'] += int(l[13])
sizes['4M'] += int(l[14])
sizes['8M'] += int(l[15])
sizes['16M'] += int(l[16])
sizes['32M'] += int(l[17])
sizes['64M'] += int(l[18])
o = open("/tmp/buddyinfo_save", "w")
o.write("{0} {1} {2} {3} {4} {5}".format(sizes['2M'],sizes['4M'], \
sizes['8M'], sizes['16M'], sizes['32M'], sizes['64M']))
o.close()
else:
nidf = open("/proc/cray_xt/nid", "r")
n = nidf.readlines()
nid = int(n[0])
inf = open("/proc/buddyinfo", "r")
b = inf.readlines()
sizes = dict( [( '2M' , 0 ), ('4M', 0), ('8M', 0), ('16M', 0), ('32M', 0), ('64M', 0)])
for line in b:
l = line.split()
sizes['2M'] += int(l[13])
sizes['4M'] += int(l[14])
sizes['8M'] += int(l[15])
sizes['16M'] += int(l[16])
sizes['32M'] += int(l[17])
sizes['64M'] += int(l[18])
obf = open("/tmp/buddyinfo_save", "r")
ob = obf.readlines()
n=0
obd0 = ob[0]
obd = obd0.split()
diff = [
(int(obd[0]) - sizes['2M']),
(int(obd[1]) - sizes['4M']),
(int(obd[2]) - sizes['8M']),
(int(obd[3]) - sizes['16M']),
(int(obd[4]) - sizes['32M']),
(int(obd[5]) - sizes['64M'])
]
o = open(outputfile, "w")
# uncomment the following line to get the actual sizes
#o.write("sizes {6} {0} {1} {2} {3} {4} {5}\n".format(sizes['2M'],sizes['4M'], \
sizes['8M'], sizes['16M'], sizes['32M'], sizes['64M'], nid))
o.write("diff {6} {0} {1} {2} {3} {4} {5}".format(diff[0], diff[1], diff[2], \
diff[3], diff[4], diff[5], nid))
o.close()
os.unlink("/tmp/buddyinfo_save")
if __name__ == "__main__":
main()
Huge pages data plugin post processing component
#
# Copyright (c) 2013 Cray Inc. All rights reserved.
#
# This is a RUR postprocessing pluging for the buddyinfo data
# collection. It copies the input files to output, adding a
# "buddyinfo" label.
#
#!/usr/bin/env python
import sys, os
from rur_plugins import rur_args
def main():
apid, inputfile, outputfile, timeout = rur_args(sys.argv[1:])
if outputfile == 0:
outputfile = inputfile + ".out"
fin=open(inputfile, "r")
l = fin.readlines()
fout=open(outputfile, 'w+')
for line in l:
fout.write("buddyinfo {0}".format(line))
if __name__ == "__main__":
main()