Date: Mon, 07 Nov 2016 18:59:48 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-ports-bugs@FreeBSD.org Subject: [Bug 214297] [patch] net-mgmt/nagios-check_cpu_usage: Sometimes fails to parse vmstat output Message-ID: <bug-214297-13@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D214297 Bug ID: 214297 Summary: [patch] net-mgmt/nagios-check_cpu_usage: Sometimes fails to parse vmstat output Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Keywords: patch Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: freebsd-ports-bugs@FreeBSD.org Reporter: vidar@karlsen.tech Keywords: patch Created attachment 176748 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D176748&action= =3Dedit Change vmstat to iostat nagios-check_cpu_usage reads output from vmstat in order to report CPU usag= e. vmstat will output straight numbers (not "easily human readable form") when= the output is not a terminal. On a busy host, this may cause the fre and flt columns to be jammed together with no separating whitespace, which in turn will cause nagios-check_cpu_us= age to return bogus values due to a sort of off-by-one error: Not busy: r b w avm fre flt re pi po fr sr in sy cs us sy id 0 0 3 762140 490772 693 0 0 0 863 4 70 833 366 1 0 99 ^^^^^^ ^^^ Busy (just testing running make in security/openssl): r b w avm fre flt re pi po fr sr in sy cs us sy id 1 0 3 865856 48101239575 0 121 0 43154 8 72 40026 1357 21 5 74 ^^^^^^^^^^^ nagios-check_cpu_usage reads the 15th, 16th and 17th column, so in the latt= er case it will report us=3D"5", sy=3D"74", id=3D"". I propose changing the following line: cpu_all=3D$( vmstat -c 2 -n 0 | tail -n 1 | awk '{print $15 " " $16 " " $17= }' ) to: cpu_all=3D$( iostat -c 2 -t proc | tail -n 1 | awk '{print $3 " " $5 " " $7= }' ) or to: cpu_all=3D$( vmstat -h -c 2 -n 0 | tail -n 1 | awk '{print $15 " " $16 " " = $17}' ) iostat doesn't appear to have this problem because it outputs much fewer columns, while the second alternative solution bypasses the problem by forc= ing vmstat to print the memory values as 1M instead of 1048576. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-214297-13>