Web Hosting Talk







View Full Version : best way???


matt2kjones
02-09-2003, 09:52 AM
hmmmm i have recently made a server status page : http://www.thedigitaldream.co.uk/server_status.php

but i want to add more there

im gunna add the uptime today

but what i want to do is this

if you go here: http://www.thedigitaldream.co.uk/data_transfer.php

now, all i want from there is the in/out bytes of eth0

so is this the best way of going about it

opening the file using file(); and storing it in an array

the moving straight to the 3rd line

then, to pin point the numbers, have my script count the spaces between the numbers so it knows where it is on the file.

the first part is easy

eth0:1814366492

all i have to do is remove eth0:

but then, then the out bandwidth is harder to get. so i was going to count the gaps, there are 8, which will put me before the out bandwidth.

is that the best way to do it???

or is there a really easy way to go around this?

Thanx

NicoV
02-09-2003, 01:41 PM
hmmm, what kind of code does the data_transfer.php page use? because i assume that pulls it information from somewhere as well. You could look at the code that that page uses to get its information, and copy the code for the information that you want, instead of grabbing the information from a page that also grabs it from some other data file.

matt2kjones
02-09-2003, 02:18 PM
that is just echoing the data from /proc/net/dev

thats the file i will read the data from

so is the way i mentioned the best way?

NethrBen
02-09-2003, 03:46 PM
I know perl has a split() function, I'd take a look at PHP's explode(). If I remember correctly it will split things into a nice array for you.

thanks,
Ben

matt2kjones
02-09-2003, 04:22 PM
great thanx, will check it out