Get server details with php ...
Moderator: General Moderators
Get server details with php ...
Just a thught, Ther is any way to get server (running linux) infromation?
What I have in mind is like:
how many and which partations are out ther?
What is the hardware that the server is running?
How much precent of the CPU/MEMORY is beeing used at the moment the script is running?
Thanka s lot,
Ill keep search Google as well.
What I have in mind is like:
how many and which partations are out ther?
What is the hardware that the server is running?
How much precent of the CPU/MEMORY is beeing used at the moment the script is running?
Thanka s lot,
Ill keep search Google as well.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Get server details with php ...
No idea on the CPU information etc but you can use the $_SERVER array to get information about the server.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Get server details with php ...
thanks , but iv'e kinda find that alredy...
I have one more question,
Ther is any way to find out which Drives ther are in the server?
Like hard drive / partations some thing like this.
because i have a function that check the space on my server, but i want the function
to self update if ill add more hard drives to the server, like i wont need to change the code.
I have one more question,
Ther is any way to find out which Drives ther are in the server?
Like hard drive / partations some thing like this.
because i have a function that check the space on my server, but i want the function
to self update if ill add more hard drives to the server, like i wont need to change the code.
Re: Get server details with php ...
That type of information can be found in files under /proc.
To see what files are available, use dir or ls at the command prompt.
To see what is in a file, use cat.
You will have to do a little research to learn where in those files to find the information you are looking for.
In PHP, you can run system commands with program execution functions.
Some commands like fdisk give access to system information, but may require root permission; and it is atypical for PHP to be run by root.
To see what files are available, use dir or ls at the command prompt.
Code: Select all
ls /procCode: Select all
cat /proc/partitionsIn PHP, you can run system commands with program execution functions.
Some commands like fdisk give access to system information, but may require root permission; and it is atypical for PHP to be run by root.
Re: Get server details with php ...
First of all, THANK YOU.
Im steping forword...
so i built this little function
and the output that I recived is :
thanks,
Im steping forword...
so i built this little function
Code: Select all
<?php
$stats = shell_exec('cat /proc/partitions');
if($stats){
echo "success<br>".$stats;
} else
echo "unsuccessful";
?> Now, i wonder if you have any idea how to work with this output...major minor #blocks name 8 0 20971520 sda 8 1 104391 sda1 8 2 2096482 sda2 8 3 18763920 sda3 7 0 512000 loop0
thanks,
Re: Get server details with php ...
If you display the script output as plain text instead of HTML, you will see that the text is actually a table with fixed-width columns.
If you split (explode) the string on the newlines (the "\n" character), you will have an array of lines. Ignoring the first two lines (the column headers and the blank line), each element of the array is a row of the table. Further, you can split each row into an array of cells, yielding a two-dimensional array. There are many ways to accomplish that using PHP's string and array functions.
Code: Select all
major minor #blocks name
8 0 20971520 sda
8 1 104391 sda1
8 2 2096482 sda2
8 3 18763920 sda3
7 0 512000 loop0Re: Get server details with php ...
First thing thanks,
Let me know if i got it right ,
The partations are sda...sda1..sda2 right?
If so I got it ...
One Last thing... what about hard drives ? Do you have any idea where i see that?
thank you =]
Let me know if i got it right ,
The partations are sda...sda1..sda2 right?
If so I got it ...
One Last thing... what about hard drives ? Do you have any idea where i see that?
thank you =]
-
jarofgreen
- Forum Commoner
- Posts: 71
- Joined: Sun Jul 11, 2010 12:40 pm
Re: Get server details with php ...
Look at this thread
viewtopic.php?f=50&t=123299
viewtopic.php?f=50&t=123299
Re: Get server details with php ...
Thank you, and every one that posted on the thred!jarofgreen wrote:Look at this thread
viewtopic.php?f=50&t=123299
I just wanted to say that I kinda wanted to do it myself,
But that will work just fine.
Thank you agian.
-
jarofgreen
- Forum Commoner
- Posts: 71
- Joined: Sun Jul 11, 2010 12:40 pm
Re: Get server details with php ...
It's open source, I'm sure they would welcome contributors 