Viewing File: /usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyo

ó
¡ôXc@sÕddlZddlZddlZddlmZddlZddlmZddlm	Z	ddl
mZdZi	dd6d	d
6dd6d
d6dd6dd6dd6dd6dd6Z
de	fd„ƒYZdS(iÿÿÿÿN(tArg(tdelimited_list(tCloudWatchRequest(tcloudwatch_dimensionit
Dimensionstdimt
MetricNametmetrictMaximumtmaxtMinimumtmintSampleCounttcounttSumtsumt	TimestampttstUnittunittValuetvalt
PutMetricDatacBsjeZdZedddddeddƒedd	dd
dd/dd
deddddƒedddddd/ddddddƒedddddddd/dejƒedddd/ddddƒedddddd/de	dd e
ƒdd!ƒed"d#dd/dd$dd%ƒed&d'dd/dd(dd)ƒgZd*„Zd+„Z
d,„Zd-„Zd.„ZRS(0sJ

    Add data values or statistics to a CloudWatch metric

    A metric datum consists of a metric name, any of several attributes,
    and either a simple, numeric value (-v) or a set of statistical
    values (-s).

    All metric data in a given invocation of %(prog)s must belong to one
    namespace.  %(prog)s supports the following attributes (and
    equivalent aliases, in parentheses) for all data.  Each of
    these attributes has a corresponding command line option that
    specifies that attribute for all metric data.

      * MetricName (metric)
      * Dimensions (dim)
      * Timestamp (ts)
      * Unit (unit)

    Simple metric data have one additional attribute for their values:

      * Value (val)

    Statistical metric data have four additional attributes:

      * Maximum (max)
      * Minimum (min)
      * SampleCount (count)
      * Sum (sum)

    The -v/--value option allows you to specify the value of a simple
    metric datum.  To specify other attributes for data given using
    this option, use the options that correspond to them, such as
    -d/--dimensions.  In particular, the -m/--metric-name option is
    required when -v/--value is used.

    The -s/--metric-datum option allows for full control of each data
    point's attributes.  This is necessary for statistical data
    points.  To specify a metric datum using this option, join each
    attribute's name or alias from the lists above with its value
    using an '=' character, and join each of those pairs with ','
    characters.  If a value contains a ',' character, surround the
    entire attribute with '"' characters.

    For example, each of the following is a valid string
    to pass to -s/--metric-datum:

        MetricName=MyMetric,Value=1.5

        MetricName=MyMetric,Maximum=5,Minimum=1,SampleCount=5,Sum=10

        metric=MyMetric,val=9,"dim=InstanceId:i-12345678,Volume:/dev/sda"

    Attributes specified via -s/--metric-datum take precedence over those
    specified with attribute-specific command line options, such as
    -d/--dimensions.

    Timestamps must use a format specified in ISO 8601, such as
    "1989-11-09T19:17:45.000+01:00".  Note that the CloudWatch
    service does not accept data with timestamps more than two weeks
    in the past.

    Dimensions' attributes are specified as a comma-separated list
    of dimension names and values that are themselves separated by
    ':' characters.  This means that when more than one dimension is
    necessary, the entire Dimensions attribute must be enclosed in '"'
    characters.  Most shell environments require this to be escaped.
    s-ns--namespacetdestt	Namespacetrequiredthelps,namespace for the new metric data (required)s-vs--valuet
simple_valuestroute_totmetavartFLOATttypetactiontappendsZa simple value for a metric datum.  Each use
                specifies a new metric datum.s-ss--metric-datumtattr_valuessKEY1=VALUE1,KEY2=VALUE2,...s±names and values of the attributes for a metric
                datum.  When values include ',' characters, enclose the
                entire name/value pair in '"' characters.s--statistic-valuess--statisticValuess-ms
--metric-nametMETRICs(name of the metric to add metric data tos-ds--dimensionst,t	item_typesLone or more dimensions to associate with the new
                metric datas-ts--timestampsYYYY-MM-DDThh:mm:ssZs!timestamp for the new metric datas-us--unittUNITsOunit in which to report the new metric data
                points (e.g. Bytes)cCs–tj|ƒg}x6|jjdƒp+dD]}|j|j|ƒƒq,Wx6|jjdƒpddD]}|j|j|ƒƒqeW||jd<dS(NRR"tdata(((Rt	configuretargstgetR!t&_PutMetricData__build_datum_from_valuet&_PutMetricData__build_datum_from_pairs(tselfR'R((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyR(—s
cCs„|jjdƒpg}x^tdt|ƒtƒD]D}t|tt|ƒƒ}i|||!d6|jd<|jƒq1W|jdS(NR'itmembert
MetricData(R)R*trangetlentPOINTS_PER_REQUESTRtparamstsend(R-R'tslice_startt	slice_end((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pytmain¢scCs{i}yt|ƒ|d<Wn)tk
rEtjdj|ƒƒ‚nX|j|ƒ|jdƒswtjj	dƒ‚n|S(NRs0argument -v/--value: value '{0}' must be numericRs-argument -v/--value requires -m/--metric-name(
tfloatt
ValueErrortargparsetArgumentTypeErrortformatt_PutMetricData__complete_datumR*trequestbuildert
exceptionst
ArgumentError(R-tvaluetdatum((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyt__build_datum_from_value­s

	c
Cskddddg}i}|jƒs6tjdƒ‚nxHttjtj|ƒƒƒD](}y|jdƒ\}}Wnet	k
rÛ|j
dƒs¢|j
dƒr½tjd	j|ƒƒ‚ntjd
j||ƒƒ‚nXtj
||ƒ}||krLy t|ƒ|jdiƒ|<Wq}t	k
rHtjdj||ƒƒ‚q}XqU|d
kržyt|ƒ||<Wq}t	k
rštjdj||ƒƒ‚q}XqU|dkrI|j|igd6ƒx¹|jdƒD]q}y|jdƒ\}}	Wn,t	k
rtjdj||ƒƒ‚nX||dji|d6|	d
6ƒqÑWqU|dkrb|||<qUtjdj||ƒƒ‚qUW|j|ƒ|j
dƒs¸tjdj|ƒƒ‚nd|kr@d
|krþtjdj|t|djƒƒƒƒ‚nxf|D]4}||dkrtjdj||ƒƒ‚qqWn'd
|krgtjdj|ƒƒ‚n|S(NRR
RRs3argument -s/--metric-datum: value must not be emptyt=sdim=sDimensions=siargument -s/--metric-datum: dimension names and values in datum '{0}' must be separated with ':', not '='sOargument -s/--metric-datum: '{0}' in datum '{1}' must have format KEY=VALUE,...tStatisticValuessEargument -s/--metric-datum: {0} value for datum '{1}' must be numericRRR.R$t:sZargument -s/--metric-datum: dimension '{0}' for datum '{1}' must have format KEY:VALUE,...tNameRRRsMargument -s/--metric-datum: datum '{0}' contains unrecognized attribute '{1}'s§argument -s/--metric-datum: datum '{0}' must have a metric name; supply one individually with 'MetricName=NAME' or set a default for this request with -m/--metric-namesVargument -s/--metric-datum: datum '{0}' must not contain both Value and {1} attributessGargument -s/--metric-datum: a {0} is required for statistic datum '{1}'soargument -s/--metric-datum: datum '{0}' must contain either a Value or a Maximum, Minimum, SampleCount, and Sum(s
MetricNameRR(tstripR:R;tnexttcsvtreadertiotBytesIOtsplitR9t
startswithR<t
DATUM_KEYSR*R8t
setdefaultR!R=tvalues(
R-tpairs_as_strtstatistic_set_keysRBtpairtkeyRtdim_pairtdim_nametdim_val((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyt__build_datum_from_pairs»s†%
 




"
cCs¥idd6dd6dd6}xK|jƒD]=\}}|jj|ƒr(|j||jj|ƒƒq(q(W|jjdƒr¡|jdi|jjdƒd	6ƒndS(
Ntmetric_nameRt	timestampRRRt
dimensionsRR.(titemsR)R*RQ(R-RBtattr_mapRVR((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyt__complete_datum
s
#	N(t__name__t
__module__t__doc__RtTruetNoneR8R:tSUPPRESSRRtARGSR(R7R+R,R=(((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyR2s6C				O(R:RJRLR>Rtrequestbuilder.exceptionsteuca2ools.commands.argtypesRteuca2ools.commands.monitoringRt&euca2ools.commands.monitoring.argtypesRR2RPR(((sO/usr/lib/python2.7/site-packages/euca2ools/commands/monitoring/putmetricdata.pyt<module>s$


Back to Directory File Manager