{"id":21044943,"url":"https://github.com/opusvl/check_dockerapi","last_synced_at":"2025-03-13T22:11:45.684Z","repository":{"id":148071786,"uuid":"308087053","full_name":"OpusVL/check_dockerapi","owner":"OpusVL","description":"Icinga2 / Nagios Check docker containers using the docker API","archived":false,"fork":false,"pushed_at":"2020-10-28T17:21:59.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-20T17:35:09.025Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpusVL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"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":"2020-10-28T17:07:53.000Z","updated_at":"2020-10-28T17:20:55.000Z","dependencies_parsed_at":"2023-05-19T01:45:30.303Z","dependency_job_id":null,"html_url":"https://github.com/OpusVL/check_dockerapi","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/OpusVL%2Fcheck_dockerapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpusVL%2Fcheck_dockerapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpusVL%2Fcheck_dockerapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpusVL%2Fcheck_dockerapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpusVL","download_url":"https://codeload.github.com/OpusVL/check_dockerapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489835,"owners_count":20299001,"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-19T14:19:13.483Z","updated_at":"2025-03-13T22:11:45.654Z","avatar_url":"https://github.com/OpusVL.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Icinga2 / Nagios - CHECK_DOCKERAPI\n\nScripts for monitoring docker containers using the docker API.\n\nDependencies: curl, jq and awk\n\n## check_dockerapi\n\nThis script connects to the docker API and retrieves json from the URL `/container/json?all=true`. It then iterates through all the states and returns a count of running and not running containers. It also returns all of the names of the containers along with the state and how long since it was created.\n\nIt supports connecting to the API using a client certificate, which is the suggested minimum level of authentication required  for the exposed API.\n\nDetails of the API calls can be found here: [https://docs.docker.com/engine/api/v1.40/](https://docs.docker.com/engine/api/v1.40/)\n\nHow to go about protecting the API using client certificates can be found here: [https://docs.docker.com/engine/security/https/](https://docs.docker.com/engine/security/https/)\n\n```shell\n$ ./check_dockerapi -h\n\ncheck_dockerapi Revision 1.0.0 - Checks Docker Container Status from Docker API for Icinga2\n\nUsage: check_dockerapi\n\n  -h           Show this page\n\n  -H | --host  Host name / IP of Docker API server (required)\n\n  -P | --port  Port Number of Docker API Service\n\n  --https      Use HTTPS requires cert, key and cacert set\n\n    --cert       Client certificate (pem)\n\n    --key        Client key (pem)\n\n    --cacert     CA cert (pem)\n\n  --include    String of container names to include\n\n  --exclude    String of container names to exclude\n\nUsage: check_dockerapi --help\n```\n\nExample:\n\nEnsure it runs as the user nagios and has certificates that the user can read.\n\n```shell\nsudo -u nagios ./check_dockerapi -H myhost -P 2376 --https --cert /var/lib/nagios/icinga2-cert.pem --key /var/lib/nagios/icinga2-key.pem --cacert /var/lib/nagios/ca.pem\n```\n\n### custom-commands.conf\n\nAdd into icinga2 config:\n\n```text\nobject CheckCommand \"check_dockerapi\" {\n  command = [ PluginDir + \"/check_dockerapi\" ]\n  arguments = {\n    \"-H\" = \"$dockerapi_host$\"\n    \"-P\" = \"$dockerapi_port$\"\n    \"--include\" = \"$dockerapi_include$\"\n    \"--exclude\" = \"$dockerapi_exclude$\"\n    \"--https\" = {\n      set_if = \"$dockerapi_https$\"\n    }\n    \"--cert\" = \"$dockerapi_cert$\"\n    \"--key\" = \"$dockerapi_key$\"\n    \"--cacert\" = \"$dockerapi_cacert$\"\n  }\n}\n```\n\n## check_dockerapi_stats\n\nLike it's parent this connects to the docker API, but this time returns performance metrics from a specific container.\n\n```shell\n$ ./check_dockerapi_stats -h\n\ncheck_dockerapi_stats Revision 1.0.0 - Checks Docker Container Status from Docker API for Icinga2\n\nUsage: check_dockerapi_stats\n\n  -h               Show this page\n\n  -H | --host      Host name / IP of Docker API server (required)\n\n  -P | --port      Port Number of Docker API Service\n\n  --https      Use HTTPS requires cert, key and cacert set\n\n    --cert       Client certificate (pem)\n\n    --key        Client key (pem)\n\n    --cacert     CA cert (pem)\n\n  -C | --container Name of container to inspect\n\nUsage: check_dockerapi_stats --help\n```\n\nExample:\n\n```shell\nsudo -u nagios ./check_dockerapi_stats -H myhost -P 2376 --https --cert /var/lib/nagios/icinga2-cert.pem --key /var/lib/nagios/icinga2-key.pem --cacert /var/lib/nagios/ca.pem --container mycontainer_db_1\n```\n\n## Caveats\n\nIf you use HTTPS, you need to ensure that the client certificate can be verified against the server certificate. This means you __MUST__ ensure that the `SubjectAlternativeName` of the server certificate matches the `-H` host name parameter you are using either by IP address or name, but the certificate must have the same name included in it's SAN.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopusvl%2Fcheck_dockerapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopusvl%2Fcheck_dockerapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopusvl%2Fcheck_dockerapi/lists"}