Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To sample customized metrics, InformPoint must be installed on the sampled instance server. In the case of a remote SQL server instance, the InformPoint that samples the instance is the one installed on the remote SQL server collector.

Creating customized executable files

A customized metric can be associated with a host script that you create, so that Alerts operatively monitors a parameter specific to your environment.

Save the host script in the server machine where the sampled instance is running, in the directory:

<i3<i3_root>root>\products\pulse\userprograms.

Although the root directory of the running script is <i3<i3_root>root>, the program runs from the userprograms directory.

To simulate a run of customized metric, use a command line shell and type from the Precise root directory:

For Windows operating

...

systems    .\products\pulse\userprograms\MYPROG.bat.

For UNIX or Linux operating systems

...

    ./products/pulse/userprograms/MYPROG.sh.

You can create a customized metric that returns a single value or a list of values. A customized metric that returns a single value is created by apply the following guidelines:•    The

  • The script must return a single value to the Standard Output (echo command). The type of the value must be numeric or float. Alerts compares this value to the customized metric thresholds to determine the metric alert status.

...

  • The script must output only the value. To avoid that commands be printed, Windows scripts must start with @echo off. UNIX scripts must start with the shell type, for example #!/bin/ksh.

...

  • You can use dynamic parameters for customized metrics in the command line.

See Using dynamic parameters in customized metrics.

A customized metric that returns a table with multiple values is created by apply the following guidelines:•    The

  • The script must return a list of values to the Standard Output (echo command). Each line in the output must contain a name and a value separated by a tab (\t only, not a space). The value must be numeric or float. Alerts compares these values to the customized metric thresholds to determine the metric alert status.

...

  • The script must output only the value. To avoid that commands be printed, Windows scripts must start with @echo off. UNIX scripts must start with the shell type, for example  #!/bin/ksh.

...

  • In some operating systems, the tab character may be ignored when printing it using the echo command. In those cases, use the ' character around the text, as follows:  echo 'Alerts 80'.

You can use dynamic parameters for customized metrics in the command line.  See Using dynamic parameters in customized metrics.

Info

...

It is recommended to test your scripts in your environment before running them through Alerts. For UNIX scripts, verify that the script has rx security permissions.

Windows script examples

The examples for Windows scripts, whose file names end with _example, are listed in the following tables. These files can be found also in any server where InformPoint is installed, in the directory:

<i3<i3_root>root>\products\pulse\userprograms

The table below shows an example of customized metrics with a single value.

Table 16-9    Example 9 Example of customized metrics with a single value - Windows

Script fileScript

...

linesDescription
simple_example.

...

bat@ECHO OFF ECHO

...

<value>This script returns a constant value that creates a straight line graph.
simple2_example.

...

bat@ECHO OFF

<program_run_command> ECHO

...

%ERRORLEVEL%This script indicates whether or not a certain program is running. The script returns 0 if the program runs with no errors, and n>0 if errors occurred. You can set Near-Critical threshold to 1 to alert each time the program fails.

The table below shows an example of customized metrics with multiple values.

Table 16-10    Example 10 Example of customized metrics with multiple values (table type) — Windows

Script fileScript

...

linesDescription
table_example.

...

bat

@ECHO OFF
ECHO Demo 0
ECHO Demo2 1

ECHO Demo3

...

2This script returns a list of items including their values for each sample. A tab character (not space) separates between the item name and the item value.

UNIX/Linux shell script examples

The examples for UNIX/Linux shell scripts, which their file names end with _example, are listed in the following tables. These files can be found also in any server where InformPoint is installed, in the directory:

<i3<i3_root>root>/products/pulse/userprograms.

The table below shows an example of customized metrics with a single value for UNIX or Linux scripts.

Table 16-11    Examples 11 Examples of customized metrics with a single value (UNIX/Linux)

Script

...

fileScript linesDescription
simple_example.

...

sh#!/bin/ksh
echo

...

<value>This script returns a constant value that creates a straight line graph.
simple2_example.

...

sh

#!/bin/ksh
if
test -e test.txt
then
cat test.txt | wc -c
else

echo 0

...


fi
This script counts the number of characters of a specified text file. For example, you can set the metric thresholds to alert when the file size exceeds a certain size.

The table below shows an example of customized metrics with multiple values (table type) for UNIX or Linux scripts.

Table 16-12    Example 12 Example of customized metrics with multiple values (table type) - UNIX/Linux

Script fileScript

...

linesDescription
table_example.

...

bat#!/bin/ksh
echo 'Demo 0'
echo 'Demo2 1'
echo 'Demo3 2'

...

This script returns a list of items including their values for each sample. A tab character (not space) separates between the item name and the item value.

...

Creating customized stored procedures

To monitor a parameter specific to Oracle or SQL Server AppTiers, you can create a stored procedure and connect it to a customized metric of Alerts. The type of your stored procedure, Oracle or MS-SQL, must be according to your PMDB type.

In addition, the stored procedure can be defined only in Oracle or SQL Server AppTier instances. To create Oracle stored procedure metrics, you must install the Precise for Oracle FocalPoint with at least one instance. To create MS-SQL stored procedure metrics, you must install the Precise for SQL Server FocalPoint with at least one instance.

Creating MS-SQL stored procedures

When creating a stored procedure in MS-SQL, apply the following guidelines:

To create MS-SQL stored procedures1.    Connect

  1. Connect to the database as Precise for SQL Server user.

...

  1. Ensure that the name of the stored procedure includes the database name. For Oracle users, the procedure name must not end with a semicolon (;).

...

  1. The naming convention for the program in Alerts must be:  databaseName..

...

  1. Procedure().

...

  1. Verify that the return value of the execution is a single numeric value (integer).

    Info

...

  1. You can use any procedure and an unlimited number of parameters, including no parameters.

To create an MS-SQL stored procedure1.    Apply

  1. Apply the following format:
    CREATE PROCEDURE user_def @@var1 type1, ...., @@var-n type-n
    AS
    - Custom query
    GO

...

  1. Use the following format within the call from the customized metric (the code should be entered in the Program box when adding a new Customized Metric):
    user_database..user_def val1, ...., val-n

Example of an MS-SQL stored procedure

The following stored procedure enables Alerts to send an email when the number of rows in a table called SALES.ITEMS reaches an amount that you set in the Thresholds tab.

To apply the MS-SQL stored procedure1.    Connect

  1. Connect to the database schema of the Precise for SQL Server.

...

  1. Create the function user_def in the user_database as follows:
    CREATE PROCEDURE user_def @@sampling_rateint,@@sampling_period int
    AS
    SELECT count(*) FROM SALES..ITEMS
    GO

...

  1. When you create the customized metric under the MS-SQL instance, set the program name to:
    SALES..user_def @SAMPLING_RATE, @SAMPLING_PERIOD

Use dynamic parameters. See Using dynamic parameters in customized metrics.

To test the MS-SQL stored procedure1.    Connect

  1. Connect to the database schema of the Precise for SQL Server.

...

  1. Run the function user_def in the user_database as follows:
    user_database..user_def sampling_rate , sampling_period

Creating Oracle stored procedures

When creating a stored procedure in Oracle, apply the following guidelines:

To create Oracle stored procedures1.    Connect

  1. Connect to the database as Precise for Oracle user.

...

  1. Ensure that the name of the stored procedure includes the package name and ends without a semicolon (;).

...

  1. The naming convention for the program in Alerts must be:  PackageName.ProcedureName().

...

  1. Verify that the return value of the execution is a single numeric value (integer).

To create the Oracle stored procedure package•    Apply

  • Apply the format as follows:
    Create or replace package user_defined_pack as
    function user_def(var1 type1, .... , var-n type-n)
    return return-type;
    pragma restrict_references(user_def,WNDS,WNPS);
    end user_defined_pack;
    /

To create the Oracle stored procedure package body and insert your custom code into the user defined functions1.    Apply

  1. Apply the following format
    Create or replace package body user_defined_pack as
    function user_def(var1 type1, ...., var-n type-n) return
    return- type is
         begin
              -- Custom
         code end
         user_def;
    end user_defined_pack;

...

  1. Use the following format within the call the call from the customized metric (the code should be entered in the Program box when adding a new Customized Metric):
    user_database..user_def val1, ...., val-n

You can use any package or function name, and an unlimited number of parameters (including NONE).

Example of an Oracle stored procedure

The following stored procedure enables Alerts to send an email when the number of rows in a table called ITEMS, which belongs to a user called SALES, reaches an amount that you set in the Thresholds tab.

To apply the Oracle stored procedure1.    Connect

  1. Connect to the database schema of the Precise for Oracle.

...

  1. Create the package  user_defined_pack as follows:
    Create or replace package user_defined_pack as
    function user_def(sampling_rate number, sampling_period
    number, warning_threshold number, critical_threshold number)
    return number; pragma
    restrict_references(user_def,WNDS,WNPS);
    end user_defined_pack;
    /

...

  1. Run the following script in the Precise for Oracle database schema to create the package body of package user_defined_pack:
    Create or replace package body user_defined_pack as
    function user_def(sampling_rate number, sampling_period
    number, warning_threshold number, critical_threshold number)
    return number is
    tbl_num_rows number; BEGIN
    select num_rows into tbl_num_rows from sys.dba_tables where
    table_name='ITEMS' and owner='SALES';
    return (tbl_num_rows);
    end user_def;
    end user_defined_pack;
    /

 

...

  1. When you create the customized metric under the Oracle instance, set the program name to:
    user_defined_pack.user_def ( @SAMPLING_RATE , @SAMPLING_PERIOD ,
    @NEAR_CRITICAL_THRESHOLD , @CRITICAL_THRESHOLD )

Use dynamic parameters. See Using dynamic parameters in customized metrics.

To test the Oracle stored procedure1.    Connect

  1. Connect to the database schema of the Precise for Oracle.

...

  1. Run the function user_def in the user_database with your values as follows:
    select user_defined_pack.user_def(sampling_rate,
    sampling_period, warning_threshold,
    critical_threshold) as value from dual;

Anchor
UseDynamicParametersInCustomMetrics
UseDynamicParametersInCustomMetrics
Using dynamic parameters in customized metrics

When you set a customized metric, you can use dynamic parameters in the Program command line.NOTE    The

Info

The dynamic parameters in customized metrics are not the same as used in actions.

The table below describes the dynamic parameters that you can use in customized metrics.

Table 16-13    Dynamic 13 Dynamic parameters

Dynamic

...

parameterDefinition
@METRIC_

...

IDID of the customized metric.
@METRIC_

...

NAMEName of the customized metric.
@INSTANCE_

...

IDID of the instance that is sampled by the customized metric.
@INSTANCE_

...

NAMEName of the instance that is sampled by the customized metric.
@SERVER_MACHINE_

...

NAMEName of the server machine on which the InformPoint agent is installed.
@INSTANCE_SERVER_MACHINE_

...

NAMEName of the server machine on which the instance is running. (May be differ from

...

@SERVER_MACHINE_NAME only on MS-SQL instances.)
@TECHNOLOGY_

...

CODEThe code of the metric's technology.
@SAMPLING_

...

RATESampling rate (in minutes).
@ANSI_CURRENT_

...

TIMETimestamp of the sampling.
@WARNING_

...

THRESHOLDWarning (near critical) threshold value.
@CRITICAL_

...

THRESHOLDCritical threshold value.
@INCLUDE_

...

LIST

Include list of the items to consider when sampling data (the format is: value1, value2, value3, ...). The values of this parameter equal to the values that you set in the Consider only the following items text box in the threshold tab.

See “Defining thresholds on the Thresholds tab” on page 66.

@EXCLUDE_

...

LIST

Exclude list of the items to ignore when sampling data (the format is: value1, value2, value3, ...). The values of this parameter equal to the values that you set in the Ignore the following items text box in the threshold tab.

See “Defining thresholds on the Thresholds tab” on page 66.

...

 

Precise. Performance intelligence from click to storage. Learn more > >

...