Start of change

Statistics Server Token Management Information

Purpose

Returns the server token manager statistics. These statistics can be used to monitor token-related activity for all file systems that are owned on the local server system. It can also be used to monitor token related activity between this local server system and each individual client system that is accessing the file systems that are owned on the local server system.

Format

syscall_parmlist

  opcode            int                  252       STATOP_STKM
  parms[0]          int                  offset to STAT_API
  parms[1]          int                  Offset of output following STAT_API
  parms[2]          int                  0
  parms[3]          int                  0
  parms[4]          int                  0
  parms[5]          int                  0
  parms[6]          int                  0

STAT_API
  sa_eye            char[4]              "STAP"
  sa_len            int                  length of buffer that 
                                         follows STAT_API
  sa_ver            int                  1
  sa_flags          char[1]              0x00
  SA_RESET                               0x80 Reset statistics
  sa_fill           char[3]              0
  sa_reserve        int[4]               0
  sa_supported_ver  int                  version of data returned
  sa_reserved       int[3]               0
  posix_time_high   unsigned int         high order 32 bits since epoch
  posix_time_low    unsigned int         low order 32 bits since epoch
  posix_useconds    unsigned int         microseconds
  pad1              int

STKM_API_STATS
  st_eye            char[4]              "STKM"
  st_len            short                size of STKM_API_STATS structure
  st_reserved1      char[2]
  st_maxtokens      unsigned long long   Max num of tokens allowed
  st_allocated      unsigned long long   Number of physically allocated 
                                         tokens
  st_inuse          unsigned long long   Number of tokens in use
  st_files          unsigned long long   Number of file structures 
                                         allocated
  st_obtains        unsigned long long   Number of tokens obtained
  st_returns        unsigned long long   Number of tokens returned
  st_revokes        unsigned long long   Number of tokens revoked
  st_asyncgrants    unsigned long long   Number of async grants requests
  st_gcs            unsigned long long   Number of token garbage collections
  st_reserved2      char[8]
  st_thrashing      unsigned long long   Number of thrashing files
  st_resolution     unsigned long long   Number of thrash resolutions
  st_reserved3      char[40]
  
Start of change
  ss_sysinfo        STKM_SYS_STATS[33]
     ss_eye         char[4]              "STSS"
     ss_len         short                size of STKM_SYS_STATS structure
     ss_reserved1   char[2]
     ss_name        char[8]              Sysname
     ss_token       unsigned long long   Number of tokens the
                                         system currently holds
     ss_obtains     unsigned long long   Number of token obtained
     ss_returns     unsigned long long   Number of token returned
     ss_revokes     unsigned long long   Number of token revokes
     ss_asyncgrant  unsigned long long   Number of asynchronously 
                                         granted tokens
     ss_reserved2   char[16] 
         
  ss_thrashing_objs STKM_THRASHING_FILES[64]
     inode          unsigned int         thrashing file inode
     unique         unsigned int         thrashing file uniqueifer
     name           char[45]             name of thrashing file
     reserved       char[3]

  Return_value    0 if request is successful, -1 if it is not successful

  Return_code
    EINTR         zFS is shutting down
    EINVAL        Invalid parameter list
    EMVSERR       Internal error using an osi service

  Reason_code
    0xEFnnxxxx    See z/OS Distributed File Service Messages and Codes
End of change

Usage notes

  • Users of the API supply as input a buffer that contains a syscall_parmlist followed by a STAT_API structure. Output is placed in the buffer after the STAT_API structure.
  • Start of changeThe output consists of up to 33 STKM_SYS_STATS and up to 64 STKM_THRASHING_FILES structures. End of change
  • Start of changeUnused elements of the ss_sysinfo array have an ss_name field that consists of hex zeros.End of change
  • Start of changeUnused elements of the ss_thrashing_objs array have an inode field with the value 0. End of change

Privilege required

None.

Related services

  • Query token_cache_size
  • Set token_cache_size
  • Start of changeStatistics Sysplex Client Operations InformationEnd of change
  • Start of changeStatistics Sysplex Owner Operations Information End of change

Restrictions

None.

Example

#pragma linkage(BPX1PCT, OS)
extern void BPX1PCT(char *, int, int, char *, int *, int *, int *);

#include "stdio.h"

#define ZFSCALL_STATS 0x40000007     
#define STATOP_STKM   252
#define BUFFER_SIZE   1024 * 64

typedef struct syscall_parmlist_t {
    int opcode;                  /* Operation code to perform */
    int parms[7];                /* Specific to type of operation, */

} syscall_parmlist;

typedef  struct  reset_time {
    unsigned int   posix_time_high;   
    unsigned int   posix_time_low;    
    unsigned int   posix_usecs;       
    int     pad1;             
} RESET_TIME;

typedef struct stat_api_t {
#define     SA_EYE "STAP"
    char    sa_eye[4];           /* 4 byte identifier must be */
    int     sa_len;              /* length of the buffer to put data into*/
                                 /* this buffer area follows this struct*/
    int     sa_ver;              /* the version number currently always 1*/
#define     SA_VER_INIT 0x01
    char    sa_flags;            /* command field  must be x00 or x80, */
                                 /* x80 means reset statistics         */
#define     SA_RESET 0x80
    char    sa_fill[3];          /* spare bytes */
    int     sa_reserve[4];       /* Reserved */
    struct  reset_time reset_time_info;
} STAT_API;

typedef struct stkm_sys_stats_t {
    char               ss_eye[4];        /* eye catcher-"STSS" */
#define                SS_EYE "STSS"
    short              ss_len;
    char               ss_reserved1[2];         
    char               ss_name[8];       /* Sysname */
    unsigned long long ss_token;         /* Number of tokens the system */
                                         /* currently holds             */
    unsigned long long ss_obtains;       /* Number of token obtained */
    unsigned long long ss_returns;       /* Number of token returned */
    unsigned long long ss_revokes;       /* Number of token revokes */
    unsigned long long ss_asyncgrant;    /* Number of asynchronously */
                                         /* granted tokens           */
    char               ss_reserved2[16];
} STKM_SYS_STATS;

typedef struct stkm_thrashing_files_t
{
    unsigned int inode;
    unsigned int unique;
    char         name[45];
    char         reserved[3];
} STKM_THRASHING_FILES;

#define MAX_THRASHING_FILES     64
#define SYS_MAX_SYSPLEX_SYSTEMS 32     /* Current max # sysplex images*/
typedef struct stkm_api_stats_t
{
    char                 st_eye[4];    /* eye catcher-"STKM" */
#define                  ST_EYE "STKM"
    short                st_len;
    char                 st_reserved1[2];
    unsigned long long   st_maxtokens; /* Max num of tokens allowed */
    unsigned long long   st_allocated; /* Num. of physically allocated */
                                       /* tokens                       */
    unsigned long long   st_inuse;     /* Number of tokens in use */
    unsigned long long   st_files;     /* Number of file structures */ 
                                       /* allocated                 */
    unsigned long long   st_obtains;
    unsigned long long   st_returns;
    unsigned long long   st_revokes;
    unsigned long long   st_asyncgrants;
    unsigned long long   st_gcs;
    char                 st_reserved2[8];
    unsigned long long   st_thrashing;
    unsigned long long   st_resolution;
    char                 st_reserved3[40];

    /* 32 sysplex-members + 1 zlc */
    STKM_SYS_STATS       ss_sysinfo[SYS_MAX_SYSPLEX_SYSTEMS+1]; 
    STKM_THRASHING_FILES ss_thrashing_objs[MAX_THRASHING_FILES];
} STKM_API_STATS;

int main(int argc, char** argv)
{
    int  buff_fill_len = 0;
    int  bpxrv, bpxrc, bpxrs;
    char sysname[9];
    int  title_done;

    STAT_API              local_req;
    STAT_API              *st_req     = NULL;
    syscall_parmlist      *parmp      = NULL;
    STKM_API_STATS        *st_stats   = NULL;
    STKM_SYS_STATS        *ss_stats   = NULL;
    STKM_THRASHING_FILES  *thrashingp = NULL;
    char                  *buffp      = NULL;

    /* Initialize the local_req to 0s */
    st_req = &local_req;
    memset( st_req, 0x00, sizeof(STAT_API) );

    strcpy( local_req.sa_eye, SA_EYE, sizeof(local_req.sa_eye) );
    local_req.sa_len = sizeof(STKM_API_STATS);
    local_req.sa_ver = SA_VER_INIT;

    /* Allocate Buffer */
    buffp = (char*) malloc(BUFFER_SIZE);
    if( buffp == NULL )
    {
        printf("Malloc Error\n");
        return 0;
    }
    memset( buffp, 0x00, sizeof(syscall_parmlist) + sizeof(STAT_API));

    /* Set the run parms */
    parmp = (syscall_parmlist*) &buffp[0];
    parmp->opcode   = STATOP_STKM;
    parmp->parms[0] = buff_fill_len = sizeof(syscall_parmlist);
    parmp->parms[1] = buff_fill_len + sizeof(STAT_API);
    parmp->parms[2] = 0;
    parmp->parms[3] = 0;
    parmp->parms[4] = 0;
    parmp->parms[5] = 0;
    parmp->parms[6] = 0;
    
    st_req = (STAT_API*) &buffp[buff_fill_len];

    memcpy( st_req, &local_req, sizeof(STAT_API) );
    buff_fill_len += sizeof(STAT_API);
           
    BPX1PCT("ZFS     ",
            ZFSCALL_STATS,              /* Aggregate operation */
            BUFFER_SIZE,                /* Length of Argument */
            (char*) buffp,              /* Pointer to Argument */
            &bpxrv,                     /* Pointer to Return_value */
            &bpxrc,                     /* Pointer to Return_code */
            &bpxrs);                    /* Pointer to Reason_code */
    
    if( bpxrv )
    {
        /* Bad Return code */
        printf("Error requesting info for stkm stats\n");
        printf("Return Value: %d Return Code: %d Reason Code: %x\n",
               bpxrv, bpxrc, bpxrs);
    }
    else
    {
        /* Success.  Print the information in a table */
        st_stats = (STKM_API_STATS*) &buffp[buff_fill_len];
        ss_stats = st_stats->ss_sysinfo;
        thrashingp = st_stats->ss_thrashing_objs;

        printf("%20c     Server Token Manager (STKM) Statistics\n", ' ');
        printf("%20c     --------------------------------------\n", ' ');
        printf("Maximum tokens:   %20llu        Allocated tokens:   %20llu\n", 
               st_stats->st_maxtokens, st_stats->st_allocated);
        printf("Tokens In Use:    %20llu        File structures:    %20llu\n", 
               st_stats->st_inuse, st_stats->st_files);
        printf("Token obtains:    %20llu        Token returns:      %20llu\n",
               st_stats->st_obtains, st_stats->st_returns);
        printf("Token revokes:    %20llu        Async Grants:       %20llu\n",
               st_stats->st_revokes, st_stats->st_asyncgrants);
        printf("Garbage Collects: %20llu        Thrash Resolutions: %20llu\n",
               st_stats->st_gcs, st_stats->st_resolution);
        printf("Thrashing Files:  %20llu\n\n", st_stats->st_thrashing);

        printf("%30c             Usage Per System:    \n", ' ');
        printf("System    Tokens              Obtains             ");
        printf("Returns              Revokes              Async Grt\n");
        printf("--------  ------------------- --------------------");
        printf("-------------------- -------------------- ");
        printf("--------------------\n");

        for (int i = 0; i < (SYS_MAX_SYSPLEX_SYSTEMS+1); i++)
        {
            if (ss_stats[i].ss_name[0] == '\0')
                break;

            memcpy(&sysname, &ss_stats[i].ss_name, 8);
            sysname[8] = '\0';

            printf("%8.8s %20llu %20llu %20llu %20llu %20llu\n",
                   sysname, 
                   ss_stats[i].ss_token, 
                   ss_stats[i].ss_obtains, 
                   ss_stats[i].ss_returns,
                   ss_stats[i].ss_revokes, 
                   ss_stats[i].ss_asyncgrant);
        }
        printf("\n");

        title_done = 0;
        for (int j = 0; j < MAX_THRASHING_FILES; j++)
        {
            if (thrashingp[j].inode == 0)
                break;
            
            if (title_done == 0)
            {
                printf("              Thrashing Objects:\n");
                printf("Inode      Uniquifier   File system \n");
                printf("---------- ----------   --------------------\n");
                title_done = 1;
            }
            printf("%20u %20u %s\n", thrashingp[j].inode, 
                                     thrashingp[j].unique, 
                                     thrashingp[j].name);
        }
        if (title_done)
            printf("\n");
    }
    return 0;
}
End of change