Joe Jenkins
asked on
Show Server Load on ASP Page...
I need to be able to show the server load on an ASP page so I can get a snapshot of what the server load is like at that given page load. Graphically would be AWESOME, but I'll take text percentages any day. I could put them in the header showing each CPU and it's load average.
Is this something fairly easily obtained? I'm monitoring the load on a large inventory application that's in beta right now and this data would be very useful to me.
Joe
Is this something fairly easily obtained? I'm monitoring the load on a large inventory application that's in beta right now and this data would be very useful to me.
Joe
ASKER
Interesting idea but I'm getting a permissions error when I run it.
Output:
error '80041003'
/fsa/test2.asp, line 3
Line3:
Set objWMIService = GetObject("winmgmts:\\loca lhost\root \cimv2")
My understanding of WMI is that I'll need to have an administrator account logged in to have this work. How would that work on a website admin panel where it's using an anonymous account? Can you impersonate a user account on the server? If so, this will work beautifully.
Joe
Output:
error '80041003'
/fsa/test2.asp, line 3
Line3:
Set objWMIService = GetObject("winmgmts:\\loca
My understanding of WMI is that I'll need to have an administrator account logged in to have this work. How would that work on a website admin panel where it's using an anonymous account? Can you impersonate a user account on the server? If so, this will work beautifully.
Joe
You'll have to set that up in IIS
To do that load the IIS management module
Click the website that contains the file where you stored this script
Right click on the file and click properties
Click the file security tab
Click edit in the Authentication and access control frame
Make sure the "Enable Anonymous access" check box is checked
Put in the username and password for an administrative account on the computer
Keep in mind that this is potentially dangerous. If you add anything else to this script take extra precautions to ensure there are no security holes in it.
To do that load the IIS management module
Click the website that contains the file where you stored this script
Right click on the file and click properties
Click the file security tab
Click edit in the Authentication and access control frame
Make sure the "Enable Anonymous access" check box is checked
Put in the username and password for an administrative account on the computer
Keep in mind that this is potentially dangerous. If you add anything else to this script take extra precautions to ensure there are no security holes in it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oooooo, that'll fit nicely on the page with all the other system statistics, thank you!
One more quick thing, for integration into my bar along the top if you're logged in as our sysadmins.
Now, if I wanted to just show it in a format like:
Load: 0.40, 0, 0.45, 0
I could do:
Dim CPU_Count
Set objWMIService = GetObject("winmgmts:\\loca lhost\root \cimv2")
Set colItems = objWMIService.ExecQuery("S elect * from Win32_Processor")
For Each objItem In colItems
CPU_Count = CPU_Count + 1
Response.Write "Load: " & objItem.LoadPercentage / 100 & ", "
Next
Excellent. :) Thanks again!
Joe Jenkins
One more quick thing, for integration into my bar along the top if you're logged in as our sysadmins.
Now, if I wanted to just show it in a format like:
Load: 0.40, 0, 0.45, 0
I could do:
Dim CPU_Count
Set objWMIService = GetObject("winmgmts:\\loca
Set colItems = objWMIService.ExecQuery("S
For Each objItem In colItems
CPU_Count = CPU_Count + 1
Response.Write "Load: " & objItem.LoadPercentage / 100 & ", "
Next
Excellent. :) Thanks again!
Joe Jenkins
Dim CPU_Count
Set objWMIService = GetObject("winmgmts:\\loca
Set colItems = objWMIService.ExecQuery("S
For Each objItem In colItems
CPU_Count = CPU_Count + 1
Response.Write "CPU " & CPU_Count & ": <br><ul>"
Response.Write "Load Percentage: " & objItem.LoadPercentage & "</ul>"
Next
There's a bunch of other information you can retrieve from the objItem object. Take a look at this page:
http://www-sharp.com/articles/HardwareInfo.php