{"id":17942496,"url":"https://github.com/dbroeglin/nagios_check","last_synced_at":"2026-03-05T23:35:19.881Z","repository":{"id":1897317,"uuid":"2823857","full_name":"dbroeglin/nagios_check","owner":"dbroeglin","description":"Ruby Nagios Check Integration","archived":false,"fork":false,"pushed_at":"2024-04-07T05:35:57.000Z","size":38,"stargazers_count":13,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-22T16:57:55.628Z","etag":null,"topics":["checker","gem","nagios","nagios-dev","probe","ruby"],"latest_commit_sha":null,"homepage":"","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/dbroeglin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","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":"2011-11-21T23:06:58.000Z","updated_at":"2024-04-07T05:43:04.000Z","dependencies_parsed_at":"2024-06-21T02:28:45.863Z","dependency_job_id":null,"html_url":"https://github.com/dbroeglin/nagios_check","commit_stats":{"total_commits":40,"total_committers":7,"mean_commits":5.714285714285714,"dds":0.25,"last_synced_commit":"ba95c2d6f62d2c1de739026efd015a7cbf0fa94a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/dbroeglin/nagios_check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbroeglin%2Fnagios_check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbroeglin%2Fnagios_check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbroeglin%2Fnagios_check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbroeglin%2Fnagios_check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbroeglin","download_url":"https://codeload.github.com/dbroeglin/nagios_check/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbroeglin%2Fnagios_check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29768337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T01:40:24.820Z","status":"online","status_checked_at":"2026-02-24T02:00:07.497Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["checker","gem","nagios","nagios-dev","probe","ruby"],"created_at":"2024-10-29T03:05:51.581Z","updated_at":"2026-03-05T23:35:19.863Z","avatar_url":"https://github.com/dbroeglin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"NagiosCheck\n============\n\n[![Gem Version](https://badge.fury.io/rb/nagios_check.svg)](https://badge.fury.io/rb/nagios_check)\n\nDescription\n-----------\n\nNagiosCheck is a simple and efficient tool for building custom probes for the\nNagios monitoring system. It alleviates the pain of parsing command line\noptions, writing and formatting the check results according to the Nagios \nplugin API.\n\nInstallation\n------------\n \n``` bash\ngem install nagios_check\n```\n\nFeatures\n--------\n\n* Provide a simple to use DSL for building your own probes.\n* Parse command line options.\n* Report status data to Nagios (handles exceptions as UNKNOWN status).\n* Provide a Nagios like range description format for the WARNING and CRITICAL states.\n* Provide a simple timeout functionality to be more Nagios friendly.\n* Report performance data to Nagios.\n\nUsage and documentation\n-----------------------\n\nNagiosCheck is a module. To use it, simply include it in a class and declare\nhow the check should behave:\n\n``` ruby\nrequire \"nagios_check\"\n\nclass SimpleCheck\n  include NagiosCheck\n\n  on \"--host HOST\", \"-H HOST\", :mandatory\n  on \"--port PORT\", \"-P PORT\", Integer, default: 8080\n\n  enable_warning\n  enable_critical\n  enable_timeout\n\n  def check\n    time = do_some_check(options.host, options.port)\n    \n    store_value :duration, time\n    store_message \"The check took #{time} seconds\"\n  end\nend\n\nSimpleCheck.new.run\n```\n\nThe command can then be used by Nagios:\n\n``` bash\n  ruby simple_check.rb -H my_host -P my_port -w 4 -c 8 -t 10\n```\n\nIf the number passed to `store_value` is between 0 and 4 inclusive the result is OK.  If it is greater than 4 and less than 8 inclusive the result is WARNING. If it is greater than 8 the result is CRITICAL. See [Nagios Developer Guidelines][nagios-dev] for more details on how the arguments of `-w` and `-c` are interpreted.\n\nIf `store_value` is called multiple times, the value from the first call is used to determine the result. Multiple `store_value` calls can be used to include additional performance data in the output.\n\nIf the check method lasts more than 10 seconds, it times out and the returned value is UNKNOWN.\n\nCalling `store_message` is optional. However, the text passed to `store_message` will be displayed next to the check status in the Nagios web interface and can be included in notification mails to provide some context in a human readable format. \n\nIf the only metric we are interested is the time it takes to execute the check, an alternative shorter way of writting the above would be:\n\n```ruby\ndef check\n  time(value_name: 'duration') do\n    do_some_check(options.host, options.port)\n  end\nend\n```\n\nThis check will execute `do_some_check` measure the time it takes to execute it and return both status and performance data labeled `duration`. \n\nWriting Tests for Checks\n------------------------\n\nChecks can be integration tested by calling the `perform` method\ninstead of the `run` method. `perform` takes an array of command line\narguments and returns a `NagiosCheck::Result` object, which supports\n`ok?`, `warning?` and `critical?` methods to query the status and\nexposes the stored values:\n\n```ruby\nRSpec.describe SomeCheck do\n  it 'is ok by default' do\n    result = SomeCheck.new.perform(%w(-w 5 -c 10))\n\n    expect(result).to be_ok\n  end\n\n  it 'results in warning if there are more thn 5 uploads purchases' do\n    # Setup environment such that the check detects problems\n    # ...\n\n    result = SomeCheck.new.perform(%w(-w 5 -c 10))\n\n    expect(result).to be_warning\n    expect(result.values[:some_stored_value]).to eq(6)\n  end\nend\n\n```\n\nLicense\n-------\nReleased under the MIT License.  See the [MIT-LICENSE][license] file for further details.\n\n[license]: https://github.com/dbroeglin/nagios_check/blob/master/MIT-LICENSE \n[nagios-dev]: http://nagiosplug.sourceforge.net/developer-guidelines.html\n\nCopyright 2011-2016 Dominique Broeglin \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbroeglin%2Fnagios_check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbroeglin%2Fnagios_check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbroeglin%2Fnagios_check/lists"}