EOSERV Forum > Programming > php request: $uptime displayed on website
Topic is locked.
Page: << 1 2 >>
php request: $uptime displayed on website
Author Message
Post #140341 Re: php request: $uptime displayed on website

Okay, this could be completely wrong... But It's also just an idea.

I'm no good with code from scratch only fixing code that's already written.


But, These websites that check your port like "canyouseeme.org"  If you're running your server and you check the port that your server runs through the port checker can see your service.

Is it possible to have a Time Clock count the seconds/minutes/hours whatever you want to see how long it can see your service as well as how long it's down for? If so then you can just have them average out to place an uptime percentage on your website >_>... But as I said I could be completely wrong with this. And I imagine you'd need an infinite loop to keep reading the source. And when it stops then your "No Service" counter would go and when it continues then you "On Service" would go >_> therefor Averaging it out in a set number of time.

14 years, 10 weeks ago
Post #141381 Re: php request: $uptime displayed on website

Hey there, I have a solution to your issue! It's probably REALLY ugly code but it is a solution none the less.. Assuming you know how to set up cron jobs? ( Which are basically just a list of scripts/programs that the computer will execute at regular intervals of which you define, I know how toin linux, I don't know if there's something similar in windows) I have written a simple PHP script that will connect to the server you assign it to, and will update a table called "serverinfo" (which it will create if it doesn't exist within your eoserv database) and increment a field called"uptime" by the interval which you set in minutes and display how long the server has been up, in minutes. Also I thought ahead and decided to add a little "security" feature if you will so your uptime can't be fucked with. you have to browse to uptime.php?accesskey=abcdefg in order for the scriptto fully execute and you can change this access key if you should so desire, just be sure to make sure you assign the accesskey in your cron job :) If you wish to use this basic script I can work on it some more to make it more suited to your requirements but it's the best I/anyone has come up withso far by the looks of it? 

Here's the script: https://tehsausage.com/paste/uptime //doesn't create a table. Look to my next post for this fix.

Any more info needed, just message back 

---
If money doesn't grow on trees, then why do banks have branches?
14 years, 8 weeks ago
Post #141383 Re: php request: $uptime displayed on website
DanScott posted: (30th Apr 2012, 05:43 pm)

Hey there, I have a solution to your issue! It's probably REALLY ugly code but it is a solution none the less.. Assuming you know how to set up cron jobs? ( Which are basically just a list of scripts/programs that the computer will execute at regular intervals of which you define, I know how toin linux, I don't know if there's something similar in windows) I have written a simple PHP script that will connect to the server you assign it to, and will update a table called "serverinfo" (which it will create if it doesn't exist within your eoserv database) and increment a field called"uptime" by the interval which you set in minutes and display how long the server has been up, in minutes. Also I thought ahead and decided to add a little "security" feature if you will so your uptime can't be fucked with. you have to browse to uptime.php?accesskey=abcdefg in order for the scriptto fully execute and you can change this access key if you should so desire, just be sure to make sure you assign the accesskey in your cron job :) If you wish to use this basic script I can work on it some more to make it more suited to your requirements but it's the best I/anyone has come up withso far by the looks of it? 

Here's the script: https://tehsausage.com/paste/uptime

Any more info needed, just message back 


Do you got a HTML script for this?
14 years, 8 weeks ago
Post #141384 Re: php request: $uptime displayed on website

Uh, I don't think HTML has quite the capabilities of PHP so far as connecting to a server :L so in answer to your question, no. Sorry. 

Also, it has been pointed out that my script in my previous post doesn't actually create the table haha. Apologies for that guys. You can find the rectified version here https://tehsausage.com/paste/uptimerecifiedfinallol that will hopefully successfully create the table if you do not have it in your database currently.
---
If money doesn't grow on trees, then why do banks have branches?
14 years, 8 weeks ago
Post #141385 Re: php request: $uptime displayed on website

thanks man, its just what I wanted, a solution that works

---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 8 weeks ago
Post #141386 Re: php request: $uptime displayed on website

No worries, I hope you get this working :)

---
If money doesn't grow on trees, then why do banks have branches?
14 years, 8 weeks ago
Post #141388 Re: php request: $uptime displayed on website

me?

bwahaha I'm no coder.. it's all you dude

---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 8 weeks ago
Post #141397 Re: php request: $uptime displayed on website

Finished off a nicer script for you in a new thread :) I think it more meets your specifications :P

---
If money doesn't grow on trees, then why do banks have branches?
14 years, 8 weeks ago
Page: << 1 2 >>
Topic is locked.
EOSERV Forum > Programming > php request: $uptime displayed on website