Built a a script to watch the conntrack levels inside all qrouter namespaces
This commit is contained in:
parent
384eab9966
commit
27177cbd74
|
@ -5,12 +5,13 @@ from pyroute2 import netns, NSPopen
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
registry = CollectorRegistry()
|
|
||||||
|
|
||||||
g_count = Gauge('test_nf_conntrack_count', 'nf_conntrack_count inside given namespace', ['host','namespace'],registry=registry )
|
|
||||||
g_max = Gauge('test_nf_conntrack_max', 'nf_conntrack_max inside given namespace', ['host','namespace'],registry=registry )
|
|
||||||
hostname=socket.gethostname()
|
hostname=socket.gethostname()
|
||||||
while True:
|
while True:
|
||||||
|
registry = CollectorRegistry()
|
||||||
|
g_count = Gauge('test_nf_conntrack_count', 'nf_conntrack_count inside given namespace', ['host','namespace'],registry=registry )
|
||||||
|
g_max = Gauge('test_nf_conntrack_max', 'nf_conntrack_max inside given namespace', ['host','namespace'],registry=registry )
|
||||||
for _item in netns.listnetns():
|
for _item in netns.listnetns():
|
||||||
if str(_item).startswith("qrouter"):
|
if str(_item).startswith("qrouter"):
|
||||||
nsp = NSPopen(_item, ['cat', '/proc/sys/net/netfilter/nf_conntrack_count'], stdout=subprocess.PIPE)
|
nsp = NSPopen(_item, ['cat', '/proc/sys/net/netfilter/nf_conntrack_count'], stdout=subprocess.PIPE)
|
||||||
|
@ -28,10 +29,11 @@ while True:
|
||||||
g_count.labels(hostname,_item).set(nsresult_count)
|
g_count.labels(hostname,_item).set(nsresult_count)
|
||||||
g_max.labels(hostname,_item).set(nsresult_max)
|
g_max.labels(hostname,_item).set(nsresult_max)
|
||||||
# exit()
|
# exit()
|
||||||
|
push_to_gateway('10.10.110.250:9091', job='cory_test_job2', registry=registry)
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
push_to_gateway('10.10.110.250:9091', job='cory_test_job2', registry=registry)
|
|
||||||
|
|
||||||
# print("Done")
|
# print("Done")
|
||||||
# # curl -X GET http://10.10.110.250:9091/api/v1/metrics | jq
|
# # curl -X GET http://10.10.110.250:9091/api/v1/metrics | jq
|
||||||
|
|
Loading…
Reference in New Issue