Rename openvztraffic monitor to proxmoxopenvztraffic

This commit is contained in:
Marc Aymerich 2016-11-14 09:24:41 +00:00
parent e339e0fb56
commit 1c870de0f6
2 changed files with 8 additions and 8 deletions

View file

@ -340,7 +340,7 @@ class Exim4Traffic(ServiceMonitor):
if sender[0] < int(date) < end_date: if sender[0] < int(date) < end_date:
sender[2] += int(size[2:]) sender[2] += int(size[2:])
except IOError as e: except IOError as e:
sys.stderr.write(e) sys.stderr.write(str(e))
for username, opts in users.iteritems(): for username, opts in users.iteritems():
__, object_id, size = opts __, object_id, size = opts
@ -429,7 +429,7 @@ class VsFTPdTraffic(ServiceMonitor):
bytes = bytes_regex.search(line).groups()[0] bytes = bytes_regex.search(line).groups()[0]
user[2] += int(bytes) user[2] += int(bytes)
except IOError as e: except IOError as e:
sys.stderr.write(e) sys.stderr.write(str(e))
for username, opts in users.items(): for username, opts in users.items():
__, object_id, size = opts __, object_id, size = opts

View file

@ -90,15 +90,15 @@ class ProxmoxOVZ(ServiceController):
return context return context
# TODO rename to proxmox class ProxmoxOpenVZTraffic(ServiceMonitor):
class OpenVZTraffic(ServiceMonitor):
model = 'vps.VPS' model = 'vps.VPS'
resource = ServiceMonitor.TRAFFIC resource = ServiceMonitor.TRAFFIC
monthly_sum_old_values = True monthly_sum_old_values = True
GET_PROXMOX_INFO = ProxmoxOVZ.GET_PROXMOX_INFO
def prepare(self): def prepare(self):
super(OpenVZTraffic, self).prepare() super(ProxmoxOpenVZTraffic, self).prepare()
self.append(ProxmoxOVZ.GET_PROXMOX_INFO) self.append(self.GET_PROXMOX_INFO)
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
function monitor () { function monitor () {
object_id=$1 object_id=$1
@ -116,7 +116,7 @@ class OpenVZTraffic(ServiceMonitor):
def process(self, line): def process(self, line):
""" diff with last stored state """ """ diff with last stored state """
object_id, value, state = super(OpenVZTraffic, self).process(line) object_id, value, state = super(ProxmoxOpenVZTraffic, self).process(line)
value = decimal.Decimal(value) value = decimal.Decimal(value)
last = self.get_last_data(object_id) last = self.get_last_data(object_id)
if not last or last.state > value: if not last or last.state > value: