Thomas MerkelThomas MerkelMemory and CPU usage tools on Illumos (3.3.2016, 11:26 UTC)

This is only a small overview of memory and CPU usage tools on Illumos. Mostly I forgot the commands so it's like a personal reference page :-)

Total physical memory

Show DIMM and hardware overview via prtdiag:

prtdiag -v

Show max physical memory via prtconf:

prtconf | grep Memory

Create an overview 10 times every 5 seconds:

vmstat 5 10

Memory usage by process

Show percentage of memory usage by process, you could use sort to sorting the output:

ps -A -o pmem -o pcpu -o args

Overall CPU usage

Two processor reports with five seconds interval:

mpstat 5 2

Important fields are:

  • usr: user time in percent
  • sys: system time in percent
  • idl: idle time in percent

CPU usage by process

Use prstat which is more or less similar to top on Linux. There are different sorting and command line options available.

Sort by cpu usage (default):


Sort by memory usage:

prstat -s rss

Sort by virtual memory usage:

prstat -s size

Sort by process execution time:

prstat -s time

Find top five processes:

prstat -n 5

Also print process numbers for each user:

prstat -a

Follow a particular process id:

prstat -p <pid>

Follow threads of a particular process id:

prstat -L -p <pid>
Thomas MerkelThomas MerkelCreate ISO image from folder in MacOSX (1.3.2016, 21:28 UTC)

You maybe run into an problem that your remote server has no network connection because of some drivers are missing? And the only thing that works is to use IPMI and remote virtual devices which contains your driver?

For that I created an folder which contains the drivers, packages and create an ISO image with hdiutil.

hdiutil makehybrid -o ~/image.iso ~/your/folder -iso -joliet

The tool creates an ISO file in your home, image.iso. You could burn that to an CD or you could use it with your IPMI tool and mount it remotely.

Thomas MerkelThomas MerkelThe equal sign in Bash (26.2.2016, 12:21 UTC)

From bash scripts by my co-workers I noticed there is a big misunderstanding of using the equals sign in bash if statements.

Should I use one square bracket or two, should I use two equal signs or one?

You could use one [ (square bracket) with one = (equal sign). This is valid in bash and sh.

if [ "$random" = "$example" ]

This is documented for the bash test builtin if you type help test. One square bracket [ is an alias for test. You could also find it in the Bash manual. This will work in most shells since the original version of Unix.

The official bash way is to use two [[ (square brackets) and two == (equal signs). It matches the syntax of most other programming languages.

if [[ "$random" == "$example" ]]

Now the biggest mess starts, because bash also supports one square bracket and two equal signs.

if [ "$random" == "$example" ]

The bash authors decided to deviate from the traditional behaviour of /bin/sh and support this syntax. Anyway, this feature is not documented and it will not work on sh and it's derivates. For example dash which is default on Ubuntu will through an syntax error.

If you consider to use your shell script on different systems you should not use the undocumented function :-)

Thomas MerkelThomas MerkelUpdate X terminal title (25.2.2016, 12:12 UTC)

Your window title of an X terminal and the MacOS X title could be updated with hostname and path automatically.

And it could be so simple, add the following line to your ~/.bashrc:

# Change the window title of X terminals
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"

An additional feature is provided by MacOS X by using right click on the title. It allow you to open the current folder or any above folder.

Thomas MerkelThomas MerkelMigrate ZFS pool to a different server (5.2.2016, 09:28 UTC)

I hope you run your server with ZFS already :-)

For some reason you may need to migrate your ZFS pool with all snapshots to a different server. This could be a backup reason or simple a migration scenario.

In the example the pool named zones. So first you create a recursive snapshot of your pool:

zfs snapshot -r zones@migrate_20160204

You could simple verify that the snapshots exists via:

zfs list -t snapshot

I use SSH to migrate the data between two servers. It depends on your network, so you could also switch to netcat or something similar.

zfs send -R zones@migrate_20160204 | ssh user@host "zfs receive -Fd zones"

You may like to add options like -v to show some more detailed output of the transferred data.

It could be your data is modified during the migration. For that reason you could easily create a new snapshot after the send and receive command finished.

zfs create -r snapshot zones@migrate_20160205

Incremental zfs send is possible with the -i option. So zfs send only the difference between two snapshots to the remote server.

zfs send -R -i zones@migrate_20160204 zones@migrate_20160204 | \
    ssh user@host "zfs receive -F zones"
hackyhackyFestool Fan (1.2.2016, 16:16 UTC)

Es ist mal wieder Zeit fuer eine Geburtstagstorte und, in diesem Fall, Cakepops ;) Die Bilder sind zwar schon ein paar Tage alt und die Torte existiert schon lange nicht mehr, aber ich bin immer noch ein bisschen stolz darauf und deshalb muss ich das jetzt posten :P

Die Torte besteht aus zwei Stockwerken, einmal Schoko- und Vanilleteig. Der Ueberzug besteht, wie immer aus, Fondant :) Und auch fast alles ist essbar, hehe.

10384121_859442247453739_1532375005785466039_n 11018849_859961127401851_7749393644161650539_n 11043128_860292980701999_8511857932166885464_n


hackyhackyUSA and USB (27.1.2016, 08:17 UTC)


SuppenwiediSuppenwiediALL CREATURES WELCOME (4.1.2016, 19:10 UTC) CREATURES WELCOME
SuppenwiediSuppenwiediALL CREATURES WELCOME - Impressions CCCamp 2015 (4.1.2016, 19:10 UTC) CREATURES WELCOME - Impressions CCCamp 2015
Thomas MerkelThomas MerkelGPG Feature import-clean (30.11.2015, 20:35 UTC)

You GnuPG keyring got a little bit messy over time? Than you're not alone - I transferred my keyring from computer to computer since I use GnuPG so it contains more than thousands of keys. The trustdb calculation takes minutes to complete so it's time for an housekeeping task.

Maybe unknown GnuPG feature is import-clean which allow you to cleanup your keyring and remove unusable signatures.

  After import, compact (remove all signatures except the self-signature)
  any user IDs from the new key that are not usable.  Then, remove any
  signatures from the new key that are not usable.
  This includes signatures that were issued by keys that are not present
  on the keyring.

You should do it by refreshing all keys from the keyserver:

gpg --no-options --keyserver \
    --keyserver-options import-clean,export-clean --refresh-keys

After I've used the above command my trustdb calculation time is decreased a lot.

LinksRSS 0.92   RDF 1.
Atom Feed   Frubar.Network