Skip to content

Instantly share code, notes, and snippets.

@nathwill
Last active July 7, 2016 18:47
Show Gist options
  • Save nathwill/c23bf6ab8c346064f283c0e52b84e473 to your computer and use it in GitHub Desktop.
Save nathwill/c23bf6ab8c346064f283c0e52b84e473 to your computer and use it in GitHub Desktop.
#!/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()
@nathwill
Copy link
Author

nathwill commented Jul 7, 2016

root@695ce8a0eaa6:~# ./test.py --endpoint=xxxxxx.alooma.io --username=xxxxxxx --password=xxxxxx --warning=20 --critical=50
alooma_restream_check OK: Restream queue is at 0.0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment