{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf600 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} {\*\expandedcolortbl;;} \margl1440\margr1440\vieww24180\viewh17400\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 \f0\fs24 \cf0 import collectd\ from cinderclient.client import Client as CinderClient\ from cinderclient import exceptions\ import traceback\ \ #== Our Own Functions go here: ==#\ def configer(ObjConfiguration):\ collectd.debug('Configuring Stuff') \ \ def initer():\ collectd.debug('initing stuff')\ \ def reader(input_data=None):\ metric = collectd.Values();\ metric.plugin = 'cinder_plugin'\ metric.type = 'volumes_count'\ \ client = CinderClient('2', \'91myuser\'92, \'91my password\'92, 'services', 'https://svl-fab7-lab1.cisco.com:5000/v\ 2.0')\ volumes_count = client.volumes.list()\ metric.values = [len(volumes_count)]\ metric.host = 'OverwritenHostname'\ total_count = len(volumes_count)\ metric.dispatch()\ metric.type = 'volume-snapshots-count'\ snapshots = client.volume_snapshots.list()\ total_snap = len(snapshots)\ metric.values = [len(snapshots)]\ metric.dispatch()\ \ \ def write(val, data=None):\ '''Prepare value before writing '''\ client = CinderClient('2', \'91myuser\'92, \'91mypassword\'92, 'services', 'https://svl-fab7-lab1.cisco.com:5000/v\ 2.0')\ volumes_count = client.volumes.list()\ # data=volumes_count[1]\ for data in volumes_count[:]:\ collectd.info('skher: writing data (val=%r, data=%r)' % (val, data))\ for v in val.values:\ collectd.info("skher: writing %s (%s): %f" % (val.plugin, val.type, v))\ \ #== Hook Callbacks, Order is important! ==#\ collectd.register_config(configer)\ collectd.register_init(initer)\ collectd.register_read(reader)\ collectd.register_write(write)\ }