Some customers are looking for an effective way to be notified when free disk space in the OS partitions is getting short without the need of implementing a third-party agent but using instead out-of-the-box OS and Gateway tools.
API Gateway 10.x
In some cases, patches, backup files, MySQL bin-logs can fill the disk partitions causing a shortage of free space.
When a partition reaches 100% of usage, it can lead to unfortunate consequences where the Gateway is unable to operate or a data loss may be experienced.
Out of the box, the Operating System and Gateway can help regarding this.
An idea is to use a simple script to be executed via cronjob (for example daily or hourly) which calls an ad-hoc API published in the Gateway if the disk space exceeds a defined threshold.
Then the API will send an email to a recipient or an alert to an external Syslog server.
Below is an example of a basic script:
#!/bin/bash
CURRENT=$(df /var/lib/mysql | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=80
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
curl -v -k https://localhost:8443/mail
fi
In this example, the script executes the OS command "df /var/lib/mysql" (path can be changed to monitor a different partition) and retrieve the percentage of disk usage.
Then compares the disk usage percentage with the threshold defined in the 3rd line of the script (in this example 80%) and if the value exceeds the threshold, the script will call a crafted Gateway API (in this example called /mail) .
In the API policy logic, we can then use for instance a Send Mail assertion to notify a designated recipient that the disk usage is over the threshold.
The script and the Policy Logic can be further implemented to meet additional requirements.