Last active
August 29, 2015 14:09
-
-
Save technovangelist/2f2a117cd9a6f4e7323e to your computer and use it in GitHub Desktop.
MyCustomCheck.py
This file contains hidden or 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
| from checks import AgentCheck | |
| import re | |
| import psutil | |
| class CheckProcessNotRunning(AgentCheck): | |
| def check(self, instance): | |
| search = instance['search'] | |
| running_names = [p.name().strip() for p in psutil.process_iter()] | |
| matched = len([n for n in running_names if re.match(search, n)]) | |
| if matched > 0: | |
| status = AgentCheck.ALERT | |
| else: | |
| status = AgentCheck.OK | |
| message = "OMG!!! %s is running" % search | |
| self.service_check('sample.check_proc_not_running', status, tags=['search:%s' % search, 'test'], message= | |
| message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment