peletiah/openvz — Issue #1: Beancounters for destroyed containers break the script
Author: eanders
Created: 2012-01-18 16:24:20+00:00
State: open

If there are past beancounter failures for containers that have been destroyed the script throws the following error:

/check_beancounter.py -i -e elliot@server.com

Traceback (most recent call last):
File "./check_beancounter.py", line 198, in
current_data = compare_data(beancounter_data,data_read,count,email)
File "./check_beancounter.py", line 119, in compare_data
count_change=cntcheck(data_read,current_data,veid,fields,count,count_change)
File "./check_beancounter.py", line 71, in cntcheck
hostname=find_veid(veid)
File "./check_beancounter.py", line 24, in find_veid
veid_conf=open('/etc/vz/conf/' + str(veid) + '.conf','r')
IOError: [Errno 2] No such file or directory: '/etc/vz/conf/319.conf'

I don't know enough python yet, but wrapping the first line in find_veid in a try, to make sure the conf file exists before working with it should solve the problem. It should be safe to ignore any beancounter failures for containers not running or that don't have config files.