diff options
| author | Lasse Luttermann Poulsen <llp@nordu.net> | 2017-08-30 08:54:54 +0200 |
|---|---|---|
| committer | Lasse Luttermann Poulsen <llp@nordu.net> | 2017-08-30 08:54:54 +0200 |
| commit | b6ef028195729806d41747239e2f74ce0589ff47 (patch) | |
| tree | e712cf577d7742222419aab627ccc67a2fe6398a /nginx-vod-status-exporter/modules/nginx_vod.py | |
| parent | 36644a379cbecc17662f9b60f5c32a61a6d00155 (diff) | |
restructuring
Diffstat (limited to 'nginx-vod-status-exporter/modules/nginx_vod.py')
| -rwxr-xr-x | nginx-vod-status-exporter/modules/nginx_vod.py | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/nginx-vod-status-exporter/modules/nginx_vod.py b/nginx-vod-status-exporter/modules/nginx_vod.py deleted file mode 100755 index c4547cf..0000000 --- a/nginx-vod-status-exporter/modules/nginx_vod.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/env python2.6 - -import sys -import os -import inspect -sys.path.insert(0, os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + "/client_python") - -import httplib -import xml.etree.ElementTree as XET - -from prometheus_client import start_http_server, Summary, Gauge - -""" -vod_status_con = httplib.HTTPConnection('127.0.0.1', 87, timeout=2) -vod_status_con.request("GET", "/vod_status") - -resp = vod_status_con.getresponse() -""" - -def rec_xml_loop(xml, data, path=""): - children = xml.getchildren() - if len(children) < 1: - data[path + xml.tag] = xml.text - else: - for c in children: - if path == "": - rec_xml_loop(c, data, xml.tag) - else: - rec_xml_loop(c, data, path + "_" + xml.tag) - - if path == "": - return data - -VOD_HOST = "127.0.0.1" -VOD_PORT = 87 -VOD_PATH = "/vod_status" - -# REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request') -# TEST_SEC = Gauge('time_now_sec', 'Current value for det second hand on our clock') - -def get_xml(host=VOD_HOST, port=VOD_PORT, path=VOD_PATH): - vod_status_con = httplib.HTTPConnection(host, port, timeout=2) - vod_status_con.request("GET", path) - resp = vod_status_con.getresponse() - - if resp.status == 200: - data = resp.read() - vod_status_con.close() - return data - else: - vod_status_con.close() - raise Exception("Unable to fetch info from http server {}:{}/{}".format(host, port, path)) - -def init_datapoints(data_dict, labels): - from_xml_data = dict() - xml_obj = XET.fromstring(get_xml()) - xml_data_dict = rec_xml_loop(xml_obj, from_xml_data) - for key in xml_data_dict: - data_dict[key] = Gauge(key, key, labels) - -def update_datapoints(data_dict, label_vals): - from_xml_data = dict() - xml_obj = XET.fromstring(get_xml()) - xml_data_dict = rec_xml_loop(xml_obj, from_xml_data) - for key in data_dict: - if key in xml_data_dict: - try: - float(xml_data_dict[key]) - except ValueError: - pass - else: - data_dict[key].labels(*label_vals).set(xml_data_dict[key]) - - |
