Last active
July 7, 2016 18:47
-
-
Save nathwill/c23bf6ab8c346064f283c0e52b84e473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sensu_plugin import SensuPluginCheck | |
import alooma | |
class AloomaRestreamCheck(SensuPluginCheck): | |
def setup(self): | |
self.parser.add_argument( | |
'-w', | |
'--warning', | |
required=True, | |
type=int, | |
help='Integer warning level' | |
) | |
self.parser.add_argument( | |
'-c', | |
'--critical', | |
required=True, | |
type=int, | |
help='Integer critical level' | |
) | |
self.parser.add_argument( | |
'-e', | |
'--endpoint', | |
required=True, | |
help='Alooma endpoint (e.g. myorg.alooma.io)' | |
) | |
self.parser.add_argument( | |
'-u', | |
'--username', | |
required=True, | |
help='Alooma username' | |
) | |
self.parser.add_argument( | |
'-p', | |
'--password', | |
required=True, | |
help='Alooma password' | |
) | |
def run(self): | |
self.check_name('alooma_restream_check') | |
a = alooma.Alooma( | |
self.options.endpoint, | |
self.options.username, | |
self.options.password | |
) | |
stats = a.get_restream_stats() | |
percent_used = stats['size_used'] / stats['max_size'] * 100.0 | |
msg = "Restream queue is at {0}%".format(percent_used) | |
if percent_used >= self.options.critical: | |
self.critical(msg) | |
elif percent_used >= self.options.warning: | |
self.warning(msg) | |
else: | |
self.ok(msg) | |
if __name__ == "__main__": | |
f = AloomaRestreamCheck() |
Author
nathwill
commented
Jul 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment