Thursday, November 7, 2013

Script to read any Windows Event/Application Log

Awhile back there was a discussion on the TME10 list about reading a custom application event log that a developer is using. The out of the box problem is that the ITM agents don't allow you to specify a log to look at, it only looks at the basic Windows logs. The ultimate solution is to write a script to grad the data.
So here is a simple PERL script that will read all messages from all Windows event/application logs. With a little tweaking, it can be used to feed a Universal Agent that will report to ITM based on Event number or LogFile name.

use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my @computers = ("localhost");
foreach my $computer (@computers) {
print "";
print "==========================================";
print "Computer: $computer";
print "==========================================";

my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_NTLogEventLog", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems) {
print "Log: $objItem->{Log}";
print "Record: $objItem->{Record}";
print "";
}
}

Sample Emailing Script

 

Here is a simple custom emailing script using Perl. You need to install Mail::Sendmail module from CPAN to get it to work. You also need to change the values of $mailhost and $from field values.

Here is a typical usage of this program.

/itm_email.pl somebody@email.com "Sample Subject" "Sample message body"


#!/usr/bin/perl

# Send emails via this platform independent module
use Mail::Sendmail;

main();

sub main {
my ($to, $subject, $message) = @ARGV;
send_email($to, $subject, $message);
}

# Sends email using Mail::Sendmail module
sub send_email {
my ($to, $subject, $message) = @_;
my ($mailhost, $from, %mail, @to);

$mailhost = "smtp.mydomain.com";
$from = "itm_alerts\@mydomain.com";

%mail = (
Smtp => $mailhost,
From => $from,
To => $to,
Subject => $subject,
Message => $message,
);
sendmail(%mail);
}

Tuesday, November 5, 2013

Collecting diagnostic data for troubleshooting ITNM issues

http://www-01.ibm.com/support/docview.wss?uid=swg21653437

Technote (FAQ)

Question

Would you like a tool that automates the collection of troubleshooting data for ITNM, instead of manually trying to find, format, group, and collect what Support needs to remotely diagnose your problem ?

Answer

This is the MustGather document for the IBM Tivoli Network Manager IP(ITNM) product, including the TIP and TCR. The attached "itnm_data.pl" utility knows how to format and collect the data files that IBM Support need in order to diagnose problems with the ITNM product.

Introduction to itnm_data.pl

The itnm_data.pl utility was created to assist you with gathering the information necessary to troubleshoot IBM Tivoli Network Manager issues.

This utility may capture the following information, based on the collection type:
Environmental(OS, ulimits)
Version information
Logs and traces(ITNM/TIP/TCR as necessary)
Configuration files
Disco agents/stitchers
Poller status/targets/policies
Disco/Model cache
Network Views

Instructions for Use

There are two types of command line flags that will affect what is collected via itnm_data.pl. The first type of flags are used to indicate what kind of collection is being done. You can only use one collection type per run.

These are:
-e Reporting(BIRT/Cognos)
-d Discovery
-i Install
-p Polling
-t ITM Agent
-r RCA
-g GUI(TIP)
-dc Disco Cache
-mc Model Cache

The next set of flags will make certain modifications to the data being collected:
-o output directory(/tmp by default)
-x skip $NCHOME/log/precision directory
-c collect core files(could be large)
-f automatically FTP the file to IBM(-pmr required)
-pmr PMR Number(in xxxxx,xxx,xxx format, used to name output file)

To run the script use:

ncp_perl $NCHOME/precision/scripts/perl/scripts/itnm_data.pl -domain DOMAINNAME


followed by the appropriate flags as documented above.

Providing the data to IBM

You can automatically send the data to IBM, if your machine has external(Internet) access, by using the -f and -pmr flags. Otherwise, you can use your normal method or the customer portal to upload the data once the file is created. At the end of the script run, it will alert you to where the file exists.

Downloading the itnm_data.pl package

IBM's recommended browser is Firefox. It is therefore recommended that you use Firefox to download the attached tar file. Chrome has also been tested with success.

WARNING: Experience has shown that Internet Explorer (IE) can corrupt the tar file during its download process, though this may depend on the version of IE being used ... sorry, no IE version details available.

Ensure you always FTP the tar package using binary mode. Un-tar on the system where it is to be used, preferably in the $NCHOME/precision/scripts/perl/scripts directory.

Click on the following icon link to download the latest version (v1.0.1) of the itnm_data.pl utility: