3.1.8 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 5.8 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 describes the format in which used port information is stored.

Table 3-14 Format for user-created data

OptionValue
ttTCP
ksThe host name
lrThe total number of TCP ports for the host
lrThe number of currently active TCP ports for the host
lrThe number of listening TCP ports for the host

To collect information:

  1. Create a batch operation for collecting information about used ports.
    In this example, a batch operation is used to collect information about used ports, as shown below.
    Batch creation example in Windows 2003 (D:\homework\sample.bat):

    @echo off
    echo Product Name=PFM-Agent for Platform (Windows) > D:\homework\userdata.tcp
    echo FormVer=0001 >> D:\homework\userdata.tcp
    echo tt ks lr lr lr >> D:\homework\userdata.tcp
    hostname > D:\homework\userdata.tmp
    netstat -ap tcp | find "TCP" /C >> D:\homework\userdata.tmp
    netstat -ap tcp | find "ESTABLISHED" /C >> D:\homework\userdata.tmp
    netstat -ap tcp | find "LISTENING" /C >> D:\homework\userdata.tmp
    (
    set /p ks=
    set /p lr1=
    set /p lr2=
    set /p lr3=
    ) < D:\homework\userdata.tmp
    del D:\homework\userdata.tmp
    echo TCP %ks% %lr1% %lr2% %lr3% >> D:\homework\userdata.tcp

    Note
    As the example batch operation shown here was created for Windows 2003, it might not operate correctly in other OSs, and might not always operate correctly on Windows 2003 due to differences in environments.
  2. Execute the batch operation created in step 1.
    The following shows the user-created data created as a result of batch execution.
    User-created data (D:\homework\userdata.tcp):

    Product Name=PFM-Agent for Platform (Windows)
    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 example of executing the jpcuser command to convert user-created data into a user data file.
    Example of jpcuser command execution:

    "C:\Program Files\HITACHI\jp1pc\agtt\agent\jpcuser\jpcuser" PI_UPIB
    -file D:\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.