Test haproxy 1.8 seamless reload

10 01 2018

How to test the seamless reload option in Haproxy 1.8.

Add into the configuration file under global section the following line:
stats socket /var/run/haproxy.sock level admin expose-fd listeners process 1

Create a reload loop for the service:
# while true ; do systemctl reload haproxy ; sleep 3 ; done

Send request while service is reloading:
# ab -r -c 20 -n 100000 http://127.0.0.1/

Check that the report doesn’t cotains any “Failed requests”.

More info:
https://bugs.launchpad.net/ubuntu/+source/haproxy/+bug/1712925

Advertisements




Python script who generates threads

5 01 2018

#!/usr/bin/env python3
import time
from threading import Thread
num_threads = 100
sleep_secs= 60
def create_thread(i):
print "Sleeping "+ str(sleep_secs) +" secs - Thread %d \n" % i
time.sleep(sleep_secs)
for i in range(num_threads):
t = Thread(target=create_thread, args=(i,))
t.start()
print "End"

View threads in top pressing “H”
View threads in ps with “-T”





Upgrade FreeBSD – /usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory

30 12 2017

Preparing to download files... done.
/usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory
/usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory
/usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory
/usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory

Solution tested on 11.0 to 11.1, but it can work in any other:

1.- Empty “/var/db/freebsd-update/”.

2.- Edit the following line in “/etc/freebsd-update.conf”:
# Components src world kernel
Components src

3.- Execute “freebsd-update -r 11.1-RELEASE upgrade” and “freebsd-update install”.

4.- Edit the following line in “/etc/freebsd-update.conf”:
# Components src world kernel
Components kernel

5.- Execute “freebsd-update -r 11.1-RELEASE upgrade”, “freebsd-update install”, “reboot” and “freebsd-update install”.

6.- Edit the following line in “/etc/freebsd-update.conf”:
# Components src world kernel
Components world

7.- Execute “freebsd-update fetch”, “freebsd-update install” and “cd /usr/src && mergemaster -Ui”.

8.- Edit the following line in “/etc/freebsd-update.conf”:
Components src world kernel
9.- Execute “freebsd-update fetch”, “freebsd-update install” and “reboot”.

10.- Upgraded!

More info:
https://forums.freebsd.org/threads/36851/





Fix random hangs in Debian 9 with Nouveau Nvidia graphic module

7 12 2017

With and old Nvidia graphic card, like GeForce 6150SE nForce 430, and a new Debian with the latest Nouveau module, it is common to get hangs of the kernel produced by a bad beaviour of the graphic driver.

To mitigate it, add to the file “/etc/default/grub” the following content:

GRUB_CMDLINE_LINUX="nouveau.noaccel=1"





Increase filesystem without lvm in VMWare

4 12 2017

This method allow to increase a filesystem without using lvm, a simple virtual disk assigned to a virtual machine. It works if it is the root partition too. It doesn’t require reboot.

Note: Only works if the filesystem partition to grow is the last partition of the disk:

0.- Make a clone of the virtual machine for backup.

1.- Resize virtual disk in VMWare.

2.- Inside the vm, check the scsi connected devices:
# ls /sys/class/scsi_device/
0:0:0:0 2:0:0:0

3.- Force a reescan:
# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
# echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan

4.- Move the GTP backup partition table to the real end of the resized disk:
# gdisk /dev/sda
Command (? for help):
x
Command (? for help):
e
Relocating backup data structures to the end of the disk
Expert command (? for help):
w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N):
Y

5.- Notify the partition change:
# partprobe

6.- Delete the target partition and recreate it using the new extra espace. This is only to define the new end of the partition:
# gdisk /dev/sda
Command (? for help):
d
Partition number (1-3):
3
Command (? for help):
n
Partition number (3-128, default 3):
[ENTER]
First sector (34-73400286, default = 2222080) or {+-}size{KMGTP}:
[ENTER]
Last sector (2222080-73400286, default = 73400286) or {+-}size{KMGTP}:
[ENTER]
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
[ENTER]
Changed type of partition to 'Linux filesystem'
Command (? for help):
w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N):
Y

7.- Notify the partition change:
# partprobe

8.- Finally, grow the filesystem:
# resize2fs /dev/sda3





Basic go setup in Debian

30 11 2017

Install go package:
# apt-get install golang

Create dir for go workspace, so it can install packages and related stuff. Usually it goes in the home dir, but it would be ok elsewhere.
# mkdir ~/go

Set up the env variables. The GOROOT variable points to the location the Go tools are installed – if you didn’t install them to a custom location, you don’t have to set this manually:
# export GOPATH=$HOME/go
# export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# source ~/.bashrc

Finally, install whatever you want. It would make the bin inside ~/go:
# go get github.com/neezgee/apache_exporter





Systemd unit for Monyog

15 11 2017

Systemd unit for Monyog. Create a new file in “/etc/systemd/system/monyog.service” with the following content:

[Unit]
Description=Webyog MONyog Service
After=network.target
[Service]
SyslogIdentifier=monyog
LimitNOFILE=262144
ExecStart=/usr/local/bin/MONyog-bin
Restart=on-failure
[Install]
WantedBy=multi-user.target