#!/bin/sh # # /usr/local/bin/UPTIME # # add to crontab thus: # # ln -s /usr/local/bin/UPTIME /etc/cron.hourly # ########################################################## # BOOTDATE="December 28, 1998" CURRBOOT=`ls -al / | grep proc | awk '{print $6" "$7" "$8}'` # ########################################################## # # echo "==============================================" \ > /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt # echo "Former bootdate: $BOOTDATE" >> /home/httpd/pubhtml/uptime.txt echo "End of an era - July 16, 2001 - after 900+ days" \ >> /home/httpd/pubhtml/uptime.txt echo "a hard drive 'spot' got us ... oh well." \ >> /home/httpd/pubhtml/uptime.txt echo >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo -n "The system, `hostname`" >> /home/httpd/pubhtml/uptime.txt echo " last rebooted on $CURRBOOT" >> /home/httpd/pubhtml/uptime.txt echo -n "and has now been up " >> /home/httpd/pubhtml/uptime.txt echo "continuously for " >> /home/httpd/pubhtml/uptime.txt BASE=`procinfo | awk -F: '{print $2}' | grep "d " | \ tail -n -5 | head -n 3 | awk -Fd '{print sum += $1}' | \ tail -n -1 ` # Jiffies overflow the Long at 497.1 days OFFSET=497 OFFSET=0 TOTAL=$[ $BASE + $OFFSET ] echo -n "$TOTAL" >> /home/httpd/pubhtml/uptime.txt echo -n " days - we " >> /home/httpd/pubhtml/uptime.txt echo "ignore hours and minutes." >> /home/httpd/pubhtml/uptime.txt # echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt # cat - << ENDBRAG >> /home/httpd/pubhtml/uptime.txt This host is a 386DX/33 with 16 meg of ram, and a generic IDE hard drive. It is on a UPS, and built using an old I-BUS sbc ISA processor card, in a former Automatic Teller Machine 19 inch rackmount case. It has two generic NIC's and a ISA internal modem card. It has, during its life handled full rate T-1 connections, dialup RAS and fax sources, webservice, mailing list services, anon. FTP services. The administrator has not physically touched it or its keyboard since 1997. It has no monitor. ENDBRAG # echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # dmesg | grep Cache >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt # echo -n "Last updated: " \ >> /home/httpd/pubhtml/uptime.txt date >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt # echo -n "This system booted on " >> /home/httpd/pubhtml/uptime.txt echo -n $BOOTDATE >> /home/httpd/pubhtml/uptime.txt echo " -- the clock rolled " \ >> /home/httpd/pubhtml/uptime.txt echo "over every 497.1 days --- We've summed the various sub-fields " \ >> /home/httpd/pubhtml/uptime.txt echo "for a more understandable statement of the true uptime." \ >> /home/httpd/pubhtml/uptime.txt # echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt # echo >> /home/httpd/pubhtml/uptime.txt # /usr/bin/procinfo >> /home/httpd/pubhtml/uptime.txt # echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt echo " produced by: http://bopper.wcbe.org/UPTIME " \ >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt echo -n "Updated at: " >> /home/httpd/pubhtml/uptime.txt date >> /home/httpd/pubhtml/uptime.txt echo "==============================================" \ >> /home/httpd/pubhtml/uptime.txt