Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Total uptime scripts.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
crs
Apprentice
Apprentice


Joined: 19 Apr 2003
Posts: 188

PostPosted: Fri Sep 19, 2003 7:04 am    Post subject: Total uptime scripts. Reply with quote

Hello. I have one simple thing to sum up uptime.

Lets go:

We need have two files:

Code:
 touch increaseup.sh
touch totalup.sh


Later copy and paste this code into file:

- in to increaseup.sh copy:

Code:

#!/bin/bash

TOTAL_UP_FILE=/root/uptime

UPTIME=`cat /proc/uptime | awk -F"." '{print $1}'`

if [ -s $TOTAL_UP_FILE ]; then
   SAVED_UPTIME=`cat $TOTAL_UP_FILE`
fi

TOTAL_UPTIME=$[$SAVED_UPTIME+$UPTIME]

echo $TOTAL_UPTIME > $TOTAL_UP_FILE

echo " * ...increasing total uptime..."
exit 0


- in to totalup.sh copy:

Code:

#!/bin/bash

TOTAL_UP_FILE=/root/uptime

if [ -s $TOTAL_UP_FILE ]; then
   UPTIME=`cat $TOTAL_UP_FILE`
fi

DAYS=$[$UPTIME/86400]
UPT=$[$UPTIME-$DAYS*86400]
UPTIME=$UPT

HOURS=$[$UPTIME/3600]
UPT=$[UPTIME-$HOURS*3600]
UPTIME=$UPT

MINS=$[$UPTIME/60]
UPT=$[$UPTIME-$MINS*60]
SECS=$UPT

echo "*** Total uptime counter start: xx/xx/xx"
echo "*** Total uptime: $DAYS d, $HOURS h, $MINS m, $SECS s ($DAYS d, $HOURS:$MINS:$SECS)"

exit 0


Next step is:
Code:
 touch /root/uptime


(or different file, but you have change this in files above).

Now you have to add the:
Code:
 /path/to/inreaseup.sh


to: /etc/conf.d/local.stop.

Now after reboot or shutdown script will be sum up your uptime. You may check this using totalup.sh:

Code:
 /path/to/totaupl.sh


PS. I added totalup.sh to /etc/conf.d/locale/start.

G.
Back to top
View user's profile Send private message
alec
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 270
Location: Here

PostPosted: Sat Sep 20, 2003 8:33 am    Post subject: Reply with quote

Also have a look at uptimed.
Back to top
View user's profile Send private message
Redeeman
l33t
l33t


Joined: 25 Sep 2003
Posts: 957
Location: Denmark

PostPosted: Wed Jan 07, 2004 10:37 pm    Post subject: Reply with quote

cool! tell us about more of such stuff!
_________________
Sandberg Enterprises
Back to top
View user's profile Send private message
pixelcatcher
n00b
n00b


Joined: 31 Jan 2004
Posts: 60
Location: Stuttgart

PostPosted: Mon Jun 07, 2004 6:39 am    Post subject: Reply with quote

yes, indeed very nice idea and nice scripts....(I'm using it on both of my gentoo boxes! thank you!)

what I would like to see:
(check vnstat, which has such features, but is used for network traffic)


- logging data for each day / week / month / ...
- ability to get statistics (average uptime / average load? / .... maybe even plotted with gnuplot)
- updating the database via cron so that a hang doesnt mean you loose your uptime
_________________
www.pixelcatcher.de
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum