{"id":21470051,"url":"https://github.com/sensu-plugins/sensu-plugin-python","last_synced_at":"2025-05-12T14:47:41.568Z","repository":{"id":13031524,"uuid":"15711185","full_name":"sensu-plugins/sensu-plugin-python","owner":"sensu-plugins","description":"A framework for writing Sensu plugins \u0026 handlers with Python.","archived":false,"fork":false,"pushed_at":"2021-04-29T19:32:23.000Z","size":105,"stargazers_count":64,"open_issues_count":5,"forks_count":21,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-06T07:15:04.025Z","etag":null,"topics":["library","monitoring","python","sensu","sensu-plugin"],"latest_commit_sha":null,"homepage":"http://sensu-plugins.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sensu-plugins.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-07T17:22:11.000Z","updated_at":"2024-02-04T06:06:07.000Z","dependencies_parsed_at":"2022-09-18T23:13:28.223Z","dependency_job_id":null,"html_url":"https://github.com/sensu-plugins/sensu-plugin-python","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugin-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugin-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugin-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugin-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sensu-plugins","download_url":"https://codeload.github.com/sensu-plugins/sensu-plugin-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253758131,"owners_count":21959533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","monitoring","python","sensu","sensu-plugin"],"created_at":"2024-11-23T09:21:28.300Z","updated_at":"2025-05-12T14:47:41.548Z","avatar_url":"https://github.com/sensu-plugins.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![sensu](https://raw.github.com/sensu/sensu/master/sensu-logo.png)\n\n# Python Sensu Plugin\n\nThis is a framework for writing your own [Sensu](https://github.com/sensu/sensu) plugins in Python.\nIt's not required to write a plugin (most Nagios plugins will work\nwithout modification); it just makes it easier.\n\n[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugin-python.png?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugin-python)\n\n## Checks\n\nTo implement your own check, subclass SensuPluginCheck, like\nthis:\n\n    from sensu_plugin import SensuPluginCheck\n\n    class MyCheck(SensuPluginCheck):\n      def setup(self):\n        # Setup is called with self.parser set and is responsible for setting up\n        # self.options before the run method is called\n\n        self.parser.add_argument(\n          '-w',\n          '--warning',\n          required=True,\n          type=int,\n          help='Integer warning level to output'\n        )\n        self.parser.add_argument(\n          '-m',\n          '--message',\n          default=None,\n          help='Message to print'\n        )\n\n\n      def run(self):\n        # this method is called to perform the actual check\n\n        self.check_name('my_awesome_check') # defaults to class name\n\n        if self.options.warning == 0:\n          self.ok(self.options.message)\n        elif self.options.warning == 1:\n          self.warning(self.options.message)\n        elif self.options.warning == 2:\n          self.critical(self.options.message)\n        else:\n          self.unknown(self.options.message)\n\n    if __name__ == \"__main__\":\n      f = MyCheck()\n\n## Remote (JIT) Checks\n\nTo submit checks on behalf of another system, import push_event:\n\n    from sensu_plugin.pushevent import push_event\n\nThen use with:\n\n    push_event(source=\"a_remote_host\", check_name=\"MyCheckName\", exit_code=2, message=\"My check has failed\")\n\nThis will submit a check result (a failure) appearing to come from the remote host 'a_remote_host', for check 'MyCheckName'.\n\nThe default assumption is that there is a local sensu client running on port 3030, but you can override this by passing in sensu_client_host and sensu_client_port parameters.\n\nThe check submits the check in json format.  Arbitrary extra fields can be added, e.g.\n\n    push_event(source=\"a_remote_host\", check_name=\"MyCheckName\", exit_code=2, message=\"My check has failed\", team=\"MyTeam\")\n\n## Metrics\n\nFor a metric you can subclass one of the following;\n\n* SensuPluginMetricGraphite\n* SensuPluginMetricInfluxdb\n* SensuPluginMetricJSON\n* SensuPluginMetricStatsd\n\n### Graphite\n\n    from sensu_plugin import SensuPluginMetricGraphite\n\n    class MyGraphiteMetric (SensuPluginMetricGraphite):\n        def run(self):\n            self.ok('sensu', 1)\n\n    if __name__ == \"__main__\":\n        metric = MyGraphiteMetric()\n\n### Influxdb\n\n    from sensu_plugin import SensuPluginMetricInfluxdb\n\n    class MyInfluxdbMetric (SensuPluginMetricInfluxdb):\n        def run(self):\n            self.ok('sensu', 'baz=42', 'env=prod,location=us-midwest')\n\n    if __name__ == \"__main__\":\n        metric = MyInfluxdbMetric()\n\n### JSON\n\n    from sensu_plugin import SensuPluginMetricJSON\n\n    class MyJSONMetric(OLDSensuPluginMetricJSON):\n        def run(self):\n            self.ok({'foo': 1, 'bar': 'anything'})\n\n    if __name__ == \"__main__\":\n        metric = MyJSONMetric()\n\n### StatsD\n\n    from sensu_plugin import SensuPluginMetricStatsd\n\n    class MyStatsdMetric(SensuPluginMetricStatsd):\n        def run(self):\n            self.ok('sensu.baz', 42, 'g')\n\n    if __name__ == \"__main__\":\n        metric = MyStatsdMetric()\n\n## License\n\n* Based heavily on [sensu-plugin](https://github.com/sensu/sensu-plugin) Copyright 2011 Decklin Foster\n* Python port Copyright 2014 S. Zachariah Sprackett\n\nReleased under the same terms as Sensu (the MIT license); see LICENSE\nfor details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugin-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensu-plugins%2Fsensu-plugin-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugin-python/lists"}