diff options
Diffstat (limited to 'content/html/gemfeed/atom.xml')
| m--------- | content/html | 6 | ||||
| -rw-r--r-- | content/html/gemfeed/atom.xml | 2517 |
2 files changed, 6 insertions, 2517 deletions
diff --git a/content/html b/content/html new file mode 160000 +Subproject 27ed46c9129db86669052d4e7211340da1081d8 diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml deleted file mode 100644 index 7f97acd0..00000000 --- a/content/html/gemfeed/atom.xml +++ /dev/null @@ -1,2517 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2021-05-18T21:32:49+01:00</updated> - <title>buetow.org feed</title> - <subtitle>Having fun with computers!</subtitle> - <link href="https://buetow.org/gemfeed/atom.xml" rel="self" /> - <link href="https://buetow.org/" /> - <id>https://buetow.org/</id> - <entry> - <title>Personal Bash coding style guide</title> - <link href="https://buetow.org/gemfeed/2021-05-16-personal-bash-coding-style-guide.html" /> - <id>https://buetow.org/gemfeed/2021-05-16-personal-bash-coding-style-guide.html</id> - <updated>2021-05-16T14:51:57+01:00</updated> - <author> - <name>Paul Buetow</name> - <email>comments@mx.buetow.org</email> - </author> - <summary>Lately, I have been polishing and writing a lot of Bash code. Not that I never wrote a lot of Bash, but now as I also looked through the 'Google Shell Style Guide' I thought it is time to also write my own thoughts on that. I agree to that guide in most, but not in all points. . .....to read on please visit my site.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1>Personal Bash coding style guide</h1> -<pre> - .---------------------------. - /,--..---..---..---..---..--. `. - //___||___||___||___||___||___\_| - [j__ ######################## [_| - \============================| - .==| |"""||"""||"""||"""| |"""|| -/======"---""---""---""---"=| =|| -|____ []* ____ | ==|| -// \\ // \\ |===|| hjw -"\__/"---------------"\__/"-+---+' -</pre> -<p class="quote"><i>Written by Paul Buetow 2021-05-16</i></p> -<p>Lately, I have been polishing and writing a lot of Bash code. Not that I never wrote a lot of Bash, but now as I also looked through the "Google Shell Style Guide" I thought it is time to also write my own thoughts on that. I agree to that guide in most, but not in all points. </p> -<a class="textlink" href="https://google.github.io/styleguide/shellguide.html">Google Shell Style Guide</a><br /> -<h2>My modifications</h2> -<p>These are my personal modifications of the Google Guide.</p> -<h3>Shebang</h3> -<p>Google recommends using always</p> -<pre> -#!/bin/bash -</pre> -<p>as the shebang line. But that does not really work on all Unix and Unix like operating systems (e.g. the *BSDs don't have Bash installed to /bin/bash). Better is:</p> -<pre> -#!/usr/bin/env bash -</pre> -<h3>2 space soft-tabs indentation</h3> -<p>I know there have been many tab- and soft-tab wars on this planet. Google recommends using 2 space soft-tabs for Bash scripts. </p> -<p>I personally don't really care if I use 2 or 4 space indentations. I agree however that tabs should not be used. I personally tend to use 4 space soft-tabs as that's currently how my Vim is configured for any programming language. What matters most though is consistency within the same script/project.</p> -<p>Google also recommends limiting the line length to 80 characters. For some people that seem's to be an ancient habit from the 80's, where all computer terminals couldn't display longer lines. But I think that the 80 character mark is still a good practice at least for shell scripts. For example, I am often writing code on a Microsoft Go Tablet PC (running Linux of course) and it comes in very handy if the lines are not too long due to the relatively small display on the device.</p> -<p>I hit the 80 character line length quicker with the 4 spaces than with 2 spaces, but that makes me refactor the Bash code more aggressively which is actually a good thing. </p> -<h3>Breaking long pipes</h3> -<p>Google recommends breaking up long pipes like this:</p> -<pre> -# All fits on one line -command1 | command2 - -# Long commands -command1 \ - | command2 \ - | command3 \ - | command4 -</pre> -<p>I think there is a better way like the following, which is less noisy. The pipe | already indicates the Bash that another command is expected, thus making the explicit line breaks with \ obsolete:</p> -<pre> -# Long commands -command1 | - command2 | - command3 | - command4 -</pre> -<h3>Quoting your variables</h3> -<p>Google recommends to always quote your variables. I think generally you should do that only for variables where you are unsure about the content/values of the variables (e.g. content is from an external input source and may contains whitespace or other special characters). In my opinion, the code will become quite noisy when you always quote your variables like this:</p> -<pre> -greet () { - local -r greeting="${1}" - local -r name="${2}" - echo "${greeting} ${name}!" -} -</pre> -<p>In this particular example I agree that you should quote them as you don't really know what is the input (are there for example whitespace characters?). But if you are sure that you are only using simple bare words then I think that the code looks much cleaner when you do this instead:</p> -<pre> -say_hello_to_paul () { - local -r greeting=Hello - local -r name=Paul - echo "$greeting $name!" -} -</pre> -<p>You see I also omitted the curly braces { } around the variables. I only use the curly braces around variables when it makes the code either easier/clearer to read or if it is necessary to use them:</p> -<pre> -declare FOO=bar -# Curly braces around FOO are necessary -echo "foo${FOO}baz" -</pre> -<p>A few more words on always quoting the variables: For the sake of consistency (and for the sake of making ShellCheck happy) I am not against quoting everything I encounter. I personally also think that the larger the Bash script becomes, the more important it becomes to always quote variables. That's because it will be more likely that you might not remember that some of the functions don't work on values with spaces in it for example. It's just that I won't quote everything in every small script I write. </p> -<h3>Prefer builtin commands over external commands</h3> -<p>Google recommends using the builtin commands over external available commands where possible:</p> -<pre> -# Prefer this: -addition=$(( X + Y )) -substitution="${string/#foo/bar}" - -# Instead of this: -addition="$(expr "${X}" + "${Y}")" -substitution="$(echo "${string}" | sed -e 's/^foo/bar/')" -</pre> -<p>I don't agree fully here. The external commands (especially sed) are much more sophisticated and powerful than the Bash builtin versions. Sed can do much more than the Bash can ever do natively when it comes to text manipulation (the name "sed" stands for streaming editor after all).</p> -<p>I prefer to do light text processing with the Bash builtins and more complicated text processing with external programs such as sed, grep, awk, cut and tr. There is however also the case of medium-light text processing where I would want to use external programs too. That is so because I remember using them better than the Bash builtins. The Bash can get quite obscure here (even Perl will be more readable then - Side note: I love Perl).</p> -<p>Also, you would like to use an external command for floating-point calculation (e.g. bc) instead using the Bash builtins (worth noticing that ZSH supports builtin floating-points).</p> -<p>I even didn't get started what you can do with Awk (especially GNU Awk), a fully fledged programming language. Tiny Awk snippets tend to be used quite often in Shell scripts without honouring the real power of Awk. But if you did everything in Perl or Awk or another scripting language, then it wouldn't be a Bash script anymore, wouldn't it? ;-)</p> -<h2>My additions</h2> -<h3>Use of 'yes' and 'no'</h3> -<p>Bash does not support a boolean type. I tend to just use the strings 'yes' and 'no' here. For some time I used 0 for false and 1 for true, but I think that the yes/no strings are easier to read. Yes, the Bash script would need to perform string comparisons on every check, but if performance is important to you, you wouldn't want to use a Bash script anyway, correct?</p> -<pre> -declare -r SUGAR_FREE=yes -declare -r I_NEED_THE_BUZZ=no - -buy_soda () { - local -r sugar_free=$1 - - if [[ $sugar_free == yes ]]; then - echo 'Diet Dr. Pepper' - else - echo 'Pepsi Coke' - fi -} - -buy_soda $I_NEED_THE_BUZZ -</pre> -<h3>Non-evil alternative to variable assignments via eval</h3> -<p>Google is in the opinion that eval should be avoided. I think so too. They list these examples in their guide:</p> -<pre> -# What does this set? -# Did it succeed? In part or whole? -eval $(set_my_variables) - -# What happens if one of the returned values has a space in it? -variable="$(eval some_function)" - -</pre> -<p>However, if I want to read variables from another file I don't have to use eval here. I just source the file:</p> -<pre> -% cat vars.source.sh -declare foo=bar -declare bar=baz -declare bay=foo - -% bash -c 'source vars.source.sh; echo $foo $bar $baz' -bar baz foo -</pre> -<p>And if I want to assign variables dynamically then I could just run an external script and source its output (This is how you could do metaprogramming in Bash without the use of eval - write code which produces code for immediate execution):</p> -<pre> -% cat vars.sh -#!/usr/bin/env bash -cat <<END -declare date="$(date)" -declare user=$USER -END - -% bash -c 'source <(./vars.sh); echo "Hello $user, it is $date"' -Hello paul, it is Sat 15 May 19:21:12 BST 2021 -</pre> -<p>The downside is that ShellCheck won't be able to follow the dynamic sourcing anymore.</p> -<h3>Prefer pipes over arrays for list processing</h3> -<p>When I do list processing in Bash, I prefer to use pipes. You can chain then through Bash functions as well which is pretty neat. Usually my list processing scripts are of a structure like this:</p> -<pre> -filter_lines () { - echo 'Start filtering lines in a fancy way!' >&2 - grep ... | sed .... -} - -process_lines () { - echo 'Start processing line by line!' >&2 - while read -r line; do - ... do something and produce a result... - echo "$result" - done -} - -# Do some post processing of the data -postprocess_lines () { - echo 'Start removing duplicates!' >&2 - sort -u -} - -genreate_report () { - echo 'My boss wants to have a report!' >&2 - tee outfile.txt - wc -l outfile.txt -} - -main () { - filter_lines | - process_lines | - postprocess_lines | - generate_report -} - -main -</pre> -<p>The stdout is always passed as a pipe to the next following stage. The stderr is used for info logging.</p> -<h3>Assign-then-shift</h3> -<p>I often refactor existing Bash code. That leads me to adding and removing function arguments quite often. It's quite repetitive work changing the $1, $2.... function argument numbers every time you change the order or add/remove possible arguments.</p> -<p>The solution is to use of the "assign-then-shift"-method, which goes like this: "local -r var1=$1; shift; local -r var2=$1; shift". The idea is that you only use "$1" to assign function arguments to named (better readable) local function variables. You will never have to bother about "$2" or above. That is very useful when you constantly refactor your code and remove or add function arguments. It's something what I picked up from a colleague (a pure Bash wizard) some time ago:</p> -<pre> -some_function () { - local -r param_foo="$1"; shift - local -r param_baz="$1"; shift - local -r param_bay="$1"; shift - ... -} -</pre> -<p>Want to add a param_baz? Just do this:</p> -<pre> -some_function () { - local -r param_foo="$1"; shift - local -r param_bar="$1"; shift - local -r param_baz="$1"; shift - local -r param_bay="$1"; shift - ... -} -</pre> -<p>Want to remove param_foo? Nothing easier than that:</p> -<pre> -some_function () { - local -r param_bar="$1"; shift - local -r param_baz="$1"; shift - local -r param_bay="$1"; shift - ... -} -</pre> -<p>As you can see I didn't need to change any other assignments within the function. Of course you would also need to change the function argument lists at every occasion where the function is invoked - you would do that within the same refactoring session.</p> -<h3>Paranoid mode</h3> -<p>I call this the paranoid mode. The Bash will stop executing when a command exists with a status not equal to 0:</p> -<pre> -set -e -grep -q foo <<< bar -echo Jo -</pre> -<p>Here 'Jo' will never be printed out as the grep didn't find any match. It's unrealistic for most scripts to purely run in paranoid mode so there must be a way to add exceptions. Critical Bash scripts of mine tend to look like this:</p> -<pre> -#!/usr/bin/env bash - -set -e - -some_function () { - .. some critical code - ... - - set +e - # Grep might fail, but that's OK now - grep .... - local -i ec=$? - set -e - - .. critical code continues ... - if [[ $ec -ne 0 ]]; then - ... - fi - ... -} -</pre> -<h2>Learned</h2> -<p>There are also a couple of things I've learned from Googles guide.</p> -<h3>Unintended lexicographical comparison.</h3> -<p>The following looks like valid Bash code:</p> -<pre> -if [[ "${my_var}" > 3 ]]; then - # True for 4, false for 22. - do_something -fi -</pre> -<p>... but is probably unintended lexicographical comparison. A correct way would be:</p> -<pre> -if (( my_var > 3 )); then - do_something -fi -</pre> -<p>or</p> -<pre> -if [[ "${my_var}" -gt 3 ]]; then - do_something -fi -</pre> -<h3>PIPESTATUS</h3> -<p>To be honest, I have never used the PIPESTATUS variable before. I knew that it's there, but I never bothered to fully understand it how it works until now.</p> -<p>The PIPESTATUS variable in Bash allows checking of the return code from all parts of a pipe. If it’s only necessary to check success or failure of the whole pipe, then the following is acceptable:</p> -<pre> -tar -cf - ./* | ( cd "${dir}" && tar -xf - ) -if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then - echo "Unable to tar files to ${dir}" >&2 -fi -</pre> -<p>However, as PIPESTATUS will be overwritten as soon as you do any other command, if you need to act differently on errors based on where it happened in the pipe, you’ll need to assign PIPESTATUS to another variable immediately after running the command (don’t forget that [ is a command and will wipe out PIPESTATUS).</p> -<pre> -tar -cf - ./* | ( cd "${DIR}" && tar -xf - ) -return_codes=( "${PIPESTATUS[@]}" ) -if (( return_codes[0] != 0 )); then - do_something -fi -if (( return_codes[1] != 0 )); then - do_something_else -fi -</pre> -<h2>Use common sense and BE CONSISTENT.</h2> -<p>The following 2 paragraphs are completely quoted from the Google guidelines. But they hit the hammer on the head:</p> -<p class="quote"><i>If you are editing code, take a few minutes to look at the code around you and determine its style. If they use spaces around their if clauses, you should, too. If their comments have little boxes of stars around them, make your comments have little boxes of stars around them too.</i></p> -<p class="quote"><i>The point of having style guidelines is to have a common vocabulary of coding so people can concentrate on what you are saying, rather than on how you are saying it. We present global style rules here so people know the vocabulary. But local style is also important. If code you add to a file looks drastically different from the existing code around it, the discontinuity throws readers out of their rhythm when they go to read it. Try to avoid this.</i></p> -<h2>Advanced Bash learning pro tip</h2> -<p>I also highly recommend having a read through the "Advanced Bash-Scripting Guide" (which is not from Google). I use it as the universal Bash reference and learn something new every time I have a look at it.</p> -<a class="textlink" href="https://tldp.org/LDP/abs/html/">Advanced Bash-Scripting Guide</a><br /> -<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> - </div> - </content> - </entry> - <entry> - <title>Welcome to the Geminispace</title> - <link href="https://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html" /> - <id>https://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html</id> - <updated>2021-04-24T19:28:41+01:00</updated> - <author> - <name>Paul Buetow</name> - <email>comments@mx.buetow.org</email> - </author> - <summary>Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1>Welcome to the Geminispace</h1> -<p class="quote"><i>Written by Paul Buetow 2021-04-24, last updated 2021-04-30, ASCII Art by Andy Hood</i></p> -<p>Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:</p> -<a class="textlink" href="https://buetow.org">https://buetow.org</a><br /> -<p>If you however still use HTTP then you are just surfing the fallback HTML version of this capsule. In that case I suggest reading on what this is all about :-).</p> -<pre> - - /\ - / \ - | | - |NASA| - | | - | | - | | - ' ` - |Gemini| - | | - |______| - '-`'-` . - / . \'\ . .' - ''( .'\.' ' .;' -'.;.;' ;'.;' ..;;' AsH - -</pre> -<h2>Motivation</h2> -<h3>My urge to revamp my personal website</h3> -<p>For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.</p> -<h3>My still great Laptop running hot</h3> -<p>Earlier this year (2021) I noticed that my almost 7 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website. </p> -<p>All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.</p> -<h2>Discovering the Gemini internet protocol</h2> -<p>Around the same time I discovered a relatively new more lightweight protocol named Gemini which does not support all these CPU intensive features like HTML, JavaScript and CSS do. Also, tracking and ads is not supported by the Gemini protocol.</p> -<p>The "downside" is that due to the limited capabilities of the Gemini protocol all sites look very old and spartan. But that is not really a downside, that is in fact a design choice people made. It is up to the client software how your capsule looks. For example, you could use a graphical client with nice font renderings and colors to improve the appearance. Or you could just use a very minimalistic command line black-and-white Gemini client. It's your (the user's) choice.</p> -<i>Screenshot Amfora Gemini terminal client surfing this site:</i><a href="https://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace/amfora-screenshot.png"><img alt="Screenshot Amfora Gemini terminal client surfing this site" title="Screenshot Amfora Gemini terminal client surfing this site" src="https://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace/amfora-screenshot.png" /></a><br /> -<p>Why is there a need for a new protocol? As the modern web is a superset of Gemini, can't we just use simple HTML 1.0? That's a good and valid question. It is not a technical problem but a human problem. We tend to abuse the features once they are available. You can be sure that things stay simple and efficient as long as you are using the Gemini protocol. On the other hand you can't force every website in the modern web to only create plain and simple looking HTML pages.</p> -<h2>My own Gemini capsule</h2> -<p>As it is very easy to set up and maintain your own Gemini capsule (Gemini server + content composed via the Gemtext markup language) I decided to create my own. What I really like about Gemini is that I can just use my favorite text editor and get typing. I don't need to worry about the style and design of the presence and I also don't have to test anything in ten different web browsers. I can only focus on the content! As a matter of fact, I am using the Vim editor + it's spellchecker + auto word completion functionality to write this. </p> -<h2>Advantages summarised</h2> -<ul> -<li>Supports an alternative to the modern bloated web</li> -<li>Easy to operate and easy to write content</li> -<li>No need to worry about various web browser compatibilities</li> -<li>It's the client's responsibility how the content is designed+presented</li> -<li>Lightweight (although not as lightweight as the Gopher protocol)</li> -<li>Supports privacy (no cookies, no request header fingerprinting, TLS encryption)</li> -<li>Fun to play with (it's a bit geeky yes, but a lot of fun!)</li> -</ul> -<h2>Dive into deep Gemini space</h2> -<p>Check out one of the following links for more information about Gemini. For example, you will find a FAQ which explains why the protocol is named "Gemini". Many Gemini capsules are dual hosted via Gemini and HTTP(S), so that people new to Gemini can sneak peek the content with a normal web browser. As a matter of fact, some people go as far as tri-hosting all their content via HTTP(S), Gemini and Gopher.</p> -<a class="textlink" href="https://gemini.circumlunar.space">https://gemini.circumlunar.space</a><br /> -<a class="textlink" href="https://gemini.circumlunar.space">https://gemini.circumlunar.space</a><br /> -<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> - </div> - </content> - </entry> - <entry> - <title>DTail - The distributed log tail program</title> - <link href="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html" /> - <id>https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html</id> - <updated>2021-04-22T19:28:41+01:00</updated> - <author> - <name>Paul Buetow</name> - <email>comments@mx.buetow.org</email> - </author> - <summary>This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1>DTail - The distributed log tail program</h1> -<p class="quote"><i>Written by Paul Buetow 2021-04-22, last updated 2021-04-26</i></p> -<i>DTail logo image:</i><a href="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/title.png"><img alt="DTail logo image" title="DTail logo image" src="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/title.png" /></a><br /> -<p>This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.</p> -<a class="textlink" href="https://medium.com/mimecast-engineering/dtail-the-distributed-log-tail-program-79b8087904bb">Original Mimecast Engineering Blog post at Medium</a><br /> -<p>Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.</p> -<p>At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.</p> -<p>Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.</p> -<p>Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.</p> -<h2>A Mimecast Pet Project</h2> -<p>DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:</p> -<a class="textlink" href="https://dtail.dev">https://dtail.dev</a><br /> -<p>Try it out — We would love any feedback. But first, read on…</p> -<h2>Differentiating from log management systems</h2> -<p>Why not just use a full-blown log management system? There are various Open-Source and commercial log management solutions available on the market you could choose from (e.g. the ELK stack). Most of them store the logs in a centralized location and are fairly complex to set up and operate. Possibly they are also pretty expensive to operate if you have to buy dedicated hardware (or pay fees to your cloud provider) and have to hire support staff for it.</p> -<p>DTail does not aim to replace any of the log management tools already available but is rather an additional tool crafted especially for ad-hoc debugging and troubleshooting purposes. DTail is cheap to operate as it does not require any dedicated hardware for log storage as it operates directly on the source of the logs. It means that there is a DTail server installed on all server boxes producing logs. This decentralized comes with the direct advantages that there is no introduced delay because the logs are not shipped to a central log storage device. The reduced complexity also makes it more robust against outages. You won’t be able to troubleshoot your distributed application very well if the log management infrastructure isn’t working either.</p> -<i>DTail sample session animated gif:</i><a href="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dtail.gif"><img alt="DTail sample session animated gif" title="DTail sample session animated gif" src="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dtail.gif" /></a><br /> -<p>As a downside, you won’t be able to access any logs with DTail when the server is down. Furthermore, a server can store logs only up to a certain capacity as disks will fill up. For the purpose of ad-hoc debugging, these are not typically issues. Usually, it’s the application you want to debug and not the server. And disk space is rarely an issue for bare metal and VM-based systems these days, with sufficient space for several weeks’ worth of log storage being available. DTail also supports reading compressed logs. The currently supported compression algorithms are gzip and zstd.</p> -<h2>Combining simplicity, security and efficiency</h2> -<p>DTail also has a client component that connects to multiple servers concurrently for log files (or any other text files).</p> -<p>The DTail client interacts with a DTail server on port TCP/2222 via SSH protocol and does not interact in any way with the system’s SSH server (e.g., OpenSSH Server) which might be running at port TCP/22 already. As a matter of fact, you don’t need a regular SSH server running for DTail at all. There is no support for interactive login shells at TCP/2222 either, as by design that port can only be used for text data streaming. The SSH protocol is used for the public/private key infrastructure and transport encryption only and DTail implements its own protocol on top of SSH for the features provided. There is no need to set up or buy any additional TLS certificates. The port 2222 can be easily reconfigured if you preferred to use a different one.</p> -<p>The DTail server, which is a single static binary, will not fork an external process. This means that all features are implemented in native Go code (exception: Linux ACL support is implemented in C, but it must be enabled explicitly on compile time) and therefore helping to make it robust, secure, efficient, and easy to deploy. A single client, running on a standard Laptop, can connect to thousands of servers concurrently while still maintaining a small resource footprint.</p> -<p>Recent log files are very likely still in the file system caches on the servers. Therefore, there tends to be a minimal I/O overhead involved.</p> -<h2>The DTail family of commands</h2> -<p>Following the UNIX philosophy, DTail includes multiple command-line commands each of them for a different purpose:</p> -<ul> -<li>dserver: The DTail server, the only binary required to be installed on the servers involved.</li> -<li>dtail: The distributed log tail client for following log files.</li> -<li>dcat: The distributed cat client for concatenating and displaying text files.</li> -<li>dgrep: The distributed grep client for searching text files for a regular expression pattern.</li> -<li>dmap: The distributed map-reduce client for aggregating stats from log files.</li> -</ul> -<i>DGrep sample session animated gif:</i><a href="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dgrep.gif"><img alt="DGrep sample session animated gif" title="DGrep sample session animated gif" src="https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dgrep.gif" /></a><br /> -<h2>Usage example</h2> -<p>The use of these commands is almost self-explanatory for a person already used to the standard command line in Unix systems. One of the main goals is to make DTail easy to use. A tool that is too complicated to use under high-pressure scenarios (e.g., during an incident) can be quite detrimental.</p> -<p>The basic idea is to start one of the clients from the command line and provide a list of servers to connect to with –servers. You also must provide a path of remote (log) files via –files. If you want to process multiple files per server, you could either provide a comma-separated list of file paths or make use of file system globbing (or a combination of both).</p> -<p>The following example would connect to all DTail servers listed in the serverlist.txt, follow all files with the ending .log and filter for lines containing the string error. You can specify any Go compatible regular expression. In this example we add the case-insensitive flag to the regex:</p> -<pre> -dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:error)’ -</pre> -<p>You usually want to specify a regular expression as a client argument. This will mean that responses are pre-filtered for all matching lines on the server-side and thus sending back only the relevant lines to the client. If your logs are growing very rapidly and the regex is not specific enough there might be the chance that your client is not fast enough to keep up processing all of the responses. This could be due to a network bottleneck or just as simple as a slow terminal emulator displaying the log lines on the client-side.</p> -<p>A green 100 in the client output before each log line received from the server always indicates that there were no such problems and 100% of all log lines could be displayed on your terminal (have a look at the animated Gifs in this post). If the percentage falls below 100 it means that some of the channels used by the servers to send data to the client are congested and lines were dropped. In this case, the color will change from green to red. The user then could decide to run the same query but with a more specific regex.</p> -<p>You could also provide a comma-separated list of servers as opposed to a text file. There are many more options you could use. The ones listed here are just the very basic ones. There are more instructions and usage examples on the GitHub page. Also, you can study even more of the available options via the –help switch (some real treasures might be hidden there).</p> -<h2>Fitting it in</h2> -<p>DTail integrates nicely into the user management of existing infrastructure. It follows normal system permissions and does not open new “holes” on the server which helps to keep security departments happy. The user would not have more or less file read permissions than he would have via a regular SSH login shell. There is a full SSH key, traditional UNIX permissions, and Linux ACL support. There is also a very low resource footprint involved. On average for tailing and searching log files less than 100MB RAM and less than a quarter of a CPU core per participating server are required. Complex map-reduce queries on big data sets will require more resources accordingly.</p> -<h2>Advanced features</h2> -<p>The features listed here are out of the scope of this blog post but are worthwhile to mention:</p> -<ul> -<li>Distributed map-reduce queries on stats provided in log files with dmap. dmap comes with its own SQL-like aggregation query language.</li> -<li>Stats streaming with continuous map-reduce queries. The difference to normal queries is that the stats are aggregated over a specified interval only on the newly written log lines. Thus, giving a de-facto live stat view for each interval.</li> -<li>Server-side scheduled queries on log files. The queries are configured in the DTail server configuration file and scheduled at certain time intervals. Results are written to CSV files. This is useful for generating daily stats from the log files without the need for an interactive client.</li> -<li>Server-side stats streaming with continuous map-reduce queries. This for example can be used to periodically generate stats from the logs at a configured interval, e.g., log error counts by the minute. These then can be sent to a time-series database (e.g., Graphite) and then plotted in a Grafana dashboard.</li> -<li>Support for custom extensions. E.g., for different server discovery methods (so you don’t have to rely on plain server lists) and log file formats (so that map-reduce queries can parse more stats from the logs).</li> -</ul> -<h2>For the future</h2> -<p>There are various features we want to see in the future.</p> -<ul> -<li>A spartan mode, not printing out any extra information but the raw remote log files would be a nice feature to have. This will make it easier to post-process the data produced by the DTail client with common UNIX tools. (To some degree this is possible already, just disable the ANSI terminal color output of the client with -noColors and pipe the output to another program).</li> -<li>Tempting would be implementing the dgoawk command, a distributed version of the AWK programming language purely implemented in Go, for advanced text data stream processing capabilities. There are 3rd party libraries available implementing AWK in pure Go which could be used.</li> -<li>A more complex change would be the support of federated queries. You can connect to thousands of servers from a single client running on a laptop. But does it scale to 100k of servers? Some of the servers could be used as middleware for connecting to even more servers.</li> -<li>Another aspect is to extend the documentation. Especially the advanced features such as map-reduce query language and how to configure the server-side queries currently do require more documentation. For now, you can read the code, sample config files or just ask the author for that! But this will be certainly addressed in the future.</li> -</ul> -<h2>Open Source</h2> -<p>Mimecast highly encourages you to have a look at DTail and submit an issue for any features you would like to see. Have you found a bug? Maybe you just have a question or comment? If you want to go a step further: We would also love to see pull requests for any features or improvements. Either way, if in doubt just contact us via the DTail GitHub page.</p> -<a class="textlink" href="https://dtail.dev">https://dtail.dev</a><br /> -<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> - </div> - </content> - </entry> - <entry> - <title>Realistic load testing with I/O Riot for Linux</title> - <link href="https://buetow.org/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html" /> - <id>https://buetow.org/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html</id> - <updated>2018-06-01T14:50:29+01:00</updated> - <author> - <name>Paul Buetow</name> - <email>comments@mx.buetow.org</email> - </author> - <summary>This text first was published in the german IT-Administrator computer Magazine. 3 years have passed since and I decided to publish it on my blog too. . .....to read on please visit my site.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1>Realistic load testing with I/O Riot for Linux</h1> -<pre> - .---. - / \ - \.@-@./ - /`\_/`\ - // _ \\ - | \ )|_ - /`\_`> <_/ \ -jgs\__/'---'\__/ -</pre> -<p class="quote"><i>Written by Paul Buetow 2018-06-01, last updated 2021-05-08</i></p> -<h2>Foreword</h2> -<p>This text first was published in the german IT-Administrator computer Magazine. 3 years have passed since and I decided to publish it on my blog too. </p> -<a class="textlink" href="https://www.admin-magazin.de/Das-Heft/2018/06/Realistische-Lasttests-mit-I-O-Riot">https://www.admin-magazin.de/Das-Heft/2018/06/Realistische-Lasttests-mit-I-O-Riot</a><br /> -<p>I havn't worked on I/O Riot for some time now, but all what is written here is still valid. I am still using I/O Riot to debug I/O issues and pattern once in a while, so by all means the tool is not obsolete yet. The tool even helped to resolve a major production incident at work caused by disk I/O.</p> -<p>I am eagerly looking forward to revamp I/O Riot so that it uses the new BPF Linux capabilities instead of plain old Systemtap (or alternatively: Newer versions of Systemtap can also use BPF as the backend I have learned). Also, when I wrote I/O Riot initially, I didn't have any experience with the Go programming language yet and therefore I wrote it in C. Once it gets revamped I might consider using Go instead of C as it would spare me from many segmentation faults and headaches during development ;-). I might also just stick to C for plain performance reasons and just refactor the code dealing with concurrency.</p> -<p>Pleace notice that some of the screenshots show the command "ioreplay" instead of "ioriot". That's because the name has changed after taking those.</p> -<h1>The article</h1> -<p>With I/O Riot IT administrators can load test and optimize the I/O subsystem of Linux-based operating systems. The tool makes it possible to record I/O patterns and replay them at a later time as often as desired. This means bottlenecks can be reproduced and eradicated. </p> -<p>When storing huge amounts of data, such as more than 200 billion archived emails at Mimecast, it's not only the available storage capacity that matters, but also the data throughput and latency. At the same time, operating costs must be kept as low as possible. The more systems involved, the more important it is to optimize the hardware, the operating system and the applications running on it.</p> -<h2>Background: Existing Techniques</h2> -<p>Conventional I/O benchmarking: Administrators usually use open source benchmarking tools like IOZone and bonnie++. Available database systems such as Redis and MySQL come with their own benchmarking tools. The common problem with these tools is that they work with prescribed artificial I/O patterns. Although this can test both sequential and randomized data access, the patterns do not correspond to what can be found on production systems.</p> -<p>Testing by load test environment: Another option is to use a separate load test environment in which, as far as possible, a production environment with all its dependencies is simulated. However, an environment consisting of many microservices is very complex. Microservices are usually managed by different teams, which means extra coordination effort for each load test. Another challenge is to generate the load as authentically as possible so that the patterns correspond to a productive environment. Such a load test environment can only handle as many requests as its weakest link can handle. For example, load generators send many read and write requests to a frontend microservice, whereby the frontend forwards the requests to a backend microservice responsible for storing the data. If the frontend service does not process the requests efficiently enough, the backend service is not well utilized in the first place. As a rule, all microservices are clustered across many servers, which makes everything even more complicated. Under all these conditions it is very difficult to test I/O of separate backend systems. Moreover, for many small and medium-sized companies, a separate load test environment would not be feasible for cost reasons.</p> -<p>Testing in the production environment: For these reasons, benchmarks are often carried out in the production environment. In order to derive value from this such tests are especially performed during peak hours when systems are under high load. However, testing on production systems is associated with risks and can lead to failure or loss of data without adequate protection.</p> -<h2>Benchmarking the Email Cloud at Mimecast</h2> -<p>For email archiving, Mimecast uses an internally developed microservice, which is operated directly on Linux-based storage systems. A storage cluster is divided into several replication volumes. Data is always replicated three times across two secure data centers. Customer data is automatically allocated to one or more volumes, depending on throughput, so that all volumes are automatically assigned the same load. Customer data is archived on conventional, but inexpensive hard disks with several terabytes of storage capacity each. I/O benchmarking proved difficult for all the reasons mentioned above. Furthermore, there are no ready-made tools for this purpose in the case of self-developed software. The service operates on many block devices simultaneously, which can make the RAID controller a bottleneck. None of the freely available benchmarking tools can test several block devices at the same time without extra effort. In addition, emails typically consist of many small files. Randomized access to many small files is particularly inefficient. In addition to many software adaptations, the hardware and operating system must also be optimized.</p> -<p>Mimecast encourages employees to be innovative and pursue their own ideas in the form of an internal competition, Pet Project. The goal of the pet project I/O Riot was to simplify OS and hardware level I/O benchmarking. The first prototype of I/O Riot was awarded an internal roadmap prize in the spring of 2017. A few months later, I/O Riot was used to reduce write latency in the storage clusters by about 50%. The improvement was first verified by I/O replay on a test system and then successively applied to all storage systems. I/O Riot was also used to resolve a production incident caused by disk I/O load.</p> -<h2>Using I/O Riot</h2> -<p>First, all I/O events are logged to a file on a production system with I/O Riot. It is t |
