diff --git a/plugins/pdns/pdns_errors b/plugins/pdns/pdns_errors index 589d0c3a..c84373c0 100755 --- a/plugins/pdns/pdns_errors +++ b/plugins/pdns/pdns_errors @@ -43,4 +43,4 @@ if [ "$1" = "config" ]; then fi -$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep corrupt'\|'servfail'\|'timedout | sed 's/-/_/g' +$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | egrep "corrupt|servfail|timedout" | sed 's/-/_/g' diff --git a/plugins/pdns/pdns_queries b/plugins/pdns/pdns_queries index 87cf44e2..617d9cc7 100755 --- a/plugins/pdns/pdns_queries +++ b/plugins/pdns/pdns_queries @@ -55,4 +55,4 @@ if [ "$1" = "config" ]; then fi -$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep udp-'\|'recursing'\|'tcp | sed 's/-/_/g' +$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | egrep "udp-|recursing|tcp" | sed 's/-/_/g' diff --git a/plugins/pdns/pdns_rel b/plugins/pdns/pdns_rel index 3eee007d..586a0e51 100755 --- a/plugins/pdns/pdns_rel +++ b/plugins/pdns/pdns_rel @@ -38,18 +38,18 @@ fi hits=$($command packetcache-hit) queries=$($command udp-queries) -if [ -f $state_file ]; then - old_hits=$(cat $state_file | head -n1) - old_queries=$(cat $state_file | tail -n1) +if [ -f "$state_file" ]; then + old_hits=$(head -n1 "$state_file") + old_queries=$(tail -n1 "$state_file") fi -if [ -f $state_file ] && [ $(ls -l --time-style=+%s $state_file | awk '{print $6}') -gt $(date --date="7 minutes ago" +%s) ] ; then - d_hits=$(($hits - $old_hits)) - d_queries=$(($queries - $old_queries)) +if [ -f "$state_file" ] && [ "$(stat --format=%Y "$state_file")" -gt "$(date --date="7 minutes ago" +%s)" ] ; then + d_hits=$((hits - old_hits)) + d_queries=$((queries - old_queries)) if [ $d_queries -gt 0 ] ; then - echo packetcache_hitrate.value $(( $d_hits * 100 / $d_queries )) + echo packetcache_hitrate.value $(( d_hits * 100 / d_queries )) fi fi -echo $hits > $state_file -echo $queries >> $state_file +echo "$hits" > "$state_file" +echo "$queries" >> "$state_file"