Commit a51c2e76 authored by Josué Ortega's avatar Josué Ortega

New upstream version 1.0.13

parent 2f201d2d
......@@ -39,18 +39,18 @@ Output truncated for brevity.
::
PID COMMAND USERNAME CPU RAM COMMANDLINE
0 kernel root -- -- kernel PID 0
116 KernelEventAgent root 0.01s 0% /usr/sbin/KernelEventAgent
426 corestoragehelperd root 0.05s 0% corestoragehelperd
808 PluginXPCService johan 0.05s 0% /System/Library/PrivateFrameworks/StoreXPCServices.framework/Versions/A/XPCServices/com.apple.appsto
...
80678 -fish johan 0.25s 0% -fish
80490 Google Chrome Helper johan 14.76s 1% /Applications/Google Chrome.app/Contents/Versions/58.0.3029.110/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=renderer --field-trial-handle=1 --lang=sv --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --blink-settings=disallowFetchForDocWrittenScriptsInMainFrame=false,disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections=false --enable-pinch --num-raster-threads=2 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,34037;0,11,34037;0,12,34037;0,13,3553;0,14,3553;0,15,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,34037;1,11,34037;1,12,34037;1,13,3553;1,14,3553;1,15,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,34037;2,11,34037;2,12,34037;2,13,3553;2,14,3553;2,15,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,34037;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,34037;3,13,3553;3,14,34037;3,15,34037;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,34037;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4,11,3553;4,12,34037;4,13,3553;4,14,34037;4,15,34037 --disable-accelerated-video-decode --disable-webrtc-hw-vp8-encoding --renderer-client-id=1309
80729 mdworker johan 0.06s 0% /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared
80728 AddressBookSourceSync johan 0.28s 0% /System/Library/Frameworks/AddressBook.framework/Versions/A/Helpers/AddressBookSourceSync.app/Contents/MacOS/AddressBookSourceSync
80720 GradleWrapperMain johan 2.6s 1% /usr/bin/java -Xdock:name=Gradle -Xdock:icon=/Users/johan/src/flickr-uploader/FlickrUploaderAndroid/media/gradle.icns -Dorg.gradle.appname=gradlew -classpath /Users/johan/src/flickr-uploader/FlickrUploaderAndroid/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain build
80727 GradleDaemon johan 25.56s 2% /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Xmx1536M -Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp /Users/johan/.gradle/wrapper/dists/gradle-3.5-all/7s64ktr9gh78lhv83n6m1hq9u6/gradle-3.5/lib/gradle-launcher-3.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 3.5
PID COMMAND USERNAME CPU CPUTIME RAM COMMANDLINE
0 kernel root -- -- -- kernel PID 0
273 SandboxHelper _coreaudiod 0% 0.01s 0% /System/Library/Frameworks/AudioToolbox.framework/XPCServices/com.apple.audio.SandboxHelper.xpc/Contents/MacOS/com.apple.audio.SandboxHelper
596 installerdiagd root 0% 0.01s 0% /System/Library/PrivateFrameworks/InstallerDiagnostics.framework/Versions/A/Resources/installerdiagd
983 periodic-wrapper root 0% 0.01s 0% /usr/libexec/periodic-wrapper daily
...
57417 Google Chrome Helper johan 0% 1m03s 2% /Applications/Google Chrome.app/Contents/Versions/70.0.3538.102/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=renderer --field-trial-handle=5536258455526146518,14669732848005555331,131072 --service-pipe-token=7224348701576210538 --lang=sv --metrics-client-id=576E1A60-CA59-34F4-6C0C-57F64BD5F01C --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --num-raster-threads=4 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --service-request-channel-token=7224348701576210538 --renderer-client-id=1119 --no-v8-untrusted-code-mitigations --seatbelt-client=418
14983 studio johan 0% 1h22m 14% /Applications/Android Studio.app/Contents/MacOS/studio
57993 kcm root 0% 0.02s 0% /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/kcm --launchd
57602 Code Helper johan 0% 12.73s 2% /private/var/folders/cg/d7qzk4s13s9c8t49t3txdjpr0000gn/T/AppTranslocation/B5DDDD81-5A91-4961-B18B-20DAB3925EB0/d/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --type=renderer --js-flags=--nolazy --no-sandbox --primordial-pipe-token=570B948A976AACDA8EBB532E5680C83E --lang=sv --app-path=/private/var/folders/cg/d7qzk4s13s9c8t49t3txdjpr0000gn/T/AppTranslocation/B5DDDD81-5A91-4961-B18B-20DAB3925EB0/d/Visual Studio Code.app/Contents/Resources/app --node-integration=true --webview-tag=true --no-sandbox --background-color=#171717 --disable-blink-features=Auxclick --enable-pinch --num-raster-threads=4 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,34037;0,11,34037;0,12,34037;0,13,3553;0,14,3553;0,15,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,34037;1,11,34037;1,12,34037;1,13,3553;1,14,3553;1,15,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,34037;2,11,34037;2,12,34037;2,13,3553;2,14,3553;2,15,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,34037;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,34037;3,13,3553;3,14,34037;3,15,34037;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,34037;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4,11,3553;4,12,34037;4,13,3553;4,14,34037;4,15,34037 --service-request-channel-token=570B948A976AACDA8EBB532E5680C83E --renderer-client-id=110
57996 cat johan 0% 0.0s 0% cat
57745 GradleDaemon johan 0% 32.75s 3% /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Xmx1536m -Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp /Users/johan/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg/gradle-4.6/lib/gradle-launcher-4.6.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 4.6
* To give you the most interesting processes close to your next prompt, ``px``
puts last in its output processes that:
......@@ -71,9 +71,8 @@ This lists all Java processes. Note how they are presented as their main class
::
PID COMMAND USERNAME CPU RAM COMMANDLINE
80727 GradleDaemon johan 1m46s 5% /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Xmx1536M -Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp /Users/johan/.gradle/wrapper/dists/gradle-3.5-all/7s64ktr9gh78lhv83n6m1hq9u6/gradle-3.5/lib/gradle-launcher-3.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 3.5
81192 GradleWrapperMain johan 2.57s 1% /usr/bin/java -Xdock:name=Gradle -Xdock:icon=/Users/johan/src/flickr-uploader/FlickrUploaderAndroid/media/gradle.icns -Dorg.gradle.appname=gradlew -classpath /Users/johan/src/flickr-uploader/FlickrUploaderAndroid/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain build
PID COMMAND USERNAME CPU CPUTIME RAM COMMANDLINE
57745 GradleDaemon johan 0% 35.09s 3% /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Xmx1536m -Dfile.encoding=UTF-8 -Duser.country=SE -Dus
``px _coreaudiod``
------------------
......@@ -81,9 +80,10 @@ This lists all processes owned by the ``_coreaudiod`` user.
::
PID COMMAND USERNAME CPU RAM COMMANDLINE
204 DriverHelper _coreaudiod 6.67s 0% /System/Library/Frameworks/CoreAudio.framework/Versions/A/XPCServices/com.apple.audio.DriverHelper.xpc/Contents/MacOS/com.apple.audio.DriverHelper
195 coreaudiod _coreaudiod 43m10s 0% /usr/sbin/coreaudiod
PID COMMAND USERNAME CPU CPUTIME RAM COMMANDLINE
273 SandboxHelper _coreaudiod 0% 0.01s 0% /System/Library/Frameworks/AudioToolbox.framework/XPCServices/com.apple.audio.SandboxHelper.xpc/Contents/MacOS/com.apple.audio.SandboxHelper
190 DriverHelper _coreaudiod 0% 0.3s 0% /System/Library/Frameworks/CoreAudio.framework/Versions/A/XPCServices/com.apple.audio.DriverHelper.xpc/Contents/MacOS/com.apple.audio.DriverHelper
182 coreaudiod _coreaudiod 0% 11m28s 0% /usr/sbin/coreaudiod
``sudo px 80727``
-----------------
......
......@@ -81,7 +81,7 @@ fi
PYTEST_ADDOPTS="--cov=px -v" ./setup.py test
# Create px wheel...
rm -rf dist .deps/px-*.egg .deps/px-*.whl "${ENVDIR}"/px-*.whl build/lib/px
rm -rf dist "${ENVDIR}"/pxpx-*.whl build/lib/px
./setup.py bdist_wheel --universal --dist-dir="${ENVDIR}"
# ... and package everything in px.pex
......
......@@ -19,9 +19,9 @@ if sys.version_info.major >= 3:
from typing import Optional # NOQA
# Match + group: " 77082 1 Mon Mar 7 09:33:11 2016 netbios 0:00.08 0.0 /usr/sbin/netbiosd hej"
# Match + group: " 7708 1 Mon Mar 7 09:33:11 2016 netbios 0.1 0:00.08 0.0 /usr/sbin/netbiosd hj"
PS_LINE = re.compile(
" *([0-9]+) +([0-9]+) +([A-Za-z0-9: ]+) +([^ ]+) +([-0-9.:]+) +([0-9.]+) +(.*)")
" *([0-9]+) +([0-9]+) +([A-Za-z0-9: ]+) +([^ ]+) +([0-9.]+) +([-0-9.:]+) +([0-9.]+) +(.*)")
# Match + group: "1:02.03"
CPUTIME_OSX = re.compile("^([0-9]+):([0-9][0-9]\.[0-9]+)$")
......@@ -56,6 +56,12 @@ class PxProcess(object):
self.memory_percent_s = (
"{:.0f}%".format(process_builder.memory_percent))
self.cpu_percent = process_builder.cpu_percent
self.cpu_percent_s = "--"
if self.cpu_percent is not None:
self.cpu_percent_s = (
"{:.0f}%".format(process_builder.cpu_percent))
# Setting the CPU time like this implicitly recomputes the score
self.set_cpu_time_seconds(process_builder.cpu_time)
......@@ -153,6 +159,7 @@ class PxProcessBuilder(object):
self.ppid = None # type: Optional[int]
self.start_time_string = None # type: Text
self.username = None # type: Text
self.cpu_percent = None # type: Optional[float]
self.cpu_time = None # type: Optional[float]
self.memory_percent = None # type: Optional[float]
......@@ -164,7 +171,7 @@ def call_ps():
env = os.environ.copy()
if "LANG" in env:
del env["LANG"]
ps = subprocess.Popen(["ps", "-ax", "-o", "pid,ppid,lstart,uid,time,%mem,command"],
ps = subprocess.Popen(["ps", "-ax", "-o", "pid,ppid,lstart,uid,pcpu,time,%mem,command"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
return ps.communicate()[0].decode('utf-8').splitlines()[1:]
......@@ -215,9 +222,10 @@ def ps_line_to_process(ps_line, now):
process_builder.ppid = int(match.group(2))
process_builder.start_time_string = match.group(3)
process_builder.username = uid_to_username(int(match.group(4)))
process_builder.cpu_time = parse_time(match.group(5))
process_builder.memory_percent = float(match.group(6))
process_builder.cmdline = match.group(7)
process_builder.cpu_percent = float(match.group(5))
process_builder.cpu_time = parse_time(match.group(6))
process_builder.memory_percent = float(match.group(7))
process_builder.cmdline = match.group(8)
return PxProcess(process_builder, now)
......
......@@ -49,7 +49,8 @@ def to_screen_lines(procs, columns):
headings.pid = "PID"
headings.command = "COMMAND"
headings.username = "USERNAME"
headings.cpu_time_s = "CPU"
headings.cpu_percent_s = "CPU"
headings.cpu_time_s = "CPUTIME"
headings.memory_percent_s = "RAM"
headings.cmdline = "COMMANDLINE"
procs = [headings] + procs
......@@ -59,12 +60,14 @@ def to_screen_lines(procs, columns):
command_width = 0
username_width = 0
cpu_width = 0
cputime_width = 0
mem_width = 0
for proc in procs:
pid_width = max(pid_width, len(str(proc.pid)))
command_width = max(command_width, len(proc.command))
username_width = max(username_width, len(proc.username))
cpu_width = max(cpu_width, len(proc.cpu_time_s))
cpu_width = max(cpu_width, len(proc.cpu_percent_s))
cputime_width = max(cputime_width, len(proc.cpu_time_s))
mem_width = max(mem_width, len(proc.memory_percent_s))
format = (
......@@ -72,6 +75,7 @@ def to_screen_lines(procs, columns):
u'} {:' + str(command_width) +
u'} {:' + str(username_width) +
u'} {:>' + str(cpu_width) +
u'} {:>' + str(cputime_width) +
u'} {:>' + str(mem_width) + u'} {}')
# Print process list using the computed column widths
......@@ -79,8 +83,8 @@ def to_screen_lines(procs, columns):
for proc in procs:
line = format.format(
proc.pid, proc.command, proc.username,
proc.cpu_time_s, proc.memory_percent_s,
proc.cmdline)
proc.cpu_percent_s, proc.cpu_time_s,
proc.memory_percent_s, proc.cmdline)
lines.append(line[0:columns])
return lines
......
......@@ -98,6 +98,7 @@ def test_ps_line_to_process_3():
" 4432"
" Thu Feb 25 07:42:36 2016"
" " + str(os.getuid()) +
" 5.5"
" 1-19:31:31"
" 19.7"
" /usr/sbin/mysqld"
......@@ -110,6 +111,7 @@ def test_ps_line_to_process_3():
" --socket=/var/run/mysqld/mysqld.sock"
" --port=3306", testutils.now())
assert process.username == getpass.getuser()
assert process.cpu_percent_s == "6%"
assert process.memory_percent_s == "20%"
assert process.cpu_time_s == "1d19h"
assert process.command == "mysqld"
......
......@@ -10,8 +10,8 @@ from . import testutils
def test_to_screen_lines_unbounded():
procs = [testutils.create_process(commandline="/usr/bin/fluff 1234")]
assert px_terminal.to_screen_lines(procs, None) == [
" PID COMMAND USERNAME CPU RAM COMMANDLINE",
"47536 fluff root 0.03s 0% /usr/bin/fluff 1234"
" PID COMMAND USERNAME CPU CPUTIME RAM COMMANDLINE",
"47536 fluff root 0% 0.03s 0% /usr/bin/fluff 1234"
]
......
......@@ -31,6 +31,7 @@ def now():
def create_process(pid=47536, ppid=1234,
timestring=TIMESTRING,
uid=0,
cpuusage="0.0",
cputime="0:00.03", mempercent="0.0",
commandline="/usr/sbin/cupsd -l",
now=now()):
......@@ -40,6 +41,7 @@ def create_process(pid=47536, ppid=1234,
str(ppid) + spaces() +
timestring + spaces() +
str(uid) + spaces() +
cpuusage + spaces() +
cputime + spaces() +
mempercent + spaces() +
commandline)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment