Browsed by
Archives: Notes

Bash Environment Variable Functions

Bash Environment Variable Functions

A set of useful (Linux) Bash environment variable functions, taken / adapted, and added some information (not a plain copy) from blog post: https://hackaday.com/2022/01/26/linux-fu-bash-strings/ The examples below start with a $ if it is the command line, and without if it is the output (or input) of the command. Shell script command line arguments Numeric Substrings Remove leading or trailing parts Search / Replace Default values Changing case Bash built-in if tests Related external programs

Check SSL Certificate Expire From Command Line

Check SSL Certificate Expire From Command Line

If you want to check SSL Certificate expires from the Linux command line, you can do that like this: (Of course replace the www.kaper.com by the host you want to check). Here’s a full example run: If you want to see some more details (for example to get a copy of the public certificates), use: Don’t have openssl client? And you do not want to install it locally? You can also run it in docker: Note: you can use the…

Read More Read More

Curl Command To Measure DNS And Network Timing

Curl Command To Measure DNS And Network Timing

The curl command line tool has a reporting option which you can use to measure different bits of timing in the network handling. This can be useful to monitor or investigate network issues: Example output: You can also insert \n’s in the option to put the result on multiple lines:

ESP8266 Pins To Use

ESP8266 Pins To Use

Whenever you use an ESP8266 in a project, you have to choose which pin’s to use for what functions. Not all pin’s are equally suitable to use. Some have special functions, or require special handling during startup. This website: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ has an excellent list of pin names and functions, with a description of which ones to use or not to use. Here is a copy of their summary table. You should visit their site if you are interested in more…

Read More Read More

Finding docker container for overlay folder

Finding docker container for overlay folder

In folder’s /var/lib/docker/overlay2/* there is data stored per container. If for example your disk starts running out of space, and you find in the overlay2 folder which one is eating up the space, you might want to know for which docker container this was. I found some suggestions on stackoverflow on how to do that, and collected them here for my own reference:

Java/Kotlin Unit Testing – Test Stdout/Stderr/Logs

Java/Kotlin Unit Testing – Test Stdout/Stderr/Logs

Note: see also my old blog post if you want a more complex solution 😉 It targets at replacing the log appender. The below described method is simpler (nice!), it just listens in on ALL standard output+errors. Note: if you want a “Kotest” version, you can look at a great blog post by Tomas Zezula here: Streamlining Console Output Verification with Kotest When using spring-boot unit testing (library spring-boot-test-2.6.2.jar or newer), you can capture the output as send to the…

Read More Read More

Kind == Mini Kubernetes Cluster

Kind == Mini Kubernetes Cluster

If you need to run a local (mini) Kubernetes cluster for some simple tests, you can try “Kind”. In seems to runs inside a single docker image (so you need docker on your machine). See https://kind.sigs.k8s.io/docs/user/quick-start/ on how to install it. Example installation (GoLang example): If Kind was installed, you can use a simple cluster create command: Or create it like this (from Linux command line) if you need special settings -for example needed if you want to use kubectl…

Read More Read More

Kubernetes External Service

Kubernetes External Service

To make a local service in a Kubernetes cluster, which points to an address on a remote system, you can use the following yaml as example: This probably (will test this some time later) will also work if you want to move a service from “namespace-a” to “namespace-b”, and want to keep a reference inside “namespace-a” for other pods which depend on it:

Kubernetes Isolate Crashed Pod

Kubernetes Isolate Crashed Pod

See also full blog post: Kubernetes: Isolate Crashed Pod If you are running your pod (services / containers) on a Kubernetes cluster, and the pod runs into problems, you can decide to take it out of the load, but keep the pod running for further investigations. To park or isolate a pod: Find your pod name. Find the pod selector labels in use. Update one of the selector labels. Debug. Delete the broken pod. In summary; by changing one of…

Read More Read More

Kubernetes Simple Redirect In Ingress Rule

Kubernetes Simple Redirect In Ingress Rule

Suppose you are moving some sort of tool from one Kubernetes cluster to another one, then it would be nice for your users to get a redirect from the old URL to the new one (or at least for a while). You can achieve this by modifying your OLD ingress rule YML, by adding an annotation in it: Of course leave the rest of the old ingress rule in tact, to let it being triggered on the old URL. You…

Read More Read More

Linux Emergency Reset / Shutdown

Linux Emergency Reset / Shutdown

I was always convinced that a Linux server would not easily break down or get stuck. However, after running an on-premise Kubernetes cluster for a couple of years, on non-optimal kernels or with non-optimal OS-packages on it, I have seen some quite severe issues. In some cases, a machine started logging lot’s of kernel panics, and then became slow and only partially functioning. In that state, typing sudo reboot often did not work. It would just time out on it,…

Read More Read More

Linux Sync Buffer Progress Monitoring (e.g. For Copy To USB)

Linux Sync Buffer Progress Monitoring (e.g. For Copy To USB)

On my Linux system (Linux Mint), if I copy a huge file to an USB stick, then I always type “sync” in a shell command line to make sure all buffers are flushed to the USB stick before I eject the USB stick. This writing of the buffers can take quite a while (perhaps due to the huge amount of cache memory in the laptop). To monitor progress, you can type the following in a shell: It will show something…

Read More Read More

Lombok SonarQube Config

Lombok SonarQube Config

To skip code which is generated by Lombok in the SonarQube code checks, create a file “lombok.config” in your Java/Kotlin maven project, with these two lines in it: The addLombokGeneratedAnnotation setting does the trick…

Maven Version Plugin Automatic Updates

Maven Version Plugin Automatic Updates

Whenever you edit a Java/Kotlin maven project, you should see if you need to update any used libraries. For this purpose, I have a bash alias command which runs the next three statements in a row: The full alias line looks like this (in ~/.bash_aliased) Note: it seems the plug-in is not perfect 😉 Sometimes it does major updates, even if you ask it not to. So always carefully look at the changes which are made! The URL as used…

Read More Read More

Netty Cache Thread Memory Issues

Netty Cache Thread Memory Issues

When running spring-boot using netty (we ran: 4.1.69), and async code, your server might run into a memory issue after running for a while. In our case we were using spring-cloud-gateway (we ran: 3.0.5), and after two weeks of running, we started hitting long garbage collection times. To get around this, we did multiple code fixes, amongst one was disabling the thread-local caches for non-netty threads. To do this, add JVM option: For an explanation, see: https://github.com/spring-projects/spring-framework/issues/21174 Quote: The PooledByteBufAllocator…

Read More Read More

PostgreSQL Show/Stop Long Running Queries

PostgreSQL Show/Stop Long Running Queries

Sometimes when playing around with large PostgreSQL datasets in an SQL GUI, Grafana dashboards, or from any other tool, you might make a query mistake which makes the query run forever. This could eat up your database CPU or your max IOPs (in case of cloud services). You can find long running queries by executing the next command in an SQL GUI: To nicely ask all long running queries to be stopped, execute this: And if you want a forced…

Read More Read More

Running CTOP in Docker

Running CTOP in Docker

CTOP is a nice command line tool to look at running Docker containers. To prevent from having to install the ctop binary locally, and always have the latest version, I do run it inside docker. For easy execution, I created a (Linux) bash alias: Just add it to your .bashrc (or some other file you load when opening a new shell, like ~/.bash_aliases). From then on, you can just type ctop as command line command, and it will launch the…

Read More Read More