5 Replies - 2420 Views - Last Post: 04 February 2013 - 05:34 AM Rate Topic: -----

#1 ceptic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-January 13

jqplot and php

Posted 02 February 2013 - 12:10 PM

quick few quiries if anyone can help:

im wanting to pull information from the web server and post it into nice graphs

so far ive managed to pull the average load.
but
how would i pull cpu details in php?
how would i pull ram information in php?


and how would i then plot this in a graph
like the server load graph below

http://www.keentheme...quer/index.html


any idea?

thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: jqplot and php

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: jqplot and php

Posted 02 February 2013 - 12:14 PM

Well.. you would check their documentation and see that all the chart needs is an array of numbers.. give it that and bam-o! You got nice looking charts!

http://www.jqplot.co...line-charts.php
Was This Post Helpful? 0
  • +
  • -

#3 ceptic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-January 13

Re: jqplot and php

Posted 02 February 2013 - 12:33 PM

View Postmodi123_1, on 02 February 2013 - 12:14 PM, said:

Well.. you would check their documentation and see that all the chart needs is an array of numbers.. give it that and bam-o! You got nice looking charts!

http://www.jqplot.co...line-charts.php



thanks only problem the jqplot doesnt look like the one on the website speciefied above and

if im putting the data into a array how would i update this array every x amount of seconds?
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3814
  • View blog
  • Posts: 13,527
  • Joined: 12-December 12

Re: jqplot and php

Posted 02 February 2013 - 12:48 PM

Quote

thanks only problem the jqplot doesnt look like the one on the website speciefied above

It it were me.. I would get the sample graph working first, before attempting to substitute my own data.

Quote

if im putting the data into a array how would i update this array every x amount of seconds?

You would use (normally) Ajax to make a request to the server for the updated data and feed this into your Javascript array. Again, I would get it working for a single, static, array firstly.

You are making it very difficult for yourself if you are trying to do everything at once. If it doesn't work, how would you know which part is failing?!

This post has been edited by andrewsw: 02 February 2013 - 12:51 PM

Was This Post Helpful? 0
  • +
  • -

#5 ceptic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-January 13

Re: jqplot and php

Posted 04 February 2013 - 03:50 AM

View Postandrewsw, on 02 February 2013 - 12:48 PM, said:

Quote

thanks only problem the jqplot doesnt look like the one on the website speciefied above

It it were me.. I would get the sample graph working first, before attempting to substitute my own data.

Quote

if im putting the data into a array how would i update this array every x amount of seconds?

You would use (normally) Ajax to make a request to the server for the updated data and feed this into your Javascript array. Again, I would get it working for a single, static, array firstly.

You are making it very difficult for yourself if you are trying to do everything at once. If it doesn't work, how would you know which part is failing?!


Hey thanks for your feedback ive decided im going to insert all the data into a database and pull it into an array and that way it shows history of uptime ram etc

Quick query in regards to that

$row=mysql_query (SELECT * FROM server ORDER BY upsite DESC LIMIT 10)

Echo $row


Would the statement above constantly pull the last 10 results? Or would i need to use ajax to do that?


Also my file which runs the script to pull data how would i get that to run every 10seconds?

Would putting a cron on it work?


Thanks
Jordan
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3814
  • View blog
  • Posts: 13,527
  • Joined: 12-December 12

Re: jqplot and php

Posted 04 February 2013 - 05:34 AM

$row=mysql_query (SELECT * FROM server ORDER BY upsite DESC LIMIT 10)
echo $row

Well, yes, it would return the last 10 rows (if you add quotes and semi-colons!), but you can't echo the row like that. You would use code like the following.

// Perform Query
$result = mysql_query($query);

if ($result) {
    while ($row = mysql_fetch_assoc($result)) {
        echo $row['firstname'];
        echo $row['lastname'];
        echo $row['address'];
        echo $row['age'];
    }
}

The docs

But that is PHP code: it will run once on the server and forward the results to your page. To keep grabbing data would require making Ajax requests, using Javascript's setInterval or setTimeout.

I don't know much about CRON jobs, but they are scheduled server-side scripts. They are used to perform maintenance tasks on the server and cannot affect a page that is already being viewed in a browser.

The mysql library is DEPRECATED - use mysqli or PDO instead.

This post has been edited by andrewsw: 04 February 2013 - 05:35 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1