mirror of
https://github.com/recklessop/Zerto_Exporter.git
synced 2026-07-02 23:53:13 -04:00
Update python-node-exporter.py
This commit is contained in:
+38
-36
@@ -400,46 +400,48 @@ def GetDataFunc():
|
||||
sleep(1)
|
||||
|
||||
def ThreadProbe():
|
||||
log.debug("Thread Probe Started")
|
||||
metricsDictionary = {}
|
||||
while True:
|
||||
log.debug("Thread Probe Started")
|
||||
metricsDictionary = {}
|
||||
|
||||
log.debug("Is Auth Thread Alive")
|
||||
if auth_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 0
|
||||
log.debug("Is Auth Thread Alive")
|
||||
if auth_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 0
|
||||
|
||||
log.debug("Is Data Thread Alive")
|
||||
if data_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 0
|
||||
log.debug("Is Data Thread Alive")
|
||||
if data_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 0
|
||||
|
||||
log.debug("Is Stats Thread Alive")
|
||||
if stats_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 0
|
||||
log.debug("Is Stats Thread Alive")
|
||||
if stats_thread.is_alive():
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 1
|
||||
else:
|
||||
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 0
|
||||
|
||||
log.debug("Writing Probe data to files")
|
||||
file_object = open('threads', 'w')
|
||||
txt_object = open('threads.txt', 'w')
|
||||
for item in metricsDictionary :
|
||||
file_object.write(item)
|
||||
file_object.write(" ")
|
||||
file_object.write(str(metricsDictionary[item]))
|
||||
file_object.write("\n")
|
||||
txt_object.write(item)
|
||||
txt_object.write(" ")
|
||||
txt_object.write(str(metricsDictionary[item]))
|
||||
txt_object.write("\n")
|
||||
|
||||
log.debug("Trying to Close probe txt files")
|
||||
file_object.close()
|
||||
txt_object.close()
|
||||
log.debug("Writing Probe data to files")
|
||||
file_object = open('threads', 'w')
|
||||
txt_object = open('threads.txt', 'w')
|
||||
for item in metricsDictionary :
|
||||
file_object.write(item)
|
||||
file_object.write(" ")
|
||||
file_object.write(str(metricsDictionary[item]))
|
||||
file_object.write("\n")
|
||||
txt_object.write(item)
|
||||
txt_object.write(" ")
|
||||
txt_object.write(str(metricsDictionary[item]))
|
||||
txt_object.write("\n")
|
||||
|
||||
log.debug("Trying to Close probe txt files")
|
||||
file_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-----------------
|
||||
def WebServer():
|
||||
@@ -449,7 +451,7 @@ def WebServer():
|
||||
Handler = http.server.SimpleHTTPRequestHandler
|
||||
|
||||
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()
|
||||
|
||||
def start_thread(target_func):
|
||||
|
||||
Reference in New Issue
Block a user