Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Shell Script] Visualizzare Occupazione CPU ???
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
kNemo
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2004
Posts: 116

PostPosted: Fri Jul 02, 2004 7:42 pm    Post subject: [Shell Script] Visualizzare Occupazione CPU ??? Reply with quote

Qualcuno saprebbe fare uno script di Shell che visualizzi l'occupazione della CPU ???

io avevo pensato di fare una cosa di questo tipo
top | grep CPU(s)*,

ma non funziona...
Qualcuno a qualche idea ???
_________________
Powered by:
Gentoo Base System version 1.4.16 (Kernel 2.4.26-gentoo-r9)
Portage 2.0.50-r9 (default-x86-2004.2, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.4.26-gentoo-r9)

ScreenShot
http://gendevel.altervista.org/home.php?s=oth&p=screensht


Last edited by kNemo on Fri Jul 02, 2004 7:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31292
Location: here

PostPosted: Fri Jul 02, 2004 7:47 pm    Post subject: Reply with quote

E prendere qualche programma tipo gdesklet o wmcpuload,... per vederla?
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
kNemo
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2004
Posts: 116

PostPosted: Fri Jul 02, 2004 7:51 pm    Post subject: Reply with quote

no... :lol:
mi serve per la scuola...
_________________
Powered by:
Gentoo Base System version 1.4.16 (Kernel 2.4.26-gentoo-r9)
Portage 2.0.50-r9 (default-x86-2004.2, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.4.26-gentoo-r9)

ScreenShot
http://gendevel.altervista.org/home.php?s=oth&p=screensht
Back to top
View user's profile Send private message
kNemo
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2004
Posts: 116

PostPosted: Fri Jul 02, 2004 8:10 pm    Post subject: Reply with quote

Mi andebbe bene anche uno script in Python... :roll:
_________________
Powered by:
Gentoo Base System version 1.4.16 (Kernel 2.4.26-gentoo-r9)
Portage 2.0.50-r9 (default-x86-2004.2, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.4.26-gentoo-r9)

ScreenShot
http://gendevel.altervista.org/home.php?s=oth&p=screensht
Back to top
View user's profile Send private message
ema
Guru
Guru


Joined: 27 Aug 2003
Posts: 380

PostPosted: Sat Jul 03, 2004 4:30 pm    Post subject: Reply with quote

/geekmode on
io ho fatto assieme a un amico una cosa di sto tipo: lui ha fatto un programmino in C che prende l'uso della cpu dal sistema e lo redirige verso la porta parallela, con un valore tra 0 e 255... da li un d/a converter che ho fatto io fa visualizzare il carico di sistema su uno strumento a lancetta 8)

vinceremo l'oscar dell'inutility? lol

/geekmode off
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Sat Jul 03, 2004 5:16 pm    Post subject: Reply with quote

uno script shell per definizione e' qualcosa che da un output univoco e unico, mente la cpu SECERNE (:D) un valore che e' molto incostante nel tempo...sei sicuro che cosi serva a qualcosa?
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Cazzantonio
Bodhisattva
Bodhisattva


Joined: 20 Mar 2004
Posts: 4514
Location: Somewere around the world

PostPosted: Sat Jul 03, 2004 6:00 pm    Post subject: Reply with quote

A me
Code:
ale@casa01 ale $ top |grep  Cpu
Cpu(s):  5.5% us,  3.3% sy,  0.9% ni, 88.2% id,  2.0% wa,  0.0% hi,  0.0% si
Cpu(s):  3.0% us,  0.7% sy,  0.0% ni, 96.3% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu(s):  3.3% us,  1.0% sy,  0.0% ni, 95.4% id,  0.3% wa,  0.0% hi,  0.0% si
Cpu(s):  7.7% us,  1.7% sy,  0.0% ni, 90.3% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s):  7.0% us,  1.7% sy,  0.3% ni, 91.0% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu(s): 26.8% us,  4.0% sy,  0.0% ni, 68.9% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s): 17.5% us,  2.3% sy,  0.3% ni, 79.5% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s): 17.1% us,  3.0% sy,  0.3% ni, 63.9% id, 15.4% wa,  0.3% hi,  0.0% si
..... continua

funziona perfettamente...
Forse semplicemente lo scrivevi tutto maiuscolo.... :roll:
Code:
ale@casa01 ale $ top |grep CPU
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           

e ti dava questo come output
_________________
Any mans death diminishes me, because I am involved in Mankinde; and therefore never send to know for whom the bell tolls; It tolls for thee.
-John Donne
Back to top
View user's profile Send private message
Cazzantonio
Bodhisattva
Bodhisattva


Joined: 20 Mar 2004
Posts: 4514
Location: Somewere around the world

PostPosted: Sat Jul 03, 2004 6:05 pm    Post subject: Reply with quote

Cazzantonio wrote:
A me
Code:
ale@casa01 ale $ top |grep  Cpu
Cpu(s):  5.5% us,  3.3% sy,  0.9% ni, 88.2% id,  2.0% wa,  0.0% hi,  0.0% si
Cpu(s):  3.0% us,  0.7% sy,  0.0% ni, 96.3% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu(s):  3.3% us,  1.0% sy,  0.0% ni, 95.4% id,  0.3% wa,  0.0% hi,  0.0% si
Cpu(s):  7.7% us,  1.7% sy,  0.0% ni, 90.3% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s):  7.0% us,  1.7% sy,  0.3% ni, 91.0% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu(s): 26.8% us,  4.0% sy,  0.0% ni, 68.9% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s): 17.5% us,  2.3% sy,  0.3% ni, 79.5% id,  0.0% wa,  0.3% hi,  0.0% si
Cpu(s): 17.1% us,  3.0% sy,  0.3% ni, 63.9% id, 15.4% wa,  0.3% hi,  0.0% si
..... continua

funziona perfettamente...
Forse semplicemente lo scrivevi tutto maiuscolo.... :roll:
Code:
ale@casa01 ale $ top |grep CPU
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           

e ti dava questo come output


P.S.
Comunque complimenti a ema per il bellissimo oggetto :D mi viene voglia di farlo anche a me :D :D
_________________
Any mans death diminishes me, because I am involved in Mankinde; and therefore never send to know for whom the bell tolls; It tolls for thee.
-John Donne
Back to top
View user's profile Send private message
kNemo
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2004
Posts: 116

PostPosted: Sat Jul 03, 2004 6:07 pm    Post subject: Reply with quote

A me' serve uno script Shell o Python per visualizzare l'occupazione della CPU...
Di piu' non so' dire...

PS: Con Cpu "minuscolo" funziona...
Grazie.
_________________
Powered by:
Gentoo Base System version 1.4.16 (Kernel 2.4.26-gentoo-r9)
Portage 2.0.50-r9 (default-x86-2004.2, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.4.26-gentoo-r9)

ScreenShot
http://gendevel.altervista.org/home.php?s=oth&p=screensht
Back to top
View user's profile Send private message
xchris
Advocate
Advocate


Joined: 10 Jul 2003
Posts: 2824

PostPosted: Sat Jul 03, 2004 6:23 pm    Post subject: Reply with quote

il modo migliore cmq per intercettarlo e' usare top in batch mode

Code:

top -b -n 1 | grep Cpu


ciao
_________________
while True:Gentoo()
Back to top
View user's profile Send private message
kNemo
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2004
Posts: 116

PostPosted: Sat Jul 03, 2004 6:28 pm    Post subject: Reply with quote

top -b -n 1 | grep Cpu | cut -d ' ' -f -3
_________________
Powered by:
Gentoo Base System version 1.4.16 (Kernel 2.4.26-gentoo-r9)
Portage 2.0.50-r9 (default-x86-2004.2, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.4.26-gentoo-r9)

ScreenShot
http://gendevel.altervista.org/home.php?s=oth&p=screensht
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31292
Location: here

PostPosted: Sat Jul 03, 2004 7:03 pm    Post subject: Reply with quote

Ecco lo script (si poteva fare meglio)
Code:
#!/bin/sh
while [ 1 ]; do
  CPU=`top -b -n 2 -d 0.3 | grep Cpu | tail -n 1 | head -c 13 | tail -c 5`
  clear
  echo -n -e "\033[1;1H $CPU"
done

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sat Sep 22, 2007 12:49 pm    Post subject: Reply with quote

Si puo leggere da qualche parte in /proc/qualcosa l'utilizzo delle cpu?
mi serve per fare uno scriptino...
_________________
LP
Back to top
View user's profile Send private message
cloc3
Advocate
Advocate


Joined: 13 Jan 2004
Posts: 4808
Location: http://www.gentoo-users.org/user/cloc3/

PostPosted: Sat Sep 22, 2007 1:01 pm    Post subject: Reply with quote

lucapost wrote:
Si puo leggere da qualche parte in /proc/qualcosa l'utilizzo delle cpu?
mi serve per fare uno scriptino...

Code:

cat /proc/stat

vedi `man proc` per approfondimenti.
_________________
vu vu vu
gentù
mi piaci tu
Back to top
View user's profile Send private message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sat Sep 22, 2007 1:19 pm    Post subject: Reply with quote

ottimo! :wink:
_________________
LP
Back to top
View user's profile Send private message
lavish
Bodhisattva
Bodhisattva


Joined: 13 Sep 2004
Posts: 4296

PostPosted: Sat Sep 22, 2007 3:25 pm    Post subject: Reply with quote

Spostato da Forum italiano (Italian) a Forum di discussione italiano.

@lucapost: lasciami indovinare... status di dwm? :lol:
_________________
minimalblue.com | secgroup.github.io/
Back to top
View user's profile Send private message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sat Sep 22, 2007 5:50 pm    Post subject: Reply with quote

per provar a capire che valori devo considerare ho provato a leggere il man, ma ahimè non ci ho captio molto...
poi ho trovato questo: http://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-it-4/s1-proc-topfiles.html, ci ho capito ancora meno!

che rapporto devo considerare per vedere il carico percentuale su ogni cpu?


Quote:
@lucapost: lasciami indovinare... status di dwm? :lol:

8)
_________________
LP
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum