Hot answers tagged

7

You don't need to free "buff/cache". "buff/cache" is memory that Linux uses for disk caching, and that will be freed when applications require it. So you don't have to worry if a large amount is being shown in this field, as it doesn't count as "used" memory. Quoted from http://www.linuxatemyram.com (emphasis mine): Both you and Linux agree that memory ...


6

It works if you add one filter after another. Run top and add a filter for the first user. Press o and enter !USER=user1 , then press o and add the next filter !USER=user2 and so forth...


3

You would need additional software installed for that. You could use sar (see https://linux.die.net/man/1/sar ) or the monitoring-system of your choice. sar -q will report load averages (among others...) $ sar -q 1 5 Linux 4.9.0-9-amd64 (sds-ulm-edv-553-workstation) 09/10/2019 _x86_64_ (2 CPU) 02:04:43 PM runq-sz plist-sz ldavg-1 ldavg-5 ...


3

A single thread can not be split between multiple cores: A program needs to be written to have more than one thread (one per core), or there needs to be more than one program. If not then you won't use the cores. Writing programs to use more cores is not trivial, and not all problems can be parallelised (written to run on more than one core). If a problem ...


3

"Idle". From the source code: switch (this->state) { case 'R': Frame_running++; break; case 't': // 't' (tracing stop) case 'T': Frame_stopped++; break; case 'Z': Frame_zombied++; break; default: /* currently: 'D' (disk sleep), 'I' (...


3

Using top and awk one could easily create e.g. a comma separated log of %CPU ($9) + %MEM ($10) usage that can later be fed into any statistics and graphing tool. top -b -d $delay -p $pid | awk -v OFS="," '$1+0>0 { print strftime("%Y-%m-%d %H:%M:%S"),$1,$NF,$9,$10; fflush() }' Output will be like 2019-03-26 17:43:47,2991,firefox,13.0,5.2 2019-03-26 17:...


3

You should use the --line-buffered option of grep (since your question is tagged "centos", you're most certainly using GNU grep). By default, grep will only use line buffering when the output is a terminal (just like stdio functions: printf, puts, etc). The --line-buffered option is overriding that. GNU coreutils also has a stdbuf(1) wrapper that should ...


3

There is a command to show processor related runtime statistics on the fly, called mpstat. On most distributions it is part of the sysstat package. Whilst it has an output that could be a more direct answer to your question mpstat -P ALL -I CPU, I prefer the output of mpstat -P ALL, which is much more intelligible. As an example, the output in a machine ...


2

The "st" value can be simply explained by using an T2.micro EC2 instance from AWS. In the AWS documentation you can read that you get only a 10% baseline performance per VCPU. This means that if you have a process which would consume a lot of cpu time, the "st" value will stay around 90 since you are only allowed to use 10% of the VCPU. The sum of the other ...


2

Not enough reputation to comment, but for psrecord you can also call it directly, in a programmatic way, directly in Python: from psrecord.main import monitor monitor(<pid number>, logfile = "./test.log", plot="./fig.png", include_children=True)


2

The canonical source of this information is /usr/src/linux/Documentation/filesystems/proc.txt Buffers: Relatively temporary storage for raw disk blocks shouldn't get tremendously large (20MB or so) Cached: in-memory cache for files read from the disk (the page cache). Doesn't include SwapCached. You can also find some more details here. The ...


2

top -bn 1 After you set up your top rc; top 1 W q grep what you want top -bn 1 | grep -P "^(%|top)" For output like top - 11:40:33 up 24 days, 32 min, 1 user, load average: 0.00, 0.00, 0.00 %Cpu0 : 0.0 us, 1.2 sy, 0.0 ni, 98.1 id, 0.1 wa, 0.3 hi, 0.2 si, 0.0 st %Cpu1 : 0.0 us, 0.9 sy, 0.0 ni, 98.9 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st ...


2

command:top -b -n1| sed -n '/PID/,$p' output ux_example ~]# top -b -n1| sed -n '/PID/,$p' PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 7 root RT 0 0 0 0 S 1.7 0.0 0:01.04 migration/1 1 root 20 0 19356 1564 1252 S 0.0 0.1 0:07.96 init 2 root 20 0 0 0 0 S 0.0 0.0 0:...


2

The top command is intended for interactive use. To get the output you want in a programmatic way, you might consider using ps instead, which can give most of the same information but it is more script-friendly. Example: $ ps -eo pid,uid,pri,nice,vsz,rss,s,%cpu,%mem,time,comm | head PID UID PRI NI VSZ RSS S %CPU %MEM TIME COMMAND 1 0 ...


2

In the ps manual, under the section "PROCESS STATE CODES": D uninterruptible sleep (usually IO) R running or runnable (on run queue) S interruptible sleep (waiting for an event to complete) T stopped by job control signal t stopped by debugger during the tracing W paging (not valid since the 2.6.xx kernel) X dead (...


2

VIRT is the amount of address space that the process has allocated, RES is the amount of memory that the process is using. Swap isn’t involved here, and the only relationship is that RES plus the amount of backing store used by the process (swap or something else) is less than VIRT. It’s usual for processes to allocate more address space than they’ll use.


2

/etc/passwd is one of many possible user databases. Others include things like IPA. You can use getent to see the effective passwd database. As for the shortening of the user name, that's just the way top displays; sadly it looks like that can't be changed. You might want to try the w command.


2

This is a hard one. If the load average is higher than number of CPUs (for too long), then this is a sign that things are queuing up. However if they are less, this is not a sign of anything. There can be one process, using 100% of a CPU, that is not getting its work done. On the other hand, if you have many low priority batch processes, with no real time ...


2

If it were only one user, you could do top -U '!user1' The -U filters by real user id, whereas -u filters by effective user id. I could not get multiple users to be filtered with this method.


1

If I understand you correctly, would this help? top | grep -ve "user1" -e "user2"


1

In your pipeline, the head command would deliver the first six lines of output from ps to grep, no matter what username was mentioned in those lines. Swapping the head and grep calls around would mean that the head command would only ever see lines from ps containing the wanted username. (You also likely want to use head -n 5).


1

Try this: ssh $i top -b -n 1 | tail -n +7 | awk '$9 >= 100.0' | awk -v "host=$i" '{print host, $2, $9, $12}' >> temp1


1

Instead of trying to wrap using a shell script, we can write a short C program, which allows us to switch back to the normal screen when the program is stopped: #define _GNU_SOURCE 1 #include <stdbool.h> #include <stdio.h> #include <signal.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> /* Quick ...


1

Sysdig is probably what you want, it's programmable in case it isn't. The topfiles_bytes "chisel" (sysdig script) lists the most I/O-ed files.


1

Top will show utilization of the OS. I think your vm using 4 CPUS, and mysql running 399% cpu usage, it means 98% of total CPU.


1

procps top, the one found on Ubuntu is probably the most configurable of top implementations. To change the list of fields, press f and you can add remove fields, change their orders, etc. There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top... You can save those configuration by pressing W....


1

I see not much differences between these two commands. Both top and gnome-sytem-monitor give per core %cpu utilization. (Here % can be greater than 100) The difference that you see can be attributed to the time interval at which both these commands are collecting the stats. So please change update interval in seconds under preferences->processes->...


1

You can use command like this: top -b -p 14861 -n1 |tail -1|awk '{$5=$5*1024*1024; $6=$6*1024*1024} 1'


1

Kindly check the commands below. First method Find out the number of processor configured in the host: cat /proc/cpuinfo | grep -i processor| wc -l Suppose the output we got is 4: then, a load average up to 4 is OK. If it goes beyond 4 then there is an issue. Note: the (acceptable) load average directly depends on the number of core processor ...


1

The top variant provided with FreeBSD core system does not have that -p option used to select a list of pid to watch on a pseudo real-time manner. Nevertheless, the htop package can be installed on top of your FreeBSD system and this more colorfull top (among other things) variation have this wanted -p option. htop help: From htop usage: htop 2.2.0 - (C) ...


Only top voted, non community-wiki answers of a minimum length are eligible