ps functions not available with psutil installed
Following packages installed from EPEL on CentOS 6.4:
$ rpm -qa | egrep "python-psutil|salt"
salt-0.16.3-1.el6.noarch
salt-minion-0.16.3-1.el6.noarch
python-psutil-0.6.1-1.el6.x86_64
Starting the salt-minion process in the foreground with:
/usr/bin/python /usr/bin/salt-minion -l debug
On the master:
# salt 'minion' ps.cpu_times
minion:
"ps.cpu_times" is not available.
And in the minion's log file:
[INFO ] User root Executing command ps.cpu_times with jid 20130924090103044734
[DEBUG ] Command details {'tgt_type': 'glob', 'jid': '20130924090103044734', 'tgt': 'minion*', 'ret': '', 'user': 'root', 'arg': [], 'fun': 'ps.cpu_times'}
[INFO ] Returning information for job: 20130924090103044734
Yet, if I call:
salt 'minion' cmd.run "/usr/bin/python -c 'import psutil; print psutil.cpu_times()'"
I get back:
# salt 'minion' cmd.run "/usr/bin/python -c 'import psutil; print psutil.cpu_times()'"
minion:
cputimes(user=123.25, nice=0.34000000000000002, system=199.69999999999999, idle=308202.46999999997, iowait=22.27, irq=0.01, softirq=1.78)
You are running your minion under python 2.6? If so, have a look here.
CentOS 6.4 does not have Python 2.7, so I'm pretty sure this is the case.
I have an idea on supporting at least part of what this module provides.
@jalons could you please go through the ps module and see which functions are not available under the python 2.6 version of psutil?
By functions I mean psutil.<function-name>.
@s0undt3ch Correct on python 2.6, so this does appear to be the issue.
I'll see what I can come up with RE: the ps module.
Thanks, we might be able to add support for the functions available under python 2.6 and not all, but at least some.
@s0undt3ch look here: https://code.google.com/p/psutil/source/browse/README?name=release-0.6.1 this is the version on centos...
Thanks @aboe76
@s0undt3ch I removed the check for python > 2.6 and ran the following, which returned values that appear correct:
ps.boot_time
ps.cached_physical_memory
ps.cpu_percent
ps.cpu_times
ps.disk_io_counters
ps.disk_partition_usage
ps.disk_partitions
ps.disk_usage
ps.get_pid_list
ps.network_io_counters
ps.num_cpus
ps.physical_memory_buffers
ps.physical_memory_usage
ps.top
ps.total_physical_memory
ps.virtual_memory_usage
pgrep, pkill, and kill_pid all also functioned.
I think the check should be changed from rather than checking the python version, to check a minimum psutil version.
@aboe76 I was after which are available under python 2.6 which is what the comment on the code warns us about.
@jalons that's all of the ps module...
@SEJeff ever tried psutil under python 2.6 lately? You disabled it for python 2.6 two years ago :smile:
I'm obviously confused here. My understanding is the ps module is what ultimately utilizes psutil, right? I believe all that's required to restore the ps functionality is to disable the check, as every ps function that makes underlying calls to psutil complete successfully.
@jalons yes, disabling the check apparently solves you issue, but 2 years ago, there were other issues, see here.
This problem still exists in 0.17.1! Could we please at least reduce the check to <6 instead of <7? The ps module does work on SL6.4/Centos 6.4 (python 2.6.6) with python-psutils installed, so this check really does create problems and I'm not sure solves any these days.
Hand editing /usr/lib/python2.6/site-packages/salt/modules/ps.py on the minons such that:
try:
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
return False
except Exception:
return False
return 'ps'
becomes:
try:
if sys.version_info[0] == 2 and sys.version_info[1] < 6:
return False
except Exception:
return False
return 'ps'
fixes the issue on Centos 6.4 and Scientific Linux 6.4, though frankly, I think as others have said, we could remove the version check altogether.
I've submitted a pull request (#8983) that should resolve this by looking not at the python version, but the version of psutil that is installed.