This is a simple tool (and munin plugin) to measure HDD latency with high accuracy.
Features:
- Direct I/O to bypass any caching (only on Linux (?))
- clock_gettime(CLOCK_MONOTONIC, ...) for nano-second accuracy (depending on platform)
- munin compatible output
- no external dependencies
Pretty simple stuff:
- The tool sets up and aligns a hardcoded 1MB buffer
- measures the current timestamp as described by
clock_gettime(CLOCK_MONOTONIC, ...)
- creates & opens a file for direct I/O
- writes the buffer & closes the file
- creates a second timestamp and displays the difference between the two (the elapsed time)
ioping.c
offers minimal configuration using the #define's at the beginning of the file.
#define NUM_IOPING_RUNS 3 // number of times ioping writes to disk, results will be averaged
#define SLEEP_BETWEEN_RUNS 1 // in seconds
#define PING_PATH "/var/tmp/test.ping" // file path to write to
Using /tmp
for PING_PATH
is discouraged since some servers mount a ramdisk/tmpfs on that path.
I personally use CMake but you are free to use your own build system or directly invoke gcc:
mkdir build
cmake ..
make
# run with:
./ioping
Simply drop the binary in your plugins directory and restart munin-node:
cp -v ioping /etc/munin/plugins/
systemctl restart munin-node