[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/README.rst b/README.rst
index 9ef87d1..d97a47d 100644
--- a/README.rst
+++ b/README.rst
@@ -781,6 +781,13 @@
salt-call health_checks.docker_registry_list s-apt01:5000
salt-call health_checks.docker_registry_list http://127.0.0.1:5000
+Retrieve docker containers list on target server:
+
+.. code-block:: bash
+
+ salt -C 'cid01*' health_checks.docker_ps
+ salt -C 'cid01*' health_checks.docker_ps list_all=1
+
Retrieve glusterfs pool list:
.. code-block:: bash
@@ -807,6 +814,19 @@
salt-call health_checks.gluster_volumes_check
salt-call health_checks.gluster_volumes_check expected_size=1 ignore_volumes=['/srv/volumes/aptly']
+Retrieve entropy size for host:
+
+.. code-block:: bash
+
+ salt -C 'msg02*' health_checks.get_entropy
+
+Check entropy size on all nodes:
+
+.. code-block:: bash
+
+ salt-call health_checks.entropy_check
+ salt-call health_checks.entropy_check minimum_bits=1000
+
Encrypted pillars
~~~~~~~~~~~~~~~~~
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)
+