Monitor HAProxy in Linux via Check-MK

centos, linux
$ sudo grep -v "#" /etc/haproxy/haproxy.cfg | grep "stats socket"
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
$ cd /usr/lib/check_mk_agent/plugins/
$ cat mk_haproxy.linux
if [ -f /var/run/haproxy.pid ]; then
echo "<<>>"
echo "show stat" | socat - UNIX-CONNECT:/run/haproxy/admin.sock
fi
$ chmod +x mk_haproxy.linux

Explanation

  1. Get the location of configured sock for HAProxy from /etc/haproxy/haproxy.cfg
    $ sudo grep -v "#" /etc/haproxy/haproxy.cfg | grep "stats socket"
  2. Get to check-mk plugin directory and write a file named mk_haproxy.linux with above content then save
    $ cd /usr/lib/check_mk_agent/plugins/; vi mk_haproxy.linux
  3. Change permission so it can be executed
    $ chmod +x mk_haproxy.linux
  4. Try to discover the new service in check-mk

Disable Vim Auto Visual Mode

centos

If you’re diving into the world of Vim on Linux, getting the hang of its different modes is crucial. One of these modes, Visual Mode, is handy for selecting and editing text.

But for many users, it can be a bit tricky and unnecessaries. And this is how you may disable it.


Few option to get your classical selecting text with mouse while in vim:

Option A

  1. :set mouse-=a
  2. If want to re-enable do, :set mouse=a
  3. Update your .vimrc with set mouse-=a to make any changes permanent.

Option B

  1. Hold shift while selecting with mouse

Configure New timezone Permanently in bash

centos

In the realm of Linux server administration, managing time settings is a critical aspect that directly impacts system synchronization and overall functionality.

Whether you’re a seasoned Ubuntu administrator or a novice looking to enhance your server configuration skills, this guide is tailored to help you efficiently and effectively set up and maintain the desired timezone on your Ubuntu server.

Configuration

$ timedatectl list-timezones
output omitted...
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Kuwait
Asia/Macau
output omitted...
$ sudo timedatectl set-timezone Asia/Kuala_Lumpur

Explanation

  1. list-timezones is to list all supported time zone by timedatectl
  2. set-timezone Asia/Kuala_Lumpur is to make your system to follow Kuala Lumpur’s timezone

X11 forwarding after sudo

centos
$ xauth list
<hostname>/unix:0 MIT-MAGIC-COOKIE-1 1fb2c048e3a32a3fe013c565b8422727
<hostname>/unix:12 MIT-MAGIC-COOKIE-1 29b9ba4a72136095e43540119c8da384
<hostname>/unix:11 MIT-MAGIC-COOKIE-1 99b08ccb7e8a76e75c70d7c75723505d
<hostname>/unix:10 MIT-MAGIC-COOKIE-1 b2ea07f58365b8672bea7497ffacee4f

Then execute, change user as root with sudo -i and execute xauth add followed by one entry from above output that having the highest number.

$ sudo -i
# xauth add <hostname>/unix:12 MIT-MAGIC-COOKIE-1 29b9ba4a72136095e43540119c8da384

Explanation

  1. xauth list being executed before sudoing to root to output the xauth authorization hex key
  2. after sudo as root, xauth add to add the authorization hex key from non-root into root

Installing X11 for X11 forwarding

centos
$ sudo yum install -y xorg-x11-server-common
$ sudo yum install -y  xorg-x11-xauth

Then logout, login from your shell and execute your X windows application.

Explanation

  1. xorg-x11-server-common is needed for every common file needed in x11
  2. xorg-x11-xauth is needed for X11 authorization utilities