Explaining top(1) on FreeBSD

Explaining top(1) on FreeBSD

We all understand and have at least as soon as utilized the top( 1 ) command to track info about our cpu and procedures, however the number of you understand what each field implies? Today we will assist you through each of these fields. By default, top( 1 ) shows the ‘leading’ procedures on each system and occasionally updates this info every 2.0 seconds utilizing the raw cpu usage portion to rank the procedures in the list.


Default top( 1 ) Output

This is how to default top( 1 ) command output looks. We will utilize it as a base to explain each field and column.

 last pid: 95139; load averages: 0.21, 0.25, 0.25 up 17 06: 17: 12 21: 01:34
22 procedures: 1 running, 21 sleeping.
CPU: 0.1%user, 0.0%great, 0.0%system, 0.0%interrupt, 99.9%idle.
Mem: 5968 K Active, 285 M Inact, 2918 M Wired, 584 K Buf, 552 M Free.
ARC: 101 M Total, 32 M MFU, 24 M MRU, 392 K Anon, 1286 K Header, 44 M Other.
12 M Compressed, 52 M Uncompressed, 4.46:1 Ratio.
Swap: 1024 M Total, 1024 M Free.

PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND.
95139 klarabsd 1 23 0 14 M 3988 K CPU3 3 0: 01 0.42%top.
91467 klarabsd 1 20 0 21 M 9536 K choose 1 0: 00 0.04%sshd.
79666 root 1 20 0 13 M 3024 K choose 2 5: 05 0.02%mountd.
66928 root 1 20 0 13 M 2312 K choose 2 4: 32 0.02%powerd.
86590 ntpd 1 20 0 21 M 5452 K choose 2 2: 46 0.01%ntpd.
88853 root 1 21 0 173 M 146 M choose 1 2: 29 0.00%smbd.
62176 root 1 20 0 13 M 2812 K choose 1 2: 16 0.00%syslogd.
88570 root 1 20 0 39 M 16 M choose 0 0: 41 0.00%nmbd.
91145 root 1 20 0 13 M 2728 K nanslp 3 0: 26 0.00%cron.
80942 root 4 52 0 12 M 2300 K rpcsvc 0 0: 05 0.00%nfscbd.
83679 root 32 52 0 12 M 2788 K rpcsvc 1 0: 05 0.00%nfsd.
77923 root 1 20 0 13 M 2680 K choose 1 0: 04 0.00%rpcbind.
90750 root 1 20 0 20 M 8268 K choose 1 0: 04 0.00%sshd.
93654 root 2 20 0 136 M 104 M choose 0 0: 03 0.00%smbd.
93831 root 1 20 0 131 M 104 M choose 0 0: 03 0.00%smbd.
45020 root 1 20 0 11 M 1488 K choose 0 0: 01 0.00?vd.
91568 klarabsd 1 29 0 15 M 6196 K time out 2 0: 00 0.00%zsh.
91342 root 1 41 0 21 M 9508 K choose 3 0: 00 0.00%sshd.
312 klarabsd 3 20 0 31 M 12 M choose 0 0: 00 0.00%mocp.
83547 root 1 52 0 12 M 3036 K choose 2 0: 00 0.00%nfsd.
7478 root 1 52 0 12 M 2196 K time out 1 0: 00 0.00?jkerntz.
80887 root 1 52 0 12 M 2252 K accept 0 0: 00 0.00%nfscbd.
PID/Load/Uptime/ Time

The last pid: reveals the PID of the last (newest) procedure, which is 95139 in our example.

The load averages: field shows the load average of the system over the last 1, 5, and 15 minutes respectively. The subject of load average is normally really broad and it is computed in a different way on numerous UNIX systems, so a different post might be devoted for simply that. The up field reveals the system uptime which is 17 days, () 6 hours, seventeen minutes and twelve seconds 06: 17: 12 The last field on the leading right is the existing time 21: 01: 34 showed in HH: MM: SS format.

Processes States

We have actually now covered the very first line of output from top( 1 ) Time for the 2nd line. This one includes info about the existing count of procedures and their state. On this system, there are 22 procedures with 1 running and 21 sleeping procedures.

CPU Use

The 3rd line reveals a summary breakdown of what is presently operating on the system CPUs. The user field reveals the use of userspace procedures. The great field demonstrates how much CPU time is taken by procedures with various good( 1 ) concerns. The system field demonstrates how much CPU time is utilized by the FreeBSD kernel. The interrupt field demonstrates how much CPU time is entrusted to disrupt assistance. Finally the idle field demonstrates how much CPU time is unused or totally free.

Memory

The 4th line of the top( 1 ) command significant Mem: reveals a comprehensive summary of the memory details. The following physical memory statistics include this details:

Active reveals the variety of bytes utilized by actively running procedures. Inact reveals the variety of bytes not just recently utilized by a procedure (while the procedure itself might still stay active– simply some parts of its memory has actually not been utilized just recently). If the system requires more memory, then this non-active memory might be switched out or released to make space. The Laundry line reveals the quantity of memory that is “unclean”, requiring to be laundering prior to it can be recycled. Information that has actually been customized because it read from disk, or has actually not yet been saved on disk, can not be quickly recreated, so it needs to be composed to switch or the customized file prior to that memory can be recycled. For more information about how the non-active memory and the laundry system work, see Exploring Swap on FreeBSD The Wired count reveals the variety of bytes wired down which, unlike the other types, CAN NOT be switched out. Buf reveals the variety of bytes utilized for buffers and caches. Rather of being switched out, they will be simply released. Free reveals the complimentary memory.

You may likewise have an interest in

Get more out of your FreeBSD advancement

Kernel advancement is essential to numerous business. If you have a FreeBSD execution or you’re taking a look at scoping out work for the future, our group can assist you even more allow your efforts.

To get the basic concept of just how much system memory is really utilized versus totally free, here is a tip. The utilized memory is typically the amount of Active and Wired fields. As Inact/ Laundry/ Buf fields can be switched out, they ought to all be dealt with as ‘buffers’ or ‘cached’ details in memory that can (and will) be released when required. FreeBSD, as any other creative UNIX system, follows the slogan of ‘ Unused memory is squandered memory.’ so when the memory is not required, FreeBSD keeps it in case a non-active procedure will attempt to gain access to it once again.

ZFS ARC

The 5th line consists of ZFS Adaptive Replacement Cache or, in other words, ARC This is the quantity or RAM that ZFS utilizes as cache. We might pick what ought to be the minimum and optimum ARC size in the / etc/sysctl. conf file with vfs.zfs.arc _ minutes and vfs.zfs.arc _ max criteria.

The ZFS ARC statistics fields reveal the following info.

The Total field reveals the variety of wired bytes utilized for the ZFS ARC. The MRU field reveals the variety of ARC bytes holding Most Recently Used information. The MFU field reveals the variety of ARC bytes holding Most Frequently Used information. The Anon field reveals the variety of ARC bytes keeping in flight information that does not fit into other classifications. The Header field reveals the variety of ARC bytes holding headers. The Other field reveals other various ARC bytes required for ZFS to run effectively.

The 6th line is an extension of the ZFS ARC statistics however, as ARC is compressed on FreeBSD, it reveals statistics of just how much memory has actually been conserved thanks to utilizing the compression algorithm on all that ZFS cache. The Compressed field reveals bytes of memory utilized by ARC caches. From all the memory utilized by ARC, the 12 M( megabytes) is compressed and thanks to 4.46:1 compress Ratio showed in the future the right, it utilizes ‘just’ 12 M rather of 52 M( megabytes) displayed in the Uncompressed field that will be utilized without compression.

SWAP

The staying Swap: field on the seventh line, as you most likely thought, reveals the SWAP details. Here, it is actually basic– it simply reveals Total size of SWAP location and just how much of it is in fact Free

The 2nd part of the top( 1 ) command is the list of procedures. These are the shown columns.

 PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND

This is the part where details about specific procedures is shown. The PID is the procedure id. The USERNAME reveals the name of the procedure’s owner. The PRI column reveals the present concern of the procedure while NICE is the quantity of good( 1 ) a procedure has. SIZE reveals the text/data/stack of procedure. RES is the existing quantity of resident memory while SWAP is the quantity of swap utilized– both in kilobytes. STATE is the existing state of the procedure– it can START/SLEEP/STOP/ ZOMB/WAIT/LOCK. When a procedure is waiting on something to occur, it will show the ‘waitchan’, explaining what it is awaiting. There are lots of possible worths for this, we may need to do a whole post on a few of the typical worths. RUN is revealed as CPUn (for example, CPU3) on systems with numerous CPU cores. The C is the sensible processor on which the procedure is presently running– this shows up just on SMP systems. The TIME column reveals the variety of seconds that the procedure utilized. The WCPU reveals the weighted cpu portion. The COMMAND reveals the name of the command that the procedure is presently running.

Cores Monitoring

To simply inspect which CPU is doing what, we can utilize the command listed below to show each CPU present use statistics. This is how it’s going to look:

%top -P 0.

### Output.

last pid: 23091; load averages: 0.66, 0.50, up 0 01: 12: 58 912: 44:49
107 procedures: 2 running, 104 sleeping, 1 waiting.
CPU 0: 1.6%user, 0.0%good, 0.0%system, 0.0%interrupt, 98.4%idle.
CPU 1: 2.4%user, 0.0%good, 0.4%system, 0.0%interrupt, 97.3%idle.
CPU 2: 0.0%user, 0.0%good, 0.0%system, 1.2%interrupt, 98.8%idle.
CPU 3: 1.1%user, 0.0%good, 1.5%system, 0.0%interrupt, 97.3%idle.
CPU 4: 0.4%user, 0.0%good, 0.4%system, 0.0%interrupt, 99.2%idle.
CPU 5: 2.7%user, 0.0%good, 1.2%system, 0.0%interrupt, 96.1%idle.
CPU 6: 0.4%user, 0.0%good, 0.8%system, 0.0%interrupt, 98.8%idle.
CPU 7: 1.2%user, 0.0%good, 0.0%system, 0.0%interrupt, 98.8%idle.
Mem: 1650 M Active, 2263 M Inact, 278 M Laundry, 2623 M Wired, 24 G Free.
ARC: 354 M Total, 109 M MFU, 92 M MRU, 1508 K Anon, 3657 K Header, 147 M Other.
87 M Compressed, 313 M Uncompressed, 3.58:1 Ratio.
Swap: 1024 M Total, 1024 M Free.

Interactive Mode Options

To prevent pointing out the entire top( 1 ) male page, we will explain the ‘most fascinating’ changes that we can toggle in the interactive (default) mode. No matter to what hold-up (with letter s) the refresh is set, we can constantly revitalize the screen by hand utilizing the [CTRL][L] faster way. We can likewise revitalize the statistics utilizing the greatest ‘crucial’ on the keyboard– the easier [SPACEBAR] The letter m will toggle in between the ‘cpu’ mode (which is the default) and the ‘io’ mode. Simply type ‘ cpu’ or ‘io’ after pushing the m secret. The letter S will toggle the screen of system procedures– which is really beneficial. We can likewise kill( 1 ) a procedure utilizing the letter k or renice( 1 ) one with the letter r For arranging the display screen of procedures, utilize the letter o and after that utilize among these columns for the arranging order: cpu/ res/ size/ time — the default is cpu Utilizing the capital P letter, we can change to show per CPU statistics rather of summary portions of CPU use. With capital J we can show procedures owned just by a particular prison. The letter i can toggle showing the idle procedures.

The I/O Mode

While the default top( 1 ) mode is CPU related, the top( 1 ) on FreeBSD likewise has another mode– the I/O mode which is really beneficial in tracking procedures that do much I/O. To begin the top( 1 ) in the I/O mode together with practical sorting on the TOTAL column, utilize this command:

 # leading -S -m io -o overall

The command above likewise consists of the – S alternative to reveal the system processes due to the fact that when we begin the ZFS scrub procedure, it will disappoint as any different procedure. With the – S choice, we will see high I/O activity of the zfskern system procedure– this is where ZFS scrub does its work.

This is how the top( 1 ) I/O mode appears like on FreeBSD.

 last pid: 9572; load averages: 0.40, 0.20, 0.17 up 17 21: 37: 30 12: 21:52
75 procedures: 2 running, 72 sleeping, 1 waiting.
CPU: 0.9%user, 0.0%good, 8.6%system, 3.4%interrupt, 87.1%idle.
Mem: 32 M Active, 298 M Inact, 2922 M Wired, 584 K Buf, 512 M Free.
ARC: 191 M Total, 58 M MFU, 64 M MRU, 7201 K Anon, 3024 K Header, 60 M Other.
84 M Compressed, 1179 M Uncompressed, 14.01:1 Ratio.
Swap: 1024 M Total, 1024 M Free.

PID USERNAME VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND.
806 root 1745 78 0 465 0 465 81.72%pkg.
19 root 104 26 0 38 0 38 6.68%zfskern.
9298 klarabsd 37 12 37 0 0 37 6.50%rsync.
1303 klarabsd 29 1 29 0 0 29 5.10?.
2 root 0 0 0 0 0 0 0.00%KTLS.
3 root 0 0 0 0 0 0 0.00%crypto.
77923 root 0 0 0 0 0 0 0.00%rpcbind.
64387 klarabsd 4 0 0 0 0 0 0.00%sshd.
4 root 0 0 0 0 0 0 0.00%crypto returns 0.
9572 klarabsd 6 0 0 0 0 0 0.00%rsync.
5 root 0 0 0 0 0 0 0.00%crypto returns 1.
6 root 0 0 0 0 0 0 0.00%crypto returns 2.
68006 root 0 0 0 0 0 0 0.00%sshd.
7 root 0 0 0 0 0 0 0.00%crypto returns 3.
93831 root 1 0 0 0 0 0 0.00%smbd.
8 root 147 54 0 0 0 0 0.00?mera.
9 root 0 0 0 0 0 0 0.00%soaiod1.
91145 root 0 0 0 0 0 0 0.00%cron.
10 root 0 0 0 0 0 0 0.00%audit.
11 root 4429 4798 0 0 0 0 0.00%idle.
71883 klarabsd 4 0 0 0 0 0 0.00%sshd.
427 root 0 0 0 0 0 0 0.00%pkg.
68331 klarabsd 0 0 0 0 0 0 0.00%zsh.

It has a little various columns than the default CPU mode top( 1 ) command. These are the shown columns in the IO mode.

 PID USERNAME VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND

Let’s explain the fields we did not formerly explain. VCSW implies V oluntary C ontext SW itches and it is the kind of context switch that occurs when procedure yields prior to it has actually utilized its allocated time quantum. IVCSW suggests I n V oluntary C ontext SW itches — it is the kind of context switch that takes place when the procedure utilizes all of its assigned time quantum and it is by force changed out of CPU by scheduler, to let other procedures run. The READ column reveals the read operations (check out IOPS) and WRITE reveals the compose IOPS. FAULT demonstrates how lots of faults there were and the TOTAL column is the amount of READ and WRITE columns. The PERCENT column reveals the portion of I/O activity for each procedure.

We Need to Go Deeper

Keep in mind that procedure (and I/O) tracking does not end on top( 1 ) command on FreeBSD. To get a much better view of what takes place in the FreeBSD system at CPU and/or IO level, you need to likewise attempt a minimum of among the following commands:

· htop( 1 )

· gstat( 1 )

· systat( 1 )

· vmstat( 1 )

Summary

While top (1) is a complicated tool that uses a great deal of details, we are confident that this post will supply some insight into how to utilize top( 1 ) more effectively.

Like this post? Share it!

Read More

Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *