#!/bin/sh # # Example of generation of a file in ULS-value file format # # Path where the ULS-value file are placed. VDIR="/tmp/myprivateuls" mkdir $VDIR # Filename of the ULS-value file. # NOTE: it MUST have the extension '.uls' VFILE=$VDIR/uls_$$.uls echo "Write values to file: $VFILE" echo > $VFILE # ----- # Current date and time, that is the ULS timestamp DT=`date +"%Y-%m-%d %H:%M:%S"` # Take the hostname of the system # (Remember that hostname and ip-address must be known to ULS to accept values!) HOST=`uname -n` SECTION="My Section" TESTSTEP="first values" # ----- # Start time of the script T1=`date +"%Y-%m-%d %H:%M:%S"` # V;;;
;;;Start 2018-08-13 13:45:04;{T} echo "V;$DT;$HOST;$SECTION;$TESTSTEP;start-stop;Start $T1;{T}" >> $VFILE # ----- # a value # V;;;
;;;;[;] # Get some value V=`ls /tmp/ | wc -l` echo "V;$DT;$HOST;$SECTION;$TESTSTEP;file count;$V;#" >> $VFILE # ----- # Get the kernel release K=`uname -r` echo "E4:00;$DT;$HOST;$SECTION;$TESTSTEP;kernel release;$K; " >> $VFILE # SEND it every time, but SAVE it at the ULS-server only if # kernel release has changed or the last kernel release value # is older than 4 hours (E4:00;...). # ----- # Simulate an action echo "Pause for 5s" sleep 5 # ----- # a text expression # It may span several lines, so enclose it in double quotes. T=`ps -ef | fgrep sbin/init | grep -v grep` echo "V;$DT;$HOST;$SECTION;$TESTSTEP;init process;\"$T\"; " >> $VFILE # ' ' (blank) is the unit for normal text expressions # ----- # Script ends at T2=`date +"%Y-%m-%d %H:%M:%S"` # V;;;
;;;Stop 2018-08-13 13:45:04;{T} echo "V;$DT;$HOST;$SECTION;$TESTSTEP;start-stop;Stop $T2;{T}" >> $VFILE # ----- # flush_test_values is found in the ULS-Client for Unix. # Must be added to PATH. echo "Transfer to ULS-server" flush_test_values $VDIR # The directory is completely removed after the successful transfer echo "FINISHED"