summaryrefslogtreecommitdiff
path: root/python-status-exporter
diff options
context:
space:
mode:
authorLasse Luttermann Poulsen <llp@nordu.net>2017-08-30 08:54:54 +0200
committerLasse Luttermann Poulsen <llp@nordu.net>2017-08-30 08:54:54 +0200
commitb6ef028195729806d41747239e2f74ce0589ff47 (patch)
treee712cf577d7742222419aab627ccc67a2fe6398a /python-status-exporter
parent36644a379cbecc17662f9b60f5c32a61a6d00155 (diff)
restructuring
Diffstat (limited to 'python-status-exporter')
-rw-r--r--python-status-exporter/README.md8
-rw-r--r--python-status-exporter/modules/__init__.py0
-rwxr-xr-xpython-status-exporter/modules/nginx_vod.py74
-rw-r--r--python-status-exporter/vod_status.xml147
4 files changed, 229 insertions, 0 deletions
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
--- /dev/null
+++ b/python-status-exporter/modules/__init__.py
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 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<vod>
+ <version>1.11</version>
+ <built>Dec 6 2016 07:46:25</built>
+ <metadata_cache>
+ <store_ok>7733</store_ok>
+ <store_bytes>6865797405</store_bytes>
+ <store_err>12</store_err>
+ <store_exists>4</store_exists>
+ <fetch_hit>124784</fetch_hit>
+ <fetch_bytes>307554697138</fetch_bytes>
+ <fetch_miss>7749</fetch_miss>
+ <evicted>7190</evicted>
+ <evicted_bytes>6331583153</evicted_bytes>
+ <reset>0</reset>
+ <entries>877</entries>
+ <data_size>536681664</data_size>
+ </metadata_cache>
+ <response_cache>
+ <store_ok>3222</store_ok>
+ <store_bytes>14119056</store_bytes>
+ <store_err>0</store_err>
+ <store_exists>2</store_exists>
+ <fetch_hit>2647</fetch_hit>
+ <fetch_bytes>8168280</fetch_bytes>
+ <fetch_miss>3224</fetch_miss>
+ <evicted>0</evicted>
+ <evicted_bytes>0</evicted_bytes>
+ <reset>0</reset>
+ <entries>3222</entries>
+ <data_size>14144640</data_size>
+ </response_cache>
+ <mapping_cache>
+ <store_ok>4835</store_ok>
+ <store_bytes>608538</store_bytes>
+ <store_err>0</store_err>
+ <store_exists>3</store_exists>
+ <fetch_hit>127695</fetch_hit>
+ <fetch_bytes>16073207</fetch_bytes>
+ <fetch_miss>4838</fetch_miss>
+ <evicted>0</evicted>
+ <evicted_bytes>0</evicted_bytes>
+ <reset>0</reset>
+ <entries>4835</entries>
+ <data_size>618880</data_size>
+ </mapping_cache>
+ <performance_counters>
+ <fetch_cache>
+ <sum>1160625</sum>
+ <count>270937</count>
+ <max>624</max>
+ <max_time>1502478721</max_time>
+ <max_pid>6554</max_pid>
+ </fetch_cache>
+ <store_cache>
+ <sum>4728333</sum>
+ <count>15811</count>
+ <max>24347</max>
+ <max_time>1502474345</max_time>
+ <max_pid>6553</max_pid>
+ </store_cache>
+ <map_path>
+ <sum>174123874</sum>
+ <count>4838</count>
+ <max>595314</max>
+ <max_time>1502282976</max_time>
+ <max_pid>6551</max_pid>
+ </map_path>
+ <parse_media_set>
+ <sum>0</sum>
+ <count>0</count>
+ <max>0</max>
+ <max_time>0</max_time>
+ <max_pid>0</max_pid>
+ </parse_media_set>
+ <get_drm_info>
+ <sum>0</sum>
+ <count>0</count>
+ <max>0</max>
+ <max_time>0</max_time>
+ <max_pid>0</max_pid>
+ </get_drm_info>
+ <open_file>
+ <sum>1003069961</sum>
+ <count>132084</count>
+ <max>64910252</max>
+ <max_time>1502304904</max_time>
+ <max_pid>6556</max_pid>
+ </open_file>
+ <async_open_file>
+ <sum>0</sum>
+ <count>0</count>
+ <max>0</max>
+ <max_time>0</max_time>
+ <max_pid>0</max_pid>
+ </async_open_file>
+ <read_file>
+ <sum>0</sum>
+ <count>0</count>
+ <max>0</max>
+ <max_time>0</max_time>
+ <max_pid>0</max_pid>
+ </read_file>
+ <async_read_file>
+ <sum>1757549142</sum>
+ <count>1139994</count>
+ <max>73554424</max>
+ <max_time>1502304912</max_time>
+ <max_pid>6555</max_pid>
+ </async_read_file>
+ <media_parse>
+ <sum>31733717</sum>
+ <count>132533</count>
+ <max>275707</max>
+ <max_time>1502361911</max_time>
+ <max_pid>6557</max_pid>
+ </media_parse>
+ <build_manifest>
+ <sum>61604</sum>
+ <count>3224</count>
+ <max>1344</max>
+ <max_time>1502453099</max_time>
+ <max_pid>6552</max_pid>
+ </build_manifest>
+ <init_frame_processing>
+ <sum>4671706</sum>
+ <count>129056</count>
+ <max>1648</max>
+ <max_time>1502462617</max_time>
+ <max_pid>6555</max_pid>
+ </init_frame_processing>
+ <process_frames>
+ <sum>225751101</sum>
+ <count>1253556</count>
+ <max>134511</max>
+ <max_time>1503069418</max_time>
+ <max_pid>6554</max_pid>
+ </process_frames>
+ <total>
+ <sum>3219047113</sum>
+ <count>134927</count>
+ <max>74786470</max>
+ <max_time>1502304914</max_time>
+ <max_pid>6556</max_pid>
+ </total>
+ </performance_counters>
+</vod>