The arrow of time

Ivan Voras' blog

Colored snake!

Probably not many users noticed, but some time ago I committed a hopefully useful (but always shiny!) addition to the "snake" console screensaver - now it contains the system load numbers and is color-coded per system load :)

Just to make this clear: this is probably a completely useless piece of code but I just feel giddy about it :)

The snake is colored like this:

  • No load (first load number = 0) : light grey / "normal" console color
  • Light load (>0% - 50%) - green
  • Moderate load (51% - 75%) - yellow
  • High load (76% - 99%) - red
  • Overload (>99%) - blinking red

The measurements are SMP-aware - e.g. the screenshots below are on a dual-core machine where "50%" load means 1 full CPU core is always busy.

color snake - high load

color snake - light load

One day, if I get bored (or talked into doing this in the comments on this post :) ), I plan to implement something like this (but in text mode).

#1 Re: Colored snake!

Added on 2010-10-25T15:52 by Idwer

For the archives :)

Commit message:

http://svn.freebsd.org/viewvc/base/head/sys/dev/syscons/snake/snake_saver.c?view=log&pathrev=204248

Changeset url: http://svn.freebsd.org/viewvc/base/head/sys/dev/syscons/snake/snake_saver.c?r1=204248&r2=204247&pathrev=204248

#2 Re: Colored snake!

Added on 2010-10-25T19:03 by Ivan Voras

I know this kind of change is the least likely to make a difference to anyone but for some reason I think it's insanely cool to have color-coded load averages in a screen saver :)

#3 Re: Colored snake!

Added on 2010-10-26T04:31 by BSDr

there's NO WAY you could code that up ... ;-) it's TOO HARD ... you'd have to be SUPER SMART to do that

#4 Re: Colored snake!

Added on 2010-11-03T08:04 by Antony Mawer

I don't suppose you'd be interested in driving a commit of my text-mode splash(4) module, splash_txt? I've been using it in production for 5 years and it would be nice to see it go into the tree so it's one less thing to patch into our custom builds...

http://www.mawer.org/freebsd/

http://www.freebsd.org/cgi/query-pr.cgi?pr=143370&cat=

http://lists.freebsd.org/pipermail/freebsd-stable/2010-January/054595.html

#5 Re: Colored snake!

Added on 2010-11-03T11:48 by DES

Why "something like this (but in text mode)"? We've supported graphical console screen savers for ages; I wrote the first three (logo, rain and warp, which is still my favorite) almost eleven years ago. The only issue is that you can't use floating point arithmetic in the kernel, which makes it slightly harder to draw circular gauges, but you can pre-render the face of the gauge and use a precalculated lookup table to position the tip of the needle.

#6 Re: Text mode

Added on 2010-11-03T11:52 by Ivan Voras

Mostly because of amd64: AFAIK (I could be wrong), we don't support graphics in syscons on amd64. I don't have problems with fixed point math.

#7 Re: Text mode

Added on 2010-11-03T22:56 by DES

It's not fixed point that's the problem, it's the lack of trigonometric functions. You can get by with a relatively small lookup table, though; if you have the sin and cos values from 0 to 45 degrees, you can derive the rest of the circle with only additions and subtractions.

As for graphics mode on amd64, we have an x86 emulator in the kernel (see sys/contrib/x86emu and sys/compat/x86bios), so we can run the graphics adapter's BIOS on amd64 (and, in theory, any other platform, but AFAICT it's only enabled for amd64).

#8 Re: Text mode

Added on 2010-11-03T23:14 by Ivan Voras

I can manage fixed point trig with this: https://sourceforge.net/projects/fixedptc/ :) It will probably be "good enough."

I'll ask on the lists if the graphics mode is actually implemented on amd64 or is it theoretical.

#9 Re: Text mode

Added on 2010-11-11T21:04 by Antony Mawer

One of the annoyances with graphics mode (at least seemed to be some years back) was the limitation of 320x200, or jumping to VESA for higher resolutions. A 640x480x16 with a VGA palette would be sufficient in many cases but I'm not sure how well supported that is (at least I never managed to get this to work with splash(4), screen savers might be a different story) -- and whether or not that would work on amd64 or not as well?

#10 Re: Text mode

Added on 2010-11-29T21:32 by kace

The colored snake is great. And, I think a text-based, colored, dashboard-type screen saver is well worth pursuing, too. Forget pie charts, bar charts are just as good. Pie charts make me hungry.

Post your comment here!

Your name:
Comment title:
Text:
Type "xxx" here:

Comments are subject to moderation and will be deleted if deemed inappropriate. All content is © Ivan Voras. Comments are owned by their authors... who agree to basically surrender all rights by publishing them here :)