mirror of
https://github.com/recklessop/Zerto_Exporter.git
synced 2026-07-05 00:43:13 -04:00
Update python-node-exporter.py
This commit is contained in:
+38
-36
@@ -400,46 +400,48 @@ def GetDataFunc():
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
def ThreadProbe():
|
def ThreadProbe():
|
||||||
log.debug("Thread Probe Started")
|
while True:
|
||||||
metricsDictionary = {}
|
log.debug("Thread Probe Started")
|
||||||
|
metricsDictionary = {}
|
||||||
|
|
||||||
log.debug("Is Auth Thread Alive")
|
log.debug("Is Auth Thread Alive")
|
||||||
if auth_thread.is_alive():
|
if auth_thread.is_alive():
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 1
|
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 1
|
||||||
else:
|
else:
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 0
|
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 0
|
||||||
|
|
||||||
log.debug("Is Data Thread Alive")
|
log.debug("Is Data Thread Alive")
|
||||||
if data_thread.is_alive():
|
if data_thread.is_alive():
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 1
|
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 1
|
||||||
else:
|
else:
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 0
|
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 0
|
||||||
|
|
||||||
log.debug("Is Stats Thread Alive")
|
log.debug("Is Stats Thread Alive")
|
||||||
if stats_thread.is_alive():
|
if stats_thread.is_alive():
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 1
|
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 1
|
||||||
else:
|
else:
|
||||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 0
|
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 0
|
||||||
|
|
||||||
log.debug("Writing Probe data to files")
|
log.debug("Writing Probe data to files")
|
||||||
file_object = open('threads', 'w')
|
file_object = open('threads', 'w')
|
||||||
txt_object = open('threads.txt', 'w')
|
txt_object = open('threads.txt', 'w')
|
||||||
for item in metricsDictionary :
|
for item in metricsDictionary :
|
||||||
file_object.write(item)
|
file_object.write(item)
|
||||||
file_object.write(" ")
|
file_object.write(" ")
|
||||||
file_object.write(str(metricsDictionary[item]))
|
file_object.write(str(metricsDictionary[item]))
|
||||||
file_object.write("\n")
|
file_object.write("\n")
|
||||||
txt_object.write(item)
|
txt_object.write(item)
|
||||||
txt_object.write(" ")
|
txt_object.write(" ")
|
||||||
txt_object.write(str(metricsDictionary[item]))
|
txt_object.write(str(metricsDictionary[item]))
|
||||||
txt_object.write("\n")
|
txt_object.write("\n")
|
||||||
|
|
||||||
log.debug("Trying to Close probe txt files")
|
log.debug("Trying to Close probe txt files")
|
||||||
file_object.close()
|
file_object.close()
|
||||||
txt_object.close()
|
txt_object.close()
|
||||||
|
|
||||||
|
log.debug("Probe Thread Going to Sleep")
|
||||||
|
sleep(30)
|
||||||
|
|
||||||
log.debug("Probe Thread Going to Sleep")
|
|
||||||
sleep(30)
|
|
||||||
|
|
||||||
#----------------run http server on port 9999-----------------
|
#----------------run http server on port 9999-----------------
|
||||||
def WebServer():
|
def WebServer():
|
||||||
@@ -449,7 +451,7 @@ def WebServer():
|
|||||||
Handler = http.server.SimpleHTTPRequestHandler
|
Handler = http.server.SimpleHTTPRequestHandler
|
||||||
|
|
||||||
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||||
log.info("Webserver running on port {PORT}")
|
log.info(f"Webserver running on port {PORT}")
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
||||||
def start_thread(target_func):
|
def start_thread(target_func):
|
||||||
|
|||||||
Reference in New Issue
Block a user