def _process_top_stats(self, ssh): command = 'top -b -n 1 -d 1 -U nobody | grep varnishd' top_stats = utils.ssh_exec_command(command, ssh=ssh).split() stats = {'cpu': top_stats[8], 'memory': top_stats[9], 'virtualmem': top_stats[4], 'reservedmem': top_stats[5]} self.server_state.update_process(self.hostname, **stats)
def _process_top_stats(self, ssh): command = 'top -b -n 1 -d 1 -U nobody | grep varnishd' top_stats = utils.ssh_exec_command(command, ssh=ssh).split() stats = { 'cpu': top_stats[8], 'memory': top_stats[9], 'virtualmem': top_stats[4], 'reservedmem': top_stats[5] } self.server_state.update_process(self.hostname, **stats)
def add_server(monitor, server_config, server_state, stat_window): hostname = utils.ssh_exec_command('hostname', **server_config) host, user, password = server_config['host'], server_config['username'], server_config['password'] stats = VarnishStats(host, user, password, hostname, server_state, stat_window) stat_name = 'Stats [{0}]'.format(host) monitor.add_worker(Worker(stat_name, stats)) health_name = 'Health [{0}]'.format(host) health = VarnishHealth(host, user, password, hostname, server_state) monitor.add_worker(Worker(health_name, health))
def add_server(monitor, server_config, server_state, stat_window): hostname = utils.ssh_exec_command('hostname', **server_config) host, user, password = server_config['host'], server_config[ 'username'], server_config['password'] stats = VarnishStats(host, user, password, hostname, server_state, stat_window) stat_name = 'Stats [{0}]'.format(host) monitor.add_worker(Worker(stat_name, stats)) health_name = 'Health [{0}]'.format(host) health = VarnishHealth(host, user, password, hostname, server_state) monitor.add_worker(Worker(health_name, health))
def _get_current_varnish_counters(self, ssh): varnish_stats_xml = utils.ssh_exec_command(self.varnish_command, ssh=ssh) tree = ElementTree.fromstring(varnish_stats_xml) stat_elements = tree.findall('stat') stats = [] for stat in stat_elements: children = stat.getchildren() name = children[0].text counter = {'name': name, 'value': int(children[1].text), 'description': children[3].text} stats.append(counter) return {'timestamp': datetime.now(), 'varnish': stats}
def _get_current_varnish_counters(self, ssh): varnish_stats_xml = utils.ssh_exec_command(self.varnish_command, ssh=ssh) tree = ElementTree.fromstring(varnish_stats_xml) stat_elements = tree.findall('stat') stats = [] for stat in stat_elements: children = stat.getchildren() name = children[0].text counter = { 'name': name, 'value': int(children[1].text), 'description': children[3].text } stats.append(counter) return {'timestamp': datetime.now(), 'varnish': stats}