Allow a comma separated list of hosts for host_alive detection plugin

Some minor Readme cleanup also.

Change-Id: I7a707f5d566339db1430cbcc7597b95c1df9201c
This commit is contained in:
Tim Kuhlman 2015-07-24 11:27:59 -06:00
parent 3cd197e0c1
commit 2d7d2271a8
2 changed files with 15 additions and 13 deletions

View File

@ -5,11 +5,5 @@ configuring it to start up on boot.
## Future Considerations
- A good system for specifying active style checks for configuration would be great. Active style checks are those
which run locally but are checking a remote box.
- The ability to dynamically add detection plugins could be quite valuable. Also it could aid in the active check config.
- With the ability to dynamically add I should also include the ability to dynamically remove.
- A config file with metadata to assist in automatic configuration could be quite valuable, for example user/pass for
logging into mysql.
- The current system does not work well in the case of clusters, for example the kafka plugin will end up collecting
the same data on each node of a cluster.

View File

@ -9,26 +9,34 @@ log = logging.getLogger(__name__)
class HostAlive(monasca_setup.detection.ArgsPlugin):
""" Setup an host_alive check according to the passed in args.
Despite being a detection plugin this plugin does no detection and will be a noop without arguments.
Expects two space seperated arguments hostname and type. Type can be either 'ssh' or 'ping'. For example:
Expects two space seperated arguments hostname and type. Type can be either 'ssh' or 'ping'. hostname
can be a comma seperated list of hosts.
Examples:
'monasca-setup -d hostalive -a "hostname=remotebox type=ping"'
'monasca-setup -d hostalive -a "hostname=remotebox,remotebox2 type=ssh"'
"""
def _detect(self):
"""Run detection, set self.available True if the service is detected.
"""
self.available = self._check_required_args(['hostname', 'type'])
# Ideally the arg would be called hostnames but leaving it hostname to avoid breaking backward compatibility
def build_config(self):
"""Build the config as a Plugins object and return.
"""
config = monasca_setup.agent_config.Plugins()
log.info("\tEnabling {type} host check for {hostname}".format(**self.args))
# Since the naming in the args and in the config don't match build_instance is only good for dimensions
instance = self._build_instance([])
instance.update({'name': "{hostname} {type}".format(**self.args),
'host_name': self.args['hostname'],
'alive_test': self.args['type']})
config['host_alive'] = {'init_config': None, 'instances': [instance]}
instances = []
for hostname in self.args['hostname'].split(','):
# Since the naming in the args and in the config don't match build_instance is only good for dimensions
instance = self._build_instance([])
instance.update({'name': "{0} {1}".format(hostname, self.args['type']),
'host_name': hostname,
'alive_test': self.args['type']})
instances.append(instance)
config['host_alive'] = {'init_config': None, 'instances': instances}
return config