scottchiefbaker / dool

Python3 compatible fork of dstat
GNU General Public License v3.0
332 stars 64 forks source link

dool can't open subprocess commands (like with --mysql-io) #57

Closed andrew-niaid closed 11 months ago

andrew-niaid commented 12 months ago

On Rocky 9.2 with the default python (3.9.16), dool produces the error: module 'os' has no attribute 'popen3' when trying to use options that require spawning a subprocess such as --mysql-io.

It looks like the import asubprocess in the try block fails because asubprocess isn't valid, so it then tries the os.popen3() in the exception, but that's not valid on python 3.9.

Should import asubprocess really be import subprocess?

https://github.com/scottchiefbaker/dool/blob/332b82832b1a4394238c4ffc922308527bf1fbba/dool#L1773-L1779

scottchiefbaker commented 12 months ago

Looks like Python 3 completely dropped os.popen*()? Either way it probably should never hit that code, as it does appear subprocess.Popen() is still valid. Perhaps that import is a typo and that's the problem? If you fix the typo does that solve the issue?

Sounds like either way we need to update the exception catching to error out?

andrew-niaid commented 11 months ago

Yes, this appears to work. At least for the mysql, mysql5, and innodb plugins. The other plugins that use the same subprocess call are the gpfs and gpfs-ops plugins. They give an error with python3 (but not with python2).

# python3 /usr/bin/dool --gpfs --gpfs-ops
Module dool_gpfs failed to load. (a bytes-like object is required, not 'str')
Module dool_gpfs_ops failed to load. (a bytes-like object is required, not 'str')
None of the stats you selected are available.
# python2 /usr/bin/dool --gpfs --gpfs-ops
┄┄gpfs┄i/o┄┬┄┄┄┄┄┄┄┄gpfs┄file┄operations┄┄┄┄┄┄┄
 read write│ open  clos  read  writ  rdir  inod
   0  0.98B│   0     0     0     0     0     0
   0   256M│   0     0     0   512     0     0
   0   256M│   0     0     0   511     0     4
   0   256M│   1     1     0   512     0     0
...
scottchiefbaker commented 11 months ago

This should be fixed now.