{"id":22059282,"url":"https://github.com/opentable/sensucronic","last_synced_at":"2025-03-23T17:13:30.728Z","repository":{"id":66076014,"uuid":"90428623","full_name":"opentable/sensucronic","owner":"opentable","description":"wrapper script to integrate cronjobs with sensu client input socket","archived":false,"fork":false,"pushed_at":"2017-05-06T02:51:51.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-01-28T23:09:52.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/opentable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-06T01:15:17.000Z","updated_at":"2017-05-06T09:18:30.000Z","dependencies_parsed_at":"2023-07-24T06:45:52.953Z","dependency_job_id":null,"html_url":"https://github.com/opentable/sensucronic","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fsensucronic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fsensucronic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fsensucronic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fsensucronic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/sensucronic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245136405,"owners_count":20566588,"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":[],"created_at":"2024-11-30T17:27:50.644Z","updated_at":"2025-03-23T17:13:30.703Z","avatar_url":"https://github.com/opentable.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sensucronic\n\nsensucronic is a wrapper for your cron jobs to integrate with\nthe sensu client input socket.\n\nit's written in ruby using mixlib::cli to fit in with the rest of the\nsensu ecosystem\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sensucronic'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install sensucronic\n\n## Usage\n\n```\nsensucronic [ OPTIONS ] [ -- ] COMMAND [ ARGS ]\n```\n```\nsensucronic [ OPTIONS ] [ -- ] 'COMMAND [ ARGS ]'\n```\n\nsensucronic runs COMMAND with ARGS it generates a json report and submits\nit to the sensu-client input socket\n\nuse --help to view options\n```\nprompt% sensucronic --help \nUsage: sensucronic (options)\n    -d, --dry-run                    output result to stdout only\n    -f, --field \"key: value\"         add a field to the json report\n    -h, --help                       print this message\n    -p, --port PORT                  the port number for the sensu client input socket\n    -s, --source SOURCE              set the source attribute on the sensu result\n\n```\n\nthe OPTION --dryrun causes sensucronic to issue it's report to stdout\ninstead of the sensu client input socket.\n\n```\nprompt% sensucronic --dry-run true     \n{\n  \"command\": \"true\",\n  \"output\": \"\",\n  \"status\": 0,\n  \"exitcode\": 0,\n  \"agent\": \"sensucronic\"\n}\n```\n\nexitcodes are propogated to sensu's status field,  0 ok, 1 warn, 2 crit, 3\nunknown  but anything \u003e 3 sets status to 3.  \n\nTODO: add options to configure this.\n\n```\nprompt% sensucronic --dry-run 'echo hi; exit 20'\n{\n  \"command\": \"echo\\\\ hi\\\\;\\\\ exit\\\\ 20\",\n  \"output\": \"hi\\n\",\n  \"status\": 3,\n  \"exitcode\": 20,\n  \"agent\": \"sensucronic\"\n}\n```\n\ngiven a single quoted argument it will be parsed with a shell\notherwise it tries to exec it as command followed by arguments\n\n```\nprompt% sensucronic --dry-run  exit 3\n{\n  \"command\": \"exit 3\",\n  \"output\": \"Errno::ENOENT\\nNo such file or directory - exit\",\n  \"status\": 3,\n  \"exitcode\": 127,\n  \"agent\": \"sensucronic\"\n}\n```\n\n```\nprompt% sensucronic --dry-run  'exit 3'\n{\n  \"command\": \"exit\\\\ 3\",\n  \"output\": \"\",\n  \"status\": 3,\n  \"exitcode\": 3,\n  \"agent\": \"sensucronic\"\n}\n\n```\n\nthe option --field allows you to add arbitrary attributes to the json\nreport. you can repeat it as often as you need. note that you can't override the built in fields.\n\n```\nprompt% sensucronic --field 'team: blah' --field foo:bar --field output:blah --dry-run 'echo hi; exit 20'\n{\n  \"command\": \"echo\\\\ hi\\\\;\\\\ exit\\\\ 20\",\n  \"output\": \"hi\\n\",\n  \"status\": 3,\n  \"exitcode\": 20,\n  \"agent\": \"sensucronic\",\n  \"team\": \"blah\",\n  \"foo\": \"bar\"\n}\n```\n\n\n## TODO\n\n- allow a system wide configuration to set default attributes for a node to be included in the report.\n- accept options to configure the status in response to the exitcodes.  (always warn,  always crit ) \n- allow specifying alternate host, currently the sensu agent must be running on the local box. \n- maybe submit via http to client http api on another host\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/opentable/sensucronic\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fsensucronic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fsensucronic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fsensucronic/lists"}