1234567891011121314151617181920212223242526272829303132 |
- #!/usr/bin/python
- import collectd
- from pybrctl import BridgeController
- def getBridgeInterfaceCount():
- ifcount = {}
- brctl = BridgeController()
- for br in brctl.showall():
- ifcount[br.name] = len(br.getifs())
- return ifcount
- def read(data=None):
- stats = getBridgeInterfaceCount()
- globalCount = 0
- for k,v in stats.iteritems():
- globalCount += v
- vl = collectd.Values(type='if_count')
- vl.plugin='l2tp'
- vl.type_instance = k
- vl.dispatch(values=[v])
- vl = collectd.Values(type='if_count')
- vl.plugin='l2tp'
- vl.type_instance = 'all'
- vl.dispatch(values=[globalCount])
- def write(vl, data=None):
- for i in vl.values:
- print "%s (%s): %f" % (vl.plugin, vl.type, i)
- collectd.register_read(read)
- collectd.register_write(write);
|