timdaman / check_docker

Nagios plugin to check docker containers
GNU General Public License v3.0
152 stars 60 forks source link

Swarm support improvements #48

Open jkozera opened 6 years ago

jkozera commented 6 years ago

Hi @timdaman,

I've made a few changes which were useful for setting up Docker Swarm checks. They are available at https://github.com/timdaman/check_docker/compare/master...operasoftware:master and I thought it may be useful to upstream some of them.

Since I'm not sure what's your vision for future of check_docker, I thought I'd open an issue before making a PR.

The changes are:

  1. Slight performance improvement when fetching containers statuses if the expected status is running. (https://github.com/timdaman/check_docker/commit/61041d8c91f5ca13690994cb7bd9f083e741f937)
  2. Rework of check_docker to allow wildcard checks to pass if there's only one container matching the wildcard. This is useful in case of Swarm services, as mentioned in https://github.com/timdaman/check_docker/issues/43#issuecomment-426311066 of issue #43 when using '[stack]_[service].*' wildcards. (https://github.com/timdaman/check_docker/commit/2b1fc15968cbccff1febb30ac7362487fd0c24f5)
  3. Check for nodes statuses in check_swarm.py. (https://github.com/timdaman/check_docker/commit/92bbe134806483fb3a924ac5f4509d83ca0c19ea)
  4. Small improvements to Swarm checks wordings. (https://github.com/timdaman/check_docker/commit/211969f38c1af2642b533a3cd19d8e4c64ce4a64)
  5. .json config file support for easier automated deployment of checks. (https://github.com/timdaman/check_docker/commit/6b7849640e8d06823c5833f496202b81bf2d1a1a)

Please let me know if you think anything from the above would be useful for you, in which case I could prepare some PR.

thatsk commented 4 years ago

if we want to test this can you tell me what is procedure to check the current status will not check for swarm worker node

thatsk commented 4 years ago

root@test: ~# docker run -v /var/run/docker.sock:/var/run/docker.sock checkswarm:1.0 --swarm
CRITICAL: Node is not in a swarm
root@test: ~# docker info
Client:
 Debug Mode: false

Server:
 Containers: 5
  Running: 2
  Paused: 0
  Stopped: 3
 Images: 10
 Server Version: 19.03.3
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: 0bsch8gqddktk2y0li2xvytv1
  Is Manager: false
  Node Address: 10.173.96.253
  Manager Addresses:
   10.173.96.232:2377
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.27.2.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.51GiB
 Name: ingca01p1.infra.smf1.mobitv
 ID: LPBT:YDOY:R43D:GOYY:B25E:THWH:I7U4:BVY6:FPRD:VZQW:ASGO:LVBB
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  harbor.infra.smf1.mobitv
  127.0.0.0/8
 Live Restore Enabled: false```