Example #1
0
def refresh_info():
    context = {
        'cpu': lwp.host_cpu_percent(),
        'uptime': lwp.host_uptime(),
        'disk': lwp.host_disk_usage()
    }
    return jsonify(**context)
Example #2
0
def refresh_info():
    return jsonify({
        'cpu':
        lwp.host_cpu_percent(),
        'uptime':
        lwp.host_uptime(),
        'disk':
        lwp.host_disk_usage(partition=config.get('overview', 'partition'))
    })
Example #3
0
def get_host_info():
    """
    Returns lxc containers on the current machine and brief status information.
    """
    info = {
        'hostname': socket.gethostname(),
        'distribution': lwp.name_distro(),
        'version': lwp.check_version(),
        'network': lwp.get_net_settings(),
        'memory': lwp.host_memory_usage(),
        'cpu': lwp.host_cpu_percent(),
        'disk': lwp.host_disk_usage(),
        'uptime': lwp.host_uptime(),
    }
    return jsonify(info)
Example #4
0
 def get(self):
     os = platform.dist()
     os_str = ' '.join(os)
     host_cpu_infos = lwp.host_cpu_infos()
     
     return dict(uptime=lwp.host_uptime(),
                 hostname=socket.gethostname(),
                 dist=os_str,
                 disk_usage=lwp.host_disk_usage(),
                 cpu=dict(
                         usage=lwp.host_cpu_percent(),
                         model=host_cpu_infos['name'],
                         cores=host_cpu_infos['cores']
                     ),
                 memory=lwp.host_memory_usage(),
                 kernel=lwp.host_kernel_verion())
Example #5
0
def refresh_info():
    return jsonify({
        'cpu': lwp.host_cpu_percent(),
        'uptime': lwp.host_uptime(),
        'disk': lwp.host_disk_usage()
    })
Example #6
0
def refresh_uptime_host():
    if 'logged_in' in session:
        return jsonify(lwp.host_uptime())
Example #7
0
def refresh_info():
    return jsonify({'cpu': lwp.host_cpu_percent(),
                    'uptime': lwp.host_uptime(),
                    'disk': lwp.host_disk_usage()})
Example #8
0
def refresh_uptime_host():
    if 'logged_in' in session:
        return jsonify(lwp.host_uptime())
Example #9
0
    def get(self, container=False):
        """
        Get host stats (uptime, cpu, ram, etc)
        """

        host_cpu_infos = lwp.host_cpu_infos()

        cpu_count_logical = psutil.cpu_count()
        cpu_count_physical = psutil.cpu_count(logical=False)
        cpu_percent = lwp.host_cpu_percent()

        virtual_memory = psutil.virtual_memory()
        swap_memory = psutil.swap_memory()

        disk_partitions = psutil.disk_partitions()
        disk_partitions_usage = []
        for partition in disk_partitions:
            partition_data = psutil.disk_usage(partition.mountpoint)
            disk_partitions_usage.append({
                'name': partition.mountpoint,
                'total': partition_data.total,
                'used': partition_data.used,
                'free': partition_data.free,
                'percent': partition_data.percent
            })

        net_if_addrs = psutil.net_if_addrs()

        adapters = []

        for adapter in net_if_addrs:
            adapters.append({
                'name': adapter,
                'ipv4': None,
                'ipv6': None
            })
            index = len(adapters) - 1
            for snic in net_if_addrs[adapter]:
                if snic.family.name == 'AF_INET':
                    adapters[index]['ipv4'] = snic.address
                if snic.family.name == 'AF_INET6':
                    adapters[index]['ipv6'] = snic.address

        json_output = {
            'uptime': lwp.host_uptime(),
            'hostname': socket.gethostname(),
            'distrib': ' '.join(linux_distribution()),
            'disk': disk_partitions_usage,
            'cpu': {
                'usage': cpu_percent,
                'model': host_cpu_infos['name'],
                'physical': cpu_count_physical,
                'logical': cpu_count_logical
            },
            'memory': {
                'virtual': {
                    'total': virtual_memory.total,
                    'used': virtual_memory.used,
                    'free': virtual_memory.free,
                    'percent': virtual_memory.percent
                },
                'swap': {
                    'total': swap_memory.total,
                    'used': swap_memory.used,
                    'free': swap_memory.free,
                    'percent': swap_memory.percent
                }
            },
            'adapters': adapters,
            'kernel': platform.release(),
            'lxc': {
                'version': lxc.version,
                'lxcpath': lxc.get_global_config_item('lxc.lxcpath'),
                'default_config': lxc.get_global_config_item('lxc.default_config')
            }
        }

        if not container:
            output = {
                'attributes': json_output
            }
        else:
            output = json_output

        return {'data': output}
Example #10
0
def refresh_uptime_host():
    return jsonify(lwp.host_uptime())
Example #11
0
def refresh_info():
    return jsonify({'cpu': lwp.host_cpu_percent(),
            'uptime': lwp.host_uptime(),
            'disk': lwp.host_disk_usage(partition=config.get('overview', 'partition'))})
Example #12
0
def refresh_info():
    return jsonify({"cpu": lwp.host_cpu_percent(), "uptime": lwp.host_uptime(), "disk": lwp.host_disk_usage()})