Hello. I've been searching around for a script to display server load for my Windows server hosted here, but I can only find scripts that will work on Unix systems. The one I've found that's supposed to work on Windows server gives me an error:
Warning: (null)(): Invalid ProgID, GUID string, or Moniker: No description available in C:\Inetpub\vhosts\user\httpdocs\windowsuptime.p hp on line 8
PHP has encountered an Access Violation at 01C3E3F8
This is the souce code:
Can anyone help make this work or suggest another solution to show the Windows server load on a page??Code:<?php // PHP 5 header("Content-type: image/png"); function getServerLoad(){ $wmi = new COM("Winmgmts://"); $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor"); foreach($server as $cpu){ return $cpu->loadpercentage; } } $load = getServerLoad(); $img = @imagecreate(107, 12) or die("Server ondersteunt geen GD library..."); $background_color = imagecolorallocate($img, 255, 255, 255); $border_color = imagecolorallocate($img, 197, 197, 197); $procent = imagecolorallocate($img, 0, 0, 0); if($load < 33){ $load_color = imagecolorallocate($img, 149, 191, 77); // Green }elseif($load >= 33 && $load < 66){ $load_color = imagecolorallocate($img, 213, 184, 55); // Orange }else{ $load_color = imagecolorallocate($img, 186, 83, 83); // Red } imagerectangle($img, 0, 0, 106, 11, $border_color); imagefilledrectangle($img, 3, 3, 3 + $load, 8, $load_color); imagestring($img, 1, 50, 2, $load . "%", $procent); // Create Image imagepng($img); imagedestroy($img); ?>
Thanks in advance for any help.

HostDime Brazil
HostDime Mexico
HostDime Israel
HostDime Colombia
HostDime India
HostDime UK
Reply With Quote
