Post Uptime

Jul 07, 2014 31 Replies

I found this website

formatting link

And used the command uptime | convert label:@- uptime.png in a bash script

I then used crontab to upload the png file to the website via ftp every

20 minutes

Works for me!

I think it is standard to be able to put a hidden in a Web page, loading it with same-source plain-text or HTML, and then read that material with JavaScript and write some or all of it into the visible Web page. I've not done all of that in one Web page; but I have done all of the parts in different pages. That should require only that the web server can serve text or HTML, but may well not work in Chrome from a local disc without using a server (over-zealous security).

(c) John Stockton, nr London, UK. For Mail, see Home Page. Turnpike, WinXP. Web - FAQ-type topics, acronyms, and links. Command-prompt MiniTrue is useful for viewing/searching/altering files. Free, DOS/Win/UNIX now 2.0.6; see my .

Try this:

----snip here---- #!/usr/bin/perl # $htmlhead =

start simple:

echo " Uptime for Raspberry the wonder PI " > uptime.html uptime >> uptime.html echo " " >> uptime.html

& get uptime.html to the server (this can be done so many ways that depent on your service). You can then work on a better script, fancier html, includes etc.

Ron

If it's on the same server as the main page and script you can read the content of the file directly in javascript using XmlHttpRequest()

umop apisdn

That's easy enough to work around - leave a redirection page in the original location referring to the PHP file.

The other way that comes to mind would be to invert the problem - instead of reporting the uptime report the time the system was booted. It'd be easy enough to place the output of "who -b" into the HTML locally and upload it to the web server as an init script.

Andrew Smallshaw andrews@sdf.lonestar.org

that can't be trusted as evidence of uptime unless it's the same sytem that's running the webserver.

my raspberry pi would be showing 4 weeks uptime by that measure but it's been powered down for 2 weeks,

umop apisdn

The same is true of the uptime: sure if it says up 1 year+ it's proof that it was up at some point for at least that long but says nothing if it has subsequently been powered down since. The assumption for anything updated periodically is that it is an always-on system or at least some kind of time-out applies if you haven't heard anything for a while. If those limitations are not acceptable you need some form of real-time data acquisition, e.g. as at

formatting link
which was in use for my home network for a while - I wouldn't recommend Bourne shell for CGI scripts on the public-facing Internet but it worked well enough for me.

Andrew Smallshaw andrews@sdf.lonestar.org

Surely the easiest "fix" is to use something like the output of

#!/sh echo "RPi uptime:" uptime echo "Page last updated:" date

Then if your RPi falls off the net for any reason, visitors to the site can see how fresh/stale the uptime (or boot time) data is.

For bonus points, you could return the data in a form which is parsable by whatver javascript/php/etc you're using on the web server end - and have the page report "no update in 5 days, is the pi down?"

-Paul

http://paulseward.com

Instead of doing that why not generate an HTML document and upload it. Prepare files something like this

uptime.head

----------------------- Uptime of my pi

------------------------

uptime.tail

------------------------

------------------------

Then run

uptime > uptime.txt cat uptime.head uptime.txt uptime.tail > uptime.html

Then upload the uptime.html file. You can of course get more sophisticated and include fancier formatting and/or extra information but that should get you going. Why make the webserver work to compose the file on every request even though it hasn't changed when you can reduce the total work by generating the file at change time.

Steve O'Hara-Smith | Directable Mirror Arrays C:>WIN | A better way to focus the sun The computer obeys and wins. | licences available see You lose and Bill collects. | http://www.sohara.org/

There are a number of ways which have been suggested, all valid under different sets of requirement.

The best one will depend on:

Whether the OP wants the uptime to appear as an item in a complex page, or whether it can be displayed from a link.

Whether the server hosting it has PHP, or other scripting languages available

Whether the server can accept uploads from a program running elsewhere, and whether it can also support downloads to such a program (allowing the possibility of downloading the page, editing it automatically, and re-uploading it).

Alan Adams, from Northamptonshire alan@adamshome.org.uk http://www.nckc.org.uk/

Did my post of two weeks ago detailing this method not appear on your server?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required