pt-stak error parsing df with NFS

Reported by Jervin R on 2012-10-27
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Percona Toolkit
High
Daniel Nichter

Bug Description

[root@util01 percona]# pt-stalk --version
pt-stalk 2.1.5

[root@util01 percona]# mount | grep stor
xx.xxx.xxx.xx:/ on /mnt/stor01 type nfs4 (rw,soft,intr,rsize=32768,wsize=32768,proto=tcp,addr=xx.xxx.xxx.xx,clientaddr=xx.xxx.xxx.xx)

[root@util01 percona]# pt-stalk --collect --no-stalk --dest=/mnt/stor01/revin
2012_10_26_23_39_03 Starting /opt/percona/toolkit/bin/pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=0 --interval=0 --iterations=1 --run-time=30 --sleep=0 --dest=/mnt/stor01/revin --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=/var/run/pt-stalk.pid
2012_10_26_23_39_03 Not stalking; collect triggered immediately
2012_10_26_23_39_03 Collect triggered
/opt/percona/toolkit/bin/pt-stalk: line 559: 100 - : syntax error: operand expected (error token is "- ")

This is because the current perl based pattern matching will not match the results on the *-disk-space file based on the leading hostname.

On pt-stalk:

    556 local used_bytes=$(perl -ane 'm!^/! && print $F[2] * 1024' "$file")
    557 local free_bytes=$(perl -ane 'm!^/! && print $F[3] * 1024' "$file")
    558 local pct_used=$(perl -ane 'm!^/! && print ($F[4] =~ m/(\d+)/)' "$file")
    559 local pct_free=$((100 - $pct_used))

Sample disk-space:

[root@util01 percona]# cat /mnt/stor01/revin/2012_10_26_23_27_25-disk-space
Filesystem 1024-blocks Used Available Capacity Mounted on
xx.xxx.xxx.xxx:/ 1918433376 1052659424 768323200 58% /mnt/stor01

Maybe something like this could work since the contents of disk-space is deterministic, though Im not sure if this will work in all cases.

555,558c555,557
<
< local used_bytes=$(perl -ane 'm!^/! && print $F[2] * 1024' "$file")
< local free_bytes=$(perl -ane 'm!^/! && print $F[3] * 1024' "$file")
< local pct_used=$(perl -ane 'm!^/! && print ($F[4] =~ m/(\d+)/)' "$file")
---
> local used_bytes=$(cat "$file"|tail -n1|awk '{print $2}')
> local free_bytes=$(cat "$file"|tail -n1|awk '{print $3}')
> local pct_used=$(cat "$file"|tail -n1|awk '{print $4}')

Jervin R (revin) on 2012-10-27
description: updated
tags: added: crash nfs pt-stalk
Changed in percona-toolkit:
status: New → Triaged
summary: - pt-stak bails out when checking disk space free for NFS based
- destination
+ pt-stak error parsing df with NFS
Changed in percona-toolkit:
milestone: none → 2.2.6
assignee: nobody → Daniel Nichter (daniel-nichter)
importance: Undecided → High
status: Triaged → In Progress
tags: added: percona-36390
Daniel Nichter (daniel-nichter) wrote :

Iirc, we can't use awk to print potentially very large numbers because on 32-bit systems such numbers don't fit in a single 4-byte integer; that's why we use Perl. I could be mistaken (maybe the problem was elsewhere), but in any case, I have made a similar patch.

Changed in percona-toolkit:
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers