home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / nocol / part19 < prev    next >
Encoding:
Text File  |  1993-11-23  |  75.8 KB  |  2,256 lines

  1. Newsgroups: comp.sources.misc
  2. From: vikas@jvnc.net (Vikas Aggarwal)
  3. Subject: v40i149:  nocol - Network Monitoring System, Part19/26
  4. Message-ID: <1993Nov23.212823.22031@sparky.sterling.com>
  5. X-Md4-Signature: 1804dc18545fe7748b4f05494a3b13e1
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Tue, 23 Nov 1993 21:28:23 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: vikas@jvnc.net (Vikas Aggarwal)
  12. Posting-number: Volume 40, Issue 149
  13. Archive-name: nocol/part19
  14. Environment: INET, UNIX
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  nocol-3.0/src/INSTALL
  21. #   nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c
  22. #   nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h
  23. #   nocol-3.0/src/cmu-snmp/man/snmp_api.3
  24. #   nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h
  25. #   nocol-3.0/src/doc/nocol-overview.8 nocol-3.0/src/genmon/genmon.c
  26. #   nocol-3.0/src/lib/event_utils.c nocol-3.0/src/support/mping/MAIL
  27. # Wrapped by kent@sparky on Tue Nov  9 22:22:23 1993
  28. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  29. echo If this archive is complete, you will see the following message:
  30. echo '          "shar: End of archive 19 (of 26)."'
  31. if test -f 'nocol-3.0/src/INSTALL' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'nocol-3.0/src/INSTALL'\"
  33. else
  34.   echo shar: Extracting \"'nocol-3.0/src/INSTALL'\" \(8608 characters\)
  35.   sed "s/^X//" >'nocol-3.0/src/INSTALL' <<'END_OF_FILE'
  36. X## $Header: /home/aggarwal/lsrc/nocol/src/RCS/INSTALL,v 1.4 1993/11/03 22:38:32 aggarwal Exp $
  37. X
  38. XINSTALLATION INSTRUCTIONS FOR 'NOCOL'
  39. X=====================================
  40. X
  41. XNOTE:  Please look at the file PORTING for special instructions that
  42. X       might pertain to your operating system.
  43. X
  44. XNOTE:    You will have to install the PERL monitors manually (in perlnocol).
  45. X    See the perlnocol/README for more information.
  46. X
  47. XMost/all of the configuration is done in the top level 'Makefile' (under
  48. Xnocol/src). All customizable parameters are well documented. Edit this file
  49. Xbefore typing 'make'.
  50. X
  51. XTo build only a subset of the monitoring programs, use the following syntax:
  52. X
  53. X   make TOP=/usr/nocol SRCDIR=`pwd` SRCS="netmon pingmon trapmon"
  54. X
  55. XSample config files are also provided for each monitor. These are copied
  56. Xover in the nocol/etc/samples directory during installation. Copy these
  57. Xto nocol/etc/ and edit for each monitor.
  58. X
  59. X
  60. XMakefile
  61. X--------
  62. X1. Decide on a toplevel directory under which the software will be installed.
  63. X   Define TOP to this toplevel directory.
  64. X
  65. X   Note that the program creates the following directories under this
  66. X   toplevel directory:
  67. X
  68. X        data        output from all the monitors
  69. X        bin            for installation of all the binaries
  70. X        etc            location of all the config files
  71. X   It is advised that the location of these sudirectories be left as they
  72. X   are. However, if you must make changes, then the various subdirectory
  73. X   names can also be set individually in the Makefile.
  74. X
  75. X2. Set the value of SRCDIR to the location of the 'src' (current) directory.
  76. X   By default the Makefile sets the value to TOP/src
  77. X
  78. X3. Set NEEDOBJS to the missing functions on your system. A list of provided
  79. X   functions is provided in the Makefile (putenv.o bstring.o etc.).
  80. X
  81. X4. Set SYSLIBS to the libraries needed to link with on your system.
  82. X   This is mainly for curses/resolver/bsd sockets. These are well 
  83. X   documented in the Makefile.
  84. X
  85. X5. The 'pingmon' directory can generate the OSI version as well as the IP
  86. X   version of the 'pingmon' monitor. If you want the OSI 'osipingmon' monitor
  87. X   also, then set MAKEOSI to YES.
  88. X
  89. X   Set SYSDEFS to MULTIPING if you are using the multiple ping program for IP
  90. X   'ippingmon'. Remember to set the value of IPPING to the location of this
  91. X   ping program (multiping) also if you are defining this.
  92. X   The 'multiping' program is located under 'src/support', and can ping
  93. X   multiple sites simultaneously. Compile and install this program
  94. X   separately. Make sure that it is installed 'suid' root in the location
  95. X   specified by IPPING.
  96. X
  97. X   Set the value of IPPING and OSIPING to the exact location of the 'ping'
  98. X   programs for IP and OSI (typically under /etc or /usr/etc). If the output
  99. X   from the ping commands is as described below, then you are in luck, else
  100. X   you will need to make minor modifications in the 'src/pingmon/poll_sites.c' 
  101. X   module (the area to modify is well commented so it should be easy).
  102. X
  103. X    r2d2-vikas> /usr/etc/ping -s nisc.jvnc.net 1000  5 | tail -2
  104. X      5 packets transmitted, 5 packets received, 0% packet loss
  105. X      round-trip (ms)  min/avg/max = 4/4/5
  106. X
  107. X   If using 'multiping', the program automatically uses the '-t' option 
  108. X   (for tabular output). No modifications are needed.
  109. X
  110. X6. Set the value of NLOG_HOST to be the host that receives all the
  111. X   NOCOL log messages. Ideally, you should create a CNAME entry for
  112. X   'nocol.your.domain' in your nameserver. The default logging port
  113. X   is defined in 'noclog.h' to 5354. You can change it in the file
  114. X   you desire some other port number (preferably >1023 so that the program
  115. X   does not have to run as 'root').
  116. X   Add the following line in your /etc/services:
  117. X
  118. X    noclog        5354/udp
  119. X
  120. X7. Set the definition of SRCS to the programs that you want to compile.
  121. X   Check the values of CC (for the compiler type) and CFLAGS. Set INSTALL
  122. X   to '$(SRCDIR)/utility/myinstall', if you have a new version of 
  123. X   'install' on your system (the syntax is different on these). Use:
  124. X
  125. X    install -c -m 751 thisfile dest
  126. X
  127. X   to see if your 'install' is compatible.
  128. X
  129. X10. Type in:
  130. X
  131. X       % make 
  132. X       % make install
  133. X
  134. X    It is advised to save the output of the make command to a temporary output
  135. X    file so that it can be perused later for any errors.
  136. X
  137. X11. Install 'trapmon' (and 'multiping') as 'suid' root since they needs 
  138. X    to access priveleged ports:
  139. X
  140. X    chown root.network  trapmon multiping
  141. X    chmod 4710  trapmon multiping
  142. X
  143. X12. Copy the config files in the TOP/etc/samples directory to the TOP/etc
  144. X    directory. List the hosts which can log to 'noclogd' in the config
  145. X    file (make the directory for the log files if needed). Edit all other
  146. X    config files.
  147. X
  148. X12. Miscellaneous:
  149. X   - The sample 'TOP/bin/keepalive_monitors' program should be modified
  150. X     and run from your crontab periodically (you can distribute the 
  151. X     monitors on two systems and share the /nocol disk via NFS).
  152. X     List all the monitors that you want to run in this file.
  153. X
  154. X   - edit the 'bin/notifier' program. This is useful to send email
  155. X     when a site is in critical mode for an extended period of time.
  156. X     Modify and put in your crontab to run once an hour.
  157. X
  158. X   - Remember to put an entry in your crontab to move the NOCOL log
  159. X     files (or delete them) and send a HUP signal to the 'noclogd'
  160. X     daemon every night.
  161. X
  162. X13. Test 'noclogd' by starting it up in debug mode (-d). See if it
  163. X    complains about anything.
  164. X    Start up the various monitors using 'keepalive_monitors'.
  165. X    Use 'nocol -l 4' to see if any data is being collected under the 
  166. X    DATA directory. Look in the TOP/etc/*.error files for any errors.
  167. X
  168. X14. You can add user 'nocol'  to your password file to allow anyone to
  169. X    log in as user 'nocol' and see the state of the network. A typical
  170. X    entry is:
  171. X
  172. X    nocol::65534:65534:JvNC NETMON:/tmp:/nocol/bin/nocol
  173. X
  174. X
  175. XPERLNOCOL
  176. X---------
  177. X
  178. XThere is a new PERL ('Pattern Extraction and Programming Language')
  179. Xinterface for developing additional NOCOL monitors. To use this,
  180. Xyou need to have PERL installed on your system (perl is available
  181. Xfrom ftp.uu.net or from ftp.netlabs.com).
  182. X
  183. X1.  Edit perlnocol/nocollib.pl  and set the values of:
  184. X    $nocolroot , $NLOG_HOST, $NLOG_PORT
  185. X
  186. X    Edit the location of the perl program on your system (the first line
  187. X    in the perl scripts).
  188. X
  189. X2.  Watch out for the padding in the '$event_t'  template. Compilers tend
  190. X    to align the fields of structures on even boundaries, so you might
  191. X    have to add some additional 'null' padding using 'x'. Set
  192. X    $libdebug = 1 to see the size of the $event structure. The size of
  193. X    the data files produced by the C monitors should be a multiple of the
  194. X    perl $event structure.
  195. X
  196. X3.  If the monitor that you want to run uses 'rcisco', then enter your 
  197. X    router's password in it and install it in nocol/bin  with mode 710.
  198. X    If the monitor uses 'snmpwalk', compile the applications under 
  199. X    src/cmu-snmp/ and install it in nocol/bin. Edit the SNMP community
  200. X    string to the perl script.
  201. X
  202. X4.  Create the config file.  You might need small adjustments to the
  203. X    regular expressions in &dotest()  depending upon your site.
  204. X
  205. X
  206. X5.  For troubleshooting, set the $debug and $libdebug values to '1'.
  207. X
  208. X
  209. XTROUBLESHOOTING
  210. X---------------
  211. X
  212. X1. Some warnings are to be expected, but there should be no major errors.
  213. X
  214. X2. If the errors are about include files or variable types, look for the file
  215. X   that is being included under the  /usr/include sub-directories. The
  216. X   various systems love to move include files back and forth between the
  217. X   include and the include/sys directories (especially 'time.h').
  218. X
  219. X3. For the nameserver monitor, old versions of the resolver library might
  220. X   complain. Some include files defined the '_res' variable differently, so
  221. X   try changing all occurences of '_res.nsaddr' to '_res.nsaddr_list[0]'
  222. X   in the src/nsmon/nsmon.c module (look in your /usr/include/resolv.h).
  223. X   Make sure that the 'libresolv' library exists while linking.
  224. X
  225. X4. For trapmon, the CMU SNMP library is used. Make sure that it was properly
  226. X   built under 'src/cmu-snmp/lib'
  227. X
  228. X5. Most monitors have a '-d' option for debugging, or create error
  229. X   files in the TOP/etc.
  230. X
  231. X6. If you get a 'h_addr_list[0]' not defined error, simply edit 
  232. X   nocol.h and add the following line in it:
  233. X
  234. X    #define h_addr 1
  235. X
  236. X  This is because of the difference in the hostent() structure of netdb.h
  237. X  in very old systems.
  238. X
  239. XBest of luck. Comments to 'nocol-info@jvnc.net' and bugs to
  240. X'nocol-bugs@jvnc.net'.
  241. X
  242. XREADME file has more information. For documentation on overview, look under
  243. Xdoc/nocol-overview.8.
  244. X
  245. X
  246. X    Vikas Aggarwal
  247. X    Network Engineering
  248. X    JvNCnet, GES
  249. X    ------------
  250. X
  251. END_OF_FILE
  252.   if test 8608 -ne `wc -c <'nocol-3.0/src/INSTALL'`; then
  253.     echo shar: \"'nocol-3.0/src/INSTALL'\" unpacked with wrong size!
  254.   fi
  255.   # end of 'nocol-3.0/src/INSTALL'
  256. fi
  257. if test -f 'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c' -a "${1}" != "-c" ; then 
  258.   echo shar: Will not clobber existing file \"'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c'\"
  259. else
  260.   echo shar: Extracting \"'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c'\" \(8499 characters\)
  261.   sed "s/^X//" >'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c' <<'END_OF_FILE'
  262. X/*
  263. X * snmp_var_route.c - return a pointer to the named variable.
  264. X *
  265. X *
  266. X */
  267. X/***********************************************************
  268. X    Copyright 1988, 1989 by Carnegie Mellon University
  269. X    Copyright 1989    TGV, Incorporated
  270. X
  271. X              All Rights Reserved
  272. X
  273. XPermission to use, copy, modify, and distribute this software and its
  274. Xdocumentation for any purpose and without fee is hereby granted,
  275. Xprovided that the above copyright notice appear in all copies and that
  276. Xboth that copyright notice and this permission notice appear in
  277. Xsupporting documentation, and that the name of CMU and TGV not be used
  278. Xin advertising or publicity pertaining to distribution of the software
  279. Xwithout specific, written prior permission.
  280. X
  281. XCMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  282. XINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  283. XEVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  284. XCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  285. XUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  286. XOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  287. XPERFORMANCE OF THIS SOFTWARE.
  288. X******************************************************************/
  289. X
  290. X#define GATEWAY            /* MultiNet is always configured this way! */
  291. X#include <sys/types.h>
  292. X#include <sys/socket.h>
  293. X#include <sys/time.h>
  294. X#include <netinet/in.h>
  295. X#include <syslog.h>
  296. X#include <sys/mbuf.h>
  297. X#include <net/if.h>
  298. X#define KERNEL        /* to get routehash and RTHASHSIZ */
  299. X#include <net/route.h>
  300. X#undef    KERNEL
  301. X#define rt_unit rt_hash               /* Reuse this field for device # */
  302. X#include <nlist.h>
  303. X#ifndef NULL
  304. X#define NULL 0
  305. X#endif
  306. X
  307. X#define CACHE_TIME (120)        /* Seconds */
  308. X
  309. X#include "asn1.h"
  310. X#include "snmp.h"
  311. X#include "snmp_impl.h"
  312. X#include "mib.h"
  313. X#include "snmp_vars.h"
  314. X
  315. Xstatic struct rtentry **rthead=0;
  316. Xstatic int rtsize=0, rtalloc=0;
  317. X
  318. Xstatic struct nlist nl[] = {
  319. X#define N_RTHOST       0
  320. X    { "_rthost" },
  321. X#define N_RTNET        1
  322. X    { "_rtnet" },
  323. X#define N_RTHASHSIZE    2
  324. X    { "_rthashsize" },
  325. X    0,
  326. X};
  327. X
  328. Xu_char *
  329. Xvar_ipRouteEntry(vp, name, length, exact, var_len, access_method)
  330. X    register struct variable *vp;   /* IN - pointer to variable entry that points here */
  331. X    register oid    *name;        /* IN/OUT - input name requested, output name found */
  332. X    register int    *length;    /* IN/OUT - length of input and output strings */
  333. X    int            exact;        /* IN - TRUE if an exact match was requested. */
  334. X    int            *var_len;   /* OUT - length of variable or 0 if function returned. */
  335. X    int            *access_method; /* OUT - 1 if function, 0 if char pointer. */
  336. X{
  337. X    /*
  338. X     * object identifier is of form:
  339. X     * 1.3.6.1.2.1.4.21.1.1.A.B.C.D,  where A.B.C.D is IP address.
  340. X     * IPADDR starts at offset 10.
  341. X     */
  342. X    register int Save_Valid, result, RtIndex;
  343. X    static int saveNameLen=0, saveExact=0, saveRtIndex=0;
  344. X    static oid saveName[14], Current[14];
  345. X    u_char *cp;
  346. X    oid *op;
  347. X
  348. X
  349. X    /*
  350. X     *    OPTIMIZATION:
  351. X     *
  352. X     *    If the name was the same as the last name, with the possible
  353. X     *    exception of the [9]th token, then don't read the routing table
  354. X     *
  355. X     */
  356. X
  357. X    if ((saveNameLen == *length) && (saveExact == exact)) {
  358. X    register int temp=name[9];
  359. X    name[9] = 0;
  360. X    Save_Valid = (compare(name, *length, saveName, saveNameLen) == 0);
  361. X    name[9] = temp;
  362. X    } else Save_Valid = 0;
  363. X
  364. X    if (Save_Valid) {
  365. X    register int temp=name[9];    /* Fix up 'lowest' found entry */
  366. X    bcopy((char *) Current, (char *) name, 14 * sizeof(oid));
  367. X    name[9] = temp;
  368. X    *length = 14;
  369. X    RtIndex = saveRtIndex;
  370. X    } else {
  371. X    /* fill in object part of name for current (less sizeof instance part) */
  372. X
  373. X    bcopy((char *)vp->name, (char *)Current, (int)(vp->namelen - 4) * sizeof(oid));
  374. X
  375. X#if 0
  376. X    /*
  377. X     *  Only reload if this is the start of a wildcard
  378. X     */
  379. X    if (*length < 14) {
  380. X        Route_Scan_Reload();
  381. X    }
  382. X#else
  383. X        Route_Scan_Reload();
  384. X#endif
  385. X    for(RtIndex=0; RtIndex < rtsize; RtIndex++) {
  386. X        cp = (u_char *)&(((struct sockaddr_in *) &(rthead[RtIndex]->rt_dst))->sin_addr.s_addr);
  387. X        op = Current + 10;
  388. X        *op++ = *cp++;
  389. X        *op++ = *cp++;
  390. X        *op++ = *cp++;
  391. X        *op++ = *cp++;
  392. X
  393. X        result = compare(name, *length, Current, 14);
  394. X        if ((exact && (result == 0)) || (!exact && (result < 0)))
  395. X        break;
  396. X    }
  397. X    if (RtIndex >= rtsize) return(NULL);
  398. X    /*
  399. X     *  Save in the 'cache'
  400. X     */
  401. X    bcopy((char *) name, (char *) saveName, *length * sizeof(oid));
  402. X    saveName[9] = '\0';
  403. X    saveNameLen = *length;
  404. X    saveExact = exact;
  405. X    saveRtIndex = RtIndex;
  406. X    /*
  407. X     *  Return the name
  408. X     */
  409. X    bcopy((char *) Current, (char *) name, 14 * sizeof(oid));
  410. X    *length = 14;
  411. X    }
  412. X
  413. X    *access_method = 0;
  414. X    *var_len = sizeof(long_return);
  415. X    switch(vp->magic){
  416. X    case IPROUTEDEST:
  417. X        return(u_char *) &((struct sockaddr_in *) &rthead[RtIndex]->rt_dst)->sin_addr.s_addr;
  418. X    case IPROUTEIFINDEX:
  419. X        long_return = rthead[RtIndex]->rt_unit;
  420. X        return (u_char *)&long_return;
  421. X    case IPROUTEMETRIC1:
  422. X        long_return = (rthead[RtIndex]->rt_flags & RTF_GATEWAY) ? 1 : 0;
  423. X        return (u_char *)&long_return;
  424. X    case IPROUTEMETRIC2:
  425. X        long_return = -1;
  426. X        return (u_char *)&long_return;
  427. X    case IPROUTEMETRIC3:
  428. X        long_return = -1;
  429. X        return (u_char *)&long_return;
  430. X    case IPROUTEMETRIC4:
  431. X        long_return = -1;
  432. X        return (u_char *)&long_return;
  433. X    case IPROUTENEXTHOP:
  434. X        return(u_char *) &((struct sockaddr_in *) &rthead[RtIndex]->rt_gateway)->sin_addr.s_addr;
  435. X    case IPROUTETYPE:
  436. X        long_return = (rthead[RtIndex]->rt_flags & RTF_GATEWAY) ? 4 : 3;
  437. X        return (u_char *)&long_return;
  438. X    case IPROUTEPROTO:
  439. X        long_return = (rthead[RtIndex]->rt_flags & RTF_DYNAMIC) ? 4 : 2;
  440. X        return (u_char *)&long_return;
  441. X    case IPROUTEAGE:
  442. X        long_return = 0;
  443. X        return (u_char *)&long_return;
  444. X    default:
  445. X        ERROR("");
  446. X   }
  447. X   return NULL;
  448. X}
  449. X
  450. Xinit_routes(){
  451. X
  452. X    nlist("/vmunix",nl);
  453. X}
  454. X
  455. Xstatic Route_Scan_Reload()
  456. X{
  457. X    struct mbuf **routehash, mb;
  458. X    register struct mbuf *m;
  459. X    struct ifnet ifnet;
  460. X    struct rtentry *rt;
  461. X    int i, table, qsort_compare();
  462. X    register char *cp;
  463. X    char name[16], temp[16];
  464. X    static int Time_Of_Last_Reload=0;
  465. X    struct timeval now;
  466. X    int hashsize;
  467. X
  468. X    gettimeofday(&now, (struct timezone *)0);
  469. X    if (Time_Of_Last_Reload+CACHE_TIME > now.tv_sec)
  470. X        return;
  471. X    Time_Of_Last_Reload =  now.tv_sec;
  472. X
  473. X    /*
  474. X     *  Makes sure we have SOME space allocated for new routing entries
  475. X     */
  476. X    if (!rthead) {
  477. X        rthead = (struct rtentry **) malloc(100 * sizeof(struct rtentry *));
  478. X        bzero((char *)rthead, 100 * sizeof(struct rtentry *));
  479. X        rtalloc = 100;
  480. X    }
  481. X
  482. X    for (table=N_RTHOST; table<=N_RTNET; table++) {
  483. X        klseek(nl[N_RTHASHSIZE].n_value);
  484. X        klread((char *)&hashsize, sizeof(hashsize));
  485. X        routehash = (struct mbuf **)malloc(hashsize * sizeof(struct mbuf *));
  486. X        klseek(nl[table].n_value);
  487. X        klread((char *)routehash, hashsize * sizeof(struct mbuf *));
  488. X        for (i = 0; i < hashsize; i++) {
  489. X        if (routehash[i] == 0)
  490. X            continue;
  491. X        m = routehash[i];
  492. X        while (m) {
  493. X            /*
  494. X             *    Dig the route out of the kernel...
  495. X             */
  496. X            klseek(m);
  497. X            klread(&mb, sizeof (mb));
  498. X            m = mb.m_next;
  499. X            rt = mtod(&mb, struct rtentry *);
  500. X            if (rt->rt_ifp != 0) {
  501. X            klseek(rt->rt_ifp);
  502. X            klread((char *)&ifnet, sizeof (ifnet));
  503. X            klseek((int)ifnet.if_name);
  504. X            klread(name, 16);
  505. X            name[15] = '\0';
  506. X            cp = (char *) index(name, '\0');
  507. X            *cp++ = ifnet.if_unit + '0';
  508. X            *cp = '\0';
  509. X/*            if (strcmp(name,"lo0") == 0) continue; */
  510. X            Interface_Scan_Init();
  511. X            while (Interface_Scan_Next(&rt->rt_unit, temp, 0, 0) != 0) {
  512. X                if (strcmp(name, temp) == 0) break;
  513. X            }
  514. X            }
  515. X            /*
  516. X             *    Allocate a block to hold it and add it to the database
  517. X             */
  518. X            if (rtsize >= rtalloc) {
  519. X            rthead = (struct rtentry **) realloc((char *)rthead, 2 * rtalloc * sizeof(struct rtentry *));
  520. X            bzero((char *) &rthead[rtalloc], rtalloc * sizeof(struct rtentry *));
  521. X            rtalloc *= 2;
  522. X            }
  523. X            if (!rthead[rtsize])
  524. X            rthead[rtsize] = (struct rtentry *) malloc(sizeof(struct rtentry));
  525. X            /*
  526. X             *    Add this to the database
  527. X             */
  528. X            bcopy((char *)rt, (char *)rthead[rtsize], sizeof(struct rtentry));
  529. X            rtsize++;
  530. X        }
  531. X        }
  532. X    }
  533. X    /*
  534. X     *  Sort it!
  535. X     */
  536. X    qsort((char *)rthead,rtsize,sizeof(rthead[0]),qsort_compare);
  537. X}
  538. X
  539. X
  540. X
  541. X/*
  542. X *    Create a host table
  543. X */
  544. Xstatic int qsort_compare(r1,r2)
  545. Xstruct rtentry **r1, **r2;
  546. X{
  547. X    register u_long dst1 = ntohl(((struct sockaddr_in *) &((*r1)->rt_dst))->sin_addr.s_addr);
  548. X    register u_long dst2 = ntohl(((struct sockaddr_in *) &((*r2)->rt_dst))->sin_addr.s_addr);
  549. X
  550. X    /*
  551. X     *    Do the comparison
  552. X     */
  553. X    if (dst1 == dst2) return(0);
  554. X    if (dst1 > dst2) return(1);
  555. X    return(-1);
  556. X}
  557. END_OF_FILE
  558.   if test 8499 -ne `wc -c <'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c'`; then
  559.     echo shar: \"'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c'\" unpacked with wrong size!
  560.   fi
  561.   # end of 'nocol-3.0/src/cmu-snmp/apps/snmp_var_route.c'
  562. fi
  563. if test -f 'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h' -a "${1}" != "-c" ; then 
  564.   echo shar: Will not clobber existing file \"'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h'\"
  565. else
  566.   echo shar: Extracting \"'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h'\" \(151 characters\)
  567.   sed "s/^X//" >'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h' <<'END_OF_FILE'
  568. X
  569. X#ifndef MAXHOSTNAMELEN
  570. X#define MAXHOSTNAMELEN    64
  571. X#endif
  572. X
  573. X
  574. Xextern char *community;
  575. Xextern struct sockaddr_in address;
  576. Xextern int reqid;
  577. Xextern int sd;
  578. END_OF_FILE
  579.   if test 151 -ne `wc -c <'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h'`; then
  580.     echo shar: \"'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h'\" unpacked with wrong size!
  581.   fi
  582.   # end of 'nocol-3.0/src/cmu-snmp/apps/snmpnetstat/main.h'
  583. fi
  584. if test -f 'nocol-3.0/src/cmu-snmp/man/snmp_api.3' -a "${1}" != "-c" ; then 
  585.   echo shar: Will not clobber existing file \"'nocol-3.0/src/cmu-snmp/man/snmp_api.3'\"
  586. else
  587.   echo shar: Extracting \"'nocol-3.0/src/cmu-snmp/man/snmp_api.3'\" \(8220 characters\)
  588.   sed "s/^X//" >'nocol-3.0/src/cmu-snmp/man/snmp_api.3' <<'END_OF_FILE'
  589. X.\* /***********************************************************
  590. X.\"     Copyright 1989 by Carnegie Mellon University
  591. X.\" 
  592. X.\"                       All Rights Reserved
  593. X.\" 
  594. X.\" Permission to use, copy, modify, and distribute this software and its 
  595. X.\" documentation for any purpose and without fee is hereby granted, 
  596. X.\" provided that the above copyright notice appear in all copies and that
  597. X.\" both that copyright notice and this permission notice appear in 
  598. X.\" supporting documentation, and that the name of CMU not be
  599. X.\" used in advertising or publicity pertaining to distribution of the
  600. X.\" software without specific, written prior permission.  
  601. X.\" 
  602. X.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  603. X.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  604. X.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  605. X.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  606. X.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  607. X.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  608. X.\" SOFTWARE.
  609. X.\" ******************************************************************/
  610. X.TH SNMP_API 3 "Sept 17, 1989"
  611. X.UC 5
  612. X.SH NAME
  613. Xsnmp_open, snmp_close, snmp_send, snmp_read, snmp_free_pdu, snmp_select_info, snmp_timeout \- send and receive SNMP messages
  614. X.SH SYNOPSIS
  615. X.B "#include <sys/types>
  616. X.br
  617. X.B "#include <netinet/in.h>
  618. X.br
  619. X.B "#include <sys/time.h>
  620. X.br
  621. X.B #include """snmp.h""
  622. X.br
  623. X.B #include """snmp_impl.h""
  624. X.br
  625. X.B #include """asn1.h""
  626. X.br
  627. X.B #include """snmp_api.c""
  628. X.PP
  629. X.B "extern int snmp_errno;
  630. X.PP
  631. X.B "struct snmp_session *snmp_open(session)
  632. X.br
  633. X.B "struct snmp_session *session;
  634. X.PP
  635. X.B "int snmp_close(session)
  636. X.br
  637. X.B "struct snmp_session *session;
  638. X.PP
  639. X.B "int snmp_send(session, pdu)
  640. X.br
  641. X.B "struct snmp_session *session;
  642. X.br
  643. X.B "struct snmp_pdu *pdu;
  644. X.PP
  645. X.B "void snmp_read(fdset)
  646. X.br
  647. X.B "fd_set *fdset;
  648. X.PP
  649. X.B "int snmp_select_info(numfds, fdset, timeout, block)
  650. X.br
  651. X.B "int *numfds;
  652. X.br
  653. X.B "fd_set *fdset;
  654. X.br
  655. X.B "struct timeval *timeout;
  656. X.br
  657. X.B "int *block;
  658. X.PP
  659. X.B "void snmp_timeout()
  660. X.PP
  661. X.B "void snmp_free_pdu(pdu)
  662. X.br
  663. X.B "struct snmp_pdu *pdu;
  664. X.PP
  665. X.SH DESCRIPTION
  666. X.I Snmp_open, snmp_close,
  667. Xand
  668. X.I snmp_send
  669. Xeach take as input a pointer to an object with the
  670. Xfollowing structure.  In addition,
  671. X.I snmp_open
  672. Xalso returns a pointer to an object with this structure.
  673. XThis structure contains information for a set of transactions that
  674. Xwill share similar transport characteristics.
  675. X.RS
  676. X.PP
  677. X.nf
  678. Xtypedef struct sockaddr_in  ipaddr;
  679. X
  680. Xstruct snmp_session {
  681. X    u_char  *community;    /* community for outgoing requests. */
  682. X    int        community_len;  /* Length of community name. */
  683. X    int        retries;    /* Number of retries before timeout. */
  684. X    long    timeout;    /* Number of uS until first timeout, then exponential backoff */
  685. X    char    *peername;    /* Domain name or dotted IP address of default peer */
  686. X    u_short remote_port;/* UDP port number of peer. */
  687. X    u_short local_port; /* My UDP port number, 0 for default, picked randomly */
  688. X
  689. X    /* Authentication function or NULL if null authentication is used */
  690. X    u_char  *(*authenticator)();
  691. X
  692. X    int        (*callback)();  /* Function to interpret incoming data */
  693. X
  694. X    /* Pointer to data that the callback function may consider important */
  695. X    void    *callback_magic;
  696. X};
  697. X
  698. X/*
  699. X * Set fields in session and pdu to the following to get a default or unconfigured value.
  700. X */
  701. X#define SNMP_DEFAULT_COMMUNITY_LEN  0/* for default community name */
  702. X#define SNMP_DEFAULT_RETRIES        -1
  703. X#define SNMP_DEFAULT_TIMEOUT        -1
  704. X#define SNMP_DEFAULT_REMPORT        0
  705. X#define SNMP_DEFAULT_REQID        0
  706. X#define SNMP_DEFAULT_ERRSTAT        -1
  707. X#define SNMP_DEFAULT_ERRINDEX        -1
  708. X#define SNMP_DEFAULT_ADDRESS        0
  709. X#define SNMP_DEFAULT_PEERNAME        NULL
  710. X#define SNMP_DEFAULT_ENTERPRISE_LENGTH    0
  711. X#define SNMP_DEFAULT_TIME        0
  712. X
  713. X/*
  714. X * This routine must be supplied by the application:
  715. X *
  716. X * u_char *authenticator(pdu, length, community, community_len)
  717. X * u_char *pdu;        The rest of the PDU to be authenticated
  718. X * int *length;        The length of the PDU (updated by the authenticator)
  719. X * u_char *community;    The community name to authenticate under.
  720. X * int    community_len    The length of the community name.
  721. X *
  722. X * Returns the authenticated pdu, or NULL if authentication failed.
  723. X * If null authentication is used, the authenticator in snmp_session can be
  724. X * set to NULL(0).
  725. X */
  726. X
  727. X/*
  728. X * This routine must be supplied by the application:
  729. X *
  730. X * int callback(operation, session, reqid, pdu, magic)
  731. X * int operation;
  732. X * struct snmp_session *session;    The session authenticated under.
  733. X * int reqid;                The request id of this pdu (0 for TRAP)
  734. X * struct snmp_pdu *pdu;        The pdu information.
  735. X * void *magic                A link to the data for this routine.
  736. X *
  737. X * Returns 1 if request was successful, 0 if it should be kept pending.
  738. X * Any data in the pdu must be copied because it will be freed elsewhere.
  739. X * Operations are defined below:
  740. X */
  741. X#define RECEIVED_MESSAGE   1
  742. X#define TIMED_OUT       2
  743. X.ft R
  744. X.ad
  745. X.fi
  746. X.RE
  747. X.PP
  748. X.I Snmp_send
  749. Xand
  750. X.I snmp_free_pdu
  751. Xeach take as input a pointer to an object with the
  752. Xfollowing structure.
  753. XThis structure contains information that describes a transaction
  754. Xthat will be performed over an open session.
  755. X.RS
  756. X.PP
  757. X.nf
  758. Xstruct snmp_pdu {
  759. X    ipaddr  address;    /* Address of peer */
  760. X
  761. X    int        command;    /* Type of this PDU */
  762. X
  763. X    u_long  reqid;    /* Request id */
  764. X    u_long  errstat;    /* Error status */
  765. X    u_long  errindex;    /* Error index */
  766. X
  767. X    /* Trap information */
  768. X    oid        *enterprise;/* System OID */
  769. X    int        enterprise_length;
  770. X    ipaddr  agent_addr;    /* address of object generating trap */
  771. X    int        trap_type;    /* trap type */
  772. X    int        specific_type;  /* specific type */
  773. X    u_long  time;    /* Uptime */
  774. X
  775. X    struct variable_list *variables;
  776. X};
  777. X
  778. X
  779. Xstruct variable_list {
  780. X    struct variable_list *next_variable;    /* NULL for last variable */
  781. X    oid        *name;  /* Object identifier of variable */
  782. X    int        name_length;    /* number of subid's in name */
  783. X    u_char  type;   /* ASN type of variable */
  784. X    union { /* value of variable */
  785. X    long    *integer;
  786. X    u_char    *string;
  787. X    oid    *objid;
  788. X    } val;
  789. X    int        val_len;
  790. X};
  791. X.ft R
  792. X.ad
  793. X.fi
  794. X.RE
  795. X.PP
  796. X.I Snmp_read, snmp_select_info,
  797. Xand
  798. X.I snmp_timeout
  799. Xprovide an interface for the use of the
  800. X.IR select (2)
  801. Xsystem call so that SNMP transactions can occur asynchronously.
  802. X.PP
  803. X.I Snmp_select_info
  804. Xis given the information that would have been passed to
  805. X.I select
  806. Xin the absence of SNMP.  For example, this might include window update information.
  807. XThis information is modified so that SNMP will get the service it requires from the
  808. Xcall to
  809. X.I select.
  810. XIn this case,
  811. X.I numfds, fdset,
  812. Xand
  813. X.I timeout
  814. Xcorrespond to the
  815. X.I nfds, readfds,
  816. Xand
  817. X.I timeout
  818. Xarguments to
  819. X.I select,
  820. Xrespectively.  The only exception is that timeout must always point to an allocated (but perhaps uninitialized)
  821. X.I struct timeval.
  822. XIf
  823. X.I timeout
  824. Xwould have been passed as NULL,
  825. X.I block
  826. Xis set to true, and
  827. X.I timeout
  828. Xis treated as undefined.  This same rule applies upon return from
  829. X.I snmp_select_info.
  830. X.PP
  831. XAfter calling
  832. X.I snmp_select_info, select
  833. Xis called with the returned data.  When select returns,
  834. X.I snmp_read
  835. Xis called with the
  836. X.I fd_set
  837. Xreturned from
  838. X.I select.
  839. XThis will read all SNMP sockets with input.
  840. XIf
  841. X.I select
  842. Xtimes out,
  843. X.I snmp_timeout
  844. Xshould be called to see if the timeout was intended for SNMP.
  845. X.SH DIAGNOSTICS
  846. X.PP
  847. XError return status from 
  848. X.I snmp_open
  849. Xis indicated by return of a null pointer.
  850. XError return status from 
  851. X.I snmp_close
  852. Xand
  853. X.I snmp_send
  854. Xis indicated by return of 0.  A successful status will return a 1.
  855. XThe external integer
  856. X.IR snmp_errno
  857. Xmay then be checked to see what type of error has occurred
  858. X.PP
  859. X.IR snmp_errno
  860. Xcan have the following values:
  861. X.RS
  862. X.IP SNMPERR_GENERR \w'SNMPERR_BAD_LOCPORT'u+2n
  863. XA generic error occurred.
  864. X.IP SNMPERR_BAD_LOCPORT \w'SNMPERR_BAD_LOCPORT'u+2n
  865. XThe local port was bad because it had already been
  866. Xallocated or permission was denied.
  867. X.IP SNMPERR_BAD_ADDRESS \w'SNMPERR_BAD_LOCPORT'u+2n
  868. XThe host name or address given was not useable.
  869. X.IP SNMPERR_BAD_SESSION \w'SNMPERR_BAD_SESSION'u+2n
  870. XThe specified session was not open.
  871. X.RE
  872. X.SH "SEE ALSO"
  873. Xselect(2), snmp_api.h
  874. END_OF_FILE
  875.   if test 8220 -ne `wc -c <'nocol-3.0/src/cmu-snmp/man/snmp_api.3'`; then
  876.     echo shar: \"'nocol-3.0/src/cmu-snmp/man/snmp_api.3'\" unpacked with wrong size!
  877.   fi
  878.   # end of 'nocol-3.0/src/cmu-snmp/man/snmp_api.3'
  879. fi
  880. if test -f 'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h' -a "${1}" != "-c" ; then 
  881.   echo shar: Will not clobber existing file \"'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h'\"
  882. else
  883.   echo shar: Extracting \"'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h'\" \(8565 characters\)
  884.   sed "s/^X//" >'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h' <<'END_OF_FILE'
  885. X/***********************************************************
  886. X    Copyright 1989 by Carnegie Mellon University
  887. X
  888. X                      All Rights Reserved
  889. X
  890. XPermission to use, copy, modify, and distribute this software and its 
  891. Xdocumentation for any purpose and without fee is hereby granted, 
  892. Xprovided that the above copyright notice appear in all copies and that
  893. Xboth that copyright notice and this permission notice appear in 
  894. Xsupporting documentation, and that the name of CMU not be
  895. Xused in advertising or publicity pertaining to distribution of the
  896. Xsoftware without specific, written prior permission.  
  897. X
  898. XCMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  899. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  900. XCMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  901. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  902. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  903. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  904. XSOFTWARE.
  905. X******************************************************************/
  906. X/*
  907. X * snmp_api.h - API for access to snmp.
  908. X */
  909. X
  910. X
  911. Xtypedef struct sockaddr_in  ipaddr;
  912. X
  913. Xstruct snmp_session {
  914. X    u_char  *community;    /* community for outgoing requests. */
  915. X    int        community_len;  /* Length of community name. */
  916. X    int        retries;    /* Number of retries before timeout. */
  917. X    long    timeout;    /* Number of uS until first timeout, then exponential backoff */
  918. X    char    *peername;    /* Domain name or dotted IP address of default peer */
  919. X    u_short remote_port;/* UDP port number of peer. */
  920. X    u_short local_port; /* My UDP port number, 0 for default, picked randomly */
  921. X    /* Authentication function or NULL if null authentication is used */
  922. X    u_char    *(*authenticator)();
  923. X    int        (*callback)();  /* Function to interpret incoming data */
  924. X    /* Pointer to data that the callback function may consider important */
  925. X    void    *callback_magic;
  926. X};
  927. X
  928. X/*
  929. X * Set fields in session and pdu to the following to get a default or unconfigured value.
  930. X */
  931. X#define SNMP_DEFAULT_COMMUNITY_LEN  0    /* to get a default community name */
  932. X#define SNMP_DEFAULT_RETRIES        -1
  933. X#define SNMP_DEFAULT_TIMEOUT        -1
  934. X#define SNMP_DEFAULT_REMPORT        0
  935. X#define SNMP_DEFAULT_REQID        0
  936. X#define SNMP_DEFAULT_ERRSTAT        -1
  937. X#define SNMP_DEFAULT_ERRINDEX        -1
  938. X#define SNMP_DEFAULT_ADDRESS        0
  939. X#define SNMP_DEFAULT_PEERNAME        NULL
  940. X#define SNMP_DEFAULT_ENTERPRISE_LENGTH    0
  941. X#define SNMP_DEFAULT_TIME        0
  942. X
  943. Xextern int snmp_errno;
  944. X/* Error return values */
  945. X#define SNMPERR_GENERR        -1
  946. X#define SNMPERR_BAD_LOCPORT    -2  /* local port was already in use */
  947. X#define SNMPERR_BAD_ADDRESS    -3
  948. X#define SNMPERR_BAD_SESSION    -4
  949. X#define SNMPERR_TOO_LONG    -5
  950. X
  951. X
  952. Xstruct snmp_pdu {
  953. X    ipaddr  address;    /* Address of peer */
  954. X
  955. X    int        command;    /* Type of this PDU */
  956. X
  957. X    u_long  reqid;    /* Request id */
  958. X    u_long  errstat;    /* Error status */
  959. X    u_long  errindex;    /* Error index */
  960. X
  961. X    /* Trap information */
  962. X    oid        *enterprise;/* System OID */
  963. X    int        enterprise_length;
  964. X    ipaddr  agent_addr;    /* address of object generating trap */
  965. X    int        trap_type;    /* trap type */
  966. X    int        specific_type;  /* specific type */
  967. X    u_long  time;    /* Uptime */
  968. X
  969. X    struct variable_list *variables;
  970. X};
  971. X
  972. X
  973. Xstruct variable_list {
  974. X    struct variable_list *next_variable;    /* NULL for last variable */
  975. X    oid        *name;  /* Object identifier of variable */
  976. X    int        name_length;    /* number of subid's in name */
  977. X    u_char  type;   /* ASN type of variable */
  978. X    union { /* value of variable */
  979. X    long    *integer;
  980. X    u_char    *string;
  981. X    oid    *objid;
  982. X    } val;
  983. X    int        val_len;
  984. X};
  985. X
  986. X/*
  987. X * struct snmp_session *snmp_open(session)
  988. X *    struct snmp_session *session;
  989. X * 
  990. X * Sets up the session with the snmp_session information provided
  991. X * by the user.  Then opens and binds the necessary UDP port.
  992. X * A handle to the created session is returned (this is different than
  993. X * the pointer passed to snmp_open()).  On any error, NULL is returned
  994. X * and snmp_errno is set to the appropriate error code.
  995. X */
  996. Xstruct snmp_session *snmp_open();
  997. X
  998. X/*
  999. X * int snmp_close(session)
  1000. X *     struct snmp_session *session;
  1001. X * 
  1002. X * Close the input session.  Frees all data allocated for the session,
  1003. X * dequeues any pending requests, and closes any sockets allocated for
  1004. X * the session.  Returns 0 on error, 1 otherwise.
  1005. X */
  1006. Xint snmp_close();
  1007. X
  1008. X
  1009. X/*
  1010. X * int snmp_send(session, pdu)
  1011. X *     struct snmp_session *session;
  1012. X *     struct snmp_pdu    *pdu;
  1013. X * 
  1014. X * Sends the input pdu on the session after calling snmp_build to create
  1015. X * a serialized packet.  If necessary, set some of the pdu data from the
  1016. X * session defaults.  Add a request corresponding to this pdu to the list
  1017. X * of outstanding requests on this session, then send the pdu.
  1018. X * Returns the request id of the generated packet if applicable, otherwise 1.
  1019. X * On any error, 0 is returned.
  1020. X * The pdu is freed by snmp_send() unless a failure occured.
  1021. X */
  1022. Xint snmp_send();
  1023. X
  1024. X
  1025. X/*
  1026. X * void snmp_read(fdset)
  1027. X *     fd_set  *fdset;
  1028. X * 
  1029. X * Checks to see if any of the fd's set in the fdset belong to
  1030. X * snmp.  Each socket with it's fd set has a packet read from it
  1031. X * and snmp_parse is called on the packet received.  The resulting pdu
  1032. X * is passed to the callback routine for that session.  If the callback
  1033. X * routine returns successfully, the pdu and it's request are deleted.
  1034. X */
  1035. Xvoid snmp_read();
  1036. X
  1037. X
  1038. X/*
  1039. X * void
  1040. X * snmp_free_pdu(pdu)
  1041. X *     struct snmp_pdu *pdu;
  1042. X * 
  1043. X * Frees the pdu and any malloc'd data associated with it.
  1044. X */
  1045. Xvoid snmp_free_pdu();
  1046. X
  1047. X/*
  1048. X * int snmp_select_info(numfds, fdset, timeout, block)
  1049. X * int *numfds;
  1050. X * fd_set   *fdset;
  1051. X * struct timeval *timeout;
  1052. X * int *block;
  1053. X *
  1054. X * Returns info about what snmp requires from a select statement.
  1055. X * numfds is the number of fds in the list that are significant.
  1056. X * All file descriptors opened for SNMP are OR'd into the fdset.
  1057. X * If activity occurs on any of these file descriptors, snmp_read
  1058. X * should be called with that file descriptor set.
  1059. X *
  1060. X * The timeout is the latest time that SNMP can wait for a timeout.  The
  1061. X * select should be done with the minimum time between timeout and any other
  1062. X * timeouts necessary.  This should be checked upon each invocation of select.
  1063. X * If a timeout is received, snmp_timeout should be called to check if the
  1064. X * timeout was for SNMP.  (snmp_timeout is idempotent)
  1065. X *
  1066. X * Block is 1 if the select is requested to block indefinitely, rather than time out.
  1067. X * If block is input as 1, the timeout value will be treated as undefined, but it must
  1068. X * be available for setting in snmp_select_info.  On return, if block is true, the value
  1069. X * of timeout will be undefined.
  1070. X *
  1071. X * snmp_select_info returns the number of open sockets.  (i.e. The number of sessions open)
  1072. X */
  1073. Xint snmp_select_info();
  1074. X
  1075. X/*
  1076. X * void snmp_timeout();
  1077. X * 
  1078. X * snmp_timeout should be called whenever the timeout from snmp_select_info expires,
  1079. X * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensive
  1080. X * proposition).  snmp_timeout checks to see if any of the sessions have an
  1081. X * outstanding request that has timed out.  If it finds one (or more), and that
  1082. X * pdu has more retries available, a new packet is formed from the pdu and is
  1083. X * resent.  If there are no more retries available, the callback for the session
  1084. X * is used to alert the user of the timeout.
  1085. X */
  1086. Xvoid snmp_timeout();
  1087. X
  1088. X
  1089. X/*
  1090. X * This routine must be supplied by the application:
  1091. X *
  1092. X * u_char *authenticator(pdu, length, community, community_len)
  1093. X * u_char *pdu;        The rest of the PDU to be authenticated
  1094. X * int *length;        The length of the PDU (updated by the authenticator)
  1095. X * u_char *community;    The community name to authenticate under.
  1096. X * int    community_len    The length of the community name.
  1097. X *
  1098. X * Returns the authenticated pdu, or NULL if authentication failed.
  1099. X * If null authentication is used, the authenticator in snmp_session can be
  1100. X * set to NULL(0).
  1101. X */
  1102. X
  1103. X/*
  1104. X * This routine must be supplied by the application:
  1105. X *
  1106. X * int callback(operation, session, reqid, pdu, magic)
  1107. X * int operation;
  1108. X * struct snmp_session *session;    The session authenticated under.
  1109. X * int reqid;                The request id of this pdu (0 for TRAP)
  1110. X * struct snmp_pdu *pdu;        The pdu information.
  1111. X * void *magic                A link to the data for this routine.
  1112. X *
  1113. X * Returns 1 if request was successful, 0 if it should be kept pending.
  1114. X * Any data in the pdu must be copied because it will be freed elsewhere.
  1115. X * Operations are defined below:
  1116. X */
  1117. X#define RECEIVED_MESSAGE   1
  1118. X#define TIMED_OUT       2
  1119. X
  1120. X
  1121. Xextern int snmp_dump_packet;
  1122. END_OF_FILE
  1123.   if test 8565 -ne `wc -c <'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h'`; then
  1124.     echo shar: \"'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h'\" unpacked with wrong size!
  1125.   fi
  1126.   # end of 'nocol-3.0/src/cmu-snmp/snmplib/snmp_api.h'
  1127. fi
  1128. if test -f 'nocol-3.0/src/doc/nocol-overview.8' -a "${1}" != "-c" ; then 
  1129.   echo shar: Will not clobber existing file \"'nocol-3.0/src/doc/nocol-overview.8'\"
  1130. else
  1131.   echo shar: Extracting \"'nocol-3.0/src/doc/nocol-overview.8'\" \(8941 characters\)
  1132.   sed "s/^X//" >'nocol-3.0/src/doc/nocol-overview.8' <<'END_OF_FILE'
  1133. X.\" $Header: /home/aggarwal/lsrc/nocol/src/doc/RCS/nocol-overview.8,v 1.6 1993/10/28 16:38:03 aggarwal Exp $
  1134. X.\"
  1135. X.TH NOCOL-OVERVIEW 8 "October 1, 1993"
  1136. X.SH NAME
  1137. Xnocol-overview \- Unix based network monitoring package.
  1138. X.SH SYNOPSIS
  1139. XThis is an overview of the NOCOL software. See
  1140. X.IR nocol-prog (3)
  1141. Xfor more information on the design and initiatives behind NOCOL.
  1142. X.SH DESCRIPTION
  1143. X.LP
  1144. X.B NOCOL
  1145. X.I (Network Operations Center On-Line)
  1146. Xis a collection of network monitoring programs that run on Unix systems.
  1147. XThe software consists of a number of monitoring agents that poll various
  1148. Xparameters from any system and put it in a format suitable for
  1149. Xpost-processing. The post-processors can be a 
  1150. X.I display
  1151. Xagent, an automated
  1152. X.I troubleshooting
  1153. Xprogram, an event
  1154. X.I logging
  1155. Xprogram, etc. Presently, monitors for tracking
  1156. X.I reachability, SNMP traps, data throughput rate,
  1157. Xand
  1158. X.I nameservers
  1159. Xhave been developed and are in use. Addition of more monitoring agents is
  1160. Xeasy and they will be added as necessary. A display agent-
  1161. X.IR nocol (1)
  1162. Xusing curses displays the data generated by the various monitoring
  1163. Xagents. A logging daemon (similar to syslogd) logs events from the
  1164. Xvarious monitors and can optionally run a program  (for automatic
  1165. Xtroubleshooting or notification).
  1166. X
  1167. XAll data collected by the monitoring agents follows a fixed (non-readable)
  1168. Xformat. Each data entry is termed an
  1169. X.I event
  1170. Xin NOCOL, and each event has certain flags and 
  1171. X.I severity
  1172. Xassociated with it. 
  1173. X
  1174. XThe display agent
  1175. X.IR nocol (1),
  1176. Xdisplays the output of these monitoring agents depending on the severity
  1177. Xof the event. There can be multiple displays running simultaneously and all
  1178. Xof these process and display the same set of monitored data.
  1179. X
  1180. XThere are four levels of 
  1181. X.I severity
  1182. Xassociated with an event- CRITICAL, ERROR, WARNING and INFO. The severity
  1183. Xlevel is controlled independently by the monitoring agents, and the decision
  1184. Xto raise or set an event's severity to any level depends on the logic
  1185. Ximbedded in the monitoring agent.
  1186. X
  1187. XAs an example, for the 
  1188. X.BR pingmon (8)
  1189. Xmonitor, if a site is unreachable via
  1190. X.IR ping ,
  1191. Xit would be assigned a severity of WARNING by pingmon, which would then elevate
  1192. Xto CRITICAL if the site is still unreachable after some time. In the case of
  1193. X.BR trapmon (8),
  1194. Xan SNMP trap message of
  1195. X.I EGP neighbor lost
  1196. Xwould be directly assigned a severity level of CRITICAL, while an 
  1197. X.I Warm Start
  1198. Xtrap is assigned a severity of WARNING.
  1199. X
  1200. XThe display agent (and other data post-processors) use this event
  1201. Xseverity to decide whether to display it (or troubleshoot/log it) depending
  1202. Xon the user selected \fIdisplay\fR severity level.
  1203. X
  1204. XThe software is very flexible and modular, which allows enhancements and 
  1205. Xdevelopment with a minimum amount of effort. 
  1206. XThe display module processes all the files
  1207. Xpresent in the data directory, and displays them sequentially. This
  1208. Xallows new monitoring programs to simply start generating data in the data
  1209. Xdirectory and the display module will automatically start displaying the new
  1210. Xdata. The monitoring tools can be changed, and the only element that has to
  1211. Xremain common between all the modules is the EVENT data structure.
  1212. X
  1213. X.SH CURRENT MODULES
  1214. XThe NOCOL package presently consists of the following modules:
  1215. X.IP nocol
  1216. Xwhich simply \fIdisplays\fR the data collected by the monitoring agents. 
  1217. XIt uses the
  1218. X.I curses
  1219. Xscreen management system to support a wide variety of terminal types. The
  1220. Xcriterion for displaying an event is:
  1221. X.RS
  1222. X.TP 3
  1223. X1.
  1224. XSeverity level of the \fIevent\fR is higher than the severity level set in
  1225. Xthe \fIdisplay\fR.
  1226. X.TP 3
  1227. X2.
  1228. XThe display filter (if set) matches some string in the event line.
  1229. X.RE
  1230. X.IP
  1231. XThe display can be in regular 80 column mode or in extended 132 column mode.
  1232. XCritical events are displayed in reverse video (if the terminal type supports
  1233. Xit). Additional features like displaying informational
  1234. Xmessages in a part of the window, automatic resizing window sizes, operator
  1235. Xacknowledgement via a bell when a new event goes critical are also available.
  1236. X
  1237. X.IP ippingmon
  1238. Xwhich monitors the reachability of a site via "ICMP" ping packets (ICMP was
  1239. Xpreferred over SNMP for many obvious reasons). 
  1240. XThis program can use the default output from the system's 
  1241. X.I ping
  1242. Xprogram, but an accompanying program (
  1243. X.IR multiping )
  1244. Xcan ping multiple IP sites at the same time and is preferable for monitoring
  1245. Xa large list of sites.
  1246. XA site is marked unreachable if the number of lost packets exceeds a fixed
  1247. Xthreshold (set to 3 out of 10 sent), and the
  1248. Xseverity level is increased each time that the site tests as  unreachable.
  1249. X.IP osipingmon
  1250. Xwhich is similar to the 
  1251. X.I ippingmon
  1252. Xmodule but uses the OSI \fIping\fR program instead. No multiple ping program
  1253. Xfor OSI sites has been developed at this time. The only requirement is that
  1254. Xthe system's \fIping\fR program output match the typical BSD IP ping
  1255. Xprogram's output.
  1256. X.IP nsmon
  1257. Xwhich monitors the nameservers (
  1258. X.IR named )
  1259. Xon the list of specified hosts. It periodically sends an SOA query for the
  1260. Xdefault domain and if the queried nameservers cannot resolve the query, then
  1261. Xthe site is elevated to CRITICAL status.
  1262. X.IP tpmon
  1263. XFor monitoring the throughput (kbits per second) to a list of hosts. The
  1264. Xprogram connects to the discard socket on the remote machine (using a STREAM
  1265. Xsocket) and sends large packets for a small amount of time to evaluate the
  1266. Xeffective throughput. It elevates a site to WARNING level if the throughput
  1267. Xdrops below a certain threshold (set in the configuration file).
  1268. X.IP trapmon
  1269. XConverts all SNMP traps into a format suitable for displaying using NOCOL.
  1270. XThe severity of the various traps is preset (and can be changed during
  1271. Xcompilation time).
  1272. X.IP noclogd
  1273. XThis is the NOCOL logging daemon. It listens on a UDP port for the various
  1274. Xmonitors to log events to it. It then writes out the event (in text line
  1275. Xformat), to various log files specified in a configuration file. Alternatively,
  1276. Xit can pipe the text line to a program specified in the config file (this
  1277. Xfacilitates automatic notification, troubleshooting, etc.).
  1278. X.IP genmon
  1279. XThis is a generic monitor interface for adding additional monitors. It
  1280. Xreads in text lines (in the 
  1281. X.IR noclogd (8)
  1282. Xformat) and writes them in the NOCOL datafile format. It is meant to
  1283. Xfacilitate development of additional monitors.
  1284. X.IP eventselect
  1285. XThis program parses all the NOCOL datafiles specified on the command line
  1286. Xand extracts those events that match the criterion specified on the
  1287. Xcommand line. The events can be selected by sendername, severity, time
  1288. Xor variable name. This process can be run periodically from the 
  1289. X.IR cron (1)
  1290. Xand be used to do any postprocessing (sending email, page
  1291. Xsomeone)  if a site is in critical state for a period of time, etc.
  1292. X.IP perlnocol
  1293. XThere is a collection of utility PERL routines (library) called
  1294. X.I nocollib.pl
  1295. Xthat can be used to develop monitors in the PERL programming language.
  1296. XMonitors for Novell routes,  appletalk routes,  bootp servers, modem
  1297. Xline usage on cisco terminal-servers  have been developed and included.
  1298. XThese might require slight changes for your environment. See
  1299. X.IR perlnocol (8).
  1300. X
  1301. X.SH PLATFORM
  1302. X.LP
  1303. XAny Unix system with the 
  1304. X.I curses
  1305. Xscreen management library and IP
  1306. X.I (Internet Protocol)
  1307. Xprogramming facility. Sockets are needed for the logging facility.
  1308. XIt has been tested on Sun Sparc 4.1.1, Ultrix, and
  1309. XNeXT systems. Porting to other platforms might require minor adjustments
  1310. Xdepending on the vagaries of the different vendors (mostly in the include
  1311. Xfiles).
  1312. X.SH AVAILABILITY
  1313. X.LP
  1314. X.B NOCOL
  1315. Xwas developed at JvNCnet and has been in use for monitoring the JvNCnet
  1316. Xwide area network since 1989.
  1317. X.br
  1318. XIt is available via anonymous FTP from
  1319. X.I ftp.jvnc.net
  1320. Xunder
  1321. X.IR pub/jvncnet-packages/nocol.tar.Z .
  1322. XThe system running at JvNCet can be viewed by logging into the host
  1323. X.I nocol.jvnc.net
  1324. Xwith username
  1325. X.I nocol
  1326. X(an \fIrlogin\fR instead of \fItelnet\fR will handle your X window terminal
  1327. Xtypes better).
  1328. X.br
  1329. XTo be added to the NOCOL mailing list (for future updates and bug fixes),
  1330. Xsend a message to
  1331. X.B nocol-users-request@jvnc.net
  1332. Xwith your email address.
  1333. X.SH FUTURE DEVELOPMENTS
  1334. X.LP
  1335. XPossible future enhancements are:
  1336. X.RS
  1337. X.TP 3
  1338. X1.
  1339. XMonitors for ethernet traffic (load, errors, etc.)
  1340. X.TP 3
  1341. X2.
  1342. XSNMP monitors to watch the state of certain variables 
  1343. X.RI ( "interface errors,"
  1344. X.IR "packet rate, route state changes" ).
  1345. X.RE
  1346. X.\"--------------------------------------------
  1347. X.SH AUTHOR
  1348. XThe software was developed at JvNCnet over a period of time. The overall
  1349. Xdesign and initial development was done by Vikas Aggarwal and Sze-Ying Wuu.
  1350. XAdditional development is being done and coordinated by Vikas Aggarwal
  1351. X(vikas@jvnc.net). Perl monitors contributed by John Wobus at Syracuse
  1352. XUniversity.
  1353. X.br
  1354. XCopyright 1992 JvNCnet. (See the file \fICOPYRIGHT\fR for full details)
  1355. X.SH SEE ALSO
  1356. Xnocol(1) nocol-prog(3) perlnocol(3)
  1357. Xeventselect(8) genmon(8) noclogd(8) nocol-overview(8)
  1358. Xnocol-utility(8) nsmon(8) pingmon(8) portmon(8) 
  1359. Xtpmon(8) trapmon(8)
  1360. X
  1361. END_OF_FILE
  1362.   if test 8941 -ne `wc -c <'nocol-3.0/src/doc/nocol-overview.8'`; then
  1363.     echo shar: \"'nocol-3.0/src/doc/nocol-overview.8'\" unpacked with wrong size!
  1364.   fi
  1365.   # end of 'nocol-3.0/src/doc/nocol-overview.8'
  1366. fi
  1367. if test -f 'nocol-3.0/src/genmon/genmon.c' -a "${1}" != "-c" ; then 
  1368.   echo shar: Will not clobber existing file \"'nocol-3.0/src/genmon/genmon.c'\"
  1369. else
  1370.   echo shar: Extracting \"'nocol-3.0/src/genmon/genmon.c'\" \(8179 characters\)
  1371.   sed "s/^X//" >'nocol-3.0/src/genmon/genmon.c' <<'END_OF_FILE'
  1372. X/* $Header: /home/aggarwal/lsrc/nocol/src/genmon/RCS/genmon.c,v 1.2 1993/10/30 03:20:39 aggarwal Exp $ */
  1373. X
  1374. X/* Copyright 1993 JvNCnet, Global Enterprise Services */
  1375. X
  1376. X/*+ 
  1377. X * FUNCTION:
  1378. X *     A generic monitor for nocol, to allow people to develop
  1379. X * monitors using shell scripts, etc.
  1380. X *
  1381. X * Does the initial opening of the datafile,
  1382. X * etc. and then does a popen() to the  program specified on the
  1383. X * command line. Reads back data line by line from the program and
  1384. X * stuffs it into the NOCOL structure and writes out the structure to
  1385. X * the datafile.
  1386. X *
  1387. X * Without any command line arguments, it acts like a filter, reading
  1388. X * NOCOL text lines from stdin and writing out the structure to stdout.
  1389. X *
  1390. X * Recognizes two additional keywords-  LOG and APPEND.  'LOG' means
  1391. X * that this program should do an eventlog()  and APPEND means to add
  1392. X * at the end of the existing DATAFILE on open(). Typically, the program
  1393. X * overwrites the datafile each time.
  1394. X *
  1395. X * AUTHOR:
  1396. X *
  1397. X *    Vikas Aggarwal, vikas@jvnc.net
  1398. X *
  1399. X */
  1400. X
  1401. X/*+ 
  1402. X * $Log: genmon.c,v $
  1403. X * Revision 1.2  1993/10/30  03:20:39  aggarwal
  1404. X * Added copyright.
  1405. X *
  1406. X * Revision 1.1  1993/10/08  19:16:55  aggarwal
  1407. X * Initial revision
  1408. X *
  1409. X *
  1410. X *
  1411. X */
  1412. X#include "nocol.h"
  1413. X#include <sys/file.h>            /* for access() defines */
  1414. X#include <string.h>
  1415. X
  1416. X#ifndef SLEEPTIME
  1417. X# define SLEEPTIME  15            /* after each popen()  */
  1418. X#endif
  1419. X
  1420. Xstatic int   debugflag;
  1421. Xstatic char  *myname, *pidfile, *datafile ;
  1422. Xstatic char  *execprogpath, *execprog, *execargs ; /* program to be executed */
  1423. Xextern char *skip_spaces() ;        /* in libnocol */
  1424. X
  1425. Xmain (ac, av)
  1426. X     int ac;
  1427. X     char **av;
  1428. X{
  1429. X    extern char *optarg;
  1430. X    extern int  optind;
  1431. X    int         c;
  1432. X
  1433. X    myname = av[0] ;
  1434. X
  1435. X    while ((c = getopt(ac, av, "da:e:")) != EOF)
  1436. X      switch(c)
  1437. X      {
  1438. X       case 'd':
  1439. X          debugflag++;
  1440. X          break;
  1441. X       case 'a':
  1442. X          execargs = optarg ;        /* command line args to execprog */
  1443. X          break ;
  1444. X       case 'e':
  1445. X      execprogpath = optarg ;    /* full path to prog being run */
  1446. X          break ;
  1447. X       case '?':
  1448. X       default:
  1449. X          fprintf(stderr, "%s: Unknown flag: %c\n", myname, optarg);
  1450. X          fprintf(stderr, "Usage: %s [-d] [-e <prog to exec>] ", myname);
  1451. X          fprintf(stderr, "[-a <'args to above prog'>]\n");
  1452. X      fprintf(stderr, "OR: use as filter in a pipe process flow\n");
  1453. X          exit (1);
  1454. X      }
  1455. X
  1456. X    switch ( ac - optind )
  1457. X    {
  1458. X     case 0:                                    /* default input file */
  1459. X        break ;
  1460. X     default:
  1461. X        fprintf (stderr, "%s: Bad arg '%s'\nUse -h for help, exiting\n",
  1462. X         myname, av[optind]);
  1463. X    }
  1464. X
  1465. X    if (debugflag)
  1466. X#ifndef DEBUG
  1467. X      fprintf(stderr,"%s: WARNING- program NOT compiled with DEBUG option\n",
  1468. X          myname);
  1469. X#else
  1470. X    fprintf(stderr, "%s: Debug turned on\n", myname);
  1471. X#endif
  1472. X
  1473. X    if (debugflag)
  1474. X      fprintf(stderr, "(debug) %s:  execprogpath= '%s', execargs= '%s'\n\n",
  1475. X          myname, execprogpath, execargs);
  1476. X
  1477. X    if (execprogpath != NULL && *execprogpath != '\0')
  1478. X      mastermode();
  1479. X    else            /* read from stdin  */
  1480. X      slavemode() ;
  1481. X
  1482. X}    /* end:  main()  */
  1483. X
  1484. X/*+ 
  1485. X * FUNCTION:
  1486. X *     If this program is going to run the program specified on the
  1487. X * command line (execprogpath). Creates PIDFILE, and daemonizes.
  1488. X */
  1489. Xmastermode()
  1490. X{
  1491. X    int  fd ;            /* data file descriptor */
  1492. X    char *pf ;        /* pid filename ptr */
  1493. X    char cmd[1024];    /* command to be run */
  1494. X    FILE *cmdf ;    /* for popen() */
  1495. X
  1496. X    if (access(execprogpath, F_OK | X_OK) != 0) /* check if prog executable  */
  1497. X    {
  1498. X    fprintf(stderr, "%s: Fatal error in access() ", myname) ;
  1499. X        perror (execprogpath);
  1500. X        exit(1);
  1501. X    }
  1502. X
  1503. X    if ((execprog = (char *)strrchr (execprogpath, '/')) == NULL)
  1504. X      execprog = execprogpath ;        /* no path in program name */
  1505. X    else
  1506. X      execprog++ ;                                /* skip leading '/' */
  1507. X
  1508. X    pf = malloc (strlen(execprog) + strlen(ETCDIR) + 2) ;
  1509. X    sprintf(pf, "%s/%s\0", ETCDIR, execprog) ;
  1510. X    if (standalone(pf) == -1)    /* Kill prev running process    */
  1511. X    {
  1512. X        fprintf(stderr, "%s: Error in standalone...exiting\n", myname);
  1513. X        exit (1);
  1514. X    }
  1515. X    else
  1516. X      free(pf) ;         /* not needed anymore */
  1517. X
  1518. X    if (!debugflag)
  1519. X      daemon() ;
  1520. X
  1521. X    datafile = malloc(strlen(DATADIR) + strlen (execprog) + 2) ;
  1522. X    sprintf(datafile,  "%s/%s-output\0",
  1523. X             DATADIR,  execprog); 
  1524. X
  1525. X redo:
  1526. X    if ((fd = open(datafile, O_WRONLY | O_CREAT, 0640)) < 0)
  1527. X    {
  1528. X    perror(datafile);
  1529. X    fatal ("Open failed, exiting...");
  1530. X    }
  1531. X
  1532. X    sprintf(cmd, "%s %s\0", execprogpath, execargs);
  1533. X    if ((cmdf = popen (cmd, "r")) == NULL)
  1534. X    {
  1535. X    perror("popen");
  1536. X    fatal("Exiting...");
  1537. X    }
  1538. X
  1539. X    dostream(cmdf, fd);
  1540. X
  1541. X    if (fd >= 0)
  1542. X      close (fd);
  1543. X    if (cmdf)
  1544. X      pclose(cmdf);
  1545. X
  1546. X#ifdef DEBUG
  1547. X    fprintf(stderr, "(debug) mastermode: sleeping\n");
  1548. X#endif
  1549. X    sleep (SLEEPTIME);
  1550. X    goto redo ;
  1551. X
  1552. X}    /* end:  mastermode() */
  1553. X
  1554. X/*+ 
  1555. X * FUNCTION:
  1556. X *     When this program is called at the end of a pipe, then it has
  1557. X * to read nocol event text lines from the stdin.
  1558. X * Does not 'sleep' or anything because the invoking process will
  1559. X * probably want control right away.
  1560. X */
  1561. X
  1562. Xslavemode()
  1563. X{
  1564. X#ifdef DEBUG
  1565. X    if (debugflag)
  1566. X      fprintf(stderr, "(debug) %s: Entered slavemode, reading from stdin\n",
  1567. X          myname);
  1568. X#endif
  1569. X
  1570. X    dostream(stdin,fileno(stdout));    /* work with stdin/stdout */
  1571. X
  1572. X}    /* end:  slavemode()  */
  1573. X
  1574. X/*+ 
  1575. X * FUNCTION:
  1576. X *     Read text lines from the indicated file stream and write out
  1577. X * to the open file descriptor  in the nocol format
  1578. X*/
  1579. Xdostream(fptr, fd)
  1580. X     FILE *fptr ;        /* to read text lines from */
  1581. X     int  fd;            /* to write nocol structures to */
  1582. X{
  1583. X    EVENT *pv ;
  1584. X    char  line[1024] ;        /* read line */
  1585. X
  1586. X    if (fptr == NULL  ||  fd < 0)
  1587. X      return(0);
  1588. X
  1589. X
  1590. X    while (fgets(line, sizeof (line), fptr) != NULL)
  1591. X    {
  1592. X    int   doneappend =0, dolog =0;
  1593. X    char  *tstr ;    /* temp pointer */
  1594. X
  1595. X    if ((tstr = strrchr(line, '\n')) )
  1596. X      *tstr = '\0' ;    /* chop off newline */
  1597. X#ifdef DEBUG
  1598. X    if (debugflag)
  1599. X      fprintf(stderr, "(debug) dostream: read '%s'\n", line);
  1600. X#endif
  1601. X    tstr = line ;
  1602. X    tstr = skip_spaces(tstr);
  1603. X
  1604. X    /*
  1605. X     * look for keywords such as APPEND or LOG
  1606. X     */
  1607. X    if (strncasecmp(tstr, "APPEND", strlen("APPEND")) == 0)
  1608. X    {
  1609. X        if (!doneappend)
  1610. X        {
  1611. X        /* Check if output device can be lseeked, etc. ?? */
  1612. X        if (debugflag)
  1613. X          fprintf(stderr, "(debug) dostream: scanned APPEND, appending to output\n") ;
  1614. X        lseek(fd, 0L, SEEK_END);    /* end of file */
  1615. X        doneappend = 1;
  1616. X        }
  1617. X        tstr = tstr + strlen("APPEND") ;
  1618. X        tstr = skip_spaces(tstr);
  1619. X    }
  1620. X
  1621. X    if (strncasecmp(tstr, "LOG", strlen("LOG")) == 0)
  1622. X    {
  1623. X        dolog = 1;
  1624. X        tstr = tstr + strlen("LOG") ;
  1625. X        tstr = (char *)skip_spaces(tstr);
  1626. X    }
  1627. X
  1628. X    pv= (EVENT *)logstr_to_event(tstr) ;    /* create an event struct */
  1629. X    if (pv == NULL)
  1630. X      return (-1);
  1631. X
  1632. X    if (dolog)
  1633. X      eventlog(pv);
  1634. X
  1635. X    if (write(fd, pv, sizeof (EVENT)) != sizeof (EVENT) )
  1636. X    {
  1637. X        perror("write");
  1638. X        return(-1);
  1639. X    }
  1640. X
  1641. X    }    /* end:  while()  */
  1642. X
  1643. X    
  1644. X}  /* end:  dostream()  */
  1645. X
  1646. X
  1647. X/*
  1648. X * Become a daemon: go into the background, reset our process group,
  1649. X * and clobber the current directory and stdin, stdout, stderr.
  1650. X * Ideas for what needs to be done more or less stolen from BSD sources.
  1651. X * Exits on failure, and complains vigorously!
  1652. X */
  1653. Xdaemon()
  1654. X{
  1655. X    int  retval, fd, errfd;
  1656. X    
  1657. X    if ((retval=fork()) < 0)                    /* Go into the background */
  1658. X      fatal("daemon(): fork() failed");
  1659. X    else if (retval)
  1660. X      exit(0);                    /* parent process */
  1661. X    
  1662. X    if ((int) setsid() < 0)                     /* Reset the process group */
  1663. X      fatal("daemon(): setsid() failed");
  1664. X    
  1665. X    if (chdir("/") < 0)                         /* Clobber current directory */
  1666. X      fatal("daemon(): chdir() failed");
  1667. X    
  1668. X    fd = open("/dev/null", O_RDWR, 0);          /* Clobber stdin, stdout, .. */
  1669. X
  1670. X    if (fd < 0)
  1671. X      fatal("daemon(): open() failed for errorfile");
  1672. X    if (dup2(fd, 1) < 0 || dup2(fd, 2) < 0)    /* dup stdout and stderr */
  1673. X      fatal("daemon(): dup2() failed");
  1674. X
  1675. X}    /* daemon() */
  1676. X    
  1677. X
  1678. Xfatal(s)    
  1679. Xchar *s;
  1680. X{
  1681. X    fprintf(stderr, "(fatal) %s: ", myname) ;
  1682. X    if (s)
  1683. X      fprintf(stderr, "%s\n", s);
  1684. X    else
  1685. X      fprintf(stderr, "\n");
  1686. X
  1687. X    unlink (pidfile);
  1688. X    unlink (datafile);
  1689. X
  1690. X    exit(1);
  1691. X
  1692. X}        /* fatal()  */
  1693. X
  1694. END_OF_FILE
  1695.   if test 8179 -ne `wc -c <'nocol-3.0/src/genmon/genmon.c'`; then
  1696.     echo shar: \"'nocol-3.0/src/genmon/genmon.c'\" unpacked with wrong size!
  1697.   fi
  1698.   # end of 'nocol-3.0/src/genmon/genmon.c'
  1699. fi
  1700. if test -f 'nocol-3.0/src/lib/event_utils.c' -a "${1}" != "-c" ; then 
  1701.   echo shar: Will not clobber existing file \"'nocol-3.0/src/lib/event_utils.c'\"
  1702. else
  1703.   echo shar: Extracting \"'nocol-3.0/src/lib/event_utils.c'\" \(8888 characters\)
  1704.   sed "s/^X//" >'nocol-3.0/src/lib/event_utils.c' <<'END_OF_FILE'
  1705. X/* $Header: /home/aggarwal/lsrc/nocol/src/lib/RCS/event_utils.c,v 1.3 1993/10/30 03:24:58 aggarwal Exp $ */
  1706. X
  1707. X/* Copyright 1993 JvNCnet, Global Enterprise Services */
  1708. X
  1709. X/*
  1710. X * Small collection of common routines for the NOCOL monitors, etc.
  1711. X *
  1712. X *    -vikas@jvnc.net
  1713. X *
  1714. X * $Log: event_utils.c,v $
  1715. X * Revision 1.3  1993/10/30  03:24:58  aggarwal
  1716. X * Added check for bad or illegal severity values.
  1717. X *
  1718. X *
  1719. X */
  1720. X
  1721. X#include "nocol.h"
  1722. X#include <string.h>
  1723. X
  1724. X
  1725. X/*+ 
  1726. X * FUNCTION:
  1727. X *     Skip leading spaces.
  1728. X */
  1729. Xchar *  skip_spaces(str)
  1730. X    char *str ;
  1731. X{
  1732. X    if (str == NULL)
  1733. X      return (str);
  1734. X    while (*str == ' '  || *str == '\t')
  1735. X      ++str ;                /* skip leading spaces */
  1736. X
  1737. X    return(str) ;
  1738. X}
  1739. X
  1740. X
  1741. X/*
  1742. X * Macro to escalate the severity of a site.
  1743. X * Change E_CRITICAL to E_ERROR if you don't want this program to put
  1744. X * events in the critical state.
  1745. X */
  1746. X#define ESC_SEVERITY(olds,maxs) ((olds == maxs)? maxs:(olds - 1))
  1747. X
  1748. X
  1749. X
  1750. X/*+ FUNCTION:
  1751. X *     To update the event structure and log to noclogd based on the
  1752. X *     'status' (0 or 1) and  'value' which is simply inserted.
  1753. X *     The severity is escalated if the status is down till it
  1754. X *    reaches 'maxsev'.
  1755. X *    The 'loglevel' is set to the new severity level when the status
  1756. X *    is DOWN, and set to the old severity level when the status
  1757. X *    is UP. This is done so that if a site goes critical and is
  1758. X *    logged at priority CRITICAL, then when it comes back up, it
  1759. X *    is logged at priority CRITICAL also.
  1760. X *
  1761. X *    Time is updated only when status comes back up or when the
  1762. X *    status goes down the very first time.
  1763. X */
  1764. Xupdate_event(v, status, value, maxsev)
  1765. X     EVENT *v;
  1766. X     long status;            /* site status */
  1767. X     int value, maxsev ;        /* Event.value, max severity */
  1768. X{
  1769. X    struct tm *ltime ;    
  1770. X    time_t locclock ;            /* careful: don't use 'long'    */
  1771. X    
  1772. X    locclock = time((time_t *) NULL);
  1773. X    ltime = localtime((long *)&locclock);
  1774. X
  1775. X    switch (status)
  1776. X    {
  1777. X     case 1:                /* Site responded, is up */
  1778. X    v->mon = ltime->tm_mon + 1;    /* update time */
  1779. X    v->day = ltime->tm_mday;
  1780. X    v->hour = ltime->tm_hour;
  1781. X    v->min = ltime->tm_min;
  1782. X
  1783. X    v->var.value = value ;        /* update pkts recvd. */
  1784. X    if (!(v->nocop & n_UP))        /* recent change of state */
  1785. X    {
  1786. X        v->nocop = SETF_UPDOUN(v->nocop, n_UP) ;
  1787. X        v->loglevel = v->severity; /* log at earlier level */
  1788. X        v->severity = E_INFO ;    /* change severity */
  1789. X        eventlog(v);
  1790. X    }
  1791. X    break;
  1792. X
  1793. X     case 0:            /* site down,  escalate the severity */
  1794. X    if (!(v->nocop & n_DOWN))    /* recent change of state.. */
  1795. X    {
  1796. X        v->mon = ltime->tm_mon + 1;
  1797. X        v->day = ltime->tm_mday;
  1798. X        v->hour = ltime->tm_hour;
  1799. X        v->min = ltime->tm_min;
  1800. X    }
  1801. X    
  1802. X    /*
  1803. X     * escalate severity level, and log if the severity level
  1804. X     * changes.
  1805. X     */
  1806. X    v->var.value = value;            /* new value  */
  1807. X    v->nocop = SETF_UPDOUN (v->nocop, n_DOWN);
  1808. X    v->severity = ESC_SEVERITY(v->severity, maxsev);
  1809. X    
  1810. X    if (v->loglevel != v->severity)     /* new change */
  1811. X    {
  1812. X        v->loglevel = v->severity ;  /* set to new severity */
  1813. X        eventlog(v);
  1814. X    }
  1815. X    break;
  1816. X    }        /* end switch */
  1817. X
  1818. X}
  1819. X
  1820. X/*   */
  1821. X
  1822. X/*+         event_to_logstr()
  1823. X ** FUNCTION:
  1824. X ** Formats an event structure as an ascii string that is written
  1825. X ** out to the various logfiles. Change here to get different
  1826. X ** format log lines. Not using EFMT, etc. since the log lines
  1827. X ** can have a TAG and other strings that might not be displayed.
  1828. X **
  1829. X ** Note that you should not change this function because 
  1830. X ** report generating functions might depend on this format.
  1831. X **/
  1832. Xchar *event_to_logstr(v)
  1833. X     EVENT  *v ;
  1834. X{
  1835. X    register int  i ;
  1836. X    static char  fmts[512];    /* Okay, so its a looonnng string !! */
  1837. X    char nocops[32];
  1838. X    char datestr[32] ;
  1839. X    struct tm *tm ;
  1840. X    time_t locclock ;
  1841. X
  1842. X    /*
  1843. X     * Create a string from the nocops flag
  1844. X     */
  1845. X    *nocops = '\0';
  1846. X    for (i=0 ; *(nocop_txt[i].str) != '\0' ; ++i)
  1847. X      if (v->nocop & nocop_txt[i].v)
  1848. X    strcat(strcat(nocops, nocop_txt[i].str), " ") ;
  1849. X
  1850. X    if (*nocops)
  1851. X      *(nocops + strlen(nocops) - 1) = '\0' ;     /* strip trailing blank */
  1852. X
  1853. X    /*
  1854. X     * Format the date string. Do any date format conversions here
  1855. X     */
  1856. X
  1857. X    /* Convert into Unix asctime format */
  1858. X    locclock = time((time_t *) NULL);
  1859. X    tm = localtime((long *)&locclock);        /* gets the year, etc. */
  1860. X
  1861. X    tm->tm_mon = v->mon - 1 ; tm->tm_mday = v->day ; 
  1862. X    tm->tm_hour = v->hour   ; tm->tm_min = v->min  ;
  1863. X    sprintf(datestr, "%s", (char *)asctime(tm) );
  1864. X    *(strchr(datestr, '\n')) = '\0' ;        /* delete the newline */
  1865. X
  1866. X/*   sprintf(datestr,"%02d/%02d %02d:%02d\0",v->mon,v->day,v->hour,v->min);/* */
  1867. X
  1868. X    if (v->severity < E_CRITICAL || v->severity > E_INFO)
  1869. X    {
  1870. X    fprintf(stderr, 
  1871. X        "(event_to_logstr): Bad severity %d, setting to CRITICAL\n", 
  1872. X        v->severity);
  1873. X    v->severity = E_CRITICAL ;
  1874. X    }
  1875. X    if (v->loglevel < E_CRITICAL || v->loglevel > E_INFO)
  1876. X    {
  1877. X    fprintf(stderr, 
  1878. X        "(event_to_logstr): Bad loglevel %d, setting to CRITICAL\n", 
  1879. X        v->loglevel);
  1880. X    v->loglevel = E_CRITICAL ;
  1881. X    }
  1882. X
  1883. X    /*
  1884. X     * IF YOU CHANGE THIS LINE, CHANGE THE CORRESPONDING CODE IN
  1885. X     * logstr_to_event()
  1886. X     */
  1887. X    sprintf(fmts,
  1888. X        "%s [%s]: SITE %s %s VAR %s %ld %ld %s LEVEL %s LOGLEVEL %s NOCOP %s\n",
  1889. X        datestr, v->sender, v->site.name, v->site.addr, 
  1890. X        v->var.name, v->var.value, v->var.threshold, v->var.units,
  1891. X        severity_txt[v->severity], severity_txt[v->loglevel],
  1892. X        nocops) ;
  1893. X
  1894. X    return(fmts) ;
  1895. X}
  1896. X
  1897. X/*+         logstr_to_event
  1898. X * FUNCTION:
  1899. X *     Read in a line of the logstr format and create a nocol
  1900. X * EVENT structure out of it.
  1901. X * WILL NEED TO CHANGE IF THE logstr_format() FUNCTION CHANGES.
  1902. X */
  1903. X
  1904. XEVENT *logstr_to_event(s)
  1905. X     char *s ;            /* text string with the nocol fields */
  1906. X{
  1907. X    static char  *monthlist[] = 
  1908. X    {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"} ;
  1909. X    int a, b, c ;    /* for scanning dates */
  1910. X    char  *psender, *psite, *pvar, *plevel, *ploglevel, *pnocop ;
  1911. X    char  tmps[32], *tstr;
  1912. X    register int i;
  1913. X    static EVENT v ;        /* needs to be static */
  1914. X    time_t nsecs ;
  1915. X    struct tm *ptm ;
  1916. X
  1917. X    psender   = strstr(s, "[") ; ++psender ;    /* skip past '[' */
  1918. X    psite     = strstr(s, "SITE") ;
  1919. X    pvar      = strstr(s, "VAR") ;
  1920. X    plevel    = strstr(s, "LEVEL") ;
  1921. X    ploglevel = strstr(s, "LOGLEVEL") ;
  1922. X    pnocop    = strstr(s, "NOCOP") ;
  1923. X
  1924. X    /*
  1925. X     * Parse date
  1926. X     */
  1927. X    for (i=0; s[i] != '[' ; ++i )    /* try to grab the date part */
  1928. X      tmps[i] = s[i];
  1929. X    tmps[i] = '\0' ;
  1930. X    while (tmps[--i] == ' ')        /* delete trailing spaces */
  1931. X      tmps[i] = '\0';
  1932. X
  1933. X    /*
  1934. X     * Calling get_date for robustness in parsing date's of various formats.
  1935. X     */
  1936. X       
  1937. X/*    nsecs = get_date(tmps);
  1938. X *   fprintf(stderr, "Converted date '%s'\n", ctime(&nsecs));
  1939. X *    ptm = localtime((time_t)nsecs) ;
  1940. X *    v.mon = ptm->tm_mon + 1; v.day = ptm->tm_mday; 
  1941. X *    v.hour =  ptm->tm_hour; v.min = ptm->tm_min ;
  1942. X */
  1943. X    /** Parse date:  Tue Sep 24 14:10:26 1993 **/
  1944. X    tstr = strchr(tmps, ' ');    /* Get to the month string */
  1945. X    tstr = skip_spaces(tstr);
  1946. X    for (v.mon=0 ;v.mon <12 && strncmp(tstr,monthlist[v.mon],3) != 0 ; ++v.mon)
  1947. X      ;
  1948. X    if (v.mon < 12)
  1949. X      v.mon++ ;        /* from 1 to 12 instead of 0-11 */
  1950. X    else
  1951. X    {
  1952. X    fprintf(stderr,
  1953. X        "Error (scan_logstr_format): Bad month in date string '%s'\n",
  1954. X        tstr);
  1955. X    return (NULL);
  1956. X    }
  1957. X
  1958. X/*  sscanf(tstr, "%*s %d %d:%d", v.day, (v.hour), (v.min) ); /* skip month */
  1959. X    sscanf (tstr, "%*s %d %d:%d", &a, &b, &c);
  1960. X    v.day = a ; v.hour = b ; v.min = c;
  1961. X
  1962. X    /*
  1963. X     * Sender field (in the square brackets[])
  1964. X     */
  1965. X    for (i=0 ; psender[i] != ']' ; ++i)
  1966. X      v.sender[i] = psender[i] ;
  1967. X    v.sender[i] = '\0';
  1968. X
  1969. X    strtok (psite, " \t") ;        /* Skip over keyword 'SITE' */
  1970. X    strcpy(v.site.name, strtok(NULL, " \t"));
  1971. X    strcpy(v.site.addr, strtok(NULL, " \t"));  /* hope no spaces in addr */
  1972. X
  1973. X    strtok(pvar, " \t");        /* Skip over keyword 'VAR' */
  1974. X    strcpy(v.var.name, strtok(NULL, " \t"));
  1975. X    v.var.value = atol (strtok(NULL, " \t"));
  1976. X    v.var.threshold = atol (strtok(NULL, " \t"));
  1977. X    strcpy(v.var.units, strtok(NULL, " \t")) ;
  1978. X
  1979. X    strtok (plevel, " \t");        /* skip leading keyword */
  1980. X    tstr = strtok(NULL, " \t");
  1981. X    for (a=E_CRITICAL ; severity_txt[a] != "" ; ++a)
  1982. X      if (strncmp(severity_txt[a], tstr, strlen(severity_txt[a])) == 0)
  1983. X    break;
  1984. X    v.severity = a ;
  1985. X
  1986. X    strtok(ploglevel, " \t");        /* skip leading keyword */
  1987. X    tstr = strtok(NULL, " \t");
  1988. X    for (a=E_CRITICAL ; severity_txt[a] != "" ; ++a)
  1989. X      if (strncasecmp(severity_txt[a], tstr, strlen(severity_txt[a])) == 0)
  1990. X    break;
  1991. X    v.loglevel = a ;
  1992. X
  1993. X    strtok(pnocop, " \t");        /* Skip over keyword */
  1994. X    v.nocop = 0;
  1995. X    while ((tstr = strtok(NULL, " \t")) != NULL)
  1996. X    {
  1997. X    register i = 0;
  1998. X    while (nocop_txt[i].str != "")
  1999. X      if (strncasecmp(nocop_txt[i].str,  tstr,  strlen(nocop_txt[i].str)) == 0)
  2000. X      {
  2001. X          v.nocop = v.nocop | nocop_txt[i].v ;
  2002. X          break;
  2003. X      }
  2004. X      else
  2005. X        ++i ;
  2006. X    }
  2007. X
  2008. X#ifdef DEBUG
  2009. X    fprintf(stderr, "(debug): %s\n", event_to_logstr(&v)) ;    /*  */
  2010. X#endif
  2011. X
  2012. X    return(&v) ;
  2013. X
  2014. X}    /* end:  logstr_to_event() */
  2015. X
  2016. END_OF_FILE
  2017.   if test 8888 -ne `wc -c <'nocol-3.0/src/lib/event_utils.c'`; then
  2018.     echo shar: \"'nocol-3.0/src/lib/event_utils.c'\" unpacked with wrong size!
  2019.   fi
  2020.   # end of 'nocol-3.0/src/lib/event_utils.c'
  2021. fi
  2022. if test -f 'nocol-3.0/src/support/mping/MAIL' -a "${1}" != "-c" ; then 
  2023.   echo shar: Will not clobber existing file \"'nocol-3.0/src/support/mping/MAIL'\"
  2024. else
  2025.   echo shar: Extracting \"'nocol-3.0/src/support/mping/MAIL'\" \(8786 characters\)
  2026.   sed "s/^X//" >'nocol-3.0/src/support/mping/MAIL' <<'END_OF_FILE'
  2027. XFrom Watt-Alan@Yale.EDU Fri Jun 12 08:27:44 1992
  2028. XReceived: from r2d2.jvnc.net by bambi.jvnc.net (5.65/1.34)
  2029. X    id AA04773; Fri, 12 Jun 92 08:27:42 -0400
  2030. XReceived: from MICKEY.YCC.YALE.EDU by r2d2.jvnc.net (5.65/1.34)
  2031. X    id AA12548; Fri, 12 Jun 92 08:27:28 -0400
  2032. XFrom: Watt-Alan@Yale.EDU
  2033. XReceived: by mickey.ycc.yale.edu; Fri, 12 Jun 92 08:27:26 EDT
  2034. XDate: Fri, 12 Jun 92 08:27:26 EDT
  2035. XMessage-Id: <9206121227.AA01802@mickey.ycc.yale.edu>
  2036. XTo: jvncnet-tech@jvnc.net, aggarwal@r2d2.jvnc.net
  2037. XSubject: Re: New monitoring capability - NOCOL testing
  2038. XCc: jvncnet-ops@jvnc.net, net@jvnc.net
  2039. XStatus: OR
  2040. X
  2041. X
  2042. X
  2043. XRe: ICMP ping monitor with capability to ping upto 64 sites at time.
  2044. X
  2045. XI have a program "mping" which can ping an arbitrary number of sites
  2046. Xan arbitrary number of times with specifiable packet sizes, packet
  2047. Xdata pattern, and timeout interval.
  2048. X
  2049. XThe program imposes a minimum pause between outgoing packets to
  2050. Xavoid flooding gateways.  I use 50 milliseconds here, but it can
  2051. Xbe set up or down to suit local needs.
  2052. X
  2053. XThis program is actually run from within another program (a Perl
  2054. Xscript), which continuously pings nodes according to a configuration
  2055. Xfile and outputs a running summary showing long-term error averages.
  2056. X
  2057. XThis is available via anonymous FTP from:
  2058. X
  2059. X    mickey.ycc.yale.edu    (130.132.21.200)
  2060. X    ~ftp/pub/spqr.tar
  2061. X
  2062. XDescription follows.
  2063. X
  2064. X
  2065. X    - Alan S. Watt
  2066. X      High Speed Networking, Yale University
  2067. X      Computing and Information Systems
  2068. X      Box 2112 Yale Station
  2069. X      New Haven, CT  06520-2112
  2070. X      (203) 432-6602
  2071. X      Watt-Alan@Yale.Edu
  2072. X
  2073. X
  2074. XDisclaimer:    We used to have the best Congress money could buy,
  2075. X        but like everything else these days the quality
  2076. X        has declined even as the price has risen.
  2077. X----------------------------------------------------------------------------
  2078. X
  2079. XSPQR
  2080. X
  2081. XSuccessive Ping Quality Regression     (Okay, you think of a better name)
  2082. X
  2083. X
  2084. Xspqr is a tool which can spot "low intensity" problems in LAN or WAN
  2085. Xfunctioning.  Based on the venerable "ping" (ICMP_ECHO) facility, it
  2086. Xcontinuously monitors stations based on a configuration file and keeps
  2087. Xa cumulative problem metric averaged over 5, 15, and 60 minute intervals.
  2088. X
  2089. Xspqr consists of three parts: a driver/reporting program which initiaties
  2090. Xa poll every minute and averages the results, a parallel pinger program
  2091. X(which can send ICMP_ECHO packets to an arbitrarily large number of targets
  2092. Xin parallel), and a simple display program which continuously prints the
  2093. Xcurrent status to the screen.  The display program is suitable to run
  2094. Xas a restricted shell.
  2095. X
  2096. Xmping -- the parallel pinger program
  2097. X------------------------------------
  2098. XMping is driven from a configuration file (or standard input) which
  2099. Xlists the addresses to ping, and optionally:
  2100. X
  2101. X    packet length    (default 56 bytes of ICMP data)
  2102. X    packet data    (default all zeros)
  2103. X    # packets    (default 1)
  2104. X    # retries    (default 5)
  2105. X    retry interval    (default 1 second)
  2106. X
  2107. XThe format of the file is simple, consisting of two or three fields
  2108. Xfor each entry.  The fields are:
  2109. X
  2110. X    name    address    [options]
  2111. X
  2112. XIf given, <options> is one or more comma-separated fields in the order:
  2113. X
  2114. X    size,pattern,numToGet,retry,timeout
  2115. X
  2116. XThis parses option fields left to right, as indicated by commas.  Missing
  2117. Xor empty fields use the default value (see below).  For example, the
  2118. Xoption string to specify just the size (128) and pattern (0x15) would be
  2119. X"128,0x15": the remaining fields would default.  To specify a size (128)
  2120. Xand a retry count (2), the option field would be "128,,,2".  To specify
  2121. Xjust a timeout of 2 seconds, the option string would be ",,,,2000".
  2122. X
  2123. X
  2124. X size [default: 56]:        Decimal number giving the size of the ICMP
  2125. X                data portion of the packet.  The actual IP
  2126. X                packet will be at least 8 octets larger.
  2127. X
  2128. Xpattern [default: 0x0]:    A hex number specifying a byte value to
  2129. X                initialize the ICMP data portion of the
  2130. X                packet.
  2131. X
  2132. XnumToGet [default: 1]:    Number of return packets to require.
  2133. X
  2134. Xretry [default: 5]:        Number of retries to make before declaring
  2135. X                a packet lost.  Note that if <numToGet> is
  2136. X                greater than 1, the retry limit applies to
  2137. X                each attempt.  That is if the first attempt
  2138. X                requires 4 tries before a successful return,
  2139. X                then next attempt will still make up to 5
  2140. X                tries.
  2141. X
  2142. Xtimeout [default: 1000]    Number of milliseconds to wait before
  2143. X                assuming packet lost and retrying.  The
  2144. X                default timeout is fine within an all
  2145. X                ethernet environment, but you need a longer
  2146. X                one for WAN links.
  2147. X
  2148. XThe <name> field is not used for anything except producing the report.
  2149. X
  2150. XThe <address> field can be either an IP address in any of the notations
  2151. Xacceptable to the inet_addr() function, or it can be a domain name.
  2152. XIf a domain name is used, and the gethostbyname() function returns
  2153. Xmore than one address, it is treated like multiple configuration lines,
  2154. Xone for each address.  For example the configuration line:
  2155. X
  2156. X    NS-NIC    ns.nic.ddn.mil    56,0,2
  2157. X
  2158. Xis treated as if read:
  2159. X
  2160. X    NS-NIC    192.112.36.4    56,0,2
  2161. X    NS-NIC    192.67.67.53    56,0,2
  2162. X
  2163. X
  2164. Xbased on the configuration, the parallel pinger sends packets to every
  2165. Xtarget on the list, retrying as necessary until all targets have either
  2166. X(a) returned the required number of packets or (b) failed to return a
  2167. Xpacket in the specified number of timeouts.
  2168. X
  2169. XIt then reports for each target: how many packets sent, how many returned,
  2170. Xand the total packet round trip time (in microseconds) for all returned
  2171. Xpackets.
  2172. X
  2173. Xmsummary -- the driver program
  2174. X------------------------------
  2175. XThe driver program invokes mping once each cycle (default 60 seconds)
  2176. Xand reads its output to produce a summary of all targets showing less
  2177. Xthan perfect connectivity.   There are four columns of bad/RTT pairs,
  2178. Xand a single RPT column.  The bad/RTT pairs show the percentage of
  2179. Xdropped packets and the average round trip time for: (1) the most
  2180. Xrecent poll, (2) the most recent 5 polls, (3) the most recent 15 polls,
  2181. Xand (4) the most recent 60 polls.  Thus temporary problems eventually
  2182. Xget averaged out and dropped from the report, but persistent low-level
  2183. Xproblems remain prominent.
  2184. X
  2185. XThe "RPT" column shows what percentage of the time this system has been
  2186. Xreported.  A target is dropped from the report when all averages become
  2187. X0.  Thus a target with.
  2188. X
  2189. XHere is a sample report:
  2190. X
  2191. X------------------------------------------------------------------------------
  2192. X16:19:27    Iter: 16288 Cycle:  14   current    avg. 5   avg. 15   avg. 60
  2193. XSystem Name        IP Address      bad   RTT bad   RTT bad   RTT bad   RTT RPT
  2194. X------------------ --------------- --- ----- --- ----- --- ----- --- ----- ---
  2195. Xcupid              130.132.21.192    0   1.6   2   1.8  13   1.8  18   1.8  99
  2196. Xcalvin             130.132.21.195   33   1.2  27   1.4  23   1.4  18   1.4  98
  2197. Xdual               130.132.21.211    0   1.8  14   1.8  16   1.9  12   1.7  47
  2198. Xyaleads            130.132.21.130    0   3.9   0   4.2   0   4.6   1   5.2   8
  2199. Xcondor             130.132.21.141  100   0.0 100   0.0 100   0.0 100   0.0 100
  2200. Xvenus              130.132.1.5       0   5.4   0   5.5   2   5.6   7   5.8  94
  2201. Xbiomed.med         130.132.19.48     0   5.0   0   5.2   0   5.3   4   5.5  30
  2202. Xgucci.stat         130.132.16.16     0   3.7   0   4.0   1   4.0   6   4.0 100
  2203. Xhermes.stat        130.132.16.19   100   3.9 100   3.9 100   3.9  95   3.8 100
  2204. Xsysc.eng           130.132.20.240    0   4.2   0   4.2   0   4.3   1   4.3  19
  2205. Xcld3.eng           130.132.20.251    0   4.0   0   4.0   1   4.1   2   4.1   4
  2206. X74 entries skipped for all-0 error averages
  2207. X
  2208. X------------------------------------------------------------------------------
  2209. X
  2210. XThis report shows systems "condor" is dropping all packets, and has
  2211. Xbeen for the last 60 cycles.  "hermes.stat" has been dropping all
  2212. Xpackets for at least the last 15 cycles, but sometime in the last 60
  2213. Xcycles some packets got through.  (Both situations are consistent with
  2214. Xthe target machine being down).
  2215. X
  2216. XThe more interesting reports are for machines like venus, calvin, gucci.stat,
  2217. Xand cupid.  They all show persistent long-term drop rates, evidenced by the
  2218. Xhigh value in the "RPT" column.  In a LAN environment, nodes should show
  2219. Xa 0% packet drop rate virtually all the time.  An occasional dropped packet
  2220. Xis generally not anything to worry about.  Persistent non-zero drop rates
  2221. Xto certain nodes indicates an error condition either at the end nodes or
  2222. Xon a network segment somewhere between the station running SPQR and the
  2223. Xend nodes.  Running SPQR on several nodes on different segments is a good
  2224. Xway to "triangulate" in on a problem bridge or router.  Its first use
  2225. X(actually, reason for development) was to establish that a specific
  2226. Xethernet interface on a cisco router had a 1% packet drop rate that didn't
  2227. Xshow up in the SNMP data.
  2228. X
  2229. XThe "Iter" value in the heading is the number of iterations this driver
  2230. Xprogram has made; the "Cycle" value is how many seconds it takes to run
  2231. Xeach cycle.
  2232. X
  2233. END_OF_FILE
  2234.   if test 8786 -ne `wc -c <'nocol-3.0/src/support/mping/MAIL'`; then
  2235.     echo shar: \"'nocol-3.0/src/support/mping/MAIL'\" unpacked with wrong size!
  2236.   fi
  2237.   # end of 'nocol-3.0/src/support/mping/MAIL'
  2238. fi
  2239. echo shar: End of archive 19 \(of 26\).
  2240. cp /dev/null ark19isdone
  2241. MISSING=""
  2242. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
  2243.     if test ! -f ark${I}isdone ; then
  2244.     MISSING="${MISSING} ${I}"
  2245.     fi
  2246. done
  2247. if test "${MISSING}" = "" ; then
  2248.     echo You have unpacked all 26 archives.
  2249.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2250. else
  2251.     echo You still must unpack the following archives:
  2252.     echo "        " ${MISSING}
  2253. fi
  2254. exit 0
  2255. exit 0 # Just in case...
  2256.