Operations 3 min read

Extending Zabbix Monitoring with Custom Scripts and Handling Stale NFS Handles

This article explains how Zabbix monitoring can be extended with custom shell or Python scripts to gather business-specific metrics, demonstrates a sample script that checks disk usage, and provides three methods to resolve a stale NFS file handle error, including using fuser, process inspection, and forced unmount.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Extending Zabbix Monitoring with Custom Scripts and Handling Stale NFS Handles

Zabbix monitoring supports custom scripts and self‑made templates to extend its capabilities, allowing you to monitor business‑specific metrics by writing scripts in shell, Python, or other languages.

Below is an example of a debug‑run shell script that checks disk usage and evaluates a threshold:

[root@mha ~]# sh -x watch_disk.sh
++ df -k
++ grep centos-root
++ awk '{print $4}'
df: ‘/NFS’: Stale file handle
+ Disk=320455292
+ [ 320455292 -le 83886080 ]
+ echo 1
1

The script captures the output of df -k, filters the relevant line, extracts the free space column, and compares it against a predefined limit. In this run the NFS mount returned a “Stale file handle” error, causing the script to treat the free space as a large value.

To resolve the stale NFS handle, three approaches are suggested:

Kill the processes using the mount point: fuser -k /NFS Search for processes holding the directory:

ps -ef | awk '{print $2}' | grep -v PID | xargs /usr/proc/bin/pwdx

Force unmount the NFS share: umount -f /NFS The article concludes with a list of recommended reading links covering topics such as Kubernetes deployment, Ansible roles, and other DevOps practices.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringOperationsNFSZabbixCustom Script
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.