Posts

List all available versions for a go module

Use the command: go list -m -versions module For e.g.: go list -m -versions  github.com/prometheus/common github.com/prometheus/common v0.1.0 v0.2.0 v0.3.0 v0.4.0 v0.4.1 v0.5.0 v0.6.0 v0.7.0 v0.8.0 v0.9.0 v0.9.1 v0.10.0 v0.11.0 v0.11.1 v0.12.0 v0.13.0 v0.14.0 v0.15.0 v0.16.0 v0.17.0 v0.18.0 v0.19.0 v0.20.0 v0.21.0 v0.22.0 v0.23.0 v0.24.0 v0.25.0 v0.26.0 v0.27.0 v0.28.0 v0.29.0 v0.30.0 v0.30.1 v0.31.0 v0.31.1 v0.32.0 v0.32.1 v0.33.0 v0.34.0 v0.35.0 v0.36.0 v0.37.0 More info here: https://go.dev/doc/modules/version-numbers

Access docker as a normal user from a docker running on a Windows WSL 2 Linux

Run the below command: sudo chmod o+rw /var/run/docker.sock This will enable non privileged users to run all docker commands, 

One liner command to get restart reason for a POD in Kubernetes

Run: kubectl describe pod -n <namespace> <Pod name> | grep -A2 -B2 Reason For e.g.: kubectl describe pod -n myns my-pod-6d9bdcfbfc-k9jqw | grep -A2 -B2 Reason

Get a self contained k8s config for usage in other tools(Use with caution)

Many a times we would like to view/manage the K8s cluster remotely using clients like Lens , k9s etc. I was searching for this information across, and found the below commands: # kubectl config view --flatten > k8s.cfg On the remote system, place the k8s.cfg file under: <user home dir>\.kube For e.g., on a Windows desktop for user abc, place it under: C:\Users\abc\.kube Note: You need to use this with caution as you can access complete K8s cluster with this data.

Merge multiple PDFs in Windows using Linux!!!

Docker on Windows is a boon to the developer community. Apart from the regular Linux based development I got a chance to use it today for something that I could not easily do directly on Windows (without a new third party software) I had to merge a number of PDFs to create a single PDF. Searching the Web gave me a number of options like online tools, ghostscript, pdftk etc. pdftk caught my attention as it was a perfect choice for my needs. But, I did not want to install it on my Windows desktop. I had docker desktop installed on my system. Hence I tried the following to achieve PDF merge: 1. Started a docker container with "ubuntu" image as follows: docker run --name ubuntu -d -it -v C:/temp:/var/mnt/pdf --entrypoint bash ubuntu -c tail -f /dev/null 2. Installed pdftk apt upgrade -y apt install pdftk -y 3. Executed pdftk to merge the pdfs. For e.g.: pdftk Aug2020.pdf Sep2020.pdf Oct2020.pdf Nov2020.pdf Dec2020.pdf Jan2021.pdf cat output  output.pdf 4. Now my merged pdf (out

How do I find the number of CPUs in C++11?

Below is the code snippet that helps to get the number CPUs in C++11: ------------------------------------------------------------------------------------------------------- // Get the number of parallel threads possible. Just an hint to create number of threads unsigned int n = std::thread::hardware_concurrency(); std::cout << n << " concurrent threads are supported.\n"; -------------------------------------------------------------------------------------------------------

Graylog - an easy solution for log management

Image
Recently, I was researching for opensource log management tools. I had only two requirements. Log Search and Log analytics. A lot of posts in the internet suggested me to use an ELK stack. But, I wanted to do something different. I found graylog as an alternative to ELK. One can setup and run it in minutes. It uses mongodb, elastic search and graylog server. Here is the login page: grylog provides different options to stream logs into graylog server. I used the simple UDP listener and forwarded logs from multiple devices into this listener. Next step is to create dashboards using the search. Here is the search page: Once search is done, you can add the widgets to a dashboard. The dashboard will help you to get the summary of your devices at one shot. It is also possible to generate alerts on different conditions. More here: https://www.graylog.org/