Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps functions not available with psutil installed #7432

Closed
jalons opened this issue Sep 24, 2013 · 13 comments · Fixed by #8983
Closed

ps functions not available with psutil installed #7432

jalons opened this issue Sep 24, 2013 · 13 comments · Fixed by #8983
Labels
Bug broken, incorrect, or confusing behavior expected-behavior intended functionality

Comments

@jalons
Copy link
Contributor

jalons commented Sep 24, 2013

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)
@s0undt3ch
Copy link
Collaborator

You are running your minion under python 2.6?
If so, have a look here.

@terminalmage
Copy link
Contributor

CentOS 6.4 does not have Python 2.7, so I'm pretty sure this is the case.

@s0undt3ch
Copy link
Collaborator

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>.

@jalons
Copy link
Contributor Author

jalons commented Sep 24, 2013

@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.

@s0undt3ch
Copy link
Collaborator

Thanks, we might be able to add support for the functions available under python 2.6 and not all, but at least some.

@aboe76
Copy link
Contributor

aboe76 commented Sep 24, 2013

@s0undt3ch look here:
https://code.google.com/p/psutil/source/browse/README?name=release-0.6.1
this is the version on centos...

@jalons
Copy link
Contributor Author

jalons commented Sep 24, 2013

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.

@s0undt3ch
Copy link
Collaborator

@aboe76 I was after which are available under python 2.6 which is what the comment on the code warns us about.

@s0undt3ch
Copy link
Collaborator

@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 😄

@jalons
Copy link
Contributor Author

jalons commented Sep 24, 2013

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.

@s0undt3ch
Copy link
Collaborator

@jalons yes, disabling the check apparently solves you issue, but 2 years ago, there were other issues, see here.

@smithjm
Copy link

smithjm commented Nov 12, 2013

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.

@terminalmage
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior expected-behavior intended functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants