Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
 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