Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Total uptime scripts.

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
crs
Apprentice
Apprentice
Posts: 188
Joined: Sat Apr 19, 2003 6:45 pm

Total uptime scripts.

  • Quote

Post by crs » Fri Sep 19, 2003 7:04 am

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

Lets go:

We need have two files:

Code: Select all

 touch increaseup.sh
touch totalup.sh
Later copy and paste this code into file:

- in to increaseup.sh copy:

Code: Select all

#!/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: Select all

#!/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: Select all

 touch /root/uptime 
(or different file, but you have change this in files above).

Now you have to add the:

Code: Select all

 /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: Select all

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

G.
Top
alec
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Fri Apr 19, 2002 3:02 am
Location: Here
Contact:
Contact alec
Website

  • Quote

Post by alec » Sat Sep 20, 2003 8:33 am

Also have a look at uptimed.
Top
Redeeman
l33t
l33t
User avatar
Posts: 958
Joined: Thu Sep 25, 2003 9:02 am
Location: Portugal

  • Quote

Post by Redeeman » Wed Jan 07, 2004 10:37 pm

cool! tell us about more of such stuff!
Top
pixelcatcher
n00b
n00b
Posts: 60
Joined: Sat Jan 31, 2004 2:51 pm
Location: Stuttgart

  • Quote

Post by pixelcatcher » Mon Jun 07, 2004 6:39 am

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
Top
Post Reply

4 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic