Looks good Andrea.  Go for it!

I think this is the beginning of a very cool feature set.

With regard to determining the image size, I have also contemplated the
idea of having the server do that immediately post-retrieval (while DET
stuff is still in cache), and storing it somewhere like
/etc/systemimager/IMAGE_SIZE in the image.

What do you think?

-Brian


Andrea Righi wrote:

> Hi all,
>
> this patch is a first little step to the development of a method to
> monitor the clients installation process.
>
> The reports follow this simple protocol:
>
> - a monitor server is defined using the parameter MONITOR_URL;
> - at the beginning of the autoinstallscript if the $MONITOR_URL
> variable is defined we send some infos to this url (using wget); in
> the monitor server there will be a dynamic web page that will parse
> the variables passed by wget and will store them to a DB, file, or
> something like that;
> - before the image syncronization we evaluate the disk space (parsing
> df output) and the image size (using rsync);
> - then a report task is spawned; this task periodically evaluates the
> disk space and determines the percentage of image copied in this way:
>
> (CURRENT_DISK_SIZE - INITIAL_DISK_SIZE) / IMAGE_SIZE
>
> - at the end of the image syncronization a special code (i.e. 0) is
> send to the monitor server (always using wget) to report the
> successfully ending of the syncronization
> - if something goes wrong another special error code (i.e. -1) is
> reported to the monitor server (with a wget command inside the
> shellout routine)
>
> For now that's all... I'll wait to test it better before continue the
> development..
> Obviusly this protocol can be improved by reporting not only the image
> syncronization status, but also, for example, the pre-install status
> (partitioning, etc.) or post-install status (post-install scripts,
> systemconfigurator, etc).
> Moreover we can define a set of error codes to pass to the shellout
> routine; in this way we could communicate to the monitor server the
> particular error that happened during a client installation (i.e. I/O
> error, out of disk space, disk not found, etc.).
>
> Any ideas, feedbacks, suggestions, etc. are welcome...
>
> Regards,
> -Andrea
>
>------------------------------------------------------------------------
>
>diff -urN --exclude CVS systemimager/etc/autoinstallscript.template 
>systemimager-monitor/etc/autoinstallscript.template
>--- systemimager/etc/autoinstallscript.template        2005-02-15 
>18:14:54.000000000 +0100
>+++ systemimager-monitor/etc/autoinstallscript.template        2005-02-15 
>20:26:18.000000000 +0100
>@@ -31,6 +31,25 @@
> ##SET_IMAGENAME##
> ##SET_OVERRIDES##
> 
>+# Get initial information to send to the monitor server.
>+if [ ! -z $MONITOR_URL ]; then
>+    mac=`ifconfig $DEVICE | sed -ne "s/.*HWaddr //p" | sed "s/ //g"`
>+    cpu=`cat /proc/cpuinfo | grep "model name" | sed "s/.*: //"`\ -\ `cat 
>/proc/cpuinfo | grep "cpu MHz" | sed "s/.*: //"`MHz
>+    mem=`cat /proc/meminfo | sed -ne "s/MemTotal: *//p" | sed "s/ kB//"`
>+    
>+    elapsed=`expr $(cat /proc/uptime | sed "s/\..*//") / 60`
>+    wget -qq -O /dev/null ${MONITOR_URL}?\
>+mac=`echo $mac | sed "s/:/%3a/g"`\&\
>+action=start\&\
>+ip=$IPADDRESS\&\
>+netmask=$NETMASK\&\
>+eth=$DEVICE\&\
>+cpu=`echo $cpu | sed "s/ /%20/g"`\&\
>+mem=$mem\&\
>+elapsed=$elapsed
>+
>+fi
>+
> ### BEGIN Check to be sure this not run from a working machine ###
> # Test for mounted SCSI or IDE disks
> mount | grep [hs]d[a-z][1-9] > /dev/null 2>&1
>@@ -138,6 +157,9 @@
>         echo "Quietly installing image... "
>         start_spinner
>     fi
>+    if [ ! -z $MONITOR_URL ]; then
>+        start_monitor_task
>+    fi
>     if [ "${TMPFS_STAGING}" = "yes" ]; then 
> 
>         # Deposit image into tmpfs
>@@ -170,6 +192,9 @@
> # Leave notice of which image is installed on the client
> echo $IMAGENAME > /a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout
> 
>+if [ ! -z $MONITOR_URL ]; then
>+    stop_monitor_task 0
>+fi
> 
> ### BEGIN generate new fstab file from autoinstallscript.conf ###
> ##GENERATE_FSTAB##
>diff -urN --exclude CVS systemimager/initrd_source/skel/etc/init.d/functions 
>systemimager-monitor/initrd_source/skel/etc/init.d/functions
>--- systemimager/initrd_source/skel/etc/init.d/functions       2005-02-09 
>18:25:09.000000000 +0100
>+++ systemimager-monitor/initrd_source/skel/etc/init.d/functions       
>2005-02-15 20:33:57.000000000 +0100
>@@ -218,6 +218,9 @@
> #   Usage: $COMMAND || shellout
> #
> shellout() {
>+    if [ ! -z $REPORT_PID ]; then
>+        stop_report_task -1
>+    fi
>     COUNT="$RETRY"
>     echo "Killing off running processes."
>     kill -9 $TMPFS_WATCHER_PID  >/dev/null 2>/dev/null
>@@ -1237,6 +1240,71 @@
> #
> ################################################################################
> #
>+#   Report installation status to the monitor server
>+#
>+
>+start_report_task() {
>+    # Evaluate image size.
>+    IMAGESIZE=`rsync -av $IMAGESERVER::$IMAGENAME | grep "total size" | sed 
>-e "s/total size is \([0-9]*\).*/\1/"`
>+    IMAGESIZE=`expr $IMAGESIZE / 1024`
>+
>+    # Evaluate disks size.
>+    TOT=0; LIST=`df 2>/dev/null | sed -ne "/^\/dev/p" | sed "s/  */ /g" | cut 
>-d' ' -f3`
>+    for size in $LIST; do
>+        TOT=`expr $TOT + $size`
>+    done
>+    DISKSIZE=$TOT
>+
>+    # MAC address is the primary key to identify a client -AR-
>+    mac=`ifconfig $DEVICE | sed -ne "s/.*HWaddr //p" | sed "s/ //g"`
>+    
>+    # Spawn the report task -AR-
>+    {
>+    while :; do
>+        TOT=0; LIST=`df 2>/dev/null | sed -ne "/^\/dev/p" | sed "s/  */ /g" | 
>cut -d' ' -f3`
>+        for size in $LIST; do
>+            TOT=`expr $TOT + $size`
>+        done
>+        status=`echo "($TOT - $DISKSIZE) * 100 / $IMAGESIZE" | bc`
>+        if [ $status -eq 0 ]; then 
>+            status=1
>+        fi
>+
>+        # Send status to the monitor server -AR-
>+        elapsed=`expr $(cat /proc/uptime | sed "s/\..*//") / 60`
>+        wget -qq -O /dev/null ${MONITOR_URL}?\
>+action=refresh\&\
>+mac=`echo $mac | sed "s/:/%3a/g"`\&\
>+elapsed=$elapsed\&\
>+status=$status
>+        
>+        # Wait 30 sec between each report -AR-
>+        sleep 30
>+    done
>+    }&
>+    REPORT_PID=$!
>+}
>+#
>+################################################################################
>+#
>+#   Stop to report installation status to the monitor server
>+#
>+
>+stop_report_task() {
>+    status=$1
>+    kill -9 $REPORT_PID
>+
>+    # Try to report the error to the monitor server.
>+    elapsed=`expr $(cat /proc/uptime | sed "s/\..*//") / 60`
>+    wget -qq -O /dev/null ${MONITOR_URL}?\
>+mac=`echo $mac | sed "s/:/%3a/g"`\&\
>+action=stop\&\
>+status=$status\&\
>+elapsed=$elapsed
>+}
>+#
>+################################################################################
>+#
> #   Beep incessantly
> #
> beep_incessantly() {
>  
>

-- 
------------------------------------------------------
 Brian Elliott Finley           Mobile:  630.631.6621
 gpg --keyserver wwwkeys.pgp.net --recv-keys 10F8EE52
------------------------------------------------------



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Sisuite-devel mailing list
Sisuite-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sisuite-devel

Reply via email to