argparser.add_argument('--api-listen-uri',help='ZMQ API listen address',default='tcp://*:4850')
argparser.add_argument('--kairosdb-enable',action="store_true",help='Enable usage metric input from KairosDB')
argparser.add_argument('--kairosdb-url',help='URL of the KairosDB service (ex. http://localhost:8086)',default='http://localhost:8090')
argparser.add_argument('--kairosdb-url',help='URL of the KairosDB service (ex. http://localhost:8090)',default='http://localhost:8090')
argparser.add_argument('--influxdb-enable',action="store_true",help='Enable usage metric input from InfluxDB')
argparser.add_argument('--influxdb-url',help='URL of the InfluxDB service (ex. http://localhost:8086)',default='http://localhost:8086')
argparser.add_argument('--workspace-base-path',help='Base directory where user workspaces will be created. Must be visible at this path on all hosts.',default='/mnt/zoe-workspaces')
argparser.add_argument('--workspace-deployment-path',help='Path appended to the workspace path to distinguish this deployment. If unspecified is equal to the deployment name.',default='--default--')
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Retrieves metrics about services from InfluxDB."""
importlogging
importrequests
fromzoe_lib.configimportget_conf
log=logging.getLogger(__name__)
classInfluxDBInMetrics:
"""InfluxDB metrics."""
def__init__(self):
self.base_url=get_conf().influxdb_url
defget_service_usage(self,service_id):
"""Query the DB for the current usage metrics."""
query_cpu='SELECT mean("usage_percent") FROM "docker_container_cpu" WHERE "zoe_service_id" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id)
query_mem='SELECT mean("usage") FROM "docker_container_mem" WHERE "zoe_service_id" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id)