Fix pdns_rel to always have correct output

Fix the condition to not return any values when there were no queries to the server since the last call. Return a 0 as cache hit rate in that case.
This commit is contained in:
Wolf Vogel 2024-03-02 09:07:03 +01:00 committed by GitHub
parent 40a5f3f834
commit a477dd629e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -49,6 +49,8 @@ if [ -f "$state_file" ] && [ "$(stat --format=%Y "$state_file")" -gt "$(date --d
d_queries=$((queries - old_queries))
if [ $d_queries -gt 0 ] ; then
echo packetcache_hitrate.value $(( d_hits * 100 / d_queries ))
else
echo packetcache_hitrate.value 0
fi
fi