in moneo.py [0:0]
def deploy_worker(self, hosts_file, max_threads=16): # noqa: C901
'''Deploys Moneo worker to hosts listed in the specified host ini file'''
out = pssh(cmd='rm -rf /tmp/moneo-worker', hosts_file=hosts_file, user=self.args.user)
logging.info(out)
copy_path = './src/worker/'
destination_dir = '/tmp/moneo-worker'
print('-Copying files to workers-')
logging.info('Copying files to workers')
out = pscp(copy_path, destination_dir, hosts_file, user=self.args.user)
logging.info(out)
# Copy config file
copy_path = './moneo_config.json'
out = pscp(copy_path, destination_dir, hosts_file, user=self.args.user)
logging.info(out)
print('--------------------------')
if self.args.skip_install:
pass
else:
print('-Installing Moneo on workers-')
cmd = '/tmp/moneo-worker/install/install.sh'
if self.args.launch_publisher:
agent = self.args.launch_publisher
if agent != 'geneva' and agent != 'azure_monitor' and agent != 'managed_prometheus':
logging.error("Invalid agent specified: " + agent)
raise Exception("Invalid agent specified: " + agent)
print('--------------------------')
print('-Install ' + agent + ' agent-')
logging.info('Install ' + agent + ' agent')
cmd = cmd + ' ' + agent
else:
cmd = cmd + ' false'
out = pssh(cmd=cmd, hosts_file=hosts_file, max_threads=max_threads, user=self.args.user)
logging.info(out)
print('--------------------------')
print('-Starting metric exporters on workers-')
logging.info('Starting metric exporters on workers')
cmd = '/tmp/moneo-worker/start.sh'
if self.args.launch_publisher:
agent = self.args.launch_publisher
if agent == 'geneva' and not self.args.publisher_auth:
logging.error("Geneva agent requires specified authentication")
raise Exception("Geneva agent requires specified authentication")
elif agent == 'azure_monitor' and self.args.publisher_auth:
logging.error("Azure Monitor agent does not require authentication")
raise Exception("Azure Monitor agent does not require authentication")
elif agent == 'managed_prometheus' and self.args.publisher_auth != 'umi':
logging.error("Managed Prometheus agent requires specified authentication: umi")
raise Exception("Managed Prometheus agent requires specified authentication: umi")
elif agent == 'managed_prometheus' and self.args.type != 'workers':
logging.error("Managed Prometheus agent can only be deployed on workers")
raise Exception("Managed Prometheus agent can only be deployed on workers")
cmd = cmd + ' ' + agent
if self.args.publisher_auth:
auth = self.args.publisher_auth
print('--------------------------')
print('-Enable ' + agent + ' agent authentication: ' + auth + '-')
logging.info('Enable ' + agent + ' agent authentication: ' + auth)
cmd = cmd + ' ' + auth
else:
print('-Enable ' + agent + ' agent-')
logging.info('Enable ' + agent + ' agent')
else:
cmd = cmd + ' false'
cmd = cmd + " \"\""
# ethernet device
cmd = cmd + " " + args.ethernet_device
if self.args.custom_metrics_file_path:
print('-Custom exporter enabled-')
logging.info('Custom exporter enabled')
cmd = cmd + ' ' + self.args.custom_metrics_file_path
out = pssh(cmd=cmd, hosts_file=hosts_file, max_threads=max_threads, user=self.args.user)
logging.info(out)
print('--------------------------')
print('-Deploying Complete')