Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed Jan 17, 2018 3:54 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [HOWTO] Using WMI in PERL (Scripts for Remote computers)
PostPosted: Thu Dec 16, 2004 7:39 am 
Cacti User
User avatar

Joined: Thu Nov 18, 2004 5:25 am
Posts: 60
Location: Hyderabad, India
I found many scripts contibuted by Devilsun for windows platform
I have tested all of his scripts which are running perfect in windows 2003
(Scripts for IIS, SQL Server)

[If you have problem querying sql server in local computer itself (using wmi, see links below]
This tips are for thosee members who are facing problem using the script to query remote computer. And only for those members who are able to sucessfully querying LOCALMACHINE

I am not going to explain anyting in detail, (coz every thing is new to me, right from the cacti,php,perl,wmi)

So this is the quick solution for those who want to test it for the remote computer.

I have added all new variables, assigned
#name space
    my $wmipath  = "root\\cimv2";
    my $user     = "mydomain\\adminuser";
   my $pwd      = "dumpass";

#New variable again to hold the instance of swbemlocator
   my $wmiwebloc = Win32::OLE->new('WbemScripting.SWbemLocator') ||
           die "Cannot access WMI on local machine: ", Win32::OLE->LastError;

#old way of creating $wmi object
#no need of $class
   my $class = "WinMgmts://$computer";
   my $wmi = Win32::OLE->GetObject($class);

#new way which works for both the local and remote computer
#only host name is compulsary
   my $wmi = $wmiwebloc->ConnectServer($computer,$wmipath,$user,$pwd);

As I said, I am very new, so I am looking for Devilsun and others to optimise code and make it more configurable and customisable

This are the links which helped me solving the problem querying SQL server 2000 (in both, local and remote) ... -us;820847 ... -us;827260

connecting to remote computer ... mputer.asp

File comment: Just replace hard coded credential parameters with yours [6.29 KiB]
Downloaded 1276 times

Why me lord?
 Post subject:
PostPosted: Thu Dec 16, 2004 1:11 pm 
Cacti User

Joined: Fri Jul 16, 2004 1:59 pm
Posts: 166
Location: Oregon
Very nice, and good job getting that to work off the links I sent you...I figured all it would take is just some messing with to get it to work. :D

I'm a little busy at the moment, but gimme a little bit and I'll work with it a little bit, been real busy here at work and enjoy my free time ;) I'm working with a set of new scripts that are a little bit cleaner, and doing some performance tests as well using native windows scripting.

 Post subject:
PostPosted: Sat Apr 18, 2009 12:46 pm 

Joined: Sat Apr 18, 2009 12:45 pm
Posts: 1

Can i use this to pun a batch file on remote machine .

or can i use this to run a .exe on remote machine


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 1 guest

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 post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group