I am currently playing around with OpenVZ in a production environment. So far it runs pretty stable. One of the biggest issues so far was that the vzcalc tool computes way to small limits for some of the system parameters, like the maximum number of inodes allowed. The monitoring tools either trash you with unimportant information (/proc/user_beancounters), or say nothing important (vzctl status). I created the following python snippet, in order have a one-stop view on the status of my virtual machines. Check the documentation of vzlist, in order to extend the overview with your favorite set of information. Two print statements use escape codes to set the output color to red, and back. Maybe somebody can explain me a better way for this in Python …
[source:python]
import sys
import os
maxslen=12
printparams = [['vpsid', 'VPS ID'],['hostname', 'Hostname'],
['ip', 'IP address'],['status', 'Status'],
['laverage','Load average']]
diffparams = [['numproc', 'Processes'],['numfile', 'Open files'],
['numflock','File locks'],['physpages','4k Pages'],
['numtcpsock','TCP sockets']]
diff2params = [['diskspace','Disk'],['diskinodes','Inodes']]
def printdiff (name, param, maxsuffix):
value = os.popen(‘/usr/sbin/vzlist -H -o ‘ + param + ‘ ‘ + sys.argv[1]).read()
max = os.popen(‘/usr/sbin/vzlist -H -o ‘ + param + maxsuffix + sys.argv[1]).read()
percent = int(value)*100/int(max)
if percent > 90:
sys.stdout.write(‘^[[0;31;40m')
print '%s : %i %% (%s of %s)' % (name.ljust(maxslen) ,percent, value.strip() , max.strip())
for param, name in printparams:
value = os.popen('/usr/sbin/vzlist -H -o ' + param + ' ' + sys.argv[1]).read()
print name.ljust(maxslen) + ‘ : ‘ + value.strip()
for param, name in diffparams:
printdiff(name, param, ‘.l ‘)
for param, name in diff2params:
printdiff(name, param, ‘.s ‘)
print ‘^[[0;37;40m'
[/source]