Logrotate not being executed.

linux, ubuntu

I’ve encountered a machine that its log being accumulate for few months and not being rotated, even syslog.

After making comparison with other machine that getting log rotated, all configuration, file ownership and permission is the same.

If we force the logrotate by $ sudo logrotate /etc/logrotate.conf -f, it being rotate just fine.

Going thorough the syslog showing alot of error message like

cron[877]: Authentication token is no longer valid; new one required"

Google it up and it show, that it is because my root password is expired.

Check your root password, with $ sudo chage -l root

And change the password with $ sudo passwd root

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

Raspbian: Fallback to predefined IP if DHCP failed

linux, networking, raspbian

Bellow configuration taken from /etc/dhcpcd.conf file may look fine, but no. It is not.

# define static profile
profile static_eth0
static ip_address=169.254.65.72
static routers=169.254.65.72
static domain_name_servers=169.254.65.72

# fallback to static profile on eth0
interface eth0
fallback static_eth0

It is not because we assigned an Automatic Private IP address. Means, this range normally was used by the OS to assign IP whenever its connected to network, but DHCP service is not available.

Change the IP to something else from class A or class C.

Find MAC Address from virsh

linux, virtualization

In the intricate world of Linux virtualization, obtaining accurate network information is paramount for effective management and troubleshooting.. As virtualization continues to be a cornerstone in modern computing, understanding how to retrieve MAC addresses through Virsh becomes crucial for system administrators and Linux enthusiasts alike. This guide delves into the intricacies of leveraging Virsh commands to efficiently find MAC addresses, providing a comprehensive resource for those seeking to enhance their proficiency in Linux virtualization environments.

<br />
virsh list --all | tail -n+3 | head -n -1 | \<br />
awk '{print $2}' | \<br />
while read i; do \<br />
sudo virsh dumpxml $i | grep -e "<name>\|<mac address"; \<br />
done<br />

Explanation

virsh list --all | tail -n+3 | head -n -1 | \

  • to list all VM from virsh by removing 3 lines at top and 1 line at bottom of output

awk '{print $2}' | \

  • to print 2nd ‘word’ (separated by space by default) from previous output

while read i; do \<br />
sudo virsh dumpxml $i | grep -e "<name>\|<mac address"; \<br />
done

  • to go through output, line by line, and selectively print VM name and MAC Address

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