[Tooling update] health_checks
* Added:
- Retrieve docker containers list on target server
- Retrieve entropy size for host
- Check entropy size on all nodes
Related-Prod: PROD-29236
Change-Id: I3c6aee4a6ff47f988baa3e1cc4aab09b80f112c4
diff --git a/_modules/health_checks.py b/_modules/health_checks.py
index 4245d03..3d1fa9a 100644
--- a/_modules/health_checks.py
+++ b/_modules/health_checks.py
@@ -1011,6 +1011,51 @@
return True
+def get_entropy():
+
+ ''' Retrieve entropy size for the host '''
+
+ with open('/proc/sys/kernel/random/entropy_avail', 'r') as f:
+ entropy = f.read()
+ return entropy
+
+
+def entropy_check(target='*', target_type='glob', minimum_bits=700, ignore_dead=False, **kwargs):
+
+ ''' Check entropy size in cluster '''
+
+ agent = "entropy size status"
+ out = __salt__['saltutil.cmd']( tgt=target,
+ tgt_type=target_type,
+ fun='health_checks.get_entropy',
+ timeout=3
+ ) or None
+
+ if not _minions_output(out, agent, ignore_dead):
+ __context__['retcode'] = 2
+ return False
+
+ failed_minions = []
+ verified_minions = []
+
+ print out
+ for minion in out:
+ verified_minions.append(minion)
+ entropy = int(out[minion]['ret'])
+ if entropy < minimum_bits:
+ if not minion in failed_minions:
+ failed_minions.append(minion)
+
+ if not _failed_minions(out, agent, failed_minions):
+ __context__['retcode'] = 2
+ return False
+
+ if kwargs.get("debug", False):
+ logger.info(verified_minions)
+
+ return True
+
+
def docker_registry_list(host):
''' Retrieve and list docker catalog '''
@@ -1029,3 +1074,11 @@
return versions
except:
return {}
+
+
+def docker_ps(list_all=0):
+
+ import docker
+ client = docker.client.Client(base_url='unix://var/run/docker.sock')
+ return client.containers(all=list_all)
+