Bug 229347 - sysutils/bsdstats: Device reporting broken
Summary: sysutils/bsdstats: Device reporting broken
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-26 15:51 UTC by scrappy
Modified: 2019-09-01 09:06 UTC (History)
2 users (show)

See Also:
yuri: maintainer-feedback+


Attachments
svn-diff-bsdstats (1.19 KB, patch)
2019-08-04 04:12 UTC, Walter Schwarzenfeld
no flags Details | Diff
patch as attachment instead of cut-n-paste (1.39 KB, patch)
2019-09-01 09:06 UTC, scrappy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description scrappy 2018-06-26 15:51:10 UTC
Incorrect usage of a for loop instead of while causes the query_string to be mis-generated, causing device reports to be unparseable on the server end ... following patch needs to be applied to fix ...

===
*** /tmp/300.statistics	Mon Jun 25 04:17:01 2018
--- /usr/local/etc/periodic/monthly/300.statistics	Mon Jun 25 04:28:00 2018
***************
*** 354,365 ****
     FreeBSD|DragonFly)
       local query_string=""
       local line
!       for line in $(${PCICONF} -l); do
         local DRIVER=$(echo "${line}" | ${AWK} -F\@ '{print $1}')
         local DEV=$(echo "${line}" | ${AWK} '{print $4}' | ${CUT} -c8-15)
         local CLASS=$(echo "${line}" | ${AWK} '{print $2}' | ${CUT} -c9-14)
         query_string=$query_string`echo \&dev[]=${DRIVER}:${DEV}:${CLASS}`
!       done

       echo_begin "Posting device statistics to ${checkin_server_description}"
       do_http_request_check_status "GET" "/scripts/report_devices.php?token=${TOKEN}&key=${KEY}$query_string" \
--- 354,368 ----
     FreeBSD|DragonFly)
       local query_string=""
       local line
!       while read line
!       do
         local DRIVER=$(echo "${line}" | ${AWK} -F\@ '{print $1}')
         local DEV=$(echo "${line}" | ${AWK} '{print $4}' | ${CUT} -c8-15)
         local CLASS=$(echo "${line}" | ${AWK} '{print $2}' | ${CUT} -c9-14)
         query_string=$query_string`echo \&dev[]=${DRIVER}:${DEV}:${CLASS}`
!       done << EOT
! $(${PCICONF} -l)
! EOT

       echo_begin "Posting device statistics to ${checkin_server_description}"
       do_http_request_check_status "GET" "/scripts/report_devices.php?token=${TOKEN}&key=${KEY}$query_string" \
===
Comment 1 Walter Schwarzenfeld freebsd_triage 2019-08-03 07:58:29 UTC
Maintainer feedback, please!
Comment 2 Yuri Victorovich freebsd_committer 2019-08-03 08:47:33 UTC
Patches are welcome. -)

But I think that bsdstats has never worked well in a sense that its stats are based on a very small dataset and aren't too meaningful. Not enough people have it installed.
Comment 3 Yuri Victorovich freebsd_committer 2019-08-04 03:59:06 UTC
OP: Please attach a patch and I will consider it.
Comment 4 Walter Schwarzenfeld freebsd_triage 2019-08-04 04:12:41 UTC
Created attachment 206262 [details]
svn-diff-bsdstats

I take it from comment1. Not tested.
Comment 5 Walter Schwarzenfeld freebsd_triage 2019-08-04 04:23:37 UTC
Comment on attachment 206262 [details]
svn-diff-bsdstats

Uups, there is a error in.
Comment 6 Walter Schwarzenfeld freebsd_triage 2019-08-04 05:58:30 UTC
(In reply to scrappy from comment #0)
Does not work ->
"Syntax error: end of file unexpected (expecting ";;")"

EOT is problematic.
Comment 7 scrappy 2019-09-01 09:06:20 UTC
Created attachment 207059 [details]
patch as attachment instead of cut-n-paste

I just tested patch here again, to make sure, and it seems to work fine ... sample code:

==
#!/bin/sh -
#

# Standard commands used here
#
PCICONF=/usr/sbin/pciconf
AWK=/usr/bin/awk
CUT=/usr/bin/cut

       while read line
       do
         DRIVER=$(echo "${line}" | ${AWK} -F\@ '{print $1}')
         DEV=$(echo "${line}" | ${AWK} '{print $4}' | ${CUT} -c8-15)
         CLASS=$(echo "${line}" | ${AWK} '{print $2}' | ${CUT} -c9-14)
         query_string=$query_string`echo \&dev[]=${DRIVER}:${DEV}:${CLASS}`
       done << EOT
$(${PCICONF} -l)
EOT

echo $query_string
==

Output is as expected:

==
&dev[]=none0:2f818086:088000&dev[]=none1:2f368086:110100&dev[]=none2:2f378086:110100
==

Tested on:

==
FreeBSD 11.3-PRERELEASE #14 r349760: Fri Jul  5 08:58:00 UTC 2019
==

I've attached ( vs cut-n-paste ) a diff -c on the changeg ... maybe something didn'tcome through properly in my original ...