Sponsored Content
Top Forums Shell Programming and Scripting How to get the information about cpu idle from top command? Post 302376588 by huyquocnguyen on Tuesday 1st of December 2009 08:33:45 PM
Old 12-01-2009
Code:
#!/bin/bash
a=20
CPUIDLE=$(top -d 0.1 -n 2 | grep '^Cpu(s):'| tail -1 |awk '{print $5}'|sed 's/%.*//')
echo $CPUIDLE
if [ $CPUIDLE -lt $a ]
then
     exit 1
else
     exit 0
fi


When I run, it have error:
Code:
root@ubuntu:~# ./phan6.sh
88.5
./phan6.sh: line 5: [: 88.5: integer expression expected

Please help me to fix it.
Thanks in advanced
 

10 More Discussions You Might Find Interesting

1. Solaris

CPU idle

hi when should we consider that CPU is loaded? When it is 100% idle or 0%idle?? tx (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

2. HP-UX

sar output gives 98% idle CPU

Dear All, Our HPUX 8 GB 8CPU database server is behaving abnormally for the last 4+ weeks. I have generated a sar output and it is here- 11:46:52 %usr %sys %wio %idle 11:46:53 1 1 6 92 11:46:54 0 1 0 99 11:46:55 0 1 0... (3 Replies)
Discussion started by: Ashrunil
3 Replies

3. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

4. UNIX for Dummies Questions & Answers

top command + %CPU usage exceeds 100%?

Hi there. I was looking at the output from running top and for short amounts of time, when I see all the process running and add up the values in the %CPU column the value exceeds 100% (I just add them quickly in my head). I assume that if I were to add up all my processes in the entire list,... (2 Replies)
Discussion started by: Carl1976
2 Replies

5. UNIX for Dummies Questions & Answers

Unix Top Command and sorting by CPU Usage

Ok, so I am using the Top command on my linux VPS to try and see the processes using the most CPU %. I hit the P to sort by CPU % but it wants to sort them from lowest to highest (ascending). My Telnet-SSH screen is only about 60 rows high so the processes with the highest CPU % usage are at the... (6 Replies)
Discussion started by: davemehta
6 Replies

6. AIX

Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies

7. Shell Programming and Scripting

Command to find the Memory and CPU utilization using 'top' command

Hi all, I found like top command could be used to find the Memory and CPU utilization. But i want to know how to find the Memory and CPU utilization for a particular user using top command. Thanks in advance. Thanks, Ananthi.U (2 Replies)
Discussion started by: ananthi_ku
2 Replies

8. Solaris

top is showing 0% cpu Idle

What should we do if we show a 0% cpu idl on top? (5 Replies)
Discussion started by: Pouchie1
5 Replies

9. UNIX for Dummies Questions & Answers

Query related to swap information shown by top command

Hi I have checked the output of top command in which there is a difference shown between the swap of top command for a process with total swap memory usage of the top command. Swap usage of process is higher than the total swap memory usage. top - 18:28:21 up 7:13, 5 users, load... (2 Replies)
Discussion started by: gagan2914
2 Replies

10. UNIX for Dummies Questions & Answers

Idle Process Exhausting CPU

I noticed when having some trouble with code I was testing that the CPU was becoming exhausted and I would have to reboot. After rebooting a couple times I decided to check for other problems before trying my code again. That's when I noticed that the CPU with the idle process was through the roof:... (5 Replies)
Discussion started by: Azrael
5 Replies
PMIE2COL(1)						      General Commands Manual						       PMIE2COL(1)

NAME
pmie2col - convert pmie output to multi-column format SYNOPSIS
pmie2col [-d delimiter] [-p precision] [-w width] DESCRIPTION
pmie2col is a simple tool that converts output from pmie(1) into regular column format. Each column is 7 characters wide (by default, may be changed with the -w option) with a single space between columns. That single space can be substituted with an alternate delimiter using the -d option (this is useful for importing the data into a spreadsheet, for example). The precision of the tabulated values from pmie can be specified with the -p option (default is 2 decimal places). This option can and will override any width setting in order to present the requested precision. The pmie(1) configuration must follow these rules: (1) Each pmie(1) expression is of the form ``NAME = expr;''. NAME will be used as the column heading, and must contain no white space, although special characters can be escaped by enclosing NAME in single quotes. (2) The ``expr'' must be a valid pmie(1) expression that produces a singular value. In addition, pmie(1) must be run with the -v command line option. It is also possible to use the -e command line to pmie(1) and output lines will be prefixed by a timestamp. EXAMPLE
Given this pmie(1) configuration file (config): loadav = kernel.all.load #'1 minute'; '%usr' = kernel.all.cpu.user; '%sys' = kernel.all.cpu.sys; '%wio' = kernel.all.cpu.wait.total; '%idle' = kernel.all.cpu.idle; 'max-iops' = max_inst(disk.dev.total); Then this command pipeline: $ pmie -v -t 5 <config | pmie2col -w 8 Produces output like this: loadav %usr %sys %wio %idle max-iops 0.21 ? ? ? ? ? 0.36 0.49 0.03 0.18 0.29 25.40 0.49 0.41 0.10 0.36 0.13 51.00 0.69 0.49 0.10 0.05 0.37 43.20 0.71 0.39 0.08 0.04 0.49 14.00 0.83 0.63 0.15 0.00 0.21 32.30 1.09 0.60 0.02 0.10 0.27 47.00 0.92 0.01 0.00 0.00 0.99 2.40 PCP ENVIRONMENT
Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configura- tion file, as described in pcp.conf(5). SEE ALSO
PCPIntro(1) and pmie(1). Performance Co-Pilot PCP PMIE2COL(1)
All times are GMT -4. The time now is 05:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy