aam1r
aam1r

Reputation: 11

Javascript show server load and update every few seconds

I am trying to show server load on a web page. The server load is fetched in PHP by executing the shell command "/proc/loadavg" and displaying the output as it is.

However, I want to display the same output using Javascript (jQuery is fine) and have it updated every 10 seconds.

How do I do so? I was thinking of using Ajax query but I think that is overcomplicating things

Upvotes: 0

Views: 504

Answers (1)

Pointy
Pointy

Reputation: 413720

You have no choice but to set up something like an ajax mechanism. It doesn't have to be XMLHttpRequest but it has to be some explicit communication from the browser to a URL on your server.

Think about it: the Javascript is running inside a client browser. How is it going to get the load average of the server without actually communicating with the server?

Upvotes: 1

Related Questions