From ca5267b040092a3bc5b4cf330de9ef643ddc6d15 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 6 Nov 2010 13:53:46 +0100 Subject: [PATCH] new option 'boobank_cumulate' --- scripts/boobank-munin | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/boobank-munin b/scripts/boobank-munin index 960dc530..446abb41 100755 --- a/scripts/boobank-munin +++ b/scripts/boobank-munin @@ -34,6 +34,7 @@ class BoobankMuninPlugin(object): self.monitored_accounts = os.environ['boobank_monitored'].split(' ') self.cache_expire = long(os.environ.get('boobank_cache_expire', 3600)) self.add_coming = int(os.environ.get('boobank_add_coming', 1)) + self.cumulate = int(os.environ.get('boobank_cumulate', 1)) self.cache = None def display_help(self): @@ -58,6 +59,8 @@ class BoobankMuninPlugin(object): print '# If enabled, coming operations are added to the value of accounts\'' print '# balance.' print 'env.boobank_add_coming 1' + print '# Cumulate accounts values' + print 'env.boobank_cumulate 1' print '' print 'When you change configuration, you can use this command to reset cache:' print '$ boobank-munin --reset' @@ -132,10 +135,31 @@ class BoobankMuninPlugin(object): self.write_output('graph_category weboob') self.write_output('graph_args -l 0') try: - for backend, account in self.weboob.do('iter_accounts'): - if self.monitored(account): - id = self.account2id(account) - self.write_output('%s.label %s' % (id, account.label.encode('iso-8859-15'))) + accounts = [] + if self.monitored_accounts is not None: + d = {} + for backend, account in self.weboob.do('iter_accounts'): + if self.monitored(account): + d['%s@%s' % (account.id, account.backend)] = account + + for id in self.monitored_accounts: + try: + accounts.append(d[id]) + except KeyError: + pass + else: + accounts = reversed([a for b, a in self.weboob.do('iter_accounts')]) + + first = True + for account in accounts: + id = self.account2id(account) + type = 'STACK' + if first: + type = 'AREA' + first = False + self.write_output('%s.label %s' % (id, account.label.encode('iso-8859-15'))) + if self.cumulate: + self.write_output('%s.draw %s' % (id, type)) except CallErrors: self.print_cache('boobank-munin-config') else: