Marc G. Fournier wrote:
> On Tue, 8 Aug 2006, Matthew Seaman wrote:
> 
>> Marc G. Fournier wrote:
>>> On Mon, 7 Aug 2006, Matthew Seaman wrote:
>>>
>>>> I think it would help uptake if when the bsdstats job is first run, it
>>>> issues you with a 'registered system number' -- then all of the folks
>>>> with low numbered systems get bragging rights...
>>>
>>> Actually, there is no "registered system number", as there is no
>>> "registration process" ... that was the key requirement for doing this,
>>> was that it was as "hands off" as possible, and having to go to a web
>>> site to register each and every host was just too onerous of a task ...
>>
>> Yeah.  You've leapt on the word 'register' there, and not addressed the
>> salient point.  'Register' as in 'become cognisant of', and distinguished
>> from 'signed up to.'  Even though the process is simplified and
>> automatic,
>> you're still registering systems.
>>
>> Having some sort of return from the central stats machine when the
>> periodic
>> script runs, (rather than nothing at all, as at the moment) would be a
>> good
>> idea.  Giving each system an index number shouldn't cost too much.
> 
> But, there is no such ting as an 'index number' ... when everyone
> reports in next month, for instance, there is no 'number' that will be
> re-used for them that matches something used this month ...

You use the hostname as the identifying key for the data that's sent to you.
Presumably you've got to add that hostname to a table somewhere, so that
re-running the 300.statistics script doesn't spam the database with multiples
of the same set of data.  i.e. it's the key to a unique index.  Suggests that
row number in that table of host names is your unique index number...

Anyhow, how about the following little enhancement.  This lists the CPUs on the
system pretending they are CPU0, CPU1, ... devices.  The URI escape stuff should
be automatically decoded by PHP without any extra coding required.

        Cheers,

        Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       7 Priory Courtyard
                                                      Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey         Ramsgate
                                                      Kent, CT11 9PW
--- /usr/ports/sysutils/bsdstats/files/300.statistics   Tue Aug  8 09:21:34 2006
+++ 300.statistics      Tue Aug  8 19:30:08 2006
@@ -14,25 +14,57 @@
 oldmask=$(umask)
 umask 066
 
+# RFC 2396
+uri_escape () {
+    echo [EMAIL PROTECTED] | sed -e '
+        s/%/%25/g
+        s/;/%3b/g
+        s,/,%2f,g
+        s/?/%3f/g
+        s/:/%3a/g
+        s/@/%40/g
+        s/&/%26/g
+        s/=/%3d/g
+        s/+/%2b/g
+        s/\$/%24/g
+        s/,/%2c/g
+        s/ /%20/g
+        '
+}
+
+do_fetch () {
+    /usr/bin/fetch -qo /dev/null "http://bsdstats.hub.org/scripts/$1";
+}
+
 case "$monthly_statistics_enable" in
     [Yy][Ee][Ss])
       HN=`/bin/hostname`
       SYS=`/usr/bin/uname -r`
       ARCH=`/usr/bin/uname -m`
       OS=`/usr/bin/uname -s`
-      /usr/bin/fetch -qo /dev/null 
http://bsdstats.hub.org/scripts/getid.php?hn=$HN\&sys=$SYS\&arch=$ARCH\&opsys=$OS
+      do_fetch getid.php?hn=$HN\&sys=$SYS\&arch=$ARCH\&opsys=$OS
       case "$monthly_statistics_report_devices" in
          [Yy][Ee][Ss])
 IFS="
 "
            
-            /usr/bin/fetch -qo /dev/null 
http://bsdstats.hub.org/scripts/clear_devices.php?hn=$HN
+            do_fetch clear_devices.php?hn=$HN
             for line in `/usr/sbin/pciconf -l | /usr/bin/grep -v none`
             do
                 DRIVER=`echo $line | awk -F\@ '{print $1}'`
                 VEN=`echo $line | awk '{print $4}' | cut -c12-15`
                 DEV=`echo $line | awk '{print $4}' | cut -c8-11`
-                /usr/bin/fetch -qo /dev/null 
http://bsdstats.hub.org/scripts/report_device.php?driver=$DRIVER\&vendor=$VEN\&device=$DEV\&hn=$HN
+                do_fetch 
report_device.php?driver=$DRIVER\&vendor=$VEN\&device=$DEV\&hn=$HN
+            done
+            line=$( sysctl -n hw.model )
+            VEN=$( echo $line | cut -d ' ' -f 1 )
+            DEV=$( uri_escape $( echo $line | cut -d ' ' -f 2- ) )
+            n=0
+            count=$( sysctl -n hw.ncpu )
+            while [ $n -lt $count ]
+            do
+                do_fetch 
report_device.php?driver=CPU$n\&vendor=$VEN\&device=$DEV\&hn=$HN
+                n=$(( $n + 1 ))
             done
          ;;
          esac

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to