Path: utzoo!hoptoad!uunet!convex!texsun!killer!texbell!bigtex!unisec!erc From: erc@unisec.usi.com (Ed Carp) Newsgroups: alt.sources Subject: uustatus - realtime uustat for HDB uucp (w/findpath) Keywords: uustat HDB uucp HoneyDanBer Message-ID: <1167@unisec.usi.com> Date: 20 Jan 89 08:59:51 GMT Organization: UniSecure Systems, Inc. Newport, RI Lines: 945 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh README <<'END_OF_README' Xuustatus - by Ed Carp X XHDB UUCP may be a dream to some, but for me it can be a real pain, Xkeeping up with everything that's happening on my system. This simple X(relatively) program dynamically displays the status of your UUCP Xconnections for you, without you having to cd into all of those Xpesky directories. It's also faster than uustat -m, and it's Xreal-time! X XThe best part about this mish-mash, however, is dirent.h. I liked the XBSD/XENIX directory routines a lot, but didn't have them on my System V Xbox. So, I hacked up a couple of routines that work just as well. Xopendir(), closedir(), and readdir() are all that are supported, but that Xwas (and still is) enough for most system programming applications. XI also have a little gadget that will search your path for a program - Xhandy if you can get to a program (execute it), but need to know where the Xdumb thing is, and don't have the time to waste with "find `echo $PATH|tr ... Xstuff. It's also MUCH faster, and it's included FREE! X XCompiling: X X1. cc -s -o uustatus uustatus.c -lcurses -ltermcap -O X (or whatever libraries your system needs to support curses). X cc -s -o findpath findpath.c -O X X XDocs: X The manpage source is in uustatus.1, the nroff'ed output X is in uustatus.prt, and the viewable output is in uustatus.doc. X I used the -man macro package, so it should work on anyone's X system. X X XCustomization: X X There are a number of tuneable parameters in uustatus.h X that you can play with. X X#define STATUS "/usr/spool/uucp/.Status" XThis is where HDB UUCP puts its status files. This should not be changed. X X#define LOCKFILE "/usr/spool/uucp/LCK..%s" XThis is where the lock files reside. Don't touch this, either... X X#define WORKFILE "/usr/spool/uucp/%s" XThis is another one of those "don't touch me" parameters... X X#define EXPDAYS 14 /* connections older than X days will not be displayed */ XIn this example, UUCP connections older than 14 days will not be displayed, Xregardless of their status. X X#define LOGON NO /* log expired systems? */ XIf you want to log everything that goes on, set this to YES. Generally Xuseless except for debugging. X X#define LOGFILE "/tmp/uuexp.log" XThis is where the log output goes. X X#define WAITMSG "WAIT" XStandard wait message. X X#define BWAITMSG " " /* blank wait msg string */ XThis must be the same length as the WAITMSG string (unless you want your screen Xto wind up looking strange). X X#define LLIMIT LINES-5 XThis is how many lines of data we can display on the screen. Generally Xa no-no to touch. X X#define FLIMIT 50 /* over this many files for site, we quit - must be < 100 */ XWhen we scan the directories for work, we don't want to eat up too many Xsystem resources if we have a large directory with lots of stuff in it (not Xtoo uncommon for a large news feed), so after we read FLIMIT file names, we Xquit that directory and indicate that we have over that many files. XI set mine to 50, bt you can use a smaller number if your system is very XI/O bound (like you're running XENIX on an XT with a 65ms hard drive). X X#define SLEEPTIME 10 /* time to sleep between samples */ XTime to sleep between samples. If you have a fast system with caching, Xyou might want to up this to make it more real-time. If nothing ever Xhappens on your system and you want to leave this up in a window, you Xmight want to set it to something like 30 or 60. X X XThat's it! Enjoy...and please remember -- if you make any changes or Xenhancements, please let me know (context diffs are OK). X XNo warranty expressed or implied. I have tried as best I could to make sure Xthere are no bugs, but you know how that goes...at least it doesn't do Xanything but read files... X XEnhancements: X X Well, a sorted display of systems would be nice...Any other X suggestions? X----------------------------------- cut here ----------------------------------- X Ed Carp N7EKG/5 (28.3-28.5) erc@unisec.usi.com X UniSecure Systems, Inc.; OS/2, Just say No! X Round Rock, Tx; (home) (512) 834-2507 X UUCP: erc@unisec X Snail Mail: 2001A Pipersfield X Austin, Tx 78758 X X Be ye therefore kind one to another, tenderhearted, forgiving X one another, even as God for Christ's sake hath forgiven you. X X -- Ephesians 4:32 END_OF_README if test 4247 -ne `wc -c basename.fun <<'END_OF_basename.fun' X/* X* X* basename - returns base name of whatever's pass to it X* strips off directory info X* not for MSDOS X* X*/ X Xchar *basename(string) Xchar *string; X{ X /* strips off directory information from string */ X char *strrchr(); X static char outstr[256]; X char *target, *start; X X start = strrchr(string, '/'); /* find last slash */ X if(start == NULL) return(string); X start++; /* bump past / */ X strcpy(outstr, start); X return(outstr); X} END_OF_basename.fun if test 469 -ne `wc -c dirent.h <<'END_OF_dirent.h' X/* X* X* /usr/include/dirent.h for SYS V (AT&T) X* X* Copyright 1989 by Edwin R. Carp X* X* kludgy, but it works... X* X*/ X X#define DIR FILE X#define dirent direct X#include Xstatic struct direct wdp; X XDIR *opendir(name) Xchar *name; X{ X return(fopen(name, "r")); X} X Xstruct direct *readdir(dp) XDIR *dp; X{ Xint ret; X X while(1) X { X ret=fread(&wdp, 1, sizeof(struct direct), dp); X if(ret < sizeof(struct dirent)) return((struct direct *)NULL); X if(wdp.d_ino == 0) continue; X return(&wdp); X } X} X Xclosedir(dp) XDIR *dp; X{ X fclose(dp); X} END_OF_dirent.h if test 559 -ne `wc -c findpath.1 <<'END_OF_findpath.1' X.TH FINDPATH 1 X.SH NAME Xfindpath \- find file in path Xpath \- display path directories X.SH SYNOPSIS X/usr/local/bin/findpath X.I file X.SH DESCRIPTION X.I Findpath Xwill report on the location of X.I file, Xsearching every directory in the path (as defined in the X$PATH variable), much like the operating system does when searching X$PATH to execute a program. It is handy for finding out where in your path Xa command resides. X.PP X.I Findpath Xis linked to X.I path, Xwhich simply displays a list of directories to be searched. It is much Xfaster than 'echo $PATH|tr ":" " "'. X.SH SEE ALSO Xcsh(1) X.SH CREDITS XThis utility was written by Ed Carp. END_OF_findpath.1 if test 636 -ne `wc -c findpath.c <<'END_OF_findpath.c' Xstatic char *sccsid = "%Z% %M% %I% %G% %U%"; X/* X* X* findpath - find a command in a path X* path - list directories searched in path X* X* usage: findpath command(s) X* path X* X* Written by Ed Carp X* X*/ X#include X#ifndef BSD X#include X#else X#include X#endif X#include X#include X#include "basename.fun" X#include "strrep.fun" X Xchar *getenv(); X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X DIR *d; X struct dirent *dire; X char *dir, *ptr, path[512], home[64]; X int i=1, vflag=0, pflag=0; X X if(strcmp("path", basename(argv[0])) == 0) X { X pflag = 1; X vflag = 1; X } X if(argc < 2 && pflag == 0) X { X fprintf(stderr, "usage: findpath command(s)...\n"); X exit(1); X } X if((dir=getenv("path")) == (char *)NULL) X { X if((dir=getenv("PATH")) == (char *)NULL) X { X fprintf(stderr, "PATH not set!\n"); X exit(1); X } X } X /* expand ~ in path to $HOME */ X strcpy(home, getenv("HOME")); X if(home != (char *)EOF) X { X while((ptr=strrep("~", home, dir)) != (char *)EOF) X { X strcpy(dir, ptr); X } X } X strcpy(path, dir); /* save it away */ X ptr = path; X while((dir=strtok(ptr, ":")) != (char *)NULL) X { X ptr = NULL; X if(!pflag) X { X if((d=opendir(dir)) == (DIR *)NULL) X { X perror(dir); X continue; X } X } X if(vflag) printf("%s\n", dir); X if(!pflag) X { X while((dire=readdir(d)) != (struct dirent *)NULL) X { X if(strcmp(dire->d_name, argv[i]) == 0) X printf("%s/%s\n", dir, argv[i]); X } X } X closedir(d); X } X} END_OF_findpath.c if test 1695 -ne `wc -c findpath.doc <<'END_OF_findpath.doc' X X X X FINDPATH(1) FINDPATH(1) X X X X NAME X findpath - find file in path path - display path directories X X SYNOPSIS X /usr/local/bin/findpath file X X DESCRIPTION X Findpath will report on the location of file, searching X every directory in the path (as defined in the $PATH X variable), much like the operating system does when X searching $PATH to execute a program. It is handy for X finding out where in your path a command resides. X X Findpath is linked to path, which simply displays a list of X directories to be searched. It is much faster than 'echo X $PATH|tr ":" " "'. X X SEE ALSO X csh(1) X X CREDITS X This utility was written by Ed Carp. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 1 (printed 1/20/89) X X X END_OF_findpath.doc if test 914 -ne `wc -c findpath.prt <<'END_OF_findpath.prt' X X X X FINDPATH(1) FINDPATH(1) X X X X NAME X findpath - find file in path path - display path directories X X SYNOPSIS X /usr/local/bin/findpath _f_i_l_e X X DESCRIPTION X _F_i_n_d_p_a_t_h will report on the location of _f_i_l_e, searching X every directory in the path (as defined in the $PATH X variable), much like the operating system does when X searching $PATH to execute a program. It is handy for X finding out where in your path a command resides. X X _F_i_n_d_p_a_t_h is linked to _p_a_t_h, which simply displays a list of X directories to be searched. It is much faster than 'echo X $PATH|tr ":" " "'. X X SEE ALSO X csh(1) X X CREDITS X This utility was written by Ed Carp. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 1 (printed 1/20/89) X X X END_OF_findpath.prt echo shar: 28 control characters may be missing from \"findpath.prt\" if test 970 -ne `wc -c strrep.fun <<'END_OF_strrep.fun' X#ifndef NULL X#include X#endif X Xchar *strrep(a, b, c) /* replace first a with b in string c */ Xchar *a, *b, *c; X{ X char *pd; X static char d[512]; /* yes, yes, could be fancier, I know! */ X X *d = NULL; X pd = d; X while(*c) X { X if(strncmp(a, c, strlen(a)) == 0) break; X *pd++ = *c++; X } X if(!*c) return((char *)EOF); /* a not found in c */ X *pd = NULL; X strcat(d, b); X strcat(d, c+strlen(a)); X return(d); X} END_OF_strrep.fun if test 446 -ne `wc -c uustatus.1 <<'END_OF_uustatus.1' X.TH UUSTATUS 1L "January 20, 1989" "Version 1.0" X.ad b X.SH NAME Xuustatus \- check UUCP status on HDB systems X.SH SYNOPSIS Xuustatus X.SH DESCRIPTION X.I Uustatus Xwill dynamically display the status of ongoing and failed UUCP connections. XIt is intended to be used with the HDB (HoneyDanBer) UUCP system. X.SH PORTING XThis utility was written for System V; however it should run "as is" on XBSD systems and should run on XENIX systems by changing the reference to X.B dirent.h Xin X.B uustatus.h Xto X.B sys/ndir.h. X.SH NOTES XAs distributed, this utility will not display statistics concerning Xfailed UUCP connections due to "WRONG TIME TO CALL" errors. X.SH CREDITS XThis utility was written by Edwin R. Carp. END_OF_uustatus.1 if test 698 -ne `wc -c uustatus.c <<'END_OF_uustatus.c' X/* X* X* uustatus - display UUCP communications status for HDB systems X* X* Written 01/19/89 by Ed Carp X* X* Copyright 1989, by Edwin R. Carp X* X*/ X Xchar *sccsid = "uustatus, version 1.0 01/20/89 Copyright 1989 by Edwin R. Carp"; X#include X#include X#include X#include X#include X#define YES 1 X#define NO 0 X#include "uustatus.h" X#include "basename.fun" XDIR *din, *win; Xstruct dirent *dp, *dpw; XFILE *in, *exp; X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X char line[128], lock[64], cretries[6]; X char cfiles[6], work[64], name[15]; X int i, status, files, retries, bye(); X int systems, expflag, display; X long secs, retryt, curr; X struct tm *t1, *t2; X X printf("%s\n\n", sccsid); X if(argc > 2) X { X printf("usage: %s\n", basename(argv[0])); X exit(1); X } X sleep(2); X chdir(STATUS); X for(i=1; i<4; i++) X signal(i, bye); X if(LOGON) exp = fopen(LOGFILE, "w"); X initscr(); X while(1) X { X move(0, 0); X if((din=opendir(".")) == (DIR *)NULL) X { X perror(STATUS); X exit(1); X } X printw("SYSTEM RETRY FILES LAST TRY NEXT TRY STATUS"); X time(&curr); X if(LOGON) fprintf(exp, "%s", ctime(&curr)); X display = systems = 0; X move(0, COLS-(1+strlen(WAITMSG))); X standout(); X addstr(WAITMSG); X standend(); X move(2, 0); X refresh(); X clrtobot(); X while((dp=readdir(din)) != (struct dirent *)NULL) X { X if(display > LLIMIT) break; X if(*dp->d_name == '.') continue; X systems++; X if((in=fopen(dp->d_name, "r")) == (FILE *)NULL) continue; X fgets(line, 510, in); X fclose(in); X line[strlen(line)-1] = NULL; X sscanf(line, "%d %d %ld %ld", &status, &retries, &secs, &retryt); X expflag = 0; X strcpy(name, dp->d_name); X if((curr - secs) > ((long)EXPDAYS*(long)24*(long)60*(long)60)) X { X if(LOGON) fprintf(exp, "%s EXPIRED! (%ld - %ld) > %ld\n", X name, curr, secs, X ((long)EXPDAYS*(long)24*(long)60*(long)60)); X expflag = 1; X } X sprintf(lock, LOCKFILE, name); X sprintf(work, WORKFILE, name); X files = 0; X if((win=opendir(work)) != (DIR *)NULL) X { X /* count the number of C. files */ X while((dp=readdir(win)) != (struct dirent *)NULL) X { X if(strncmp(dp->d_name, "C.", 2) == 0) files++; X if(files > FLIMIT) break; X } X closedir(win); X } X if(files != 0) sprintf(cfiles, "%d", files); X else strcpy(cfiles, " "); X if(files > FLIMIT) sprintf(cfiles, ">%d", FLIMIT); X if(retries != 0) sprintf(cretries, "%d", retries); X else strcpy(cretries, " "); X /* kludges for screwy status stuff with HDB */ X if(access(lock, 0) == 0 && status != 3) status = 22; X if(status == 11) status = 13; /* fix bug */ X if(status == 2) continue; /* skip WRONG TIME TO CALL */ X t1 = localtime(&secs); X retryt += secs; X t2 = localtime(&retryt); X if(expflag == 0) X printw("%-14s %-3s %-3s ", name, cretries, cfiles); X else if(LOGON) fprintf(exp, "%-14s %-3d ", name, retries); X t1 = localtime(&secs); X if(expflag == 0) printw("%02d/%02d %02d:%02d ", X t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min); X else if(LOGON) fprintf(exp, "%02d/%02d %02d:%02d ", X t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min); X t2 = localtime(&retryt); X if(expflag == 0) printw("%02d/%02d %02d:%02d ", X t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min); X else if(LOGON) fprintf(exp, "%02d/%02d %02d:%02d ", X t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min); X if(status == 3 || status == 22) standout(); X if(expflag == 0) printw("%s\n", errortext[status]); X else if(LOGON) fprintf(exp, "%s\n", errortext[status]); X if(status == 3 || status == 22) standend(); X display++; X } X printw("\n%d UUCP connections active", systems); X move(0, COLS-(1+strlen(BWAITMSG))); X addstr(BWAITMSG); X move(1, 0); X refresh(); X closedir(din); X sleep(SLEEPTIME); X } X} Xbye(sig) Xint sig; X{ X if(LOGON) fclose(exp); X endwin(); X exit(0); X} END_OF_uustatus.c if test 4438 -ne `wc -c uustatus.doc <<'END_OF_uustatus.doc' X X X X UUSTATUS(1L) Version 1.0 UUSTATUS(1L) X X X X NAME X uustatus - check UUCP status on HDB systems X X SYNOPSIS X uustatus X X DESCRIPTION X Uustatus will dynamically display the status of ongoing and X failed UUCP connections. It is intended to be used with the X HDB (HoneyDanBer) UUCP system. X X PORTING X This utility was written for System V; however it should run X "as is" on BSD systems and should run on XENIX systems by X changing the reference to dirent.h in uustatus.h to X sys/ndir.h. X X NOTES X As distributed, this utility will not display statistics X concerning failed UUCP connections due to "WRONG TIME TO X CALL" errors. X X CREDITS X This utility was written by Edwin R. Carp. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 1 (January 20, 1989) (printed 1/20/89) X X X END_OF_uustatus.doc if test 975 -ne `wc -c uustatus.h <<'END_OF_uustatus.h' X/* X* X* tuneable parameters X* X*/ X X#define STATUS "/usr/spool/uucp/.Status" X#define LOCKFILE "/usr/spool/uucp/LCK..%s" X#define WORKFILE "/usr/spool/uucp/%s" X#define EXPDAYS 14 /* connections older than X days will not be displayed */ X#define LOGON NO /* log expired systems? */ X#define LOGFILE "/tmp/uuexp.log" X#define WAITMSG "WAIT" X#define BWAITMSG " " /* blank wait msg string */ X#define LLIMIT LINES-5 X#define FLIMIT 50 /* over this many files for site, we quit - must be < 100 */ X#define SLEEPTIME 10 /* time to sleep between samples */ X X/* X* X* end of tuneable parameters X* X*/ X Xchar *errortext[] = X{ X /* SS_OK 0 */ "SUCCESSFUL", X /* SS_NO_DEVICE 1 */ "NO DEVICES AVAILABLE", X /* SS_TIME_WRONG 2 */ "WRONG TIME TO CALL", X /* SS_INPROGRESS 3 */ "TALKING", X /* SS_CONVERSATION 4 */ "CONVERSATION FAILED", X /* SS_SEQBAD 5 */ "BAD SEQUENCE CHECK", X /* SS_LOGIN_FAILED 6 */ "LOGIN FAILED", X /* SS_DIAL_FAILED 7 */ "DIAL FAILED", X /* SS_BAD_LOG_MCH 8 */ "BAD LOGIN/MACHINE COMBINATION", X /* SS_LOCKED_DEVICE 9 */ "DEVICE LOCKED", X /* SS_ASSERT_ERROR 10 */ "ASSERT ERROR", X /* SS_BADSYSTEM 11 */ "SYSTEM NOT IN Systems FILE", X /* SS_CANT_ACCESS_DEVICE 12 */ "CAN'T ACCESS DEVICE", X /* SS_DEVICE_FAILED 13 */ "DEVICE FAILED", X /* SS_WRONG_MCH 14 */ "WRONG MACHINE NAME", X /* SS_CALLBACK 15 */ "CALLBACK REQUIRED", X /* SS_RLOCKED 16 */ "REMOTE HAS A LCK FILE FOR ME", X /* SS_RUNKNOWN 17 */ "REMOTE DOES NOT KNOW ME", X /* SS_RLOGIN 18 */ "REMOTE REJECT AFTER LOGIN", X /* SS_UNKNOWN_RESPONSE 19 */ "REMOTE REJECT, UNKNOWN MESSAGE", X /* SS_STARTUP 20 */ "STARTUP FAILED", X /* SS_CHAT_FAILED 21 */ "CALLER SCRIPT FAILED", X /* 22 */ "CALL IN PROGRESS", X}; END_OF_uustatus.h if test 1698 -ne `wc -c uustatus.prt <<'END_OF_uustatus.prt' X X X X UUSTATUS(1L) Version 1.0 UUSTATUS(1L) X X X X NAME X uustatus - check UUCP status on HDB systems X X SYNOPSIS X uustatus X X DESCRIPTION X _U_u_s_t_a_t_u_s will dynamically display the status of ongoing and X failed UUCP connections. It is intended to be used with the X HDB (HoneyDanBer) UUCP system. X X PORTING X This utility was written for System V; however it should run X "as is" on BSD systems and should run on XENIX systems by X changing the reference to dirent.h in uustatus.h to X sys/ndir.h. X X NOTES X As distributed, this utility will not display statistics X concerning failed UUCP connections due to "WRONG TIME TO X CALL" errors. X X CREDITS X This utility was written by Edwin R. Carp. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 1 (January 20, 1989) (printed 1/20/89) X X X END_OF_uustatus.prt echo shar: 8 control characters may be missing from \"uustatus.prt\" if test 991 -ne `wc -c