CPU Usage
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 5:35 pm    Post subject: CPU Usage Reply with quote

Aprelium, you said you were going to post how to find the current CPU usage in PHP a little while back;

have you got this available to post yet?

thanks
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 6:42 pm    Post subject: Re: CPU Usage Reply with quote

The Inquisitor wrote:
Aprelium, you said you were going to post how to find the current CPU usage in PHP a little while back;

have you got this available to post yet?

thanks


<-- Also wants this.

Im sure someone mediocore at C could write a command line program to get such info to execute from a script. Like the memory program included with my script. (Which I stole from somewhere =P)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 6:48 pm    Post subject: Reply with quote

Lol, which I then stole from you and put onto my edited script that was from your phpgd image script :P www.elethor.com/stats and http://homeserver.abyssunderground.co.uk/system are both example of this script.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:13 pm    Post subject: Reply with quote

The Inquisitor wrote:
Lol, which I then stole from you and put onto my edited script that was from your phpgd image script :P www.elethor.com/stats and http://homeserver.abyssunderground.co.uk/system are both example of this script.


Nice =)
You could simply use fopen to check your ports without sensors (Unless you have actually disabled these) and mysql_ping for mysql.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 7:22 pm    Post subject: Reply with quote

Its not the ports I want to check, its the service itself. If PHP fails, it wont output an echo so it therefore wont load the page and make the image on the main page show green.

I am still working on it. Needs a hell of a lot of work.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:29 pm    Post subject: Reply with quote

The Inquisitor wrote:
Its not the ports I want to check, its the service itself. If PHP fails, it wont output an echo so it therefore wont load the page and make the image on the main page show green.

I am still working on it. Needs a hell of a lot of work.


Looks like it =/
For a very basic example try making an iframe with the images, the html being printed by the language you are testing.
And as for FTP, you could use ftp_connect.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 7:32 pm    Post subject: Reply with quote

Thats the way i was going to do it, with iframes. The idea was to make hidden div tags with the iframe in it then the javascript printed by the language making the image on that page change. I did this successfully with just HTML but have never tried it with PHP or any other language.

For a start I need to install ASP and Perl etc to get those ones to work but to start with I will just use PHP and HTML. I then need to know how to print in those langauges too but im sure someone on the forum or a tutorial from google will suffice.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:33 pm    Post subject: Reply with quote

The Inquisitor wrote:
Thats the way i was going to do it, with iframes. The idea was to make hidden div tags with the iframe in it then the javascript printed by the language making the image on that page change. I did this successfully with just HTML but have never tried it with PHP or any other language.

For a start I need to install ASP and Perl etc to get those ones to work but to start with I will just use PHP and HTML. I then need to know how to print in those langauges too but im sure someone on the forum or a tutorial from google will suffice.


Oh, and to be really tacky, be sure to test if HTML is working =)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 7:35 pm    Post subject: Reply with quote

lol, well if you see the page, it must be working!!! So much PHP actually :P
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:37 pm    Post subject: Reply with quote

The Inquisitor wrote:
lol, well if you see the page, it must be working!!! So much PHP actually :P


You can still impress the older folks =D
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 7:40 pm    Post subject: Reply with quote

lol, thats true. Plus i made a typo on that, 'must', not 'much'. lol.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:47 pm    Post subject: Reply with quote

The Inquisitor wrote:
lol, thats true. Plus i made a typo on that, 'must', not 'much'. lol.


My spelling would be worse, if I didnt check it.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 7:48 pm    Post subject: Reply with quote

I check as I write normally. I touch type so its easier to make mistakes and not see them.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 7:59 pm    Post subject: Reply with quote

The Inquisitor wrote:
I check as I write normally. I touch type so its easier to make mistakes and not see them.


I seem to do that without trying now =/
I bought a cheap keyboard and the letters have worn off, not much of a choice.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 8:01 pm    Post subject: Reply with quote

lol, im supprised these keys havent worn off the amount of typing ive done today!
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue May 24, 2005 8:04 pm    Post subject: Reply with quote

The Inquisitor wrote:
lol, im supprised these keys havent worn off the amount of typing ive done today!


You should get Whatpulse, its interesting to see how much you type =)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue May 24, 2005 8:10 pm    Post subject: Reply with quote

That looks nice, I might think about downloading it :P
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed May 25, 2005 1:19 pm    Post subject: Re: CPU Usage Reply with quote

The Inquisitor wrote:
Aprelium, you said you were going to post how to find the current CPU usage in PHP a little while back;

have you got this available to post yet?


Sorry but we have got no time to work on it. We have the code in C++ but we'll have to convert it to PHP.
We'll manage to work on this script today. :-) It's a promise.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed May 25, 2005 1:59 pm    Post subject: Reply with quote

Thankyou :)
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed May 25, 2005 3:49 pm    Post subject: Re: CPU Usage Reply with quote

aprelium wrote:
The Inquisitor wrote:
Aprelium, you said you were going to post how to find the current CPU usage in PHP a little while back;

have you got this available to post yet?


Sorry but we have got no time to work on it. We have the code in C++ but we'll have to convert it to PHP.
We'll manage to work on this script today. :-) It's a promise.


I dont suppose you could get the CPU power too. (E.G. "3006Mhz".) Running systeminfo takes way too long to be any use.
Oh, and I love you =)
(Man love, of course.(No gay jokes -_-))
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1332

PostPosted: Wed May 25, 2005 6:38 pm    Post subject: Re: CPU Usage Reply with quote

Here is the promised code:

Code:

<?php

if(class_exists("COM")) {
  $wmi = new COM("WinMgmts:\\\\.");
  $cpus = $wmi->InstancesOf("Win32_Processor");
 
  $i = 1;
 
  // Use the while loop on PHP 4 and foreach on PHP 5
  //while ($cpu = $cpus->Next()) {
  foreach ($cpus as $cpu) {
 
   echo "<p>Processor $i : " . $cpu->Name . " @ ";
   $clockSpeed = $cpu->CurrentClockSpeed;
   $cpuLoad = $cpu->LoadPercentage;
   echo $clockSpeed . " MHz (Load= " . $cpuLoad ."%)</p>";
   $i++;
   
  }
 
  $uptime = 0;
  $systems = $wmi->InstancesOf("Win32_PerfRawData_PerfOS_System");
 
  // Use the while loop on PHP 4 and foreach on PHP 5
  //while ($system = $systems->Next()) {
  foreach ($systems as $system) {
 
   $PerfTimeStamp = $system->Timestamp_Object ;
       $PerfTimeFreq = $system->Frequency_Object ;
   $Counter = $system->SystemUpTime ;
   $UptimeInSec = ($PerfTimeStamp - $Counter)/$PerfTimeFreq ;
   
   $uptime = max($uptime, $UptimeInSec);
  }

  echo "<p>Your system uptime is: $uptime</p>";
 }
 else {
  return "<p>Your system does not support WMI!</p>";
 }
?>


With WMI, you can get almost all the parameters of your system (even the CPU voltage!). For those who are intrested in knowing more about the WMI objects, go to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_classes.asp .

Please note that if you use PHP 4 you'll have to use the while loops instead of the foreach loops (see the comments in the code).
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed May 25, 2005 7:47 pm    Post subject: Reply with quote

Thanks for the code. I will try it right away!!! :P:P:P:P
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed May 25, 2005 11:13 pm    Post subject: Reply with quote

I love you aprelium =)
WMI looks like something fun to play with, but I honestly dont get all that $var->$var2 crap, but im sure I could get a basica understanding with a bit of playing around =)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
mahel
-


Joined: 19 Apr 2005
Posts: 21
Location: Netherlands

PostPosted: Thu May 26, 2005 8:52 am    Post subject: Reply with quote

I see this.

Processor 1 : @ MHz (Load= %)

Your system uptime is: 231837.828125

I dont see the load
________
CHRYSLER AKINO HISTORY


Last edited by mahel on Sun Feb 13, 2011 4:22 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu May 26, 2005 9:11 am    Post subject: Reply with quote

You need to uncomment certain functions for certain versions of PHP , in your
case your using PHP v4 so you need to use while() instead of foreach() , I did
the modification myself so you don't have to , enjoy showing your CPU.

Code:

<?php

if(class_exists("COM")) {
  $wmi = new COM("WinMgmts:\\\\.");
  $cpus = $wmi->InstancesOf("Win32_Processor");
 
  $i = 1;
 
  // Use the while loop on PHP 4 and foreach on PHP 5
  while ($cpu = $cpus->Next()) {
  // foreach ($cpus as $cpu) {
 
   echo "<p>Processor $i : " . $cpu->Name . " @ ";
   $clockSpeed = $cpu->CurrentClockSpeed;
   $cpuLoad = $cpu->LoadPercentage;
   echo $clockSpeed . " MHz (Load= " . $cpuLoad ."%)</p>";
   $i++;
   
  }
 
  $uptime = 0;
  $systems = $wmi->InstancesOf("Win32_PerfRawData_PerfOS_System");
 
  // Use the while loop on PHP 4 and foreach on PHP 5
  while ($system = $systems->Next()) {
  // foreach ($systems as $system) {
 
   $PerfTimeStamp = $system->Timestamp_Object ;
       $PerfTimeFreq = $system->Frequency_Object ;
   $Counter = $system->SystemUpTime ;
   $UptimeInSec = ($PerfTimeStamp - $Counter)/$PerfTimeFreq ;
   
   $uptime = max($uptime, $UptimeInSec);
  }

  echo "<p>Your system uptime is: $uptime</p>";
 }
 else {
  return "<p>Your system does not support WMI!</p>";
 }
?>


Sincerely , TRUSTpunk
Back to top View user's profile Send private message Visit poster's website
mahel
-


Joined: 19 Apr 2005
Posts: 21
Location: Netherlands

PostPosted: Thu May 26, 2005 9:26 am    Post subject: Reply with quote

yes i saw that, and also did that, still the result is like this,

Processor 1 : @ MHz (Load= %)

Your system uptime is: 233915.796875
________
Extreme Vaporizer


Last edited by mahel on Sun Feb 13, 2011 4:23 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu May 26, 2005 3:05 pm    Post subject: Reply with quote

mahel,

What is your PHP version and what is the exact version of Windows you have?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mahel
-


Joined: 19 Apr 2005
Posts: 21
Location: Netherlands

PostPosted: Thu May 26, 2005 3:22 pm    Post subject: Reply with quote

i have PHP Version 4.3.11

the OS is
Xp pro SP2
________
BUY EASY VAPE


Last edited by mahel on Sun Feb 13, 2011 4:23 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu May 26, 2005 3:42 pm    Post subject: Reply with quote

I have just tried this script but it causes a php.exe error. It says it needs to be closed because of a serious error.

i have tried it on my Laptop running XP Pro SP2 and my webserver XP Pro (no SP's), both cause the same error. I HAVE selected the correct option in the script (the one that you mention in the comments) so its just the script itself that is causing the error.

When it eventually shows a page its an error 500 Internal Server Error.

Hope you can help.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu May 26, 2005 4:35 pm    Post subject: Reply with quote

The Inquisitor wrote:
I have just tried this script but it causes a php.exe error. It says it needs to be closed because of a serious error.

i have tried it on my Laptop running XP Pro SP2 and my webserver XP Pro (no SP's), both cause the same error. I HAVE selected the correct option in the script (the one that you mention in the comments) so its just the script itself that is causing the error.

When it eventually shows a page its an error 500 Internal Server Error.

Hope you can help.


o_O
Seems to work for PHP5.03 =/
Try splitting the script up, commenting certain things, to find the cause.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu May 26, 2005 5:20 pm    Post subject: Reply with quote

Thanks, I will try 5.03 but Aprelium said it will work with PHP4. Thanks anyway.

Aprelium, can you see what you can do please?
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu May 26, 2005 8:50 pm    Post subject: Reply with quote

Mahel,

Can you send us your cgi.log file or tell us what error messages are there?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri May 27, 2005 10:37 am    Post subject: Reply with quote

I tried it with PHP5 but it continually shows 100% load when infact its about 30% or less.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Fri May 27, 2005 4:28 pm    Post subject: Reply with quote

The Inquisitor wrote:
I tried it with PHP5 but it continually shows 100% load when infact its about 30% or less.


php-cgi.exe can knock it up pretty high, but I doubt itd be 100% =/
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri May 27, 2005 4:32 pm    Post subject: Reply with quote

I know its not 100% because I have task manager up at the same time of executing. It doesnt exceed 40% at any point. I have run the script about 25-30 times all with the same result.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri May 27, 2005 9:40 pm    Post subject: Reply with quote

WMI gives you the CPU usage for the last second. So if your PHP takes more than 1 second to load, it is normal to have this 100% figure. :-(
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Fri May 27, 2005 10:07 pm    Post subject: Reply with quote

aprelium wrote:
WMI gives you the CPU usage for the last second. So if your PHP takes more than 1 second to load, it is normal to have this 100% figure. :-(


My generation time is about 2 seconds from a proxy.
Try putting usleep(500000) or something to make it take its time a little then get accurete usage.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat May 28, 2005 9:58 pm    Post subject: Reply with quote

I put the wrong link in my profile, NOW there is a working demonstration of the CPU usage script :)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
jlp09550
-


Joined: 05 Jun 2005
Posts: 123
Location: Louisiana, USA

PostPosted: Thu Jun 09, 2005 7:16 pm    Post subject: Reply with quote

I'm trying to use the FIRST code above from admin, but it says this:
URL: http://lfu.no-ip.org/1.php
Quote:
Your system uptime is: 0



And.... This comes up with the editied one or the one from TRUSTPink:
URL: http://lfu.no-ip.org/2.php
Quote:
Fatal error: Call to undefined method variant::Next() in C:\Documents and Settings\Jared\Desktop\web-server\2.php on line 10


BTW, I'm using PHP 5, if you were to please make a code for PHP 5 if there isn't one or these codes are only for PHP 4 or whatever! :)
_________________
Hosted Abyss Sites-
http://jared.chibipaws.com/ - My Stuffs
http://jaredblog.chibipaws.com/ - My Blog
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Jun 10, 2005 12:17 pm    Post subject: Reply with quote

jlp09550 wrote:

And.... This comes up with the editied one or the one from TRUSTPink:
URL: http://lfu.no-ip.org/2.php
Quote:
Fatal error: Call to undefined method variant::Next() in C:\Documents and Settings\Jared\Desktop\web-server\2.php on line 10


BTW, I'm using PHP 5, if you were to please make a code for PHP 5 if there isn't one or these codes are only for PHP 4 or whatever! :)

In our original code, there is a comment to explain how to have the code work on PHP 4 or PHP 5:
Code:

// Use the while loop on PHP 4 and foreach on PHP 5
while ($system = $systems->Next()) {
// foreach ($systems as $system) {

_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
jlp09550
-


Joined: 05 Jun 2005
Posts: 123
Location: Louisiana, USA

PostPosted: Fri Jun 10, 2005 5:40 pm    Post subject: Reply with quote

OK, Now it says this:

Quote:
Your system uptime is: 0

URL: http://lfu.no-ip.org/phpinfo.php
_________________
Hosted Abyss Sites-
http://jared.chibipaws.com/ - My Stuffs
http://jaredblog.chibipaws.com/ - My Blog
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Jun 11, 2005 12:02 pm    Post subject: Reply with quote

jlp09550 wrote:
OK, Now it says this:

Quote:
Your system uptime is: 0

URL: http://lfu.no-ip.org/phpinfo.php

And what you get for the processor information that is dumped before that?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
jlp09550
-


Joined: 05 Jun 2005
Posts: 123
Location: Louisiana, USA

PostPosted: Sat Jun 11, 2005 6:18 pm    Post subject: Reply with quote

Quote:
And what you get for the processor information that is dumped before that?


Sorry, I'm not much of a PHP expert, but I like tinkering around with PHP scripts and I'm learning... though, sorry I really don't understand that yet, apreiulum! =(
_________________
Hosted Abyss Sites-
http://jared.chibipaws.com/ - My Stuffs
http://jaredblog.chibipaws.com/ - My Blog
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Jun 12, 2005 4:00 pm    Post subject: Reply with quote

jlp09550,

We'll rephrase our question: if you use the full script we have written above, it should write some information about your processor and then write the uptime. You say the uptime is always 0, but what about the processor information?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
jlp09550
-


Joined: 05 Jun 2005
Posts: 123
Location: Louisiana, USA

PostPosted: Sun Jun 12, 2005 8:45 pm    Post subject: Reply with quote

Quote:
jlp09550,

We'll rephrase our question: if you use the full script we have written above, it should write some information about your processor and then write the uptime. You say the uptime is always 0, but what about the processor information?

Oh, that is all it wrote. Just the uptime info.
_________________
Hosted Abyss Sites-
http://jared.chibipaws.com/ - My Stuffs
http://jaredblog.chibipaws.com/ - My Blog
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Jun 13, 2005 12:06 pm    Post subject: Reply with quote

I have just discovered some bad news... This script only works on Intel Pentiums, not AMD chipsets. My Server is an AMD chipset and so is my laptop, thats why it wont work. However this computer I am using now is Intel Pentium 4 and the script works happily.

I'm so disappointed... :( :( :( :( :(
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Mon Jun 13, 2005 12:29 pm    Post subject: Reply with quote

admin wrote:
<?php

if(class_exists("COM")) {
$wmi = new COM("WinMgmts:\\\\.");
$cpus = $wmi->InstancesOf("Win32_Processor");

$i = 1;

// Use the while loop on PHP 4 and foreach on PHP 5
//while ($cpu = $cpus->Next()) {
foreach ($cpus as $cpu) {

echo "<p>Processor $i : " . $cpu->Name . " @ ";
$clockSpeed = $cpu->CurrentClockSpeed;
$cpuLoad = $cpu->LoadPercentage;
echo $clockSpeed . " MHz (Load= " . $cpuLoad ."%)</p>";
$i++;

}

$uptime = 0;
$systems = $wmi->InstancesOf("Win32_PerfRawData_PerfOS_System");

// Use the while loop on PHP 4 and foreach on PHP 5
//while ($system = $systems->Next()) {
foreach ($systems as $system) {

$PerfTimeStamp = $system->Timestamp_Object ;
$PerfTimeFreq = $system->Frequency_Object ;
$Counter = $system->SystemUpTime ;
$UptimeInSec = ($PerfTimeStamp - $Counter)/$PerfTimeFreq ;

$uptime = max($uptime, $UptimeInSec);
}

echo "<p>Your system uptime is: $uptime</p>";
}
else {
return "<p>Your system does not support WMI!</p>";
}
?>


The Inquisitor wrote:
I have just discovered some bad news... This script only works on Intel Pentiums, not AMD chipsets. My Server is an AMD chipset and so is my laptop, thats why it wont work. However this computer I am using now is Intel Pentium 4 and the script works happily.


If your referring to the quoted code, then yes it does work on AMD based systems. It outputs this on mine:
Quote:
Processor 1 : AMD Athlon(TM) XP 1600+ @ 1407 MHz (Load= 8%)

Your system uptime is: 662.7930496

_________________
Olly
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Jun 13, 2005 1:46 pm    Post subject: Reply with quote

Hmmm, OK, I just came to that conclusion because it didnt work on either of my systems but then worked on a pentium system :S
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Goatie.dk
-


Joined: 11 Feb 2005
Posts: 125
Location: Denmark > Herning

PostPosted: Mon Jun 13, 2005 10:38 pm    Post subject: Reply with quote

the script doesn't print out anything... i have php v4.3.10 and i do use the while loop. when i look at the sourcecode it doesnt show anything after the php code
_________________
The insane dane who loves AWS :D
http://home.goatie.dk <- pic = online.. no pic, guess ;P
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed Jun 15, 2005 5:04 am    Post subject: Reply with quote

Goatie.dk wrote:
the script doesn't print out anything... i have php v4.3.10 and i do use the while loop. when i look at the sourcecode it doesnt show anything after the php code


You see the PHP source? o_O
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group