-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipvs_state
More file actions
executable file
·34 lines (33 loc) · 1.25 KB
/
Copy pathipvs_state
File metadata and controls
executable file
·34 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
import sys
import re
if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print "yes"
elif len(sys.argv) == 2 and sys.argv[1] == "config":
print 'graph_title IPVS Connection State'
print 'graph_vlabel connections'
print 'graph_category ipvs'
print 'graph_order active inactive'
print 'active.label Active Connections'
print 'active.type GAUGE'
print 'active.draw AREA'
print 'inactive.label Inactive Connections'
print 'inactive.type GAUGE'
print 'inactive.draw STACK'
print 'all.label All Connections'
print 'all.graph no'
print 'all.sum active inactive'
print 'graph_args --base 1000'
else:
readfile = open('/proc/net/ip_vs', 'r')
gactive = 0
ginactive = 0
for line in readfile:
if re.match('^ ->', line):
a, b, c, d, active, inactive = line.split()
if active == 'ActiveConn':
continue
gactive = gactive + int(active)
ginactive = ginactive + int(inactive)
print("active.value %s" % int(gactive))
print("inactive.value %s" % int(ginactive))