$ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 6-AUG-1992 16:29:20.70 By user DWING (DWING@UH01.Colorado.EDU) $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. BRKTHRU.H;2 $! 2. PLIST.DAT;2 $! 3. STATEDEF.H;2 $! 4. SYSWATCH.C;2 $! 5. SYSWATCH_BUILD.COM;1 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X#define`09BRK$C_DEVICE`09`091 X#define`09BRK$C_USERNAME`09`092 X#define`09BRK$C_ALLUSERS`09`093 X#define`09BRK$C_ALLTERMS`09`094 X#define`09BRK$C_MAXSENDTYPE`094 X X#define`09BRK$C_GENERAL`09`090 X#define`09BRK$C_PHONE`09`091 X#define`09BRK$C_MAIL`09`092 X#define`09BRK$C_QUEUE`09`093 X#define`09BRK$C_SHUTDOWN`09`094 X#define`09BRK$C_URGENT`09`095 X#define`09BRK$C_DCL`09`096 X#define`09BRK$C_OPCOM`09`097 X#define`09BRK$C_USER1`09`0932 X#define`09BRK$C_USER2`09`0933 X#define`09BRK$C_USER3`09`0934 X#define`09BRK$C_USER4`09`0935 X#define`09BRK$C_USER5`09`0936 X#define`09BRK$C_USER6`09`0937 X#define`09BRK$C_USER7`09`0938 X#define`09BRK$C_USER8`09`0939 X#define`09BRK$C_USER9`09`0940 X#define`09BRK$C_USER10`09`0941 X#define`09BRK$C_USER11`09`0942 X#define`09BRK$C_USER12`09`0943 X#define`09BRK$C_USER13`09`0944 X#define`09BRK$C_USER14`09`0945 X#define`09BRK$C_USER15`09`0946 X#define`09BRK$C_USER16`09`0947 X X#define`09BRK$M_SCREEN`09`09256 X#define`09BRK$M_BOTTOM`09`09512 X#define`09BRK$M_NOREFRESH`09`091024 X#define`09BRK$M_CLUSTER`09`092048 X X#define`09BRK$S_FLAGS_INPUT`092 X#define`09BRK$S_ERASE_LINES`098 X X#define`09BRK$V_ERASE_LINES`090 X#define`09BRK$V_SCREEN`09`098 X#define`09BRK$V_BOTTOM`09`099 X#define`09BRK$V_NOREFRESH`09`0910 X#define`09BRK$V_CLUSTER`09`0911 $ CALL UNPACK BRKTHRU.H;2 1795649484 $ create 'f' XTIMER=120 XPRCNAM=SYSPROC:SNYDER,SMITH,OPERATOR XBIOCNT<200 XBYTCNT<150 XCPUTIM>120000 XSTATE<>5 XPRCNAM=MYPROC:SMITH,OPERATOR XSTATE<>7 $ CALL UNPACK PLIST.DAT;2 910182155 $ create 'f' X#define SCH$C_COLPG`091 X#define SCH$C_MWAIT`092 X#define SCH$C_CEF`093 X#define SCH$C_PFW`094 X#define SCH$C_LEF`095 X#define SCH$C_LEFO`096 X#define SCH$C_HIB`097 X#define SCH$C_HIBO`098 X#define SCH$C_SUSP`099 X#define SCH$C_SUSPO`0910 X#define SCH$C_FPG`0911 X#define SCH$C_COM`0912 X#define SCH$C_COMO`0913 X#define SCH$C_CUR`0914 $ CALL UNPACK STATEDEF.H;2 645221977 $ create 'f' X/* SYSWATCH X * A monitoring utility for detached processes X * X * Written by Curt Snyder, Irvine, California X * X * This program from VAX Professional, July/August 1992. X * X * Requires WORLD and OPER privileges X * X */ X X X/******************/ X/* include files */ X/******************/ X#include X#include X#include X#include X#include X#include X#include "statedef.h" X#include "brkthru.h" X X#define TRUE 1 X#define FALSE 0 X X/***********************************/ X/* quad is used for timer purposes */ X/***********************************/ Xtypedef int quad`5B2`5D; X X/********************************************/ X/* define conditional codes and return code */ X/********************************************/ X#define GE 0 X#define LE 1 X#define NE 2 X#define EQ 3 X#define GT 4 X#define LT 5 X#define NO_PROCESS 0x0200 X X#define TIMER 1 X#define default_seconds 30 X X/**************************/ X/* descriptor definition */ X/**************************/ X#define LENGTH(descriptor)`09descriptor.dsc$w_length X X/**********************************/ X/* parameter_list contains a linked */ X/* list of entries to examine and */ X/* the conditions which trigger a */ X/* warning message.`09`09 */ X/**********************************/ Xstruct parameter_list X`7B X short flag; /* the jpi definition to examine */ X short comparison;`09/* the condition code */ X int value;`09`09/* the value to compare to */ X struct parameter_list *next; X`7D; X X/***********************************/ X/* this structure contains the`09 */ X/* list of processes to watch for, */ X/* the notification list and points*/ X/* to the warning list`09`09 */ X/***********************************/ Xstruct process_list X`7B X int pidadr; X char prcnam`5B16`5D; X char notify_list`5B80`5D; X struct parameter_list *dolist; X struct process_list *next; X`7D; X X/*************************************/ X/* used by the getjpi system service */ X/*************************************/ Xstruct jpi_item X`7B X short buflen; X short item_code; X int *buffer; X int *retlen; X`7D; X X X/**********************/ X/* global variables */ X/**********************/ X Xstruct jpi_item jplist`5B24`5D; Xstruct process_list *first = NULL, X`09`09*curr = NULL; Xstruct parameter_list *cwarn = NULL; Xint seconds = default_seconds; X X X/***********************************/ X/* storage for the values returned */ X/* from GETJPI`09`09`09 */ X/***********************************/ Xlong aptcnt,astcnt,biocnt,bufio,bytcnt, X cputim,diocnt,dirio,enqcnt,filcnt, X freptecnt,gpgcnt,imagecount,jobprccnt, X pageflts,pagfilcnt,ppgcnt,prccnt, X state,tqcnt,volumes,wssize; X X/***************************/ X/* return length variables */ X/***************************/ Xshort aptlen,astlen,biolen,buflen, X bytlen,cpulen,diolen,dirlen, X enqlen,fillen,freplen,gpglen, X imaglen,jobprclen,paglen,pagfilen, X ppglen,prclen,statelen,tqlen,vollen,wsslen; X X/***************************/ X/* predefines sys$getjpi */ X/***************************/ Xint sys$getjpiw(int,int,int, X`09`09struct jpi_item *,int,int,int); X X/******************************/ X/* sets the seconds value for */ X/* the timer`09`09 */ X/******************************/ Xvoid set_timer( linein) Xchar *linein; X`7B X char *sloc; X char hold_char`5B80`5D; X X sloc = strchr(linein,'='); X X/* no time specified, use default */ X if (sloc==NULL) return; X X sloc++; /* move past the = sign */ X X strncpy(hold_char,sloc,80); X seconds = atoi(hold_char); X if (seconds == 0) X seconds = default_seconds; X`7D /* end set_timer() function */ X X X/******************************/ X/* adds an entry to the */ X/* process_list, based on linein */ X/******************************/ Xvoid add_list( linein ) Xchar *linein; X`7B X struct process_list *hparms; X char *sloc; X X /* we don't have a warning list yet */ X cwarn = NULL; X /* get some space */ X hparms = malloc(sizeof (struct process_list)); X if (hparms == NULL) X `7B /* failed */ X printf ("Error allocating space for parameter list\n"); X exit(); X `7D /* end hparms==NULL */ X X/* null the process id */ X hparms->pidadr = 0; X /* extract the notify list */ X sloc = strchr(linein,':'); X /* must have one */ X if (sloc != NULL) X `7B X *sloc = 0; /*null terminate the string */ X sloc++; /* move past the null value */ X strncpy(hparms->notify_list,sloc,80); /* extract the text */ X `7D /* end sloc != NULL */ X X /* now find the equal sign */ X sloc = strchr(linein,'='); X if (sloc == NULL) /* failed, exit */ X `7B X printf ("Error in parameter file on line %s\nNo equal sign\n",linein); X exit(); X `7D /* end sloc == NULL */ X X sloc++; /* move past the = sign */ X strncpy(hparms->prcnam,sloc,15); /* extract the procedure name */ X hparms->prcnam`5B15`5D = 0; X hparms->dolist = NULL; /* null the pointers to the other items */ X hparms->next = NULL; X if (first == NULL) /* is this the very first procedure */ X first = hparms; X else X curr->next = hparms; /* extend the list */ X curr = hparms; /* now point to the entry we just added */ X`7D /* end add_list() function */ X X/***********************************/ X/* add a warning entry to either */ X/* the current warning list or the */ X/* current procedure`09`09 */ X/***********************************/ Xvoid add_warn ( linein, ptype ) Xchar *linein; Xint ptype; X`7B X struct parameter_list *hwarn; X int sloc; X X /* get some space */ X hwarn = malloc(sizeof(struct parameter_list)); X X if (hwarn == NULL) /* failed, exit */ X `7B X printf ("Error allocating memory for warning list\n"); X exit(); X `7D /* end hwarn == NULL */ X /* if this is our first entry, point to it*/ X if (curr->dolist == NULL) X curr->dolist = hwarn; X else X cwarn->next = hwarn; /* otherwise extend the list */ X cwarn = hwarn; /* make this one the current end of list */ X X X cwarn->flag = ptype; /* set the flag */ X cwarn->value = 0; X cwarn->next = NULL; /* don't point anywhere */ X sloc = strcspn(linein,"!=<>"); /* are we really checking anything?*/ X X if (sloc == strlen(linein)) /* if not, fail and exit */ X `7B X printf ("Error in line %s\nNo comparison characters\n",linein); X exit(); X `7D /* end sloc == strlen(lineine)*/ X X if (strncmp(&linein`5Bsloc`5D,"<>",2)==0) /* find the comparison entry*/ X cwarn->comparison = NE; X else X if (strncmp(&linein`5Bsloc`5D,"!=",2)==0) X cwarn->comparison = NE; X else X if (strncmp(&linein`5Bsloc`5D,"<=",2)==0) X cwarn->comparison = LE; X else X if (strncmp(&linein`5Bsloc`5D,">=",2)==0) X cwarn->comparison = GE; X else X if (linein`5Bsloc`5D== '=') X cwarn->comparison = EQ; X else X if (linein`5Bsloc`5D== '<') X cwarn->comparison = LT; X else X if (linein`5Bsloc`5D== '>') X cwarn->comparison = GT; X X sloc++;`09/* move forward one character*/ X if (cwarn->comparison <= NE) sloc++;`09/* two character comparisons */ X strcpy(linein,&linein`5Bsloc`5D); /* get the numerical entry*/ X cwarn->value = atoi(linein); /* change it to a number*/ X`7D /* end add_warn() function */ X X/***************************************/ X/* this procedures finds out what */ X/* parameter is specified in`09 */ X/* the character field linein`09 */ X/* and returns a JPI parameter numeric */ X/***************************************/ Xint parm_type (linein) Xchar *linein; X`7B X X if (strncmp(linein,"PRCNAM",6)==0) X return (JPI$_PRCNAM); X X if (strncmp(linein,"APTCNT",6)==0) X return (JPI$_APTCNT); X if (strncmp(linein,"ASTCNT",6)==0) X return (JPI$_ASTCNT); X if (strncmp(linein,"BIOCNT",6)==0) X return (JPI$_BIOCNT); X if (strncmp(linein,"BUFIO",5)==0) X return (JPI$_BUFIO); X if (strncmp(linein,"BYTCNT",6)==0) X return (JPI$_BYTCNT); X if (strncmp(linein,"CPUTIM",6)==0) X return (JPI$_CPUTIM); X if (strncmp(linein,"DIOCNT",6)==0) X return (JPI$_DIOCNT); X if (strncmp(linein,"DIRIO",5)==0) X return (JPI$_DIRIO); X if (strncmp(linein,"ENQCNT",6)==0) X return (JPI$_ENQCNT); X if (strncmp(linein,"FILCNT",6)==0) X return (JPI$_FILCNT); X if (strncmp(linein,"FREPTECNT",9)==0) X return (JPI$_FREPTECNT); X if (strncmp(linein,"GPGCNT",6)==0) X return (JPI$_GPGCNT); X if (strncmp(linein,"IMAGECOUNT",10)==0) X return (JPI$_IMAGECOUNT); X if (strncmp(linein,"JOBPRCCNT",9)==0) X return (JPI$_JOBPRCCNT); X if (strncmp(linein,"PAGEFLTS",8)==0) X return (JPI$_PAGEFLTS); X if (strncmp(linein,"PAGFILCNT",9)==0) X return (JPI$_PAGFILCNT); X if (strncmp(linein,"PPGCNT",6)==0) X return (JPI$_PPGCNT); X if (strncmp(linein,"PRCCNT",6)==0) X return (JPI$_PRCCNT); X if (strncmp(linein,"STATE",5)==0) X return (JPI$_STATE); X if (strncmp(linein,"TQCNT",5)==0) X return (JPI$_TQCNT); X if (strncmp(linein,"VOLUMES",7)==0) X return (JPI$_VOLUMES); X if (strncmp(linein,"WSSIZE",6)==0) X return (JPI$_WSSIZE); X if (strncmp(linein,"TIMER",5)==0) X return (TIMER); X return 0; X`7D /* end parm_type() function */ X X/***************************************/ X/* this procedures takes the character */ X/* field linein and parses it`09 */ X/***************************************/ Xvoid parse_line ( linein ) Xchar *linein; X`7B X int prm_typ; X X /* what kind of line is it? */ X prm_typ = parm_type (linein); X switch (prm_typ) X `7B X case 0 : break; /* must have been empty or invalid */ X case JPI$_PRCNAM : add_list(linein); /* a process name */ X`09`09break; X case TIMER : set_timer(linein); X`09`09break; X default : add_warn ( linein,prm_typ ); /* a parameter */ X`09break; X `7D /* end switch */ X`7D /* end parse_line() function */ X X X/************************************/ X/* open and read the parameter file */ X/************************************/ Xvoid read_parms() X`7B X FILE *infile; X char linein`5B81`5D; X int i; X X infile = fopen("plist.dat","r"); X if (infile==NULL) X `7B X printf ("Error opening plist.dat\n"); X exit(); X `7D /* end infile == NULL */ X X while (!feof(infile)) X `7B X fgets(linein,80,infile); X linein`5B80`5D = 0; X /* make it upper case for cleanliness sake */ X for (i=0;i 3600) X `7B X hour = (int) seconds/3600; X seconds -= (hour * 3600); X `7D X if (seconds > 60) X `7B X minute = (int) seconds/60; X seconds -= (minute * 60); X `7D X second = seconds; X X sprintf (stime,"0 %2d:%2d:%2d.00",hour,minute,second); X for (i=2;iflag; X X switch (jplist`5Boffset`5D.item_code) X `7B X case JPI$_APTCNT : X jplist`5Boffset`5D.buffer = &aptcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &aptlen; X break; X case JPI$_ASTCNT : X jplist`5Boffset`5D.buffer = &astcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &astlen; X break; X case JPI$_BIOCNT : X jplist`5Boffset`5D.buffer = &biocnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &biolen; X break; X case JPI$_BUFIO : X jplist`5Boffset`5D.buffer = &bufio; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &buflen; X break; X case JPI$_BYTCNT : X jplist`5Boffset`5D.buffer = &bytcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &bytlen; X break; X case JPI$_CPUTIM : X jplist`5Boffset`5D.buffer = &cputim; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &cpulen; X break; X case JPI$_DIOCNT : X jplist`5Boffset`5D.buffer = &diocnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &diolen; X break; X case JPI$_DIRIO : X jplist`5Boffset`5D.buffer = &dirio; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &dirlen; X break; X case JPI$_ENQCNT : X jplist`5Boffset`5D.buffer = &enqcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &enqlen; X break; X case JPI$_FILCNT : X jplist`5Boffset`5D.buffer = &filcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &fillen; X break; X case JPI$_FREPTECNT : X jplist`5Boffset`5D.buffer = &freptecnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &freplen; X break; X case JPI$_GPGCNT : X jplist`5Boffset`5D.buffer = &gpgcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &gpglen; X break; X case JPI$_IMAGECOUNT : X jplist`5Boffset`5D.buffer = &imagecount; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &imaglen; X break; X case JPI$_JOBPRCCNT : X jplist`5Boffset`5D.buffer = &jobprccnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &jobprclen; X break; X case JPI$_PAGEFLTS : X jplist`5Boffset`5D.buffer = &pageflts; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &paglen; X break; X case JPI$_PAGFILCNT : X jplist`5Boffset`5D.buffer = &pagfilcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &pagfilen; X break; X case JPI$_PPGCNT : X jplist`5Boffset`5D.buffer = &ppgcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &ppglen; X break; X case JPI$_PRCCNT : X jplist`5Boffset`5D.buffer = &prccnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &prclen; X break; X case JPI$_STATE : X jplist`5Boffset`5D.buffer = &state; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &statelen; X break; X case JPI$_TQCNT : X jplist`5Boffset`5D.buffer = &tqcnt; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &tqlen; X break; X case JPI$_VOLUMES : X jplist`5Boffset`5D.buffer = &volumes; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &vollen; X break; X case JPI$_WSSIZE : X jplist`5Boffset`5D.buffer = &wssize; X jplist`5Boffset`5D.buflen = 16; X jplist`5Boffset`5D.retlen = &wsslen; X break; X `7D /* end switch */ X`7D /* end set_item () function */ X X/***********************************/ X/* set the current jplist item at */ X/* offset to nulls to terminate it */ X/***********************************/ Xvoid null_item ( offset ) X`7B X jplist`5Boffset`5D.buflen = 0; X jplist`5Boffset`5D.item_code = 0; X jplist`5Boffset`5D.buffer = 0; X jplist`5Boffset`5D.retlen = 0; X`7D /* end null_item() function */ X X X/**************************************/ X/* send a warning based on`09 */ X/* stat_code to the distribution list */ X/* for the current process.`09 */ X/**************************************/ Xvoid send_warning( stat_code ) Xint stat_code; X`7B X char msg_buff`5B255`5D; /* msg to be sent */ X $DESCRIPTOR(_msg_buff,msg_buff); X char hsend`5B80`5D; /* holding variable for dist list */ X int sloc;`09 /* used for offset into strings */ X char sendto`5B80`5D; /* a username to send to */ X $DESCRIPTOR(_sendto,sendto); X char evaluation`5B20`5D; /* used to pretty up the text */ X int retcode; X long carcon = 32; /* carriage control spec */ X /* send it across the cluster, use screen control and put X the message at the bottom of the CRT */ X long flags = BRK$M_CLUSTER+BRK$M_SCREEN+BRK$M_BOTTOM; X long sndtyp = BRK$C_USERNAME; /* sending to username */ X X struct X `7B X short io_stat,count; X short ecnt`5B2`5D; X `7D iosb; /* BRKTHRU I/O status block */ X X /* if the error is not NO_PROCESS, X find out what the comparison was */ X X if (stat_code != NO_PROCESS) X `7B X switch (cwarn->comparison) X `7B X case GE : strcpy(evaluation,"greater or equal to"); X`09 break; X case LE : strcpy(evaluation,"less than or equal to"); X`09 break; X case NE : strcpy(evaluation,"not equal to"); X`09 break; X case EQ : strcpy(evaluation,"equal to"); X`09 break; X case LT : strcpy(evaluation,"less than"); X`09 break; X case GT : strcpy(evaluation,"greater than"); X`09 break; X `7D /* end switch */ X `7D /* end if no_process*/ X X/* build the text describing the error */ X switch (stat_code) X `7B X case NO_PROCESS : sprintf(msg_buff, X"\n%cThe process %s is not on the system%c\n\n",7,curr->prcnam,7); X`09`09 break; X case JPI$_APTCNT : sprintf (msg_buff, X"\n%cThe process %s has an aptcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,aptcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_ASTCNT : sprintf (msg_buff, X"\n%cThe process %s has an astcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,astcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_BIOCNT : sprintf (msg_buff, X"\n%cThe process %s has a biocnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,biocnt,evaluation,cwarn->value,7); X`09break; X case JPI$_BUFIO : sprintf (msg_buff, X"\n%cThe process %s has a bufio of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,bufio,evaluation,cwarn->value,7); X`09break; X case JPI$_BYTCNT : sprintf (msg_buff, X"\n%cThe process %s has a bytcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,bytcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_CPUTIM : sprintf (msg_buff, X"\n%cThe process %s has a cputim of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,cputim,evaluation,cwarn->value,7); X`09break; X case JPI$_DIOCNT : sprintf (msg_buff, X"\n%cThe process %s has a diocnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,diocnt,evaluation,cwarn->value,7); X`09break; X case JPI$_DIRIO : sprintf (msg_buff, X"\n%cThe process %s has a dirio of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,dirio,evaluation,cwarn->value,7); X`09break; X case JPI$_ENQCNT : sprintf (msg_buff, X"\n%cThe process %s has an enqcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,enqcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_FILCNT : sprintf (msg_buff, X"\n%cThe process %s has an filcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,filcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_FREPTECNT : sprintf (msg_buff, X"\n%cThe process %s has an freptecnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,freptecnt,evaluation,cwarn->value,7); X`09break; X case JPI$_GPGCNT : sprintf (msg_buff, X"\n%cThe process %s has a gpgcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,gpgcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_IMAGECOUNT : sprintf (msg_buff, X"\n%cThe process %s has an imagecount of %d, which is %s the value %d%c\n\n" V, X`09 7,curr->prcnam,imagecount,evaluation,cwarn->value,7); X`09break; X case JPI$_JOBPRCCNT : sprintf (msg_buff, X"\n%cThe process %s has a jobprccnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,jobprccnt,evaluation,cwarn->value,7); X`09break; X case JPI$_PAGEFLTS : sprintf (msg_buff, X"\n%cThe process %s has had %d pagefaults, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,pageflts,evaluation,cwarn->value,7); X`09break; X case JPI$_PAGFILCNT : sprintf (msg_buff, X"\n%cThe process %s has a pagefilecnt of %d, which is %s the value %d%c\n\n" V, X`09 7,curr->prcnam,pagfilcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_PPGCNT : sprintf (msg_buff, X"\n%cThe process %s has a ppgcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,ppgcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_PRCCNT : sprintf (msg_buff, X"\n%cThe process %s has an prccnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,prccnt,evaluation,cwarn->value,7); X`09break; X case JPI$_STATE : sprintf (msg_buff, X"\n%cThe process %s has a state of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,state,evaluation,cwarn->value,7); X`09break; X case JPI$_TQCNT : sprintf (msg_buff, X"\n%cThe process %s has a tqcnt of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,tqcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_VOLUMES : sprintf (msg_buff, X"\n%cThe process %s has mounted %d volumes, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,aptcnt,evaluation,cwarn->value,7); X`09break; X case JPI$_WSSIZE : sprintf (msg_buff, X"\n%cThe process %s has an wssize of %d, which is %s the value %d%c\n\n", X`09 7,curr->prcnam,aptcnt,evaluation,cwarn->value,7); X`09break; X `7D /* end switch */ X LENGTH(_msg_buff) = strlen(msg_buff); X X/* build the send list, and send the message X until all users have been notified`09*/ X X/* put the list into a holding variable */ X strcpy(hsend,curr->notify_list); X /* loop until we have reached the end of the variable */ X while (hsend`5B0`5D!=0) X `7B X sloc = strchr(hsend,','); /* find a comma*/ X if (sloc == 0) /* none left, must be one name only */ X `7B X strcpy(sendto,hsend); X hsend`5B0`5D=0; X `7D X else /* found a comma */ X `7B X sloc = abs(&hsend`5B0`5D - sloc); /* move to line offset */ X strncpy(sendto,hsend,sloc);`09 /* copy to the comma */ X sendto`5Bsloc`5D = 0;`09`09 /* terminate the line */ X strcpy(hsend,&hsend`5Bsloc+1`5D); /* copy everything after the comma*/ X `7D X LENGTH(_sendto) = strlen(sendto); X X/* send the message */ X retcode = SYS$BRKTHRUW (0,&_msg_buff,&_sendto,sndtyp,&iosb, X`09`09`09carcon,flags,0,0,0,0); X X if (retcode != SS$_NORMAL && retcode != SS$_NOSUCHDEV) X exit(retcode); X `7D /* end while hsend`5B0`5D != 0 */ X`7D /* end send_warning() function */ X X X/*************************************/ X/* this procedures checks the status */ X/* of cwarn against the value`09 */ X/* in job information retrieval */ X/* array at point offset`09 */ X/*************************************/ Xvoid check_status( offset ) Xint offset; X`7B X switch (cwarn->comparison) X `7B X case GE : X if (*jplist`5Boffset`5D.buffer >= cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X case LE : X if (*jplist`5Boffset`5D.buffer <= cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X case NE : X if (*jplist`5Boffset`5D.buffer != cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X case EQ : X if (*jplist`5Boffset`5D.buffer == cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X case GT : X if (*jplist`5Boffset`5D.buffer > cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X case LT : X if (*jplist`5Boffset`5D.buffer < cwarn->value) X`09`09send_warning ( cwarn->flag); X`09 break; X `7D /* end switch */ X`7D /* end check_status function */ X X X/*************************************/ X/* load the process id's. findall */ X/* is a switch that is used to define*/ X/* whether all the processes from */ X/* parameter file should be used or */ X/* only those that do not have their */ X/* process id's established. */ X/*************************************/ Xvoid load_pid( findall ) Xint findall; X`7B X int pidadr = -1; /* wild card process id */ X int procid;`09 /* return the pid to here */ X long retid;`09 /* return field length */ X int iosb`5B2`5D;`09 /* i/o status block */ X register jpi_status; X char prcnam`5B16`5D; /* process name */ X long retlen = 0; /* process name return length */ X /* jpi call list, get the process name and the process id */ X struct jpi_item jplist`5B3`5D = `7B X `7Bsizeof(prcnam)-1,JPI$_PRCNAM,&prcnam`5B0`5D,&retlen`7D, X `7Bsizeof(procid),JPI$_PID,&procid,&retid`7D, X `7B0,0,0,0`7D`7D; X /* used to create the parameter list */ X struct process_list *hparms; X /* switch to verify that a match was found */ X int fndmatch; X X do X `7B /* get the process information */ X jpi_status = sys$getjpiw(0,&pidadr,0,&jplist,&iosb,0,0); X if (jpi_status != SS$_NORMAL && jpi_status != SS$_NOMOREPROC) X exit(jpi_status); /* indicates fatal error */ X /* found a process */ X if (jpi_status == SS$_NORMAL) X `7B X fndmatch = FALSE; /* turn off the switch */ X /* loop through the parm list X`09until a match is found or the X`09end of the list is reached */ X X for (hparms=first;hparms!=NULL && !fndmatch;hparms = hparms->next) X `7B /* check for findall or a null process id */ X if (findall `7C`7C (!findall && hparms->pidadr == 0)) X if (strcmp(hparms->prcnam,prcnam)== 0) /* process name match?*/ X `7B X hparms->pidadr = procid; /* set the id */ X fndmatch = TRUE;`09 /* exit the loop */ X `7D /* end if strcmp*/ X `7D /* end for hparms*/ X `7D /* end if jpi_status */ X `7D while (jpi_status == SS$_NORMAL); /* end do */ X`7D /* end load_pid() function */ X X X X X/***********************************/ X/* this procedure checks the`09 */ X/* system for operational validity */ X/***********************************/ Xvoid check_system() X`7B X int iosb`5B2`5D;`09 /* i/o status block */ X register jpi_status; X int offset; X X/* loop through the descriptors for the processes to watch */ X for (curr=first;curr!= NULL; curr = curr->next) X `7B X if (curr->pidadr == 0) /* haven't found this one yet */ X load_pid (FALSE); X if (curr->pidadr == 0) /*still haven't found it */ X send_warning(NO_PROCESS); X else /* no process id found at this time */ X `7B X offset = 0; /* build a list of the parameters to warn against */ X for (cwarn = curr->dolist;cwarn!=NULL;cwarn = cwarn->next) X set_item(offset++); /* add an item */ X null_item(offset); /* terminate with nulls */ X X /* get the status */ X jpi_status = sys$getjpiw(0,&curr->pidadr,0,&jplist,&iosb,0,0); X X if (jpi_status == SS$_NONEXPR) /* doesn't exist! */ X `7B X send_warning(NO_PROCESS); X curr->pidadr = 0; /* prepare it to be checked again */ X `7D /* end if jpi_status */ X else X `7B X if (jpi_status != SS$_NORMAL) X exit(jpi_status); /* check for other errors*/ X X offset = 0; X for (cwarn = curr->dolist;cwarn != NULL;cwarn = cwarn->next) X check_status(offset++); /* check each entry */ X `7D /* end else on status */ X `7D /* end else pidadr == 0 */ X `7D /* end for loop */ X`7D /* end check_system() function */ X X X/******************************/ X/* this is the infinite loop */ X/* that drives this program. */ X/******************************/ Xvoid watch_system() X`7B X set_sleep(); X while (TRUE) X `7B X check_system(); X sleep(); X `7D /* end while true */ X`7D /* end watch_system() function */ X X X X/**********************************/ X/* the main procedure. Reads the */ X/* parameters and then watches`09 */ X/**********************************/ Xmain() X`7B X read_parms(); X load_pid(TRUE); X watch_system(); X`7D /* end main() function */ X X $ CALL UNPACK SYSWATCH.C;2 1734634383 $ create 'f' X$ cc/list/debug=notrace syswatch X$ link/notrace syswatch,sys$library:vaxcrtl/library $ CALL UNPACK SYSWATCH_BUILD.COM;1 253248681 $ v=f$verify(v) $ EXIT