Jump to content


Photo

Top Processes Based Memory or CPU Usage Workflow

Alfred2 Workflow

  • Please log in to reply
51 replies to this topic

#1 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 17 March 2013 - 01:09 PM


Alfred 2 Top Process Workflow

 
The initial motive of this workflow is to avoid frequent visits to the Activity Monitor when the fan goes loud. Now it has been evolved with two major features:
 
Suggestions are welcome. And Please go to http://zhaocai.githu...2-top-workflow/ for better view of the installation instruction.
 
- 1) List/Kill Top Processes by Memory/CPU/IO Usage
 
mixed%20top%20processes.png
 
 
- 2) (working in progress) Get a glance of system status including internal battery, fan speed, CPU/GPU Temperature, bluetooth battery, disk capacity, etc.
 
glance.png
 
Usage
 
0. Show Help
 
Just type -?, -h, or --help after the keyword to show help.
 
help.png
 
1. Top Processes
 
A. Keywords:
 
1.) top: Show a mixed processes list based on top cpu/memory usage.
 
 
     1. top -m, top --memory to show processes ranked by memory usage
 
     2. top -c, top --cpu, to show processes ranked by cpu usage
 
     3. top -i, top --io, to show processes ranked by io usage with callback from top io trace collector.
 
   Top IO requires [DTrace][Dtrace] and it would take a while to finish. The new callback design is to run the job in he background and post a notification (OSX 10.8+) using notification center. Click on the notification to show the result in alfred.
 
callback.png
 
 
 
 
Modifier Key
 
   - none    : The default action is to list files opened by process ID
   - control : Kill the selected process
   - command : kill forcefully (kill -9)
   - alt     : Nice (lower) the selected process's cpu priority
   - shift   : Search web for process information
 
 
2.) kill: Filter process to kill.
 
Modifier Key
 
   - none: The default action is to kill by process ID
   - command : kill forcefully (kill -9)
 
3.) lsof: List files opened by process id
 
Modifier Key
 
   - none: The default action is to reveal file in Finder
 
B. Filter by Query
 
1.) To search for process state, use :idle, :sleep, :stopped, :zombie, :uninterruptible, :runnable, etc.
 
top%20sleep.png
 
 
2. Glance an Eye on your system
 
#### A. Keywords:
 
  • glance: Show system information including internal battery, bluetooth battery, disk capacity, etc.
 
 
battery.png
 
B. Change Display Order
 
  • Activate Alfred PreferencesAdvancedTop Result Keyword Latching
 
 
Alfred_Preferences_Learning.png
 
  • Hit Enter for the feedback item you wish to show up on the top.
 
 
Installation

Two ways are provided:

  1. You can download the Top Processes.alfredworkflow and import to Alfred 2. This method is suitable forregular users.

  2. You can git clone or fork this repository and use rake install and rake uninstall to install. Check rake -T for available tasks. This method create a symlink to the alfred workflow directory: "~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows". This method is suitable fordevelopers.

 
 
Troubleshooting
 
1. Does not work in Mac OSX 10.9 (Maverick)
 
In OSX 10.9, the system ruby is upgraded to 2.0.0. You need to download the new version of this workflow which packs the ruby gems for 2.0.0 inside.
 
If the downloaded version does not work, try 
 
1.) open Terminal.app. If you use rvm or rbenv, switch to the system ruby.
  • run cd "$HOME/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/me.zhaowu.top" && rake bundle:update
 
2. iotop causes mouse lagging
 
This issue is not caused by this workflow but by [DTrace][DTrace]. The related system log message is IOHIDSystem cursor update overdue. Resending..
In my Macbook Pro, any [DTrace][DTrace] based program will introduce this issue including the mac built-in /usr/bin/iotop, and /Applications/Xcode.app/Contents/Applications/Instruments.app .
 
I upgrade to OS X 10.9 and this issue is resolved.
 
3. Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
 
Add the following contents to /etc/launchd.conf. Restart is required.
 
setenv LANG en_US.UTF-8
setenv LC_ALL en_US.UTF-8
 
 

 


Edited by zhaowu, 24 October 2013 - 01:08 PM.

  • twinpeaks, drking, CarlosNZ and 8 others like this

#2 lmartins

lmartins

    Member

  • Member
  • PipPip
  • 89 posts

Posted 17 March 2013 - 03:29 PM

This will keep me from frequent visits to the Activity Monitor. Thanks :-)



#3 slappy

slappy

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 17 March 2013 - 06:14 PM

Interesting.  One question on the workflow, what exactly does the cmd modifier do?  

 

Press and hold cmd and the highlighted items info changes to 'Force Kill'.  

If I continue to hold down cmd and either click on the selected item or hit the return key it will kill the app.  

If I don't press the cmd key and either mouse click or hit return on an item it will also kill the app.  



#4 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 17 March 2013 - 09:09 PM

Normally, kill a process means to send a signal to the process and let it finish it up and quit. It is safe. 

 

Force Kill means to send '-9       KILL (non-catchable, non-ignorable kill)' signal to kill the process. Normal it is not recommended to do that unless the process is hung or not responding. You may lose data by this.

 

Interesting.  One question on the workflow, what exactly does the cmd modifier do?  

 

Press and hold cmd and the highlighted items info changes to 'Force Kill'.  

If I continue to hold down cmd and either click on the selected item or hit the return key it will kill the app.  

If I don't press the cmd key and either mouse click or hit return on an item it will also kill the app.  



#5 slappy

slappy

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 17 March 2013 - 09:15 PM

Understood, thanks for the quick reply. This workflow will be very handy for me. Excellent work.

#6 Carlos-Sz

Carlos-Sz

    Community Hero

  • Member
  • PipPipPip
  • 773 posts

Posted 17 March 2013 - 09:28 PM

Nice workflow.

 

What does MEM: mean in the subtitle? If memory usage it seems not properly converted. Can you add or translate it into MB?


Edited by Carlos-Sz, 17 March 2013 - 09:28 PM.


#7 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 18 March 2013 - 01:54 AM

It is % but MB. new workflow is updated in github.

Nice workflow.

 

What does MEM: mean in the subtitle? If memory usage it seems not properly converted. Can you add or translate it into MB?



#8 Carlos-Sz

Carlos-Sz

    Community Hero

  • Member
  • PipPipPip
  • 773 posts

Posted 18 March 2013 - 02:38 AM

It is % but MB. new workflow is updated in github.

 

Great!



#9 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 19 March 2013 - 03:20 AM

update: Use full command line for command like java, ruby, python, etc.



#10 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 22 March 2013 - 08:26 PM

update readme and feedback  interleaving



#11 mccamel

mccamel

    Member

  • Member
  • PipPip
  • 26 posts

Posted 22 March 2013 - 10:22 PM

Wow this is a very good idea.  Thanks



#12 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 25 March 2013 - 07:24 AM

Update: (March 25, 2013)
- add `lsof` keyword to List Files Opened by Process ID as default action
- now you can search for process state like idle, sleep, stopped, zombie, uninterruptible, runnable, etc.

- add kill keyword which would be a replacement for similar workflow


Edited by zhaowu, 25 March 2013 - 07:59 AM.


#13 haikkonen

haikkonen

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 26 March 2013 - 06:22 AM

Just curious my friend, can you share to us your theme? Is a very nice one!!

Regards,



#14 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 26 March 2013 - 07:09 AM

Just curious my friend, can you share to us your theme? Is a very nice one!!

Regards,

 

 

 


Edited by zhaowu, 26 March 2013 - 07:11 AM.


#15 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 26 March 2013 - 07:12 AM

update ( March 26, 2013 )

* hold alt key to nice cpu priority



#16 Domenic

Domenic

    Member

  • Member
  • PipPip
  • 39 posts

Posted 27 March 2013 - 12:39 PM

update ( March 26, 2013 )

* hold alt key to nice cpu priority

nice!

;)



#17 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 29 March 2013 - 02:57 AM

[Release]( 1.2 / March 28, 2013 )

 

- Use single entry for the top auto mixed mode.

- Alleyoop: Update Alfred Workflows

- rescue feedback if something goes wrong


Edited by zhaowu, 29 March 2013 - 03:06 AM.


#18 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 30 March 2013 - 03:50 AM

[Release]( 1.3 / March 29, 2013 )

- refine keywords:

 

top

  • top /m, top /mem, top /memory to show processes ranked by memory usage
  • top /c, top /cpu, to show processes ranked by cpu usage


#19 Schneppi

Schneppi

    Member

  • Member
  • PipPip
  • 29 posts

Posted 30 March 2013 - 09:42 AM

Something is wrong with your AlleyOOP Update (1.3). It shows up everytime in alleyoop.



#20 zhaowu

zhaowu

    Member

  • Member
  • PipPip
  • 96 posts

Posted 30 March 2013 - 12:26 PM

Something is wrong with your AlleyOOP Update (1.3). It shows up everytime in alleyoop.

can you check the "

update.json" file in the workflow and post it.




Also tagged with one or more of these keywords: Alfred2, Workflow

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users