Ejemplo n.º 1
0
 def get_open_files(self):
     """Return files opened by process as a list of namedtuples."""
     # XXX - C implementation available on FreeBSD >= 8 only
     # else fallback on lsof parser
     if hasattr(_psutil_bsd, "get_process_open_files"):
         rawlist = _psutil_bsd.get_process_open_files(self.pid)
         return [ntuple_openfile(path, fd) for path, fd in rawlist]
     else:
         lsof = _psposix.LsofParser(self.pid, self._process_name)
         return lsof.get_process_open_files()
Ejemplo n.º 2
0
 def get_connections(self, kind='inet'):
     """Return network connections opened by a process as a list of
     namedtuples by parsing lsof output.
     """
     if kind not in conn_tmap:
         raise ValueError("invalid %r kind argument; choose between %s" %
                          (kind, ', '.join([repr(x) for x in conn_tmap])))
     families, types = conn_tmap[kind]
     ret = []
     lsof = _psposix.LsofParser(self.pid, self._process_name)
     for conn in lsof.get_process_connections():
         if conn.family in families and conn.type in types:
             ret.append(conn)
     return ret
Ejemplo n.º 3
0
 def get_connections(self):
     """Return network connections opened by a process as a list of
     namedtuples by parsing lsof output.
     """
     lsof = _psposix.LsofParser(self.pid, self._process_name)
     return lsof.get_process_connections()
Ejemplo n.º 4
0
 def get_open_files(self):
     """Return files opened by process by parsing lsof output."""
     lsof = _psposix.LsofParser(self.pid, self._process_name)
     return lsof.get_process_open_files()