Fixing Lack of Free Swap Space Error on Zabbix Server 4.2

Published: 15 June 2019
on channel: SBCODE
9,611
76

Zabbix 5 Course : https://sbcode.net/zabbix/

My Zabbix server is reporting a lack of free swap space. It probably means that the system requires more physical memory.
My server only has 1GB of RAM, but if I create a 2GB swap file, Zabbix Server will think it has 2GBs of RAM.
When creating a swap file, create it twice the size of your available RAM.

The commands.
---------------------------------
Check if I have a swap already
$ sudo swapon -s

Double checked using free
$ free -m

List available disks to see which I want to use for the new swap
$ df -h

Choose my disk, then allocate 2gb to a new file called swapfile
$ sudo fallocate -l 2G /swapfile

Verify it now exists
$ ls -lh /swapfile

Adjust permissions so only root can use it
$ sudo chmod 600 /swapfile

Verify changes again
$ ls -lh /swapfile

Convert it to a real swapfile
$ sudo mkswap /swapfile

Turn it on
$ sudo swapon /swapfile

Checked it's usage
$ sudo swapon -s

Checked it using free
$ free -m

Now make it permanent in case of reboot
$ sudo nano /etc/fstab

Add line below to fstab
/swapfile none swap sw 0 0

Press Ctrl X, then Y to overwrite, then enter to save.

Go back to Zabbix-Server and you will see that the problem has been fixed.

Thanks for watching, remember to like, comment, subscribe and share,