1 #!/bin/bash
    2 
    3 dataDir='/home/nmon/data'
    4 htmlDir='/home/nmon/public_html'
    5 
    6 # process each node/computer
    7 ls -1 ${dataDir} | while read node
    8  do
    9 	  echo "Processing node: ${node}"
   10 		# Make sure config file is there
   11 		if [[ -f ${dataDir}/${node}/report.config ]]
   12 		 then
   13    	  # make sure output has somewhere to go
   14        if [[ ! -d ${htmlDir}/${node} ]]
   15    		 then
   16           mkdir -p ${htmlDir}/${node}
   17    	   fi
   18    		# now process each day of data that has not already been processed
   19    		cd ${dataDir}/${node}
   20    		rm -rf tmp
   21    		ls -1 *.nmon | while read file
   22    		 do
   23    			 echo "     ${file}"
   24    			 # change periods to spaces
   25    			 tmp=$(echo ${file} | sed 's/\./ /g')
   26    			 # make name the parameter list
   27    			 set ${tmp}
   28    			 # find out how many tokens
   29    			 last="$#"
   30    			 # next to last is date
   31    			 ((cnt=2))
   32    			 while ((cnt < last))
   33    				do
   34    					shift
   35    					((cnt = cnt + 1))
   36    				done
   37    		   # finally have date as first parameter
   38 				 dt="${1}"
   39 				 date=$(date -d ${dt} '+%B %-d, %Y (%A)')
   40    			 # if file does not exist, we need to generate html
   41    			 if [[ ! -f ${htmlDir}/${node}/${dt}.html ]]
   42    				then
   43             pyNmonAnalyzer -i ${node}.${dt}.nmon -b -t static -x -o html
   44    					cat html/report.html | sed "s/\"img\//\"img-${dt}\//g" | sed "s/<body>/<body><center><h2>HPC nmon Visualization<\/h2><h3>${node} on ${date}<\/h3><\/center>/"  > ${htmlDir}/${node}/${dt}.html
   45    					mv html/img ${htmlDir}/${node}/img-${dt}
   46    					rm -rf html
   47 						if [[ ! -L ${htmlDir}/${node}/index.php ]]
   48 						 then
   49 							 ln -s ${htmlDir}/index.php ${htmlDir}/${node}/index.php
   50 						 fi
   51    			  fi
   52    		 done
   53 		 fi
   54  done