mirror of
https://github.com/recklessop/Zerto_Exporter.git
synced 2026-07-06 09:13:14 -04:00
Update python-node-exporter.py
This commit is contained in:
@@ -366,6 +366,41 @@ def GetDataFunc():
|
|||||||
log.debug("Waiting 1 second for Auth Token")
|
log.debug("Waiting 1 second for Auth Token")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
def ThreadProbe():
|
||||||
|
log.debug("Thread Probe Started")
|
||||||
|
metricsDictionary = {}
|
||||||
|
|
||||||
|
if probe_thread.is_alive():
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 1
|
||||||
|
else:
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "AuthHandler" + "\"}"] = 0
|
||||||
|
|
||||||
|
if data_thread.is_alive():
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 1
|
||||||
|
else:
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "DataStats" + "\"}"] = 0
|
||||||
|
|
||||||
|
if stats_thread.is_alive():
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 1
|
||||||
|
else:
|
||||||
|
metricsDictionary["exporter_thread_status{thread=\"" + "EncryptionStats" + "\"}"] = 0
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
file_object.close()
|
||||||
|
txt_object.close()
|
||||||
|
sleep(30)
|
||||||
|
|
||||||
#----------------run http server on port 9999-----------------
|
#----------------run http server on port 9999-----------------
|
||||||
def WebServer():
|
def WebServer():
|
||||||
log.debug("Web Server Started")
|
log.debug("Web Server Started")
|
||||||
@@ -385,14 +420,19 @@ def start_thread(target_func):
|
|||||||
return thread
|
return thread
|
||||||
|
|
||||||
# start the threads
|
# start the threads
|
||||||
auth_thread = start_thread(ZvmAuthHandler)
|
print("Probe thread: " str(probe_thread = start_thread(ThreadProbe)))
|
||||||
data_thread = start_thread(GetDataFunc)
|
print("Auth thread: " str(auth_thread = start_thread(ZvmAuthHandler)))
|
||||||
stats_thread = start_thread(GetStatsFunc)
|
print("Data thread: " str(data_thread = start_thread(GetDataFunc)))
|
||||||
webserver_thread = start_thread(WebServer)
|
print("Stats thread: " str(stats_thread = start_thread(GetStatsFunc)))
|
||||||
|
print("Webserver thread: " str(webserver_thread = start_thread(WebServer)))
|
||||||
|
|
||||||
# loop indefinitely
|
# loop indefinitely
|
||||||
while True:
|
while True:
|
||||||
# check if any thread has crashed
|
# check if any thread has crashed
|
||||||
|
if not probe_thread.is_alive():
|
||||||
|
# restart the thread
|
||||||
|
print("Starting Probe Thread")
|
||||||
|
probe_thread = start_thread(ThreadProbe)
|
||||||
if not auth_thread.is_alive():
|
if not auth_thread.is_alive():
|
||||||
# restart the thread
|
# restart the thread
|
||||||
print("Starting ZvmAuthHandler Thread")
|
print("Starting ZvmAuthHandler Thread")
|
||||||
@@ -408,4 +448,5 @@ while True:
|
|||||||
if not webserver_thread.is_alive():
|
if not webserver_thread.is_alive():
|
||||||
# restart the thread
|
# restart the thread
|
||||||
print("Starting WebServer Thread")
|
print("Starting WebServer Thread")
|
||||||
webserver_thread = start_thread(WebServer)
|
webserver_thread = start_thread(WebServer)
|
||||||
|
sleep(api_timeout)
|
||||||
Reference in New Issue
Block a user