[munin/innd_total] CCache pour les stats
Ca evite d'avoir des trous quand le serveur a trop de connexions darcs-hash:20090330133324-ddb99-131fb42b77603f8499836c563f7498c6fe00fcbb.gz
This commit is contained in:
parent
d1155a8a4e
commit
e52717e769
1 changed files with 21 additions and 2 deletions
|
@ -22,6 +22,10 @@
|
|||
## Importations
|
||||
import socket, sys, time
|
||||
|
||||
## Configuration
|
||||
cache_file = "/tmp/munin_innd_total_cache"
|
||||
|
||||
|
||||
def recvlines(sock):
|
||||
buff = sock.recv(4096)
|
||||
while buff[-3] != '.':
|
||||
|
@ -80,8 +84,23 @@ if len(sys.argv) > 1 and sys.argv[1] == 'config':
|
|||
print 'total.label Total'
|
||||
else:
|
||||
# Envoi des valeurs
|
||||
lines = []
|
||||
total = 0
|
||||
for (ng, cng, val) in newsgroups:
|
||||
total += val
|
||||
print '%s.value %d' % (cng, val)
|
||||
print 'total.value %d' % total
|
||||
lines.append('%s.value %d' % (cng, val))
|
||||
lines.append('total.value %d' % total)
|
||||
|
||||
if total == 0:
|
||||
# On a sûrement eu un problème de récupération
|
||||
try:
|
||||
for line in open(cache_file, 'r'):
|
||||
print line.strip('\n')
|
||||
except:
|
||||
for line in lines:
|
||||
print line
|
||||
else:
|
||||
f = open(cache_file, 'w')
|
||||
for line in lines:
|
||||
print line
|
||||
f.write(line + '\n')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue