Human readable numbers in syslog-ng

virág

Writing an extra zero at the wrong place in a configuration file can result in a filled-up partition and data loss. This is where human readable numbers in syslog-ng can help: using kilo / mega / giga instead of writing many-digit numbers can save you lots of debugging and headache.

As the manual writes: “Starting with syslog-ng OSE version 3.5, you can use suffixes for kilo-, mega-, and gigabytes. Use the Kb, Mb, or Gb suffixes for the base-10 version, and Kib, Mib, or Gib for the base-2 version. That is, 2MB means 2000000, while 2MiB means 2097152.”

Here is an example, a network destination using disk-based buffering. Let’s say that you have a 5GB partition and you want to put a 2GB buffer file on it. If you accidentally add an extra zero at the end of the number – 10 vs 11 digits – then during a longer outage on a busy server, you easily fill up the partition. Using the GB suffix, you can avoid this problem:

destination d_network {
      network(
        "172.16.167.132"
        transport("tcp")
        port(514)
        disk-buffer(
          mem-buf-length(10000)
          disk-buf-size(2GB)
          reliable(no)
          dir("/tmp/disk-buffer")
        )
      );
};

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

Anonymous