Hitachi

JP1 Version 12 for UNIX Systems JP1/Performance Management - Agent Option for Platform Description, User's Guide and Reference


3.1.6 Examples of collecting information about used ports

PFM - Agent for Platform provides functionality to convert user-specific performance data output by users to text files (user-created data) into a format that can be stored in records provided by PFM - Agent for Platform (user data files). For details about user-specific performance data, see 7.4 Settings for collecting user-specific performance data.

The following shows an example for collecting used port information in PI_UPIB records as user-specific performance data. The following table shows the format in which used port information is stored.

Option

Value

tt

"TCP"

ks

The host name

lr

The total number of TCP ports for the host

lr

The number of currently active TCP ports for the host

lr

The number of listening TCP ports for the host

To collect information:

  1. Create a shell script for collecting information about used ports.

    In this example, a shell script is used to collect information about used ports. The following shows an example of creating a shell script.

    Example of creating a shell script in Linux (/homework/sample.sh):

    #!/bin/sh
    echo "Product Name=PFM-Agent for Platform (UNIX)" > /homework/userdata.tcp
    echo "FormVer=0001" >> /homework/userdata.tcp
    echo "tt ks lr lr lr" >> /homework/userdata.tcp
    #All TCP port
    ALL_TCP=`netstat -at | wc -l`
    ALL_TCP=`expr $ALL_TCP - 2`
    #Active TCP port
    ACTIVE_TCP=`netstat -at | grep ESTABLISHED | wc -l`
    #Listen TCP port
    LISTEN_TCP=`netstat -at | grep LISTEN | wc -l`
    #Output
    echo "TCP `uname -n` $ALL_TCP $ACTIVE_TCP $LISTEN_TCP" >> /homework/userdata.tcp
    Important

    Note that the example shell script shown here was created for Linux. This shell script might not operate correctly in other OSs, and might not always operate correctly in Linux due to differences in environments.

  2. Execute the shell script created in step 1.

    The following shows the user-created data created as a result of executing the shell script.

    User-created data (/homework/userdata.tcp):

    Product Name=PFM-Agent for Platform (UNIX)
    FormVer=0001
    tt ks lr lr lr
    TCP jp1ps05 15 3 12
  3. Convert the user-created data created in step 2 to a user data file.

    The following shows an example of executing the jpcuser command to convert user-created data into a user data file.

    Example of jpcuser command execution:

    /opt/jp1pc/agtu/agent/jpcuser/jpcuser PI_UPIB
    -file /homework/userdata.tcp
  4. Use PFM - Agent for Platform to collect the user data file output in step 3.

    When PFM - Agent for Platform collects records, the contents of the user data file are stored in user records.