Commits

Denis Khabarov committed 554b295

new file: munin-ncc
Plugin for Munin Monitoring

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+#-*- coding: utf8 -*-
+# MuninNCC - Simple plugin for Munin Monitoring to monitor ncc balance
+
+# Copyright © 2012 Denis 'Saymon21' Khabarov
+# E-Mail: saymon at hub21 dot ru (saymon@hub21.ru)
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3
+# as published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+'''
+Config for /etc/munin/plugin-conf.d/munin-node:
+
+[ncc]
+	env.NCC_USER 908....
+	env.NCC_PASSW mysuperpassword # in https://iserve.ncc-volga.ru/
+'''
+
+import ncc
+from os import getenv
+from sys import argv
+
+def main():
+	if len(argv) == 2 and argv[1] == 'config':
+		print('graph_title NCC Balance')
+		print('graph_args --base 1024 -r')
+		print('graph_category network')
+		print('graph_info This graph shows the number of balance on NCC for user %s.' %(getenv('NCC_USER')))
+		print('RUB.label RUB')
+		print('RUB.type GAUGE')
+		print('RUB.info RUB')
+		exit()
+	else:
+		mybalance = 0
+		lk = ncc.NCCBalanceFetcher(login=getenv('NCC_USER'), password=getenv('NCC_PASSW'))
+		try:
+			mybalance = lk.get_balance()
+		except ncc.QueryError:
+			print('RUB.value 0')
+			exit()
+
+		print('RUB.value %d' % mybalance)
+	
+if __name__ == "__main__":
+	main()