LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Assigning a button for top or htop. (https://www.linuxquestions.org/questions/linux-general-1/assigning-a-button-for-top-or-htop-933805/)

indiajoe 03-10-2012 04:36 PM

Assigning a button for top or htop.
 
When some program chocks the CPU or memory to 100%, the keyboard too hangs.
I want to assign a button (like the lid close button or power button) for calling top or htop with nice -20 so that i can kill the application.
The script which keeps watch of this event has be running with -20 nice number.
Is this a good idea to implement? Any ideas?

-cheers
indiajoe

TB0ne 03-10-2012 04:50 PM

Quote:

Originally Posted by indiajoe (Post 4623658)
When some program chocks the CPU or memory to 100%, the keyboard too hangs.
I want to assign a button (like the lid close button or power button) for calling top or htop with nice -20 so that i can kill the application.
The script which keeps watch of this event has be running with -20 nice number.
Is this a good idea to implement? Any ideas?

Doesn't make alot of sense to me. If the keyboard hangs, then ANY key/button on your system will also be affected and hang. You could just use whatever your GUI manager (Gnome/KDE) keyboard settings to program a key to run whatever script you want, but again, if the keyboard hangs, that will ALSO hang, so you're right back where you started.

indiajoe 03-11-2012 03:26 AM

I was thinking of situations when it is not completely hung. Mostly my system only gets extremely slow. So do you think that running a script which watches for a particular key stroke and run top with nice -20 will be as good as assigning it to any other button on my laptop?
(Many a times i have noticed that the power button starts shutdown even when my keyboard is responding very slow)
Thanking you,
indiajoe

unSpawn 03-11-2012 06:00 AM

Linux is quite efficient in how it utilizes and shares available resources among processes. Instead of searching for a way to kill processes you should find out what is or are the bottlenecks and how to make those processes play nice (more RAM, review processor and disk energy-saving states, different type of scheduler, process niceness, ionice, running certain processes sequentially like cronjobs, etc, etc). Basic tools to gather resource statistics (aka SAR) are Atop, Dstat and collectl.


All times are GMT -5. The time now is 08:43 PM.