def _dmesg_raw(self): shell = Shell('journalctl -k -n 1000') if shell.status == 0: return shell.stdout shell = Shell('dmesg') if shell.status == 0: return shell.stdout result = self._read_file('var/log/dmesg') return result
def _date(self): result = '' shell = Shell("date -u +'%F %T UTC'") if shell.status == 0: result += shell.stdout shell = Shell("date +'%Z %z'") if shell.status == 0: result = "{0} (local TZ:{1})".format(result, shell.stdout) return result
def _os_arch(self): shell = Shell('getconf LONG_BIT') if shell.status == 0: if re.search('64', shell.stdout): return '64-bit' if re.search('32', shell.stdout): return '32-bit' return NA
def _shell_out(self, cmd, timeout=1, sudo=False): sudo = sudo and self.use_sudo shell = Shell(cmd, timeout=timeout, sudo=sudo) sudo_cmd = 'sudo -n {0}'.format(cmd) if sudo else cmd logging.debug('Shell "{0}" status: {1}'.format(sudo_cmd, shell.status)) if shell.status == 0: return shell.stdout return NA
def _sysctl(self): result = {'_RAW': NA} shell = Shell('sysctl -a') if not shell.status == 0: return result result['_RAW'] = shell.stdout for out in shell.stdout.split("\n"): try: k, v = out.split(" = ") result[k] = v except: continue return result