03-05-2007 02:19 PM
We have several systems which have all devices configured in them, one of which is CiscoWorks. In our enviromnet our DNS is considered the master list of devices that are being managed.
I am writing a script which queries the DNS to get a list of all devices and their IP addresses, and I would like to query CiscoWorks and get a list of all devices and their management IP addresses.
The script will be run from a remote server (as far as CiscoWorks is concerned).
I can use the CW servlet, rme/cwcli, to extract information, eg
cwtest.pl http://server:1741/rme/cwcli cwtest.file
wher cwtest.file contains
<payload>
<command>
cwcli export inventory -u username -p password -ipaddress 192.168.24.12
</command>
</payload>
This returns XML formatted info on this device.
What is missing from this information is the management IP address for this device.
Ideally I want to extract information using the -view option for all devices, but if I cant get the management IP address it makes life a bit trickier.
I am wondering if I am using the wrong command, ie something other than cwcli export inventory.
Can anyone tell me how to get the management IP address for a device using this method?
Regards
Jeff
03-05-2007 02:44 PM
You want to get the DCR information from this device using the Device List Manipulation Service. See http://server/help/rme/fundamentals/device_GettingIPAddress.html for more details.
03-05-2007 08:28 PM
Thanks. This looks promising. I havent been able to test this fully yet as I am using PERL and I am getting a few errors which obviously relate to modules which I havent installed, or installed properly.
03-11-2007 08:13 PM
This might be a little bit off topic, but I cant get this to work using my PERL script as I keep getting the following error:
Can't locate auto/Compress/Zlib/autosplit.ix in @INC (@INC contains: /usr/local/OV/perl/lib /opt/OV/bin/Perl/lib/perl5/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl .) at /opt/OV/bin/Perl/lib/perl5/5.6.0/AutoLoader.pm line 133,
at /usr/local/OV/perl/lib/Compress/Zlib.pm line 6
CWTEST2: After getting response to request...
Response: 500 Can't locate loadable object for module HTML::Parser in @INC (@INC contains: /usr/local/OV/perl/lib /opt/OV/bin/Perl/lib/perl5/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl .)
500 Can't locate loadable object for module HTML::Parser in @INC (@INC contains: /usr/local/OV/perl/lib /opt/OV/bin/Perl/lib/perl5/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl .)
I am tyring to get this to work on a Solaris 9 platform, which is used to run HP NNM and I am using the version of PERL which comes with NNM (5.6.1). It is not connected directly to Internet and does not have much in the way of compilers etc, so I have been manually downloading what I think are the required libraries and copying the files in the lib directories to the appropriate /usr/local/OV/perl/lib directory, which I use as my site libary directory. I have done this sort of thing in the past with other libraries, eg Net-IP and Net-DNS and all works well.
I started off loading the libwww-perl-5.805 libraries so I could use the use LWP::UserAgent command required to interface with the Device List Manipulation Service, but then there were all the prerequisite libraries....
I have downloaded the following libraries from CPAN, but I cannot find any reference to this autosplit.ix file. (In alphabetical order)
Compress-Raw-Zlib-2.004
Compress-Zlib-2.004
Digest-MD5-2.36
HTML-Parser-3.56
HTML-Tagset-3.10
IO-Compress-Base-2.004
IO-Compress-Zlib-2.004
libwww-perl-5.805
Net-Libnet-0.01_03
MIME-Base64-3.07
URI-1.35
I confess my understanding of PERL is not an expert level. I learn enough to get me by as it is not my focus, so if anyone can tell me what bit I am missing it would be most appreciated.
03-11-2007 10:23 PM
You're missing parts of the Compress::Zlib module. The package list contents should be:
SITE_PERL/Compress/Zlib.pm
SITE_PERL/auto/Compress/Zlib/autosplit.ix
SITE_PERL/mach/auto/Compress/Zlib/.packlist
The autosplit.ix file should contain:
# Index created by AutoSplit for blib/lib/Compress/Zlib.pm
# (file acts as timestamp)
1;
However, you really should use NMSROOT/bin/perl. While currently a bit older, it has all the necessary modules to interface with LMS using both HTTP and HTTPS.
03-12-2007 03:25 PM
Believe me I really would like to use the NMSROOT/bin/perl but these modules arent in it. My methodology in installing the modules has an inherent flaw in it me thinks.
Having created the file with the contents specified, I have now moved on to the next problem which is:
Can't locate HTML/Parser.pm in @INC (@INC contains: /usr/local/OV/perl/lib /opt/OV/bin/Perl/lib/perl5/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0/sun4-solaris /opt/OV/bin/Perl/lib/perl5/site_perl/5.6.0 /opt/OV/bin/Perl/lib/perl5/site_perl .) at ./cwtest2.ovpl line 5.
where the file starts with:
#!/opt/OV/bin/Perl/bin/perl
use lib '/usr/local/OV/perl/lib';
use HTML::Parser;
use LWP::UserAgent;
Doing a quick scan on the Internet I find references to requiring a file called auto/HTML/Parser/Parser.so, which surprisingly enough I dont have. It looks to me like this is supposed to be created when doing a make on the library. I am not doing this but copying the files from the distribution. The distribution doesnt have it so I am stuck.
I will keep looking, but if anyone has any ideas that would be great.
03-12-2007 03:42 PM
Which modules are missing from CiscoWorks' Perl? It has HTML::Parser. It has LWP. I have used it to interface with DLMS successfully.
However, it looks like you are now missing HTML::Parser from your @INC path. The package list from HTML parser (which includes compiled code) should be:
SITE_PERL/sun4-solaris/HTML/Entities.pm
SITE_PERL/sun4-solaris/HTML/Filter.pm
SITE_PERL/sun4-solaris/HTML/HeadParser.pm
SITE_PERL/sun4-solaris/HTML/LinkExtor.pm
SITE_PERL/sun4-solaris/HTML/Parser.pm
SITE_PERL/sun4-solaris/HTML/PullParser.pm
SITE_PERL/sun4-solaris/HTML/TokeParser.pm
SITE_PERL/sun4-solaris/HTML/auto/HTML/Parser/.packlist
SITE_PERL/sun4-solaris/HTML/auto/HTML/Parser/Parser.bs
SITE_PERL/sun4-solaris/HTML/auto/HTML/Parser/Parser.so
Since this module contains compiled code, you WILL need to compile it for Solaris to produce the shared object. Again, CiscoWorks' Perl should have everything you need for interfacing with DLMS.
03-12-2007 07:08 PM
Aha. I think we are at cross purposes here. I am running PERL from our HP NNM server (Solaris), and trying to talk to our CiscoWorks servers wunning on Windows. As such I dont have the CiscoWorks PERL installed on our SOlaris box.
I am talking to our Unix people to see what is involved in getting the compiler put onto the server, as I see this the only way forward.
Thanks for your help.
03-12-2007 08:59 PM
Ah, I completely misunderstood. If you're looking for an easy way to get and maintain pre-compiled Solaris packages, I use Blastwave (http://www.blastwave.org) on all of my Solaris servers. This allows me to install all of the development and troubleshooting tools I need for CiscoWorks without the hassle of having to track down dependencies myself.
03-22-2007 03:33 PM
I have been given access to another Solaris box with a compiler on it and have now happily, and I think successfully, got all the modules I need to get the LWP::UserAgent module working. Yeehah.
I now run my test script and get the following message:
Failure: LWP will support https URLs if the Crypt::SSLeay module is installed.
I presume this is occuring a) because I dont have this module installed, and b) because CW uses SSL when authenticating.
Looking at the README for this module, it looks like I have to install the OpenSSL package. DO you know if this is correct?
03-22-2007 05:00 PM
What URL are you using? If LMS is configured for HTTP (e.g. you go to 1741 for access) you should not need crypto as the DLMS interface does not go through the regular authentication channels. However, if your server is confgiured for HTTPS access, you will need crypto support which means SSLeay which means OpenSSL.
03-22-2007 07:18 PM
Our CiscoWorks servers are set up to use port 1741, http.
That is good news that I dont need the SSLeay.
Is there any logs that I can view to see my connection attempts and other access attempts? I cant see anything useful in the logs, so maybe there is some debug level I need to change.
03-22-2007 07:32 PM
Aha!! I went back and compared my script with the sample from the doc you referred me to earlier. I noticed that I had changed the http command from POST to GET as part of my trying to get things working.
After changing that and a typo in my URL string I now get...
CWTEST2: URL to use: http://cwserver:1741/rme/com.cisco.nm.rmeng.inventory.servlet.DeviceListService
CWTEST2: After UA assignment...
CWTEST2: After request assignment...
CWTEST2: After getting response to request...
CWTEST2: Status: 500 Internal Server Error
Failure:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at com.cisco.nm.rmeng.inventory.servlet.DeviceListService.doGet(DeviceListService.java:199)
...
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:576)
at java.lang.Thread.run(Thread.java:534)
Not sure if there is much hope... :-(
03-22-2007 08:48 PM
Without seeing your code, it's impossible to know for sure, but this error makes it seem like you are not uploading the XML source file correctly. A while back, I wrote a tool called DevExp which worked with DLMS in RME 3.1 and higher. I have just adapted it for RME 4.0 (attached). It works, and should give you a good Perl example of how this should work. The code is BSD licensed.
03-22-2007 09:47 PM
I have modified your script slightly to output the IP addresses and it all works!!!
Many thanks for your patience and script.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide