Linux – expand btrfs partition

To format existing partition to btrfs:

#mkfs.btrfs -L btrfs /dev/sda3 -f
btrfs-progs v4.19.1
See http://btrfs.wiki.kernel.org for more information.

Label:              btrfs
UUID:               9d900959-0054-42a4-b99b-ad8eff6b6490
Node size:          16384
Sector size:        4096
Filesystem size:    2.14TiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1     2.14TiB  /dev/sda3

check format of existing partitions:

# fsck -N /dev/sda3
fsck from util-linux 2.36.2
[/sbin/fsck.btrfs (1) -- /dev/sda3] fsck.btrfs /dev/sda3
# fsck -N /dev/sda2
fsck from util-linux 2.36.2
[/sbin/fsck.btrfs (1) -- /] fsck.btrfs /dev/sda2
# lsblk -f
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1 vfat   FAT32       72C7-9A85                               506M     1% /boot/efi
├─sda2 btrfs              515d42a1-b51b-4d8c-8268-9731fd1912e9  529.8M    95% /
├─sda3 btrfs        btrfs 9d900959-0054-42a4-b99b-ad8eff6b6490
└─sda4 swap   1           e64e50b3-47c8-45fe-8743-de8dcf512664                [SWAP]

Check existing brfs partition:

# btrfs device usage /
/dev/sda2, ID: 1
   Device size:            40.00GiB
   Device slack:              0.00B
   Data,single:            37.94GiB
   Metadata,DUP:            2.00GiB
   System,DUP:             64.00MiB
   Unallocated:             1.00MiB

Add sda3 to existing btrfs partition:

# btrfs device add /dev/sda3 /
/dev/sda3 appears to contain an existing filesystem (btrfs).
ERROR: use the -f option to force overwrite of /dev/sda3
# btrfs device add /dev/sda3 / -f
# btrfs device usage /
/dev/sda2, ID: 1
   Device size:            40.00GiB
   Device slack:              0.00B
   Data,single:            37.94GiB
   Metadata,DUP:            2.00GiB
   System,DUP:             64.00MiB
   Unallocated:             1.00MiB

/dev/sda3, ID: 2
   Device size:             2.14TiB
   Device slack:              0.00B
   Unallocated:             2.14TiB

Job Done

Reference:

https://www.man7.org/linux/man-pages/man8/mkfs.btrfs.8.html

https://linuxhint.com/resize_a_btrfs_filesystem/

Nagios – monitor interSeptor Temperature and Humidity

Jakarta interSeptor is a server room grade temperature and humidity monitoring device that offers SNMP access:
https://www.jacarta.com/interseptor/

To manually check your temp and humidity run:
temperature:
/usr/local/nagios/libexec/check_snmp -H _interSeptor_IP_ -C _Community_String_ -o .1.3.6.1.4.1.19011.1.3.1.1.3.2.1.3.1
humidity
/usr/local/nagios/libexec//check_snmp -H _interSeptor_IP_ -C _Community_String_ -o .1.3.6.1.4.1.19011.1.3.1.1.3.2.1.5.1

the output will look like this:
SNMP OK – 207 | iso.3.6.1.4.1.19011.1.3.1.1.3.2.1.3.1=207

Please note that all temperature and humidity values are multiplied by ten when retrieved.
Therefore the returned values should be divided by ten once retrieved to attain the actual
reading.

To deal with that problem in the: /usr/local/nagios/libexec/ folder create check_interSeptor.sh file then paste this:

#!/bin/bash
# $1 - hostname
# $2 - SNMP community string
# $3 - oid
# $4 - Header
# temp oid =.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.3.1
# humidity oid = .1.3.6.1.4.1.19011.1.3.1.1.3.2.1.5.1
# oid details: https://www.jacarta.com/wp-content/uploads/interSeptor-Alarm-OIDs.pdf

snmp=$(/usr/local/nagios/libexec/check_snmp -H $1 -C $2 -o $3|cut -b 11-14)
var=$(echo "scale=2; $snmp/10" | bc )
output=$(echo "$4 - $var | $4=$var" )
echo $output

save the file and make it executable then test it:
/usr/local/nagios/libexec/check_interSeptopr.sh _interSeptor_IP_ _Community_String_ .1.3.6.1.4.1.19011.1.3.1.1.3.2.1.5.1 Humidity

Humidity – 42.20 | Humidity=42.20

Now back to Nagios:
in the commands.cfg define command:

define command {
    command_name    check_interSeptor
    command_line    $USER1$/check_interSeptopr.sh $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}

then define services:

define service{
        use                     generic-service
        host_name               interseptor
        service_description     Temperature
        check_command           check_interSeptor!BVFB2unUAX!.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.3.1!Temperature
        }

define service{
        use                     generic-service
        host_name               interseptor
        service_description     Humidity
        check_command           check_interSeptor!BVFB2unUAX!.1.3.6.1.4.1.19011.1.3.1.1.3.2.1.5.1!Humidity
        }

snmpd: error on subcontainer ‘ia_addr’ insert (-1)

On Debian 10 system – syslog is flooded with:

snmpd[6578]: error on subcontainer ‘ia_addr’ insert (-1)
snmpd[6578]: error on subcontainer ‘ia_addr’ insert (-1)
snmpd[6578]: error on subcontainer ‘ia_addr’ insert (-1)
This seems to be a bug and to fix it edit systemd unit file:

# cp /lib/systemd/system/snmpd.service /etc/systemd/system/snmpd.service
# sed -i "s|-Lsd|-LS6d|" /etc/systemd/system/snmpd.service
# systemctl daemon-reload
# systemctl restart snmpd

VMware – esxtop – troubleshooting VM CPU performance

To display VM only press V (VM only view):

then to expand specific VM press e (expand) then enter the GID number:

As this VM has 3 CPU I can see CPU usage on all of them, RDY, USED and CSTP times.

%RDY is a Key Performance Indicator!  This one defines how much time your virtual machine wanted to execute CPU cycles but could not get access to the physical CPU. It tells you how much time did you spend in a “queue”. I normally expect this value to be better than 5%. In this case we can see that this VM is struggling a bit or it is very busy.

%USED tells you how much time did the virtual machine spend executing CPU cycles on the physical CPU.

%CSTP tells you how much time a virtual machine is waiting for a virtual machine with multiple vCPU to catch up. If this number is higher than 3% you should consider lowering the amount of vCPU in your virtual machine.

Linux – Network Manager – change static IP via nmcli

1 . Display available network adapters

[root@HOST]# nmcli conn show
NAME UUID TYPE DEVICE
Wired connection 2 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ethernet ens192

2. Change the IP address, gateway and DNS:

[root@HOST]# nmcli connection modify 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.address 192.168.101.200/24
[root@HOST]# nmcli conn modify 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.gateway 192.168.101.254
[root@HOST]# nmcli conn mod 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.method manual
[root@HOST]# nmcli conn mod 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.dns 192.168.1.74
[root@HOST]# nmcli conn up 7d08ebcc-94a7-337f-9b74-edecb7cbfd37
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)