2011-03-31 05:53:51 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
fields = (
|
|
|
|
('sockets_used', 'sockets used'),
|
|
|
|
('tcp_inuse', 'TCP inuse'),
|
|
|
|
('tcp_orphan', 'TCP orphan'),
|
|
|
|
('tcp_tw', 'TCP tw'),
|
|
|
|
('tcp_alloc', 'TCP alloc'),
|
|
|
|
('tcp_mem', 'TCP mem'),
|
|
|
|
('udp_inuse', 'UDP inuse'),
|
|
|
|
('udplite_inuse', 'UDPLITE inuse'),
|
|
|
|
('raw_inuse', 'RAW inuse'),
|
|
|
|
('frag_inuse', 'FRAG inuse'),
|
|
|
|
('frag_memory', 'FRAG memory'),
|
|
|
|
)
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
arg = sys.argv[1]
|
|
|
|
if arg == 'autoconfig':
|
2018-03-27 04:56:30 +02:00
|
|
|
print('yes')
|
2011-03-31 05:53:51 +02:00
|
|
|
sys.exit(0)
|
|
|
|
if arg == 'config':
|
2018-03-27 04:56:30 +02:00
|
|
|
print('graph_title sockstat')
|
|
|
|
print('graph_category network')
|
2011-03-31 05:53:51 +02:00
|
|
|
for name, label in fields:
|
2018-03-27 04:56:30 +02:00
|
|
|
print('%s.label %s' % (name, label))
|
2011-03-31 05:53:51 +02:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
re_num = re.compile('(\d+)')
|
|
|
|
sockstat = open('/proc/net/sockstat').read()
|
|
|
|
numbers = re_num.findall(sockstat)
|
|
|
|
|
|
|
|
for i, (name, label) in enumerate(fields):
|
2018-03-27 04:56:30 +02:00
|
|
|
print('%s.value %s' % (name, numbers[i]))
|
2011-03-31 05:53:51 +02:00
|
|
|
|
|
|
|
sys.exit(0)
|