home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume26
/
sps3
/
part02
/
sps.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-08
|
7KB
|
241 lines
# ifndef lint
static char SpsHId[] = "@(#)sps.h 1.5\t8/22/91" ;
# endif
# ifdef SUNOS40
# define KERNEL
# endif SUNOS40
# include <sys/param.h>
# undef KERNEL
# include <sys/dir.h>
# include <sys/user.h>
# include <sys/proc.h>
# ifdef SUNOS40
# ifndef BSD43
# define BSD43
# endif BSD43
# endif SUNOS40
/*
** Maximum # of users to be considered. (Because user names are stored
** in a hash table, this should probably be at least double the number
** of actual users defined in /etc/passwd or by the Yellow Pages.)
*/
# ifndef MAXUSERS
# define MAXUSERS 100
# endif
/* Maximum # ttys to be considered, plus 1 for the console ... */
# ifndef MAXTTYS
# define MAXTTYS 193
# endif
/* Maximum user name length ... */
# define UNAMELEN 8
/* Maximum process-id not to be considered busy ... */
# define MSPID 2
/* # of wait states defined in the `struct info' ... */
# ifdef NFS
# ifdef SUN
# define NWAITSTATE 16
# else
# define NWAITSTATE 36
# endif SUN
# else NFS
# ifdef ULTRIX20
# define NWAITSTATE 36
# else ULTRIX20
# define NWAITSTATE 35
# endif ULTRIX20
# endif NFS
/* Convert clicks to kbytes ... */
# ifndef PGSHIFT
# define KBYTES( size ) ((size) << 1)
# else PGSHIFT
# if PGSHIFT > 10
# define KBYTES( size ) ((size) << (PGSHIFT - 10))
# else
# define KBYTES( size ) ((size) >> (10 - PGSHIFT))
# endif
# endif PGSHIFT
/* Standard files to be examined ... */
# ifndef FILE_MEM
# define FILE_MEM "/dev/mem" /* System physical memory */
# endif
# ifndef FILE_KMEM
# define FILE_KMEM "/dev/kmem" /* Kernel virtual memory */
# endif
# ifndef FILE_SWAP
# define FILE_SWAP "/dev/drum" /* Swap/paging device */
# endif
# ifndef FILE_DEV
# define FILE_DEV "/dev" /* Directory of tty entries */
# endif
# ifndef FILE_SYMBOL
# define FILE_SYMBOL "/vmunix" /* Symbol file for nlist() */
# endif
# ifndef FILE_INFO
# define FILE_INFO "/tmp/.spsinfo" /* Sps information file */
# endif
# ifndef FILE_PASSWD
# define FILE_PASSWD "/etc/passwd" /* User database */
# endif
/* Structure to hold necessary information concerning a tty ... */
struct ttyline
{
char l_name[2] ; /* Tty character name */
unsigned short l_pgrp ; /* Tty process group */
# ifdef SUNOS40
struct streamtab *l_addr ; /* Ptr to streamtab in kmem */
struct stdata *l_stdata ; /* Ptr to stdata at runtime */
# else SUNOS40
struct tty *l_addr ; /* Ptr to tty struct in kmem */
# endif SUNOS40
dev_t l_dev ; /* Tty device # */
} ;
/* Structure holding a single hash table entry ... */
struct hashtab
{
short h_uid ; /* Uid of user entry */
char h_uname[ UNAMELEN ] ; /* Corresponding name */
} ;
/*
** Format of the standard information file maintained by sps.
** This structure is filled in at initialisation time and then is read back
** in whenever sps is invoked.
** Note that the pointer variables in this structure refer to
** kernel virtual addresses, not addresses within sps.
** These variable are typed as such so that pointer arithmetic
** on the kernel addresses will work correctly.
*/
struct info
{ /* Kernel values determining process, tty and upage info ... */
struct proc *i_proc0 ; /* address of process table */
int i_nproc ; /* length of process table */
# ifndef SUNOS40
struct text *i_text0 ; /* address of text table */
# endif SUNOS40
int i_ntext ; /* length of text table */
# ifdef ULTRIX20
struct gnode *i_inode0 ; /* address of inode table */
# else ULTRIX20
struct inode *i_inode0 ; /* address of inode table */
# endif ULTRIX20
int i_ninode ; /* length of inode table */
int i_ecmx ; /* max physical memory address*/
# ifndef SUNOS40
struct buf *i_swbuf0 ; /* address of swap buffers */
int i_nswbuf ; /* # swap buffers */
struct buf *i_buf0 ; /* address of i/o buffers */
int i_nbuf ; /* # i/o buffers */
struct pte *i_usrptmap ; /* page table map */
struct pte *i_usrpt ; /* page table map */
# endif SUNOS40
struct cdevsw *i_cdevsw ; /* device switch to find ttys */
# ifdef BSD42
# ifdef NFS
struct dquot *i_quota0 ; /* disc quota structures */
# else NFS
struct quota *i_quota0 ; /* disc quota structures */
# endif NFS
int i_nquota ; /* # quota structures */
# ifdef ULTRIX40
int i_swapfrag ; /* # swap blocks allocated */
# else
int i_dmmin ; /* The start of the disc map */
int i_dmmax ; /* The end of the disc map */
# endif ULTRIX40
struct mbuf *i_mbutl ; /* Start of mbuf area */
# else BSD42
int i_hz ; /* Clock rate */
# endif BSD42
# ifdef CHAOS
caddr_t i_Chconntab ; /* Chaos connection table */
# endif
/* Kernel addresses are associated with process wait states ... */
caddr_t i_waitstate[ NWAITSTATE ] ;
/* User names, stored in a hash table ... */
struct hashtab i_hnames[ MAXUSERS ] ;
/* Tty device info ... */
struct ttyline i_ttyline[ MAXTTYS ] ;
# ifdef SUNOS40
struct seg_ops *i_segvn_ops ; /* ptr to vnode segment ops */
struct pty *i_ptybase ;
int i_npty ;
# ifdef SUNOS41
struct strstat *i_strst;
struct stdata *i_allstream;
# else SUNOS41
struct stdata *i_streams ; /* streams list */
struct stdata *i_streamsNSTREAMS ;
# endif SUNOS41
caddr_t i_sysbase ;
# endif SUNOS40
} ;
/*
** The symbol structure cross-references values read from the kernel with
** their place in the info structure, and if such a value is associated with
** a process wait state or not.
*/
struct symbol
{
char *s_kname ; /* Kernel symbol name */
char s_indirect ; /* Value requires indirection */
caddr_t *s_info ; /* Corresponding info address */
char *s_wait ; /* Reason for wait, if any */
} ;
/* The `user' structure obtained from /dev/mem or /dev/swap ... */
union userstate
{
struct user u_us ;
char u_pg[ UPAGES ][ NBPG ] ;
} ;
/* Information concerning each process filled from /dev/kmem ... */
struct process
{
struct proc pr_p ; /* struct proc from /dev/kmem */
struct process *pr_plink ; /* Normalised ptrs from above */
struct process *pr_sibling ; /* Ptr to sibling process */
struct process *pr_child ; /* Ptr to child process */
struct process *pr_pptr ; /* Ptr to parent process */
# ifdef BSD42
struct rusage pr_rself ; /* Read from upage for self */
struct rusage pr_rchild ; /* ... and the children */
# else BSD42
struct vtimes pr_vself ; /* Read from upage for self */
struct vtimes pr_vchild ; /* ... and the children */
# endif BSD42
int pr_files ; /* # open files */
struct ttyline *pr_tty ; /* Associated tty information */
char *pr_cmd ; /* Command args, from upage */
int pr_upag:1 ; /* Upage was obtained */
int pr_csaved:1 ; /* Cmd args saved by malloc() */
# ifdef SUNOS40
unsigned pr_private ; /* private pages */
unsigned pr_shared ; /* shared pages */
# endif SUNOS40
} ;
/* Structure to hold summarising information ... */
struct summary
{
long sm_ntotal ; /* Total # processes */
long sm_ktotal ; /* Total virtual memory */
long sm_nbusy ; /* # busy processes */
long sm_kbusy ; /* Busy virtual memory */
long sm_nloaded ; /* # loaded processes */
long sm_kloaded ; /* Active resident memory */
long sm_nswapped ; /* # swapped processes */
long sm_kswapped ; /* Size totally swapped out */
} ;