"Fossies" - the Fresh Open Source Software Archive

Member "atop-2.8.1/photosyst.h" (7 Jan 2023, 15003 Bytes) of package /linux/misc/atop-2.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "photosyst.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.7.1_vs_2.8.0.

    1 /*
    2 ** ATOP - System & Process Monitor
    3 **
    4 ** The program 'atop' offers the possibility to view the activity of
    5 ** the system on system-level as well as process-level.
    6 **
    7 ** Include-file describing system-level counters maintained.
    8 ** ================================================================
    9 ** Author:      Gerlof Langeveld
   10 ** E-mail:      gerlof.langeveld@atoptool.nl
   11 ** Date:        November 1996
   12 ** LINUX-port:  June 2000
   13 **
   14 ** This program is free software; you can redistribute it and/or modify it
   15 ** under the terms of the GNU General Public License as published by the
   16 ** Free Software Foundation; either version 2, or (at your option) any
   17 ** later version.
   18 **
   19 ** This program is distributed in the hope that it will be useful, but
   20 ** WITHOUT ANY WARRANTY; without even the implied warranty of
   21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   22 ** See the GNU General Public License for more details.
   23 */
   24 #ifndef __PHOTOSYST__
   25 #define __PHOTOSYST__
   26 
   27 #include "netstats.h"
   28 
   29 #define MAXCPU      2048
   30 #define MAXDSK      1024
   31 #define MAXNUMA     1024
   32 #define MAXLVM      2048
   33 #define MAXMDD      256
   34 #define MAXINTF     128
   35 #define MAXCONTAINER    128
   36 #define MAXNFSMOUNT 64
   37 #define MAXIBPORT   32
   38 #define MAXGPU      32
   39 #define MAXGPUBUS   12
   40 #define MAXGPUTYPE  12
   41 #define MAXLLC      256
   42 
   43 #define MAXDKNAM    32
   44 #define MAXIBNAME   12
   45 
   46 /************************************************************************/
   47 struct  memstat {
   48     count_t physmem;    // number of physical pages
   49     count_t freemem;    // number of free     pages
   50     count_t buffermem;  // number of buffer   pages
   51     count_t slabmem;    // number of slab     pages
   52     count_t cachemem;   // number of cache    pages
   53     count_t cachedrt;   // number of cache    pages (dirty)
   54 
   55     count_t totswap;    // number of pages in swap
   56     count_t freeswap;   // number of free swap pages
   57 
   58     count_t pgscans;    // number of page scans
   59     count_t pgsteal;    // number of page steals
   60     count_t allocstall; // try to free pages forced
   61     count_t swouts;     // number of pages swapped out
   62     count_t swins;      // number of pages swapped in
   63     count_t tcpsock;    // number of pages allocated by TCP sockets
   64     count_t udpsock;    // number of pages allocated by UDP sockets
   65 
   66     count_t commitlim;  // commit limit in pages
   67     count_t committed;  // number of reserved pages
   68 
   69     count_t shmem;      // tot shmem incl. tmpfs (pages)
   70     count_t shmrss;     // resident shared memory (pages)
   71     count_t shmswp;     // swapped shared memory (pages)
   72 
   73     count_t slabreclaim;    // reclaimable slab (pages)
   74 
   75     count_t tothugepage;    // total huge pages (huge pages)
   76     count_t freehugepage;   // free  huge pages (huge pages)
   77     count_t hugepagesz; // huge page size (bytes)
   78 
   79     count_t vmwballoon; // vmware claimed balloon pages
   80     count_t zfsarcsize; // zfsonlinux ARC size (pages)
   81     count_t swapcached; // swap cache (pages)
   82     count_t ksmsharing; // saved i.e. deduped memory (pages)
   83     count_t ksmshared;  // current size shared pages (pages)
   84     count_t zswstored;  // zswap stored pages (pages)
   85     count_t zswtotpool; // total pool size (pages)
   86     count_t oomkills;   // number of oom killings
   87     count_t compactstall;   // counter for process stalls
   88     count_t pgmigrate;  // counter for migrated successfully (pages)
   89     count_t numamigrate;    // counter for numa migrated (pages)
   90     count_t pgouts;     // total number of pages written to block device
   91     count_t pgins;      // total number of pages read from block device
   92     count_t pagetables; // page tables of processes (pages)
   93     count_t cfuture[4]; // reserved for future use
   94 };
   95 
   96 /************************************************************************/
   97 
   98 struct  mempernuma {
   99     int numanr;
  100     float   frag;       // fragmentation level for this numa
  101     count_t totmem;     // number of physical pages for this numa
  102     count_t freemem;    // number of free     pages for this numa
  103     count_t filepage;   // number of file     pages for this numa
  104     count_t dirtymem;   // number of cache    pages (dirty) for this numa
  105     count_t slabmem;    // number of slab     pages for this numa
  106     count_t slabreclaim;    // reclaimable slab (pages) for this numa
  107 
  108     count_t active;     // number of pages used more recently for this numa
  109     count_t inactive;   // number of pages less recently used for this numa
  110 
  111     count_t shmem;      // tot shmem incl. tmpfs (pages) for this numa
  112     count_t tothp;      // total huge pages (huge pages) for this numa
  113 };
  114 
  115 struct  memnuma {
  116     count_t           nrnuma;       /* the counts of numa       */
  117     struct mempernuma numa[MAXNUMA];
  118 };
  119 
  120 struct  cpupernuma {
  121     int numanr;
  122     count_t nrcpu;      // number of cpu's
  123     count_t stime;      // accumulate system  time in clock ticks for per numa
  124     count_t utime;      // accumulate user    time in clock ticks for per numa
  125     count_t ntime;      // accumulate nice    time in clock ticks for per numa
  126     count_t itime;      // accumulate idle    time in clock ticks for per numa
  127     count_t wtime;      // accumulate iowait  time in clock ticks for per numa
  128     count_t Itime;      // accumulate irq     time in clock ticks for per numa
  129     count_t Stime;      // accumulate softirq time in clock ticks for per numa
  130     count_t steal;      // accumulate steal   time in clock ticks for per numa
  131     count_t guest;      // accumulate guest   time in clock ticks for per numa
  132 };
  133 
  134 struct  cpunuma {
  135     count_t           nrnuma;       /* the counts of numa       */
  136     struct cpupernuma numa[MAXNUMA];
  137 };
  138 
  139 /************************************************************************/
  140 
  141 struct  netstat {
  142     struct ipv4_stats   ipv4;
  143     struct icmpv4_stats icmpv4;
  144     struct udpv4_stats  udpv4;
  145 
  146     struct ipv6_stats   ipv6;
  147     struct icmpv6_stats icmpv6;
  148     struct udpv6_stats  udpv6;
  149 
  150     struct tcp_stats    tcp;
  151 };
  152 
  153 /************************************************************************/
  154 
  155 struct freqcnt {
  156         count_t maxfreq;/* frequency in MHz                    */
  157         count_t cnt;    /* number of clock ticks times state   */
  158         count_t ticks;  /* number of total clock ticks         */
  159                         /* if zero, cnt is actual freq         */
  160 };
  161 
  162 struct percpu {
  163     int     cpunr;
  164     count_t     stime;  /* system  time in clock ticks      */
  165     count_t     utime;  /* user    time in clock ticks      */
  166     count_t     ntime;  /* nice    time in clock ticks      */
  167     count_t     itime;  /* idle    time in clock ticks      */
  168     count_t     wtime;  /* iowait  time in clock ticks      */
  169     count_t     Itime;  /* irq     time in clock ticks      */
  170     count_t     Stime;  /* softirq time in clock ticks      */
  171     count_t     steal;  /* steal   time in clock ticks      */
  172     count_t     guest;  /* guest   time in clock ticks      */
  173         struct freqcnt  freqcnt;/* frequency scaling info       */
  174     count_t     instr;  /* CPU instructions             */
  175     count_t     cycle;  /* CPU cycles               */
  176     count_t     cfuture[6]; /* reserved for future use  */
  177 };
  178 
  179 struct  cpustat {
  180     count_t nrcpu;  /* number of cpu's          */
  181     count_t devint; /* number of device interrupts      */
  182     count_t csw;    /* number of context switches       */
  183     count_t nprocs; /* number of processes started          */
  184     float   lavg1;  /* load average last    minute          */
  185     float   lavg5;  /* load average last  5 minutes         */
  186     float   lavg15; /* load average last 15 minutes         */
  187     count_t cfuture[4]; /* reserved for future use  */
  188 
  189     struct percpu   all;
  190     struct percpu   cpu[MAXCPU];
  191 };
  192 
  193 /************************************************************************/
  194 
  195 struct  perdsk {
  196         char    name[MAXDKNAM]; /* empty string for last        */
  197         count_t nread;      /* number of read  transfers        */
  198         count_t nrsect;     /* number of sectors read       */
  199         count_t nwrite;     /* number of write transfers        */
  200         count_t nwsect;     /* number of sectors written        */
  201         count_t io_ms;      /* number of millisecs spent for I/O    */
  202         count_t avque;      /* average queue length         */
  203         count_t ndisc;      /* number of discards (-1 = unavailable)*/
  204         count_t ndsect;     /* number of sectors discarded      */
  205         count_t inflight;   /* number of inflight I/O       */
  206         count_t cfuture[3]; /* reserved for future use      */
  207 };
  208 
  209 struct dskstat {
  210     int     ndsk;   /* number of physical disks */
  211     int     nmdd;   /* number of md volumes     */
  212     int     nlvm;   /* number of logical volumes    */
  213     struct perdsk   dsk[MAXDSK];
  214     struct perdsk   mdd[MAXMDD];
  215     struct perdsk   lvm[MAXLVM];
  216 };
  217 
  218 /************************************************************************/
  219 
  220 struct  perintf {
  221         char    name[16];   /* empty string for last        */
  222 
  223         count_t rbyte;  /* number of read bytes                 */
  224         count_t rpack;  /* number of read packets               */
  225     count_t rerrs;  /* receive errors                       */
  226     count_t rdrop;  /* receive drops                        */
  227     count_t rfifo;  /* receive fifo                         */
  228     count_t rframe; /* receive framing errors               */
  229     count_t rcompr; /* receive compressed                   */
  230     count_t rmultic;/* receive multicast                    */
  231     count_t rfuture[4]; /* reserved for future use  */
  232 
  233         count_t sbyte;  /* number of written bytes              */
  234         count_t spack;  /* number of written packets            */
  235     count_t serrs;  /* transmit errors                      */
  236     count_t sdrop;  /* transmit drops                       */
  237     count_t sfifo;  /* transmit fifo                        */
  238     count_t scollis;/* collisions                           */
  239     count_t scarrier;/* transmit carrier                    */
  240     count_t scompr; /* transmit compressed                  */
  241     count_t sfuture[4]; /* reserved for future use  */
  242 
  243     char    type;   /* interface type ('e'/'w'/'v'/'?')     */
  244     long    speed;  /* interface speed in megabits/second   */
  245     long    speedp; /* previous interface speed         */
  246     char    duplex; /* full duplex (boolean)        */
  247     count_t cfuture[4]; /* reserved for future use  */
  248 };
  249 
  250 struct intfstat {
  251     int     nrintf;
  252     struct perintf  intf[MAXINTF];
  253 };
  254 
  255 /************************************************************************/
  256 
  257 struct  pernfsmount {
  258         char    mountdev[128];      /* mountdevice          */
  259         count_t age;            /* number of seconds mounted    */
  260     
  261     count_t bytesread;      /* via normal reads     */
  262     count_t byteswrite;     /* via normal writes        */
  263     count_t bytesdread;     /* via direct reads     */
  264     count_t bytesdwrite;        /* via direct writes        */
  265     count_t bytestotread;       /* via reads            */
  266     count_t bytestotwrite;      /* via writes           */
  267     count_t pagesmread;     /* via mmap  reads      */
  268     count_t pagesmwrite;        /* via mmap  writes     */
  269 
  270     count_t future[8];
  271 };
  272 
  273 struct nfsstat {
  274     struct {
  275             count_t netcnt;
  276         count_t netudpcnt;
  277         count_t nettcpcnt;
  278         count_t nettcpcon;
  279 
  280         count_t rpccnt;
  281         count_t rpcbadfmt;
  282         count_t rpcbadaut;
  283         count_t rpcbadcln;
  284 
  285         count_t rpcread;
  286         count_t rpcwrite;
  287 
  288         count_t rchits;     /* repcache hits    */
  289         count_t rcmiss;     /* repcache misses  */
  290         count_t rcnoca;     /* uncached requests    */
  291 
  292         count_t nrbytes;    /* read bytes       */
  293         count_t nwbytes;    /* written bytes    */
  294 
  295         count_t future[8];
  296     } server;
  297 
  298     struct {
  299         count_t rpccnt;
  300         count_t rpcretrans;
  301         count_t rpcautrefresh;
  302 
  303         count_t rpcread;
  304         count_t rpcwrite;
  305 
  306         count_t future[8];
  307     } client;
  308 
  309     struct {
  310             int                 nrmounts;
  311             struct pernfsmount  nfsmnt[MAXNFSMOUNT];
  312     } nfsmounts;
  313 };
  314 
  315 /************************************************************************/
  316 struct  psi {
  317     float   avg10;      // average pressure last 10 seconds
  318     float   avg60;      // average pressure last 60 seconds
  319     float   avg300;     // average pressure last 300 seconds
  320     count_t total;      // total number of milliseconds
  321 };
  322 
  323 struct  pressure {
  324     char       present; /* pressure stats supported?    */
  325     char       future[3];
  326     struct psi cpusome; /* pressure stall info 'some'   */
  327     struct psi memsome; /* pressure stall info 'some'   */
  328     struct psi memfull; /* pressure stall info 'full'   */
  329     struct psi iosome;  /* pressure stall info 'some'   */
  330     struct psi iofull;  /* pressure stall info 'full'   */
  331 };
  332 
  333 /************************************************************************/
  334 
  335 struct  percontainer {
  336         unsigned long   ctid;       /* container id         */
  337         unsigned long   numproc;    /* number of processes      */
  338 
  339         count_t system;     /* */
  340         count_t user;       /* */
  341         count_t nice;       /* */
  342         count_t uptime;     /* */
  343 
  344         count_t physpages;  /* */
  345 };
  346 
  347 struct contstat {
  348         int                 nrcontainer;
  349         struct percontainer cont[MAXCONTAINER];
  350 };
  351 
  352 /************************************************************************/
  353 /*
  354 ** experimental stuff for access to local HTTP daemons
  355 */
  356 #define HTTPREQ "GET /server-status?auto HTTP/1.1\nHost: localhost\n\n"
  357 
  358 struct wwwstat {
  359     count_t accesses;   /* total number of HTTP-requests    */
  360     count_t totkbytes;  /* total kbytes transfer for HTTP-req   */
  361     count_t uptime;     /* number of seconds since startup  */
  362     int bworkers;   /* number of busy httpd-daemons     */
  363     int iworkers;   /* number of idle httpd-daemons     */
  364 };
  365 
  366 #if HTTPSTATS
  367 int getwwwstat(unsigned short, struct wwwstat *);
  368 #endif
  369 /************************************************************************/
  370 struct pergpu {
  371     char    taskstats;      // GPU task statistics supported?
  372     unsigned char   nrprocs;    // number of processes using GPU
  373     char    type[MAXGPUTYPE+1]; // GPU type
  374     char    busid[MAXGPUBUS+1]; // GPU bus identification
  375     int gpunr;          // GPU number
  376     int gpupercnow;     // processor percentage last second
  377                     // -1 if not supported
  378     int mempercnow;     // memory    percentage last second
  379                     // -1 if not supported
  380     count_t memtotnow;      // total memory in KiB
  381     count_t memusenow;      // used  memory in KiB
  382     count_t samples;        // number of samples
  383     count_t gpuperccum;     // cumulative processor busy percentage
  384                     // -1 if not supported
  385     count_t memperccum;     // cumulative memory percentage 
  386                     // -1 if not supported
  387     count_t memusecum;      // cumulative used memory in KiB
  388 };
  389 
  390 struct gpustat {
  391     int     nrgpus;     // total number of GPUs
  392     struct pergpu   gpu[MAXGPU];
  393 };
  394 
  395 /************************************************************************/
  396 struct perifb {
  397     char    ibname[MAXIBNAME];  // InfiniBand controller
  398     short   portnr;         // InfiniBand controller port
  399 
  400     short   lanes;          // number of lanes (traffic factor)
  401     count_t rate;           // transfer rate in megabits/sec
  402     count_t rcvb;               // bytes received
  403     count_t sndb;               // bytes transmitted
  404     count_t rcvp;               // packets received
  405     count_t sndp;               // packets transmitted
  406 };
  407 
  408 struct ifbstat {
  409     int     nrports;    // total number of IB ports
  410     struct perifb   ifb[MAXIBPORT];
  411 };
  412 
  413 /************************************************************************/
  414 struct perllc {
  415     unsigned char   id;
  416     float       occupancy;
  417     count_t     mbm_local;
  418     count_t     mbm_total;
  419 };
  420 
  421 struct llcstat {
  422     unsigned char   nrllcs;         // total number of LLC
  423     struct perllc   perllc[MAXLLC];
  424 };
  425 
  426 /************************************************************************/
  427 
  428 struct  sstat {
  429     struct cpustat  cpu;
  430     struct memstat  mem;
  431     struct netstat  net;
  432     struct intfstat intf;
  433     struct memnuma  memnuma;
  434     struct cpunuma  cpunuma;
  435     struct dskstat  dsk;
  436     struct nfsstat  nfs;
  437     struct contstat cfs;
  438     struct pressure psi;
  439     struct gpustat  gpu;
  440     struct ifbstat  ifb;
  441     struct llcstat  llc;
  442 
  443     struct wwwstat  www;
  444 };
  445 
  446 /*
  447 ** prototypes
  448 */
  449 void    photosyst (struct sstat *);
  450 void    deviatsyst(struct sstat *, struct sstat *, struct sstat *, long);
  451 void    totalsyst (char,           struct sstat *, struct sstat *);
  452 #endif