Manual disk cleanup

No matter how large a hard drive is, the space on it is finite, and if you don’t take action in advance, sooner or later it will run out. The worst thing that can happen after this is the inability of the system to work or the loss of the oldest data stored in the system.

Note

To prevent this situation, plan in advance the required hard drive size, based on the number of client machines, what exactly is collected on them and the length of data storage.

Illustration 1 — Manual disk cleanup

In the administrative panel you can set the settings auto cleaning.

You can also perform disk cleanup manually. To do this:

  1. Stop the ibatyr server with the command:

sudo service ibatyr stop
  1. Check available disk space:

df -h
  1. Delete log entries

sudo rm /var/log/*gz
  1. Remove old iBatyr Monitor databases:

4.1 Open the compact script file, which is part of iBatyr Monitor:

sudo nano /usr/share/ibatyr/bin/compact

4.2 In the opened file, uncomment the lines echo “Vacuum database” and sudo -u postgres psql ibatyr -c “vacuum full”. The final file will look like this:

#!/bin/bash
# USE compact
# HELP Cleanup unreffered dimensions and vaccum database
ibatyr stop
echo "Cleanup dimensions"
cat sql/cleanup_dimensions.sql| bin/sql
echo "Vacuum database"
sudo -u postgres psql ibatyr -c "vacuum full"
ibatyr start
echo "Cleanup done"
bin/info

4.3 Save changes.

4.4 Clear old records in the database:

sudo ibatyr cleanup X

here X is the number of days for which data should be left.

4.5 Run the script:

ibatyr compact

Note

The optimal reserve to ensure efficient operation of the database cleaning mechanism is the availability of free disk space (15% of the size of the current database).

If the disk is full to capacity, there may be problems with removal. In this case, there is a workaround that allows you to clean up the disk.

sudo tune2fs -m 0 /dev/sdX

This command allows you to free up part of the disk reserved for system needs. After this, you need to follow the cleaning sequence described above. Next, you need to return the superuser’s disk space reserve. To do this, run the following command:

sudo tune2fs -m 5 /dev/sdX

If this command is not executed, then if the settings are incorrect, there is a possibility that the entire hard drive will be occupied, including 5% of the superuser.

Note

Be sure to return the 5% reserve, 5% reserve is generally accepted standard practice.

After cleaning the disk, you need to run ibatyr again with the command

sudo service ibatyr start