WMI outside of domain

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
User avatar
Diggit2001
Cacti User
Posts: 195
Joined: Tue May 03, 2005 4:29 pm
Location: MD, US

WMI outside of domain

Post by Diggit2001 »

Hello there. I have a fully functional Cacti 0.8.6g install loaded on Windows XP with IIS. I am querying several servers using WMI/SNMP. I have a few servers that, for several reasons, can't be members of the domain. My SNMP stuff like CPU usage, logged in users, processes and NIC traffic are all working fine, but the two graphs that use WMI; memory usage and hard drive space, are not working at all. I am guessing that this is because these servers are in a workgroup instead of the domain. I am just wondering if there is a way to graph WMI stuff on servers that are not members of the domain, if that it is indeed my problem.

Thanks advance for any ideas anyone can lend.

-Chris
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

I think it's possible. You would have to modify your WMI script and then pass in the username/password you would use on the remote host. Then, you could specify a lcoal username for the machines not on the domain.
User avatar
Diggit2001
Cacti User
Posts: 195
Joined: Tue May 03, 2005 4:29 pm
Location: MD, US

Post by Diggit2001 »

Yikes. I think that's a little over my head. I'm more of a network geek than a programming geek. Can you kinda point me in the right direction towards an easy way to accomplish this?

Thanks
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Here is how you would modify the script: http://www.microsoft.com/technet/script ... y1213.mspx
africanw
Cacti User
Posts: 130
Joined: Thu Mar 31, 2005 4:24 pm
Location: Sydney, Asutralia
Contact:

Post by africanw »

Heres some example code (VBSCRIPT) on how to do it --

Networkusername=""
Networkpassword=""
Hostname=WScript.Arguments.Item(0)
Instance=WScript.Arguments.Item(1)
OStype=WScript.Arguments.Item(2)

If Hostname="." Or Hostname="localhost" Then

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& Hostname & "\root\cimv2")

If OStype="2000" Then
Set colProcesses = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PerfRawData_W3SVC_WebService" )
ElseIf OStype="2003" Then
Set colProcesses = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PerfFormattedData_W3SVC_WebService" )
End If


Else

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(Hostname, _
"root\CIMV2", _
Networkusername, _
Networkpassword, _
"MS_409", _
"NTLMDomain:" + Hostname)

If OStype="2000" Then
Set colProcesses = _
objSWbemServices.ExecQuery("SELECT * FROM Win32_PerfRawData_W3SVC_WebService")
ElseIf OStype="2003" Then
Set colProcesses = _
objSWbemServices.ExecQuery("SELECT * FROM Win32_PerfFormattedData_W3SVC_WebService")
End If
End If

CurrentConnectionsCount=0
CurrentAnonymousUsersCount=0
CurrentNonAnonymousUsersCount=0

For Each objProcess in colProcesses

CurrentConnections = objProcess.CurrentConnections
CurrentAnonymousUsers = objProcess.CurrentAnonymousUsers
CurrentNonAnonymousUsers = objProcess.CurrentNonAnonymousUsers

CurrentConnectionsCount=CurrentConnectionsCount+CurrentConnections
CurrentAnonymousUsersCount=CurrentAnonymousUsersCount+CurrentAnonymousUsers
CurrentNonAnonymousUsersCount=CurrentNonAnonymousUsersCount+CurrentNonAnonymousUsers

Next

Wscript.Echo "CurrentConnections:" & CurrentConnectionsCount & " CurrentAnonymousUsers:" & CurrentAnonymousUsersCount & " CurrentNonAnonymousUsers:" & CurrentNonAnonymousUsersCount
User avatar
Diggit2001
Cacti User
Posts: 195
Joined: Tue May 03, 2005 4:29 pm
Location: MD, US

Post by Diggit2001 »

Thanks very much for the input. Anyone have any idea how to do this with perl?
User avatar
Diggit2001
Cacti User
Posts: 195
Joined: Tue May 03, 2005 4:29 pm
Location: MD, US

Post by Diggit2001 »

OK, I got it. If anyone else is interested, here's the code I used:

my $wmipath = "root\\cimv2";
my $user = "username";
my $pwd = "password";

my $wmiwebloc = Win32::OLE->new('WbemScripting.SWbemLocator') ||
die "Cannot access WMI on local machine: ", Win32::OLE->LastError;
my $wmi = $wmiwebloc->ConnectServer($computer,$wmipath,$user,$pwd);
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests