Syslog-ng & Pi day

Today is March 14th, or as many geeks refer to it: Pi day. On this occasion, I would like to show you a syslog-ng configuration, which prints a huge π on the screen, and two recent articles that feature syslog-ng on the Raspberry Pi.

Printing π

The following configuration – that I got from my colleagues – prints a huge π sign on screen. Create a new configuration, copy and paste the configuration below and save it on your host running syslog-ng with the name pi.conf:

@version: 3.31
@include "scl.conf"

template-function "pi-art" "

      3.141592653589793238462643383279
    5028841971693993751058209749445923
   07816406286208998628034825342117067
   9821    48086         5132
  823      06647        09384
 46        09550        58223
 17        25359        4081
           2848         1117
           4502         8410
           2701         9385
          21105        55964
          46229        48954
          9303         81964
          4288         10975
         66593         34461
        284756         48233
        78678          31652        71
       2019091         456485       66
      9234603           48610454326648
     2133936            0726024914127
     3724587             00660631558
     817488               152092096

";

block source pi-art(...) {

example-msg-generator(template("$(pi-art)") `__VARARGS__`);

};

log {
  source { pi-art(); };

   destination { file("/dev/stdout"); };
};

What happens in this configuration?

  • As usual, the syslog-ng configuration starts with a version number declaration. The current version is 3.31, but I also tested this config with syslog-ng version 3.26.

  • We include scl.conf (SCL is the syslog-ng configuration library). It contains many useful configuration snippets. None of them is used here, but we are too much used to including it :-)

  • We define a custom template function, called “pi-art” that shows a huge π sign.

  • The source block is also named “pi-art” and calls example-msg-generator() to print the π character once each second, using the previously defined template function.

  • Finally, the log statement connects the pi-art() source with the standard output (our screen).

How to test it? Start syslog-ng in the foreground with the freshly saved configuration:

syslog-ng -F -f pi.conf

syslog-ng on the Raspberry Pi

Recently, Pi day is not just about physics and mathematics (and eating pies), but also about the Raspberry Pi. Syslog-ng runs on these tiny machines and I contributed two articles to the Pi day article series on https://opensource.com/:

  • Containers became widely popular because of Docker on Linux, but there are much earlier implementations, including the jail system on FreeBSD. A container is called a `jail` in the FreeBSD terminology. The jail system was first released in FreeBSD 4.0, way back in 2000, and it has been continuously improved since then. While 20 years ago it was used mostly on large servers, now you can run it on your Raspberry Pi.
    From this article, you can learn the major differences between containers on Linux and FreeBSD, getting started with FreeBSD on the Raspberry Pi, and creating your first two containers using Bastille, a jail management application for FreeBSD: https://opensource.com/article/21/3/bastille-raspberry-pi

  • I have lived in 100-plus-year-old brick houses for most of my life. They look nice, they are comfortable, and usually, they are not too expensive. However, humidity is high in winter in my climate, and mold is a recurring problem. A desktop thermometer that displays relative humidity is useful for measuring it, but it does not provide continuous monitoring.
    In comes the Raspberry Pi: it is small, inexpensive, and has many sensor options, including temperature and relative humidity. It can collect data around the clock, do some alerting, and forward data for analysis.
    From this article, you can learn not just about how to forward sensor data from your Raspberry Pi to Elasticsearch using syslog-ng, but also how relative humidity is changing when opening the windows for shorter or longer periods of time: https://opensource.com/article/21/3/sensor-data-raspberry-pi

If you have questions or comments related to syslog-ng, do not hesitate to contact us. You can reach us by email or even chat with us. For a list of possibilities, check our GitHub page under the “Community” section at https://github.com/syslog-ng/syslog-ng. On Twitter, I am available as @Pczanik.


Anonymous
Related Content