macOS: SystemUIServer eating your CPU? Check your Ethernet connection!

Recently, the SystemUIServer process on my MBP running macOS Sierra has started “eating” a lot of CPU, slowing down the whole machine, even making the clock in the top menu bar stop working properly. It usually started using one-digit percentages of the available CPU power, then growing to 10%, 15%, 20%, up to well above 60%, sometimes even 80% and more! It wasn’t a steady growth – it sometimes shrank again, just to grow even further.

The only apparent remedy was to kill the SystemUIServer process (e.g. using the Activity Monitor) from time to time (i.e. every 30 minutes -> there are also scripts to automatically restart SystemUIServer). Its CPU usage then reset to a low one-digit number.

Taking a closer look at the process in the Activity Monitor, I then noticed that the number of (used) ports (so-called “Mach ports“) by the process were steadily growing, once SystemUIServer was started. This was weird, pointing to some kind of leakage. Typically, for a CPU load of around 50%, more than 5000 Mach ports were used.

By coincidence, I then noticed that, unlike expected, my MBP wasn’t actually using Ethernet, but only WiFi. Further investigation then hinted that the according Gigabit Ethernet port on my HP 1810 switch was apparently malfunctioning (or even dead): In the macOS Network Preferences, the Thunderbolt-Ethernet connection was constantly shown as red/disconnected, although the OS was apparently trying to establish a connection again and again (and failed). First, I even suspected a problem with the Thunderbolt-Gigabit-Ethernet adapter itself (it wasn’t the problem here, the adapter seemed to work fine with another Mac and connection).

The solution to this problem thus was:

  • Connect the Ethernet cable to another, working Ethernet port: Now the SystemUIServer process consumes less than 0.1% CPU again and roughly 400 ports only, both with and without additional WiFi.
    Note that both the problem and this solution are reproducible.

Lessons learned:

  • Sometimes, very unexpected, seemingly unrelated and “small” problems can have big (negative) effects.
  • Sometimes you need a bit of luck to find the cause of a problem (a web search didn’t bring up the above hint, rather suggested updating or removing faulty apps, buggy extensions and menu widgets. I thus already tried removing or updating some of the suspected apps, extensions and widgets.)
  • Ports of HP 1810 switches can actually break/fail! Remember the saying: “I got 99 problems, but a switch ain’t one!” – well, in this case, the faulty switch was actually part of the problem and even the initial trigger of the problem! Also remember that HP offers a lifelong warranty on its (good ol’) 1810 switches.
  • Extra points for you, further research: The fact that the SystemUIServer allocates more and more Mach ports if there’s a malfunctioning Ethernet port (i.e. faulty Ethernet connection or faulty handling of a faulty Ethernet connection by the Thunderbolt-Gigabit-Ethernet adapter) is hinting that this might be an attack vector for a (new?) DoS attack. Perhaps not an easily exploitable one (on the Ethernet or MAC layer, even), but it’s nonetheless something that should actually be handled gracefully by SystemUIServer, not leading to more and more CPU and system resources being consumed.
    If you have time to research this further, let me know about your findings!

Using multiple Skype accounts on macOS

With the recent changes in Skype, the “traditional” method of running several Skype instances using different system users doesn’t work anymore (as the the new authentication dialog strangely doesn’t get the focus anymore).

So, in order to use several Skype accounts on macOS (formerly known as Mac OS X), do the following:

  1. Open the Script Editor (in the ‘Utilities’ folder in the ‘Applications’ folder)
  2. Create a new script with the following content:
    do shell script "open -na /Applications/Skype.app/Contents/MacOS/Skype --args -DataPath '/Users/your_system_user/Library/Application Support/Skype_any_identifier'"

    Replace your_system_user by your regular macOS user account (see ‘whoami’ in Terminal)
    Replace _any_identifier by the according Skype account name, e.g. _myskypename (doesn’t really matter what, just don’t use an empty string)
    Please mind the double quotes and single quotes (important!)

  3. Save the script as an application: File.. Save.., choose “Application” as file format, give it a name and store it e.g. in your home directory or in the Applications folder

Repeat these steps for any of your Skype accounts, giving each Skype account a different Skype_any_identifier. You can then start the according Skype instances by double clicking on the according app.

Explanation:

The above script starts a new instance of Skype (which would otherwise be prevented), using the -n argument. Each instance of Skype gets its own directory to store the according account data, using the -DataPath argument.

Karabiner: Use PC-style Home/End keys on Mac OS X

Karabiner allows to customize almost any aspect of the keymap on Mac OS X in a convenient way:

Karabiner – A powerful and stable keyboard customizer for OS X. (formerly known as KeyRemap4MacBook)

For example, you can make the “Home” and “End” keys behave like on a PC. Regarding these two keys, I find the PC style behaviour more intuitive, e.g. using shift-home and shift-end to select text, rather than using the tricky three-finger-combinations shift-cmd-left_cursor and shift-cmd-right_cursor in Mac OS X.

Here’s how to configure this in Karabiner:

karabiner_use_pc_style_home_and_end_keys

 

Further, I decided to lower the “Key Repeat Delay Until Repeat” to 100 ms and the “Key Repeat” to 23 ms for quicker navigation and repetitive typing.

Of course, there are many other useful tweaks to explore.

Mac OS X tools: FinderPath and HyperDock

On hacker news (i.e the better alternative interface http://hckrnews.com), I stumbled over two nice helper apps for Mac OS X:

FinderPath (free) shows the full path in the title bar of a Finder window upon double-clicking it. Like that, the full path can be selected and copied to the clipboard or one can simply edit the path and hereby easily navigate through the filesystem trees. It’s quite a time saver!

HyperDock (9.95 USD) displays thumbnail screenshots of all windows of the running apps in the Dock when hovering over them, making it easier and quicker to switch to other windows or to close them (the latter being a feature still missing in Mission Control). It also supports several other cool features, like Window Snapping.

Homebrew package for t-prot: TOFU protection for e-mail

In a current LUGS mailing list thread, mowgli pointed to the t-prot script as a nice tool to “fix” the so-called (and very common) TOFU style message quoting and some other annoyances (like commercial webmail provider signatures, overly excited !!!! statements, etc.) in e-mail messages. t-prot was originally developed for mutt, but can also be used with other mail clients.

As there wasn’t any t-prot package for my favourite Mac OS X package manager Homebrew yet (apparently only for MacPorts), I quickly created one myself [Edited on Feb 24, 2015: Updated for t-prot version 3.3]:

  1. Create the file /usr/local/Library/Formula/t-prot.rb and add the following (fantastically trivial) content:
    require "formula"
    
    class TProt < Formula
      homepage "http://www.escape.de/~tolot/mutt/"
      url "http://www.escape.de/~tolot/mutt/t-prot/downloads/t-prot-3.3.tar.gz"
      sha1 "9be24629abc598b24e887f47e9a62feddc3ed4ad"
    
      def install
        bin.install 't-prot'
        man1.install 't-prot.1'
      end
    
    end
    
  2. Install t-prot (run the following Homebrew command in a terminal window):
    brew install t-prot
  3. Add the following line to your .muttrc (or check ‘man t-prot’ or the t-prot web page for options and examples):
    set display_filter="t-prot -cemt -M=mutt"