def get_used_ports(): if systeminfo.code() == systeminfo.OSCode.Mac: return _mac_used_ports() elif systeminfo.code() == systeminfo.OSCode.Linux: raise NotImplemented('Implement used ports for Linux please.')
def _create_op_handler(self): plat = systeminfo.code() if plat == 'darwin': from operationhandler.machandler import MacOpHandler return MacOpHandler() elif plat == 'linux': distro = platform.linux_distribution()[0].lower() # List to check RedHat derived distros that use yum. _redhat = 'red hat enterprise linux server' _rpm_distros = ['fedora', 'centos', 'centos linux'] _debian_distros = ['debian', 'ubuntu', 'linuxmint'] if distro == _redhat: from operationhandler.rhelhandler import RhelOpHandler logger.debug('Using RhelOpHandler.') return RhelOpHandler() if distro in _rpm_distros: from operationhandler.rpmhandler import RpmOpHandler logger.debug('Using RpmOpHandler.') return RpmOpHandler() elif distro in _debian_distros: from operationhandler.debhandler import DebianHandler logger.debug('Using DebianHandler.') return DebianHandler() else: logger.critical( "Current platform '%s' isn't supported. Ignoring operations." % plat) return None
def get_monitor_data(): data = {} if systeminfo.code() == systeminfo.OSCode.Mac: #data = mac_monitor_data() pass else: root = {} root['memory'] = { 'used': 0, 'used_percent': 0, 'free': 0, 'free_percent': 0 } root['cpu'] = get_cpu_usage() root['file_system'] = get_file_system_data() data = root return data
def test_os_code_lowercase(): """ Test that the os code is returned and lowercase. """ eq_(systeminfo.code(), platform.system().lower(), "os code is not" "lowercase.")
def system_info(self): root = {} root['os_code'] = systeminfo.code() root['os_string'] = systeminfo.name() root['version'] = systeminfo.version() root['bit_type'] = systeminfo.bit_type() root['computer_name'] = systeminfo.computer_name() root['host_name'] = '' # TODO(urgent): Implement logger.debug("System info sent: {0}".format(json.dumps(root))) return root
def __init__(self): self._name = MonitorPlugin.Name self._previous_user_cpu = 0 self._previous_sys_cpu = 0 self._previous_idle_cpu = 0 self._previous_total_cpu = 0 if systeminfo.code() == systeminfo.OSCode.Mac: self._mac_monitor = MacMonitor() else: self._mac_monitor = None
def test_os_name(): """ Test the name of the OS. """ os_code = systeminfo.code() os_string = 'Unknown' if os_code == 'darwin': mac_ver = platform.mac_ver()[0] os_string = "OS X %s" % mac_ver elif os_code == 'linux': distro_info = platform.linux_distribution( supported_dists=systeminfo.supported_linux_distros) os_string = '%s %s' % (distro_info[0], distro_info[1]) eq_(systeminfo.name(), os_string, "OS name are not matching.")
def get_monitor_data(): data = {} if systeminfo.code() == systeminfo.OSCode.Mac: #data = mac_monitor_data() pass else: root = {} root['memory'] = {'used': 0, 'used_percent': 0, 'free': 0, 'free_percent': 0} root['cpu'] = get_cpu_usage() root['file_system'] = get_file_system_data() data = root return data
def _create_op_handler(self): plat = systeminfo.code() if plat == 'darwin': from operationhandler.machandler import MacOpHandler return MacOpHandler() elif plat == 'linux': distro = platform.linux_distribution()[0].lower() # List to check RedHat derived distros that use yum. _redhat = 'red hat enterprise linux server' _rpm_distros = ['fedora', 'centos', 'centos linux'] _debian_distros = ['debian', 'ubuntu', 'linuxmint'] if distro == _redhat: from operationhandler.rhelhandler import RhelOpHandler logger.debug('Using RhelOpHandler.') return RhelOpHandler() if distro in _rpm_distros: from operationhandler.rpmhandler import RpmOpHandler logger.debug('Using RpmOpHandler.') return RpmOpHandler() elif distro in _debian_distros: from operationhandler.debhandler import DebianHandler logger.debug('Using DebianHandler.') return DebianHandler() else: logger.critical( "Current platform '%s' isn't supported. Ignoring operations." % plat ) return None