Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94978

Re: Linux script to get most expensive processes

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'sys.platform': 0.07; 'subject:script': 0.09; 'skip:= 70': 0.10; 'amended': 0.16; 'fancy': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'platform:': 0.16; 'posix': 0.16; 'processes.': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:most': 0.16; 'wrote:': 0.16; 'script.': 0.18; '>>>': 0.20; '2015': 0.20; 'aug': 0.20; 'parameter': 0.22; 'wrote': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'linux': 0.26; 'van': 0.26; 'checking': 0.27; 'heading': 0.27; 'this.': 0.28; 'fine': 0.28; 'raise': 0.29; 'that.': 0.30; 'code': 0.30; 'are:': 0.32; 'expensive': 0.32; 'received:84': 0.32; 'getting': 0.33; 'useful': 0.33; 'skip:- 10': 0.34; 'this?': 0.34; 'worked': 0.34; 'gives': 0.35; 'done': 0.35; 'false': 0.35; 'but': 0.36; 'should': 0.36; 'possible': 0.36; 'heard': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'here.': 0.62; 'more': 0.63; 'as:': 0.79; 'subject:get': 0.81; "'for'": 0.84; 'cecil': 0.84; 'westerhof': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=OoyysHLt c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=UWU4mQFGWXkA:10 a=IkcTkHD0fZMA:10 a=JiX-h_W6vsa6h-R81moA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Subject Re: Linux script to get most expensive processes
To python-list@python.org
References <87twsehkmk.fsf@Equus.decebal.nl> <mailman.1218.1438721578.3674.python-list@python.org> <87pp32hhbr.fsf@Equus.decebal.nl>
From MRAB <python@mrabarnett.plus.com>
Date Tue, 4 Aug 2015 23:00:02 +0100
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
MIME-Version 1.0
In-Reply-To <87pp32hhbr.fsf@Equus.decebal.nl>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1219.1438725612.3674.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438725612 news.xs4all.nl 2887 [2001:888:2000:d::a6]:36333
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94978

Show key headers only | View raw


On 2015-08-04 22:30, Cecil Westerhof wrote:
> On Tuesday  4 Aug 2015 22:52 CEST, Emile van Sebille wrote:
>
>> On 8/4/2015 1:19 PM, Cecil Westerhof wrote:
>>> Under Linux I like to get the most expensive processes. The two
>>> most useful commands are: ps -eo pid,user,pcpu,args --sort=-pcpu
>>> and: ps -eo pid,user,pcpu,args --sort=-vsize
>>>
>>> In my case I am only interested in the seven most expensive
>>> processes. For this I wrote the following script.
>> <snip>
>>> Is this a reasonable way to do this? Getting the parameter is done
>>> quit simple, but I did not think fancy was necessary here.
>>
>>
>> My platform shows as linux2 and it worked fine for me when checking
>> for that.
>
> I heard that that was possible also, but none of my systems gives
> this. I should change it. I was also thinking about posix systems, but
> the Linux ps does more as others, so I did not do that.
>
> I amended the code to work with linux and linux2:
> ========================================================================
> accepted_params     = {
>      'pcpu',
>      'rss',
>      'size',
>      'time',
>      'vsize',
> }
> accepted_platforms  = {
>      'linux',
>      'linux2',
> }
> current_platform    = sys.platform
> max_line_length     = 200
> no_of_lines         = 8                     # One extra for the heading
>
> is_good_platform    = False
> for platform in accepted_platforms:
>      if platform == current_platform:
>          is_good_platform = True
>          break
> if not is_good_platform:
>      raise Exception('Got an incompatiple platform: {0}'.
>                      format(current_platform))
> ========================================================================
>
Doesn't that 'for' loop do the same as:

     is_good_platform = current_platform in accepted_platforms

?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-04 22:19 +0200
  Re: Linux script to get most expensive processes Emile van Sebille <emile@fenx.com> - 2015-08-04 13:52 -0700
    Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-04 23:30 +0200
      Re: Linux script to get most expensive processes MRAB <python@mrabarnett.plus.com> - 2015-08-04 23:00 +0100
        Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-05 01:14 +0200
      Re: Linux script to get most expensive processes Emile van Sebille <emile@fenx.com> - 2015-08-04 15:12 -0700
        Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-05 01:17 +0200
  Re: Linux script to get most expensive processes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-05 12:56 +0200
  Re: Linux script to get most expensive processes Laura Creighton <lac@openend.se> - 2015-08-06 06:06 +0200

csiph-web