Created
September 24, 2014 10:43
-
-
Save nsaje/70b60d4ac6876467d9cd to your computer and use it in GitHub Desktop.
A script to flood a Ceilometer metering queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from oslo.config import cfg | |
from ceilometer.openstack.common import context | |
from ceilometer.openstack.common import log | |
import ceilometer.publisher as publisher | |
import ceilometer.sample as sample | |
import ceilometer.messaging as messaging | |
# use with --config-file /etc/ceilometer/ceilometer.conf | |
cfg.CONF.register_cli_opts([cfg.IntOpt('messages', | |
short='m', | |
default=1, | |
help='number of messages to send'), | |
cfg.IntOpt('samples-per-message', | |
short='spm', | |
default=1, | |
help='number of samples per ' | |
'message to send'), | |
cfg.StrOpt('publisher', | |
short='p', | |
default='rpc://', | |
help='publisher to use, probably ' | |
'rpc:// for Icehouse and ' | |
'notifier:// for Juno')]) | |
cfg.CONF() | |
log.setup('flood-collector') | |
messaging.setup() | |
pub = publisher.get_publisher(cfg.CONF.publisher) | |
s = sample.Sample('test', sample.TYPE_CUMULATIVE, 'MB', 5.0, | |
'72baba3da6b9439e97fbe5334ad92b46', | |
'd3a2040216864f35ac46735d5ab6ba94', | |
'xxx', '2014-09-22T14:25:05.604471', None) | |
ctxt = context.RequestContext('admin', 'admin', is_admin=True) | |
for _ in range(cfg.CONF.messages): | |
samples = [s for _ in range(cfg.CONF.samples_per_message)] | |
pub.publish_samples(ctxt, samples) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment