From b6ef028195729806d41747239e2f74ce0589ff47 Mon Sep 17 00:00:00 2001 From: Lasse Luttermann Poulsen Date: Wed, 30 Aug 2017 08:54:54 +0200 Subject: restructuring --- nginx-vod-status-exporter/README.md | 8 -- nginx-vod-status-exporter/modules/__init__.py | 0 nginx-vod-status-exporter/modules/nginx_vod.py | 74 ------------- nginx-vod-status-exporter/vod_status.xml | 147 ------------------------- python-status-exporter/README.md | 8 ++ python-status-exporter/modules/__init__.py | 0 python-status-exporter/modules/nginx_vod.py | 74 +++++++++++++ python-status-exporter/vod_status.xml | 147 +++++++++++++++++++++++++ 8 files changed, 229 insertions(+), 229 deletions(-) delete mode 100644 nginx-vod-status-exporter/README.md delete mode 100644 nginx-vod-status-exporter/modules/__init__.py delete mode 100755 nginx-vod-status-exporter/modules/nginx_vod.py delete mode 100644 nginx-vod-status-exporter/vod_status.xml create mode 100644 python-status-exporter/README.md create mode 100644 python-status-exporter/modules/__init__.py create mode 100755 python-status-exporter/modules/nginx_vod.py create mode 100644 python-status-exporter/vod_status.xml diff --git a/nginx-vod-status-exporter/README.md b/nginx-vod-status-exporter/README.md deleted file mode 100644 index db7479a..0000000 --- a/nginx-vod-status-exporter/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Nginx VOD module status exporter - -These scripts are for exposing status from the [nginx-vod-module](https://github.com/kaltura/nginx-vod-module), to Prometheus. - -`vod_status.xml` contains an example of the XML exposed by the vod-module status page. - - - diff --git a/nginx-vod-status-exporter/modules/__init__.py b/nginx-vod-status-exporter/modules/__init__.py deleted file mode 100644 index e69de29..0000000 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]) - - diff --git a/nginx-vod-status-exporter/vod_status.xml b/nginx-vod-status-exporter/vod_status.xml deleted file mode 100644 index 7e309e5..0000000 --- a/nginx-vod-status-exporter/vod_status.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - 1.11 - Dec 6 2016 07:46:25 - - 7733 - 6865797405 - 12 - 4 - 124784 - 307554697138 - 7749 - 7190 - 6331583153 - 0 - 877 - 536681664 - - - 3222 - 14119056 - 0 - 2 - 2647 - 8168280 - 3224 - 0 - 0 - 0 - 3222 - 14144640 - - - 4835 - 608538 - 0 - 3 - 127695 - 16073207 - 4838 - 0 - 0 - 0 - 4835 - 618880 - - - - 1160625 - 270937 - 624 - 1502478721 - 6554 - - - 4728333 - 15811 - 24347 - 1502474345 - 6553 - - - 174123874 - 4838 - 595314 - 1502282976 - 6551 - - - 0 - 0 - 0 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - - - 1003069961 - 132084 - 64910252 - 1502304904 - 6556 - - - 0 - 0 - 0 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - - - 1757549142 - 1139994 - 73554424 - 1502304912 - 6555 - - - 31733717 - 132533 - 275707 - 1502361911 - 6557 - - - 61604 - 3224 - 1344 - 1502453099 - 6552 - - - 4671706 - 129056 - 1648 - 1502462617 - 6555 - - - 225751101 - 1253556 - 134511 - 1503069418 - 6554 - - - 3219047113 - 134927 - 74786470 - 1502304914 - 6556 - - - diff --git a/python-status-exporter/README.md b/python-status-exporter/README.md new file mode 100644 index 0000000..db7479a --- /dev/null +++ b/python-status-exporter/README.md @@ -0,0 +1,8 @@ +# Nginx VOD module status exporter + +These scripts are for exposing status from the [nginx-vod-module](https://github.com/kaltura/nginx-vod-module), to Prometheus. + +`vod_status.xml` contains an example of the XML exposed by the vod-module status page. + + + diff --git a/python-status-exporter/modules/__init__.py b/python-status-exporter/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-status-exporter/modules/nginx_vod.py b/python-status-exporter/modules/nginx_vod.py new file mode 100755 index 0000000..c4547cf --- /dev/null +++ b/python-status-exporter/modules/nginx_vod.py @@ -0,0 +1,74 @@ +#!/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]) + + diff --git a/python-status-exporter/vod_status.xml b/python-status-exporter/vod_status.xml new file mode 100644 index 0000000..7e309e5 --- /dev/null +++ b/python-status-exporter/vod_status.xml @@ -0,0 +1,147 @@ + + + 1.11 + Dec 6 2016 07:46:25 + + 7733 + 6865797405 + 12 + 4 + 124784 + 307554697138 + 7749 + 7190 + 6331583153 + 0 + 877 + 536681664 + + + 3222 + 14119056 + 0 + 2 + 2647 + 8168280 + 3224 + 0 + 0 + 0 + 3222 + 14144640 + + + 4835 + 608538 + 0 + 3 + 127695 + 16073207 + 4838 + 0 + 0 + 0 + 4835 + 618880 + + + + 1160625 + 270937 + 624 + 1502478721 + 6554 + + + 4728333 + 15811 + 24347 + 1502474345 + 6553 + + + 174123874 + 4838 + 595314 + 1502282976 + 6551 + + + 0 + 0 + 0 + 0 + 0 + + + 0 + 0 + 0 + 0 + 0 + + + 1003069961 + 132084 + 64910252 + 1502304904 + 6556 + + + 0 + 0 + 0 + 0 + 0 + + + 0 + 0 + 0 + 0 + 0 + + + 1757549142 + 1139994 + 73554424 + 1502304912 + 6555 + + + 31733717 + 132533 + 275707 + 1502361911 + 6557 + + + 61604 + 3224 + 1344 + 1502453099 + 6552 + + + 4671706 + 129056 + 1648 + 1502462617 + 6555 + + + 225751101 + 1253556 + 134511 + 1503069418 + 6554 + + + 3219047113 + 134927 + 74786470 + 1502304914 + 6556 + + + -- cgit v1.1