IBM Tivoli Monitoring Version 6.1 Universal Agent Script Data Provider Tips
IBM Tivoli Monitoring Version 6.1 Universal Agent Script Data Provider Tips
1
Universal Agent Script Data Provider
Tips
Brooks York
10th March, 2006
© Copyright International Business Machines Corporation 2006. All rights reserved. US Government
Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM
Corp.
Page: 1
Universal Agent and Script Data Provider Overview
This whitepaper is focused on the script data provider. It assumes some familiarity with
the IBM Tivoli Universal Agent and the concepts associated with this product. A brief
summary of the important concepts needed for understanding of the Universal Agent is
discussed below, but the reader is encouraged to see the IBM Tivoli Universal Agent
User’s Guide (SC32-9459-00) located here:
http://publib.boulder.ibm.com/infocenter/tivihelp/v3r1/index.jsp?topic=/com.ibm.itm.doc
/610uausers.htm
IBM Tivoli Monitoring Universal Agent is a generic agent of IBM Tivoli Monitoring.
This agent achieves its flexibility through a series of interfaces known as data providers.
Table 1 shows the currently available data providers for the Universal Agent.
Page: 2
Socket Listens on a TCP/IP socket for data sent
using program-to-program communication.
Enables you to collect data from remote
devices or machines for which no IBM
Tivoli Universal Agent API support is
available.
The Script Data Provider gathers data by running a script or program at regular intervals
and parsing the output to look for errors and threshold conditions. The Script Data
Provider is the final S in the ASFS data provider that is set by default when the Universal
Agent is installed. Figure 1 shows a high level diagram of the script data provider’s flow.
Figure 1. High Level Script Data Provider Flow
Page: 3
The last component that the Universal Agent needs is a data definition that defines the
structure and the source of data being monitored. This data definition file is called a
metafile and usually carries the .mdl extension.
This can be accomplished by either stopping the Universal Agent, editing this file, and
restarting the Universal Agent or by selecting Reconfigure… on the Manage Tivoli
Enterprise Monitoring Services GUI.
Unix
Verify in the $CANDLEHOME/config/um.ini that KUMA_STARTUP_DP includes
ASFS.
# ='============================================'
# Agent Specific Settings
# ='============================================'
KUMA_STARTUP_DP='ASFS'
This can be accomplished by either stoping the Universal Agent, editing this file, and
restarting the Universal Agent or by running ./itmcmd config –A um from the
$CANDLEHOME/bin directory and supplying an update to the “Data Provider (default
is: xxxx)” prompt.
Page: 4
Figure 2. Sample.pl and Script Output
sample.pl
!#/usr/bin/perl
Figure 3 shows the sample mdl file that will be used to run the sample.pl script. Items in
the mdl file are explained below as well .
Page: 5
//SOURCE SCRIPT c:\perl\bin\perl.exe c:\scripts\Submission\sample.pl Interval=60
o SCRIPT – This value on the SOURCE line tells the Universal Agent that the
Script Data Provider is to be used.
o c:\perl\bin\perl.exe – This is the location of the perl interpreter on the Windows
machine.
o c:\scripts\Submission\sample.pl – This is the script to execute.
o Interval=60 – this is how often the script should run in seconds. If the
Interval=nn parameter is omited, or if it’s set to 0 seconds, then demand-driven
data collection is in effect, which means the script only runs when (1) a
workspace open or refresh is done, or (2) when a situation is being evaluated
against an attribute in the sampleScript attribute group.
//Attributes
o Attributes are defined below this.
Number N 16 @This is just a numeric
o Number – This is the attributes name.
o N – N represents DisplayNumeric. A series of numeric characters. Note that ‘N’
is a string representation of a number and not a true integer from the TEPS and
TEMS standpoint. Therefore, the Number attribute cannot be used in a situation
that performs greater than/less than comparison, nor can it be used in a TEP chart
or graph.
o 16 – 16 is the maximum width of the number.
o @ - The text after the @ represents help text.
Figure 4 shows what the default workspace looks like once this metafile has been
imported.
Page: 6
Figure 4. The Sample Script Default Workspace
Attribute Names.
Name of application
with version (00). Attribute Values.
These values are
from the script.
Attribute group name.
Remember that the sample.pl script prints 1 String\n. The whitespace between each item
on the line is treated as a new attribute and the \n is treated as the end of data from the
script.
Page: 7
Figure 5. A Script with Multiple Lines
Modified Sample.pl
#!/usr/bin/perl
use strict;
my $line;
my @array = (0,1,2,3,4,5,6,7,8,9);
Page: 8
Data from Standard Error and Standard Out
The Script Data Provider only handles those lines that are sent to standard out, not those
sent to standard error. If standard error is desired, it will need to be piped to standard out.
Figure 6 shows a sample of data sent to standard out and standard error.
Modified sample.pl
#!/usr/bin/perl
use strict;
my $line;
my @array = (0,1,2,3,4,5,6,7,8,9);
Page: 9
As can be seen in Figure 7, only those values sent to standard out are shown in the
workspace.
The values printed to standard error are actually logged in the Universal Agent’s log.
Debugging script problems will be discussed in more detail later, but Figure 8 shows the
resulting log entry from our sample above.
Page: 10
Scripts with parameters
The Script Data Provider allows for parameters to be passed to the scripts that it invokes.
This is done by giving the //SOURCE line in the metafile an additional argument. This is
shown in Figure 9.
The Script Data Provider will pass the list of items that are enclosed in quotation marks
and after the script name to the script as input parameters. Hence this script will now
have two arguments passed to it: 1 and argument2. Figure 10 shows the change made to
the script and the resulting update in the default workspace.
Page: 11
Figure 10. Resulting Change for Agument Passing
Change to sample.pl to take input parameters.
#!/usr/bin/perl
use strict;
my $argument1 = $ARGV[0];
my $argument2 = $ARGV[1];
Environments
By default every script launched inherits the environment of the IBM Tivoli Universal
Agent. On Windows this is the Windows Service “LocalSystem” on Unix this is the id of
the user which started the IBM Tivoli Universal Agent. There are instances where these
environments will not do, the Script Data Provider allows for this.
Because many scripts need environment variables set in order to run properly, the Script
Data Provider supports an envfile=xxxx parameter on the //SOURCE SCRIPT statement.
The first time a script is run, the Script Data Provider will read the file specified and set
the execution environment according to the file. On subsequent executions the Script
Data Provider will check this file for changes and reload the changes if needed.
This envfile has the following behavior:
o The envfile must contain a series of variable=value statements, one per line.
Page: 12
o Any environment settings implementd for the child process, such as changes to
the path, have no effect on the parent UA process.
o On UNIX/Linux scripts run with a default PATH of:
usr/bin:/bin:/usr/local/bin:/usr/sbin if no PATH=xxxx is specified in the envfile.
Figure 11 shows a metafile that is used for a basic Perl script that includes several Perl
modules. On the CLI this script works fine, but using the Script Data Provider there are
errors in the log and no data shows up.
//APPL pingservers @This application will ping a list of servers and return up or down
//NAME pingstats K 300 AddTimeStamp
//SOURCE SCRIPT c:\perl\bin\perl.exe c:\scripts\perlPing.pl "c:\scripts\ips.txt"
Interval=60
//Attributes
IpAddress D 24 @This is the ip or hostname, the first item in the file passed in
ServerType @This is the server type, also the second item in the file pased in
Status D 16 @up or down depending on if the host is reachable
Windows/Unix
set > env.dat
Page: 13
Figure 12. Corrected Metafile With Environment
//APPL pingservers @This application will ping a list of servers and return up or down
//NAME pingstats K 300 AddTimeStamp
//SOURCE SCRIPT c:\perl\bin\perl.exe c:\scripts\perlPing.pl "c:\scripts\ips.txt"
envfile=c:\scripts\env.dat Interval=60
//Attributes
IpAddress D 24 @This is the ip or hostname, the first item in the file passed in
ServerType @This is the server type, also the second item in the file pased in
Status D 16 @up or down depending on if the host is reachable
PreviousValue (GetEnvValue = PREV_VALUE)
Where:
LocalHostname
The host where the IBM Tivoli Universal Agent is running.
ApplName
The name value specified on the metafile //APPL statement.
VV
The two-digit version suffix.
Using this parameter when there is only one script is optional, however if multiple
//SOURCE lines exit that define several scripts which have the same attribute group
this parameter should be used. This ensures that data is collected properly from the
two scripts.
Figure 13 shows a sample metafile along with an explanation of the changes made and
the resulting view of the workspace.
Page: 14
Figure 13. Adding ManagedSystemName to the Metafile
Page: 15
Other Parameters
The Script Data Provider has several ways to include values that are not necessarily from
the script.
Add AddTimeStamp to the //NAME statement and the LocalTimeStamp column
will be automatically inserted into the workspace.
An Environment Value may be inserted into the workspace by calling GetEnvValue.
Some generated environment values exist for compatibility with IBM Tivoli
Distributed Monitoring. Table 2 shows these values.
Figure 14 shows a metafile that uses some of these values, the script, and the output to
the workspace.
Page: 16
Figure 14. Adding Pre-defined Parameters
random.mdl
random.pl
#!/usr/bin/perl
use strict;
my $argument1 = $ARGV[0];
my $random;
$random = int(rand($argument1));
print "$random\n";
Page: 17
Note the following about these fields:
Unix/Linux
o To setuid to a different user the UA must have been started as root.
o Only the USER=xxxx is used. Root can setuid without a password.
Windows
o If a USER=xxxx is specified a PSWD=yyyy must be specified.
These values are not encrypted in the metafiles.
Debugging Problems
At some point it will be necessary to look at the Universal Agent’s logs to try and debug
a problem. These logs are located in the following location:
Windows and Unix
$CANDLE_HOME\tmaitm6\logs\hostname_um_timestamp.log
Unix
$CANDLEHOME/logs/hostname_um_timestamp.log
Below is a discussion on what can be seen in the log file with KBB_RAS1=ERROR and
KUMP_SCRIPT_DEBUG=Y.
Successful Execution
Here is an example of a script that ran successfully.
Page: 18
(4410B37F.0000-C34:kumpscrp.c,224,"KUMP_ScriptServer") Script source
<c:\scripts\Submission\random.pl> table <randomScript> is now online to the data provider This is the
… output of the
(4410B37F.0006-C34:kumplscr.c,470,"KUMP_LaunchScript") Constructed command line script.
<c:\perl\bin\perl.exe c:\scripts\Submission\random.pl 50>
(4410B37F.0007-C34:kumppsef.c,250,"KUMP_ProcessScriptEnvFile") No script environment file
specified for table <randomScript> SEptr @1D83970
…
(4410B380.001B-C34:kumplscr.c,1480,"KUMP_LaunchScript") DM Data Line: 33
(4410B380.001C-C34:kumplscr.c,1496,"KUMP_LaunchScript") Freeing DM style processing buffer
@1DDDDB8
(4410B380.001D-C34:kumpscrp.c,405,"KUMP_ScriptServer") Calculating elapsedTime from
ScriptStopTime 1141945217 and ScriptStartTime 1141945216
(4410B380.001E-C34:kumpscrp.c,408,"KUMP_ScriptServer") Script completed in 1 second(s)
(4410B380.001F-C34:kumpscrp.c,304,"KUMP_ScriptServer") >>>>>Waiting 59 seconds until next
script launch interval for table <randomScript>
Other Notes
All examples used in this document were in Perl, but the Script Data Provider is
capable of working with any application that writes data to standard out, this
includes perl, sh, ksh, java, or any executable program.
Page: 20
Notices
IBM can have patents or pending patent applications covering subject matter described in
this document. The furnishing of this document does not give you any license to these
patents. You can send license inquiries, in writing, to:
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
The following paragraph does not apply to the United Kingdom or any other country
where such provisions are inconsistent with local law:
Any references in this information to non-IBM Web sites are provided for convenience
only and do not in any manner serve as an endorsement of those Web sites.
The materials at those Web sites are not part of the materials for this IBM product and
use of those Web sites is at your own risk.
IBM can use or distribute any of the information you supply in any way it believes
appropriate without incurring any obligation to you.
Page: 21
Licensees of this program who wish to have information about it for the purpose of
enabling: (i) the exchange of information between independently created programs and
other programs (including this one) and (ii) the mutual use of the information which has
been exchanged, should contact:
IBM Corporation
2Z4A/101
11400 Burnet Road
Austin, TX 78758 U.S.A.
Such information can be available, subject to appropriate terms and conditions, including
in some cases payment of a fee.
The licensed program described in this document and all licensed material available for it
are provided by IBM International Program License Agreement or any equivalent
agreement between us.
This information contains examples of data and reports used in daily business operations.
To illustrate them as completely as possible, the examples include the names of
individuals, companies, brands, and products. All of these names are fictitious and any
similarity to the names and addresses used by an actual business enterprise is entirely
coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which
illustrate programming techniques on various operating systems. You can copy, modify,
and distribute these sample programs in any form without payment to IBM, for the
purposes of developing, using, marketing or distributing application programs
conforming to the application programming interface for the operating system for which
the sample programs are written. These examples have not been thoroughly tested under
all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or
function of these programs. You can copy, modify, and distribute these sample programs
in any form without payment to IBM for the purposes of developing, using, marketing, or
distributing application programs conforming to IBM's application programming
interfaces.
If you are viewing this information in softcopy form, the photographs and color
illustrations might not Web.
Trademarks
IBM, the IBM logo, IBM Redbooks, Tivoli, and the Tivoli logo are trademarks or
registered trademarks of International Business Machines Corporation in the United
States, other countries, or both.
Page: 22
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the
United States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft
Corporation in the United States, other countries, or both.
Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo,
Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered
trademarks of Intel Corporation or its subsidiaries in the United States and other
countries.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, and service names may be trademarks or service marks of
others.
Page: 23