diff -Nur nocol-4.2/Configure nocol-4.2.1/Configure
--- nocol-4.2/Configure Fri Jul 31 13:58:37 1998
+++ nocol-4.2.1/Configure Wed Aug 19 18:51:28 1998
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Header: /home/vikas/src/nocol/RCS/Configure,v 1.5 1998/07/31 17:58:25 vikas Exp $
+# $Header: /home/vikas/src/nocol/RCS/Configure,v 1.6 1998/08/19 22:51:10 vikas Exp $
#
# Configure script for nocol
#
@@ -171,7 +171,7 @@
ls /usr/lib/libresolv* >/dev/null 2>&1
if [ $? = 1 ]; then
ls /lib/libresolv* >/dev/null 2>&1
- if [ $? = 1]; then
+ if [ $? = 1 ]; then
ls /usr/lib/libbind* >/dev/null 2>&1
if [ $? = 1 ]; then LIBRESOLV="" ; else LIBRESOLV="-lbind" ; fi
fi
diff -Nur nocol-4.2/HISTORY nocol-4.2.1/HISTORY
--- nocol-4.2/HISTORY Wed Jul 29 12:38:41 1998
+++ nocol-4.2.1/HISTORY Fri Aug 28 00:24:09 1998
@@ -1,5 +1,10 @@
HISTORY FOR NOCOL
+nocol v4.2.1 Aug 1998
+------------
+
+ (see Release notes in html/release.html)
+
nocol v4.2 Jul 1998
----------
diff -Nur nocol-4.2/INSTALL nocol-4.2.1/INSTALL
--- nocol-4.2/INSTALL Fri Jul 31 13:36:45 1998
+++ nocol-4.2.1/INSTALL Thu Aug 27 23:26:39 1998
@@ -1,4 +1,4 @@
-## $Id: INSTALL,v 4.2 1998/07/31 17:36:37 vikas Exp $
+## $Id: INSTALL,v 4.3 1998/08/28 03:26:31 vikas Exp $
INSTALLATION INSTRUCTIONS FOR 'NOCOL' v4.2
==========================================
@@ -104,6 +104,9 @@
REMEMBER that the monitors log events to noclogd only when the state
of the event CHANGES. So nothing might be logged to noclogd if all
the sites remain at the same state (up/down) and threshold level.
+
+ You can check logging using the perl script 'testlog' under
+ perlnocol.
10. You can add user 'nocol' to your password file to allow anyone to
log in as user 'nocol' and see the state of the network. A typical
diff -Nur nocol-4.2/Makefile nocol-4.2.1/Makefile
--- nocol-4.2/Makefile Fri Jul 31 21:06:17 1998
+++ nocol-4.2.1/Makefile Fri Aug 28 00:58:09 1998
@@ -1,5 +1,5 @@
#
-# $Id$
+# $Id: Makefile.dist,v 1.1 1998/08/28 03:27:01 vikas Exp $
#
# To make a distribution 'tar' image, do
# make -f Makefile.mid tar
diff -Nur nocol-4.2/Makefile.dist nocol-4.2.1/Makefile.dist
--- nocol-4.2/Makefile.dist Fri Jul 31 13:23:10 1998
+++ nocol-4.2.1/Makefile.dist Thu Aug 27 23:27:12 1998
@@ -1,5 +1,5 @@
#
-# $Id$
+# $Id: Makefile.dist,v 1.1 1998/08/28 03:27:01 vikas Exp $
#
# To make a distribution 'tar' image, do
# make -f Makefile.mid tar
diff -Nur nocol-4.2/Makefile.mid nocol-4.2.1/Makefile.mid
--- nocol-4.2/Makefile.mid Fri Jul 31 21:05:47 1998
+++ nocol-4.2.1/Makefile.mid Thu Aug 27 23:22:38 1998
@@ -1,4 +1,4 @@
-# $Header: /home/vikas/src/nocol/RCS/Makefile.mid,v 1.2 1998/08/01 01:05:32 vikas Exp $
+# $Header: /home/vikas/src/nocol/RCS/Makefile.mid,v 1.2 1998/08/01 01:05:32 vikas Exp vikas $
#
# Makefile for 'nocol'. This file simply calls on other Makefiles in
# the subdirectories to do all the work. All the definitions are used
@@ -7,7 +7,7 @@
# To 'make' for only one program, use
# make "SRCS=trapmon" [install|clean]
#
-REV = "4.2"
+REV = "4.2.1"
package=@package@
OS=@OS@
diff -Nur nocol-4.2/doc/Makefile.mid nocol-4.2.1/doc/Makefile.mid
--- nocol-4.2/doc/Makefile.mid Wed Mar 12 09:35:29 1997
+++ nocol-4.2.1/doc/Makefile.mid Thu Aug 27 23:28:12 1998
@@ -1,4 +1,4 @@
-# $Header: /home/vikas/netmgt/nocol/src/doc/RCS/Makefile,v 1.3 1994/11/29 17:53:19 vikas Exp $
+# $Header: /home/vikas/src/nocol/doc/RCS/Makefile.mid,v 1.1 1998/08/28 03:28:09 vikas Exp $
#
# Make for installing the man pages
# This installs all the man pages with the same extension
diff -Nur nocol-4.2/doc/netconsole.1 nocol-4.2.1/doc/netconsole.1
--- nocol-4.2/doc/netconsole.1 Tue Nov 29 15:13:11 1994
+++ nocol-4.2.1/doc/netconsole.1 Thu Aug 13 11:57:21 1998
@@ -1,10 +1,11 @@
-.\" $Header: /home/vikas/netmgt/nocol/src/doc/RCS/netconsole.1,v 1.10 1994/11/29 20:12:56 vikas Exp $
+.\" $Header: /home/vikas/src/nocol/doc/RCS/netconsole.1,v 1.11 1998/08/13 15:55:40 vikas Exp $
.\"
.TH NETCONSOLE 1 "May 1994"
.SH NAME
nocol \- Curses display agent for the NOCOL (
.I Network Operation Center OnLine
) network monitoring package.
+.\" --------------------------------------------
.SH SYNOPSIS
.B netconsole
[
@@ -22,6 +23,7 @@
This program displays NOCOL format events by parsing all the datafiles in
the NOCOL data directory (or alternate directory specified).
+.\" --------------------------------------------
.SH OPTIONS
.TP
.B \-e
@@ -52,6 +54,13 @@
in a predefined
.I data
directory.
+.LP
+The default display severity level is Critical. However, you can set your
+shell environment variable
+.B NOCOL_SEVERITY
+to one of Critical, Error, Warning, Info to set your desired severity
+level.
+.\" --------------------------------------------
.SH DESCRIPTION
.LP
.B netconsole
@@ -144,6 +153,7 @@
or
.I informational.
+.\" --------------------------------------------
.SH RUN TIME OPTIONS
.LP
.I netconsole
@@ -233,13 +243,6 @@
.TP
.B q
to quit from the program.
-.\" --------------------------------------------
-.SH ACCESS
-.LP
-A sample of this program can be seen by logging onto
-.B nocol.jvnc.net
-as user
-.B nocol.
.\" --------------------------------------------
.SH AUTHOR
Vikas Aggarwal, vikas@navya.com
diff -Nur nocol-4.2/html/faq.html nocol-4.2.1/html/faq.html
--- nocol-4.2/html/faq.html Thu Jul 30 20:12:01 1998
+++ nocol-4.2.1/html/faq.html Thu Aug 27 22:49:37 1998
@@ -1,13 +1,13 @@
-
+
nocol FAQ
- Frequently Asked Questions (FAQ) about nocol
+ NOCOL : Frequently Asked Questions (FAQ)

- Last updated July 1998
+ Last updated Aug 03, 1998
- General
- Miscellanous
@@ -34,8 +36,9 @@
?
- How do I get notified when a site comes back
up ?
- - Does nocol run on Windows NT ?
- - Who developed NOCOL ?
+ - How do I get paged as soon as a site goes down?
+ - Does nocol run on Windows NT ?
+ - Who developed NOCOL ?
@@ -125,6 +128,25 @@
debug mode).
+
multiping gives error socket: Operation not
+ permitted
+ multiping requires a raw socket, and needs to be installed
+ suid root. You probably did not run make root while
+ installing nocol. Check the ownership and permission of this program-
+ it must show mode -rwsr-x--x with owner root. If
+ not, do the following:
+
+ chown root multiping
+ chmod 4751 multiping
+
+
+
+
Nothing is being logged to noclogd
+ Events are logged ONLY when their state changes. Thus, an
+ event will be logged to noclogd if a site goes from info level to
+ warning level, etc.
+
+
Can nocol handle SNMPv2 ?
NOCOL currently uses the CMU SNMP software which does not implement
@@ -150,11 +172,19 @@
goes critical, but also detect when the device comes back up.
-
Does nocol run on windows NT ?
+ How do I get paged as soon as a site goes down ?
+ In order to avoid false alarms (and prevent operators from getting
+ into the habit of wait-and-it-will-go-away), NOCOL will escalate any
+ events severity gradually. If you want to get paged or notified as
+ soon as a site or variable changes, you can watch it at the
+ Warning level instead of the Critical level.
+
+
+
Does nocol run on windows NT ?
Nope. No plans to port it at this time either.
-
Who maintains NOCOL ?
+ Who maintains NOCOL ?
This software is currently maintained by
Vikas Aggarwal. Numerous
authors have made contributions which have been added to the package.
diff -Nur nocol-4.2/html/index.html nocol-4.2.1/html/index.html
--- nocol-4.2/html/index.html Thu Jul 30 20:12:02 1998
+++ nocol-4.2.1/html/index.html Thu Aug 27 22:59:43 1998
@@ -1,28 +1,31 @@
-
+
-
- NOCOL/SNIPS Home Page
+
+
+ NOCOL SNIPS Home Page
+
+ Current Version 4.2.1
+
NOCOL/SNIPS is a system and network monitoring software
that runs on
Unix systems and can poll network and system devices. It is
@@ -55,22 +58,31 @@
BGP peers | SNMP variables | Data throughput |
+ Click here to see a sample of the web
+ interface.
+
The software is available from http://www.netplex-tech.com/software/nocol
or via ftp from ftp.navya.com.
+
+ nocol-users@navya.com is a mailing list for general discussion
+ of nocol. Click here
+ to subscribe to this mailing list (send subscribe in the
+ BODY of your email).
+
+ Send bug reports to
+ nocol-bugs@navya.com
-
-
-
- Current Version 4.2
+
+
- Download
- Copyright
- Release Notes (Change Log)
- (version v4.2)
+ (version v4.2.1)
-
+ - Mailing List Archives
- Known Bugs & Limitations
- Frequently Asked Questions (FAQ)
PLEASE READ THESE
diff -Nur nocol-4.2/html/release.html nocol-4.2.1/html/release.html
--- nocol-4.2/html/release.html Thu Jul 30 20:12:02 1998
+++ nocol-4.2.1/html/release.html Thu Aug 27 23:25:35 1998
@@ -1,8 +1,8 @@
-
+
- NOCOL/SNIPS RELEASE Notes
+ NOCOL / SNIPS RELEASE Notes
@@ -12,6 +12,30 @@
+ nocol v4.2.1 Aug 1998
+
+ - keepalive_monitors: fixed bug while restarting dead processes.
+ - nocollib.pl: local($logfd) bug in perl5 ? Causing eventlog
+ to fail.
+ - portmon.c: removed goto which was causing core dumps with
+ certain compilers.
+ - netconsole: now looks at NOCOL_SEVERITY environment variable for
+ default level while starting up.
+ - Removed various goto's in code to avoid possible compiler bugs.
+ - bgpmon: New enhanced version (completely rewritten)
+ - notifier.pl: New possible alternative to notifier.
+ - crontab.nocol: Run notifier.pl every 10 minutes instead of 1 ?.
+ - Configure: bug in test for libresolv.
+ - hostmon- new clients for Irix 6, fixed AIX, FreeBSD 2.2.x.
+ - webnocol.cgi: Was not printing out deny message on insufficient
+ privleges.
+ - genweb.pl: Compact html output for Info mode. Can customize the
+ fontsize and updates in User view (userViewUpdates, tfontsize)
+ - nsmon: Sitename (from config file) is displayed in netconsole
+ instead of the domain being monitored (removed feature added in v4.2)
+ since this is more flexible.
+
+
nocol v4.2 Jul 1998
- New monitors: apcmon, ntpmon, syslogmon, radiusmon
@@ -66,7 +90,7 @@
- Fixed bug in the CMU code in cmu-snmp/snmplib/asn1.c
- 
+ 

Binary files nocol-4.2/html/sample1/bluesq.gif and nocol-4.2.1/html/sample1/bluesq.gif differ
Binary files nocol-4.2/html/sample1/empty.gif and nocol-4.2.1/html/sample1/empty.gif differ
Binary files nocol-4.2/html/sample1/greensq.gif and nocol-4.2.1/html/sample1/greensq.gif differ
diff -Nur nocol-4.2/html/sample1/index.html nocol-4.2.1/html/sample1/index.html
--- nocol-4.2/html/sample1/index.html Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/html/sample1/index.html Thu Aug 27 22:59:03 1998
@@ -0,0 +1,246 @@
+
+
+ NOCOL - Warning view
+
+
+
+
+
+
+ |
+ Current view: Warning
+ |
+
+ Last update: 08/21/1998 17:01
+ |
+ |
+ (updated 0 min ago) |
+
+
+
+
+
+
+ | New view: |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+ Select a device name to update or troubleshoot it
+
+
+  |
+
+ |
+ |
+  |
+ # |
+  |
+ Status |
+  |
+ Device Name |
+  |
+ Address |
+  |
+ Variable / Value |
+  |
+ Down At |
+  |
+ Updates |
+  |
+
+  |
+
+
+ |
+  |
+ 1 |
+  |
+
+ Critical |
+  |
+
+ xynet |
+  |
+
+ 13.94.40.249 |
+  |
+
+
+
+ ICMP-ping= 0
+ |
+  |
+
+
+
+ 8/21 12:21 |
+  |
+
+ Scheduled outage |
+  |
+
+ |
+  |
+ 2 |
+  |
+
+ Critical |
+  |
+
+ icic-LAN |
+  |
+
+ 198.13.205.129 |
+  |
+
+
+
+ ICMP-ping= 0
+ |
+  |
+
+
+
+ 8/21 12:21 |
+  |
+
+ Vantive ticket 260173 |
+  |
+
+ |
+  |
+ 3 |
+  |
+
+ Warning |
+  |
+
+ lysite-FR |
+  |
+
+ 19.138.1.10 |
+  |
+
+
+
+ ICMP-ping= 6
+ |
+  |
+
+
+
+ 8/21 16:52 |
+  |
+
+ |
+  |
+
+ |
+  |
+ 4 |
+  |
+
+ Warning |
+  |
+
+ lysite-LAN |
+  |
+
+ 19.139.171.1 |
+  |
+
+
+
+ ICMP-ping= 6
+ |
+  |
+
+
+
+ 8/21 16:52 |
+  |
+
+ |
+  |
+
+ |
+  |
+ 5 |
+  |
+
+ Critical |
+  |
+
+ srhh |
+  |
+
+ 198.18.1.9 |
+  |
+
+
+
+ ICMP-ping= 0
+ |
+  |
+
+
+
+ 8/21 12:29 |
+  |
+
+ Telco ticket #32984 |
+  |
+
+ |
+  |
+ 6 |
+  |
+
+ Critical |
+  |
+
+ mnemic-gw |
+  |
+
+ 198.18.246.97 |
+  |
+
+
+
+ ICMP-ping= 0
+ |
+  |
+
+
+
+ 8/21 12:30 |
+  |
+
+ |
+  |
+
|
+
+
Messages
+
+NOCOL- v2.4
Binary files nocol-4.2/html/sample1/redsq.gif and nocol-4.2.1/html/sample1/redsq.gif differ
Binary files nocol-4.2/html/sample1/yellowsq.gif and nocol-4.2.1/html/sample1/yellowsq.gif differ
diff -Nur nocol-4.2/lib/Makefile.mid nocol-4.2.1/lib/Makefile.mid
--- nocol-4.2/lib/Makefile.mid Thu Aug 21 11:10:29 1997
+++ nocol-4.2.1/lib/Makefile.mid Thu Aug 27 23:28:18 1998
@@ -1,4 +1,4 @@
-# $Header$
+# $Header: /home/vikas/src/nocol/lib/RCS/Makefile.mid,v 1.1 1998/08/28 03:28:16 vikas Exp $
#
# Makefile.mid for nocol 'lib'. This file also builds the CMU-SNMP lib.
#
diff -Nur nocol-4.2/lib/misc.c nocol-4.2.1/lib/misc.c
--- nocol-4.2/lib/misc.c Fri Jul 31 14:21:33 1998
+++ nocol-4.2.1/lib/misc.c Thu Aug 13 12:11:26 1998
@@ -1,4 +1,4 @@
-/*+ $Header: /home/vikas/src/nocol/lib/RCS/misc.c,v 1.10 1998/07/31 18:21:08 vikas Exp $
+/*+ $Header: /home/vikas/src/nocol/lib/RCS/misc.c,v 1.11 1998/08/13 16:11:05 vikas Exp $
*
*/
@@ -16,6 +16,9 @@
/*
* $Log: misc.c,v $
+ * Revision 1.11 1998/08/13 16:11:05 vikas
+ * Now does not exit if it finds an empty pid file (standalone)
+ *
* Revision 1.10 1998/07/31 18:21:08 vikas
* Now puts all the pid files in the PIDDIR instead of ETCDIR
*
@@ -151,7 +154,7 @@
**/
standalone(pidfile)
- char *pidfile; /* path of the pid file */
+ char *pidfile; /* path of the pid file */
{
FILE *pidf ;
int oldpid = 0, newpid = 0;
@@ -165,22 +168,25 @@
{
if (fscanf(pidf, "%d %s", &oldpid, hostname) == EOF)
{
- fprintf(stderr, "(standalone): fscanf ");
+ fprintf(stderr, "(standalone): fscanf() error parsing old pid ");
perror(pidfile) ; /* couldn't read */
- return (-1);
+ /* return (-1); /* Lets not return,,, */
+ oldpid = 0;
}
fclose(pidf);
- if (strcmp(thishostname, hostname) != 0) /* wrong host */
+ if (oldpid)
{
+ if (strcmp(thishostname, hostname) != 0) /* wrong host */
+ {
fprintf(stderr,
"(standalone) %s: Program probably running on '%s'\n",
prognm, hostname) ;
fprintf(stderr, "Kill and delete '%s' file and restart\n",pidfile);
return (-1) ;
- }
- else /* on proper host */
- {
+ }
+ else /* on proper host */
+ {
if (kill (oldpid, SIGKILL) != 0 && errno != ESRCH)
{
fprintf(stderr,
@@ -191,7 +197,8 @@
}
else
sleep (5) ; /* Let other process die */
- }
+ }
+ } /* if(oldpid) */
} /* end if (pidfile could be opened) */
/*
diff -Nur nocol-4.2/netconsole/fill_window.c nocol-4.2.1/netconsole/fill_window.c
--- nocol-4.2/netconsole/fill_window.c Tue Nov 29 15:41:07 1994
+++ nocol-4.2.1/netconsole/fill_window.c Thu Aug 13 11:33:53 1998
@@ -1,5 +1,5 @@
/*
-** $Header: /home/vikas/netmgt/nocol/src/netconsole/RCS/fill_window.c,v 1.10 1994/11/29 20:40:34 vikas Exp $
+** $Header: /home/vikas/src/nocol/netconsole/RCS/fill_window.c,v 1.11 1998/08/13 15:33:37 vikas Exp $
*/
/*+
@@ -10,20 +10,11 @@
* as the MESSAGES window.
*
* LOGIC
- * 1) Skip over any file that begins with a "." or named 'core'
- * 2) Reset to start of window (needed since we are using WFULL
- * to decide when to stop putting out lines.
- * 3) Get next file in directory
- * - if directory type then skip
- * - open file
- * 4) If end of directory, close and return 1
- * 5) If not FULL, call display_function
- * else return(0)
- * 6) If end of file,
- * - close file
- * - open next file
- * - if end of dir, clrtobot, return(1)
- *
+ * - if no data file open, try opening new file
+ * - skip over files beginning with '.' or 'core' or dirs
+ * - if end of data files, clrtobot, return 1
+ * - until window not FULL, call display_function
+ * - if end of file, close file and open new one
*
* RETURN VALUE
* 1 if all files in directory are displayed.
@@ -37,39 +28,12 @@
/*
*
* $Log: fill_window.c,v $
+ * Revision 1.11 1998/08/13 15:33:37 vikas
+ * Rewrote to remove the goto calls.
+ *
* Revision 1.10 1994/11/29 20:40:34 vikas
* Updated as netconsole for v4.0
*
- * Revision 1.9 1994/06/12 18:09:35 vikas
- * Deleted the 'options' variable and set debug/quiet/emode to
- * be simple integers instead.
- *
- * Revision 1.8 1994/05/16 01:59:12 vikas
- * Cleanup for new release.
- *
- * Revision 1.7 1993/10/30 03:52:08 aggarwal
- * Now uses dirent(). Deleted include dir.h
- *
- * Revision 1.6 1993/10/05 04:17:41 aggarwal
- * Now skips over 'core' files.
- *
- * Revision 1.5 1992/06/18 21:03:22 aggarwal
- * Cleaned up for releasing.
- *
- * Revision 1.3 1990/05/23 17:21:21 aggarwal
- * Uncommented wmove() - see preamble (comments).
- *
- * Revision 1.2 90/05/13 22:27:02 aggarwal
- * Commented out the line for resetting the window position to (0,0)
- * since that should depend on the window being operated upon - the msg
- * win can scroll so I don't want to reset the cursor position for the
- * msg window. Have moved the line to the event_dpy.c module instead.
- * Added ' fstat' so that a directory is skipped and not treated as a
- * data file.
- *
- * Revision 1.1 90/03/09 13:05:47 aggarwal
- * Initial revision
- *
*/
#include "netconsole.h"
@@ -85,66 +49,59 @@
{
struct dirent *direntry ;
char file[MAXLINE];
- int opennew = 0; /* boolean to open file */
-
+ struct stat buf ; /* for fstat */
wmove(win, 0, 0); /* reset to start pos */
- if (*pcurfd == 0) /* No file open... */
- opennew = 1 ;
-
-open_file:
- while (opennew) /* open new file until successful */
+ while (!(WFULL(win)))
{
- struct stat buf ; /* for fstat */
-
- if (*pcurfd > 0) /* close any currently open file */
- close(*pcurfd);
-
- if ((direntry = readdir(dirp)) == NULL)
- { /* All files are done */
+ if (*pcurfd <= 0) /* open new file if no file open */
+ {
+ while (*pcurfd <= 0)
+ {
+ direntry = readdir(dirp);
+ if (direntry == NULL)
+ { /* All files are done */
wclrtobot(win); /* Clear win to bottom */
- *pcurfd = 0; /* reset to zero */
return (1); /* All files displayed */
- }
+ }
- /* name begins with a dot or 'core' or is not a file */
- if (*(direntry->d_name) == '.' || strcmp(direntry->d_name, "core") ==0)
- goto open_file ; /* ...so skip it */
-
- sprintf (file, "%s/%s\0", (char *)dir, (char *)direntry->d_name);
-
- if ((*pcurfd = open(file, O_RDONLY)) == -1) /* error */
- {
- wprintw (aw.wmsg,
- "\nERROR fill_win(open): '%s'- %s",
+ /* name begins with a dot or 'core' or is not a file */
+ if (*(direntry->d_name) == '.')
+ continue ; /* ...so skip it */
+ if (strcmp(direntry->d_name, "core") == 0)
+ continue;
+
+ sprintf (file, "%s/%s", (char *)dir, (char *)direntry->d_name);
+ if ((*pcurfd = open(file, O_RDONLY)) == -1) /* error */
+ {
+ wprintw (aw.wmsg, "\nERROR fill_win(open): '%s'- %s",
direntry->d_name, sys_errlist[errno]);
continue ;
- }
+ }
- /*
- * Here if safely opened data file
- */
- fstat (*pcurfd, &buf); /* Get info about fd */
- if ((buf.st_mode & S_IFMT) == S_IFDIR) /* It is a dir */
- { /* ..so open another */
+ fstat (*pcurfd, &buf); /* Get info about fd */
+ if ((buf.st_mode & S_IFMT) == S_IFDIR) /* It is a dir */
+ { /* ..so open another */
close(*pcurfd);
- goto open_file ;
- }
+ *pcurfd = 0;
+ continue;
+ }
- opennew = 0; /* Don't open another */
+ } /* while(pcurfd <= 0) */
if (debug)
wprintw (aw.wmsg,
"\n(DEBUG) fill_win: Opened file %s... ", direntry->d_name);
+ } /* if (*purfd == 0) */
- } /* end: while opennew */
-
- while (!(WFULL(win)))
- if (dpy_func(*pcurfd, win) == 0) /* end of file */
+ if (dpy_func(*pcurfd, win) == 0) /* end of current data file */
{
- opennew = 1; /* open another file */
- goto open_file ;
+ close (*pcurfd);
+ *pcurfd = 0;
}
- return (0) ; /* Window full */
-} /* end: fill_window */
+ } /* while(!WFULL() */
+
+ return (0) ; /* Window full */
+
+} /* end: fill_window() */
diff -Nur nocol-4.2/netconsole/netconsole-help nocol-4.2.1/netconsole/netconsole-help
--- nocol-4.2/netconsole/netconsole-help Tue Nov 29 15:41:08 1994
+++ nocol-4.2.1/netconsole/netconsole-help Thu Aug 13 11:27:08 1998
@@ -20,6 +20,9 @@
w - toggle Wide display mode
any key - for next screen
+You can set the initial display level by setting the NOCOL_SEVERITY
+shell environment variable to Info/Warn/Error/Critical.
+
The User Screen:
---------------
The screen is divided into two sections- the EVENT section and the MESSAGES
@@ -57,5 +60,6 @@
xterm for X window terminal emulator
Mail comments/suggestions to vikas@navya.com. Software is available via ftp
-from ftp.navya.com under pub/vikas/
+from ftp://ftp.navya.com/pub/ or
+ http://www.netplex-tech.com/software/nocol
diff -Nur nocol-4.2/netconsole/netconsole.c nocol-4.2.1/netconsole/netconsole.c
--- nocol-4.2/netconsole/netconsole.c Fri Jul 31 14:22:54 1998
+++ nocol-4.2.1/netconsole/netconsole.c Thu Aug 13 11:32:45 1998
@@ -1,5 +1,5 @@
/*+
- * $Header: /home/vikas/src/nocol/netconsole/RCS/netconsole.c,v 2.6 1998/07/31 18:22:48 vikas Exp $
+ * $Header: /home/vikas/src/nocol/netconsole/RCS/netconsole.c,v 2.7 1998/08/13 15:30:16 vikas Exp $
*/
/*
@@ -28,6 +28,9 @@
/*
* $Log: netconsole.c,v $
+ * Revision 2.7 1998/08/13 15:30:16 vikas
+ * Added environment variable NOCOL_SEVERITY checking (jonz@netrail.net)
+ *
* Revision 2.6 1998/07/31 18:22:48 vikas
* Added INTSIGNALS
*
@@ -66,7 +69,7 @@
*
*/
#ifndef lint
- static char rcsid[] = "$RCSfile: netconsole.c,v $ $Revision: 2.6 $ $Date: 1998/07/31 18:22:48 $" ;
+ static char rcsid[] = "$RCSfile: netconsole.c,v $ $Revision: 2.7 $ $Date: 1998/08/13 15:30:16 $" ;
#endif
/*+
@@ -85,10 +88,11 @@
int ac;
char **av;
{
- extern char *optarg;
+ extern char *optarg;
extern int optind;
register int i ; /* temporary counter */
void done(), wsizechange(); /* for signals */
+ char *envlevel;
#ifdef _NOCOLVERSION_
fprintf (stderr, "NOCOL version %s\n\n", nocol_version);
@@ -106,6 +110,22 @@
page = 1; /* init value */
level = E_CRITICAL; /* default severity */
+ /* allow environment variable to set the default display level */
+ if ( (envlevel = (char *)getenv("NOCOL_SEVERITY")) != NULL)
+ {
+ switch (*envlevel)
+ {
+ case 'C': case 'c':
+ level = E_CRITICAL ; break;
+ case 'E': case 'e':
+ level = E_ERROR; break;
+ case 'W': case 'w':
+ level = E_WARNING; break;
+ case 'I': case 'i':
+ level = E_INFO; break;
+ }
+ }
+
while ((i = getopt(ac, av, "dewl:qs")) != EOF)
switch (i)
{
@@ -184,7 +204,10 @@
fprintf (stderr, "\nUSAGE: %s %s\n\n", prognm, usage);
fprintf(stderr, "Data directory is: %s\n", datadir);
Fprintf("To verify terminal type, turn debug mode on and\n");
- Fprintf("then toggle between wide display mode (using w)\n\n");
+ Fprintf("then toggle between wide display mode (using w)\n");
+ Fprintf("You can set your shell environment variable NOCOL_SEVERITY \n");
+ Fprintf("to the initial desired level (Critical, Error, Warning, Info)\n");
+ Fprintf("\n");
return (0);
} /* end usage() */
diff -Nur nocol-4.2/netconsole/utils.c nocol-4.2.1/netconsole/utils.c
--- nocol-4.2/netconsole/utils.c Fri Jul 31 14:22:32 1998
+++ nocol-4.2.1/netconsole/utils.c Thu Aug 13 11:33:30 1998
@@ -1,5 +1,5 @@
/*
- * $Header: /home/vikas/src/nocol/netconsole/RCS/utils.c,v 1.9 1998/07/31 18:22:25 vikas Exp $
+ * $Header: /home/vikas/src/nocol/netconsole/RCS/utils.c,v 1.10 1998/08/13 15:32:56 vikas Exp $
*/
/*+
@@ -12,7 +12,7 @@
*/
#ifndef lint
- static char rcsid[] = "$RCSfile: utils.c,v $ $Revision: 1.9 $ $Date: 1998/07/31 18:22:25 $" ;
+ static char rcsid[] = "$RCSfile: utils.c,v $ $Revision: 1.10 $ $Date: 1998/08/13 15:32:56 $" ;
#endif
#include "netconsole.h"
@@ -58,51 +58,50 @@
if (strlen(prompt) > 70) /* long string */
putchar('\n');
- again:
- r = (char *)reply ;
- fgets(reply, MAXLINE, stdin); /* Use fgets() instead of gets() */
- reply[strlen(reply) - 1] = '\0'; /* strip terminating newline */
- if (*reply == '\0')
+ while (1)
{
+ r = (char *)reply ;
+ fgets(reply, MAXLINE, stdin); /* Use fgets() instead of gets() */
+ reply[strlen(reply) - 1] = '\0'; /* strip terminating newline */
+ if (*reply == '\0')
+ {
if ( nodefault )
{
printf("Invalid NULL response!! Enter again: ");
- goto again;
+ continue; /* back to while() loop */
}
else /* default has been supplied */
{
strncpy(reply, deflt, sizeof(reply) - 1) ;
- return (reply) ;
+ break;
}
- }
+ } /* if *reply */
- /*
- * Now check the user's response against the desired response_type
- */
-
- if (response_type == C_ANY)
- return (reply);
-
- invalid = 0;
- while (!invalid && *r)
- {
- register int ch_type = classify (*r++) ;
-
+ /*
+ * Now check the user's response against the desired response_type
+ */
+
+ if (response_type == C_ANY)
+ break;
+
+ for (invalid = 0; invalid == 0 && *r ; ++r)
+ {
+ register int ch_type = classify(*r) ;
if ( (response_type & ch_type) == 0)
{
- fprintf (stderr, "Invalid reply. ");
- if ( isprint(*(--r)) )
- fprintf(stderr, "(character '%c' illegal)\n", *r);
- fprintf(stderr, " Enter again: ");
- invalid = 1 ;
- break ;
+ fprintf (stderr, "Invalid reply. ");
+ if ( isprint(*(--r)) )
+ fprintf(stderr, "(character '%c' illegal)\n", *r);
+ fprintf(stderr, " Enter again: ");
+ invalid = 1 ;
}
- } /* end while */
+ } /* end while */
- if (invalid)
- goto again;
- else
- return (reply);
+ if (! invalid)
+ break;
+ } /* while(1) */
+
+ return (reply);
} /* end get_reply */
@@ -133,27 +132,27 @@
/* */
/*+ setuserenviron
-** FUNCTION
-**
-** This function attempts to set the environment variables
-** relevant to the program (like TERM). It modifies the structure
-** 'environ' which is a pointer to the strings containing the
-** variables. If an essential environment variable is not set, then
-** it sets the variable by prompting or by a default value.
-**
-** 'putenv' requires that the storage for the variable be static.
-**
-** Lastly gets the value of the termcap variable to enable 'bold'
-** on the terminals. 'md' = bold, 'mh' = half-intensity, 'me' = end all
-**
-**/
+ * FUNCTION
+ *
+ * This function attempts to get the environment variables
+ * relevant to the program (like TERM). It modifies the structure
+ * 'environ' which is a pointer to the strings containing the
+ * variables. If an essential environment variable is not set, then
+ * it sets the variable by prompting or by a default value.
+ *
+ * 'putenv' requires that the storage for the variable be static.
+ *
+ * Lastly gets the value of the termcap variable to enable 'bold'
+ * on the terminals. 'md' = bold, 'mh' = half-intensity, 'me' = end all
+ *
+ */
setuserenviron ()
{
char termtype[MAXLINE], bp[1024] ; /* needed by tgetent */
char *get_reply() ;
static char newvar[MAXLINE]; /* has to be static */
-
+
bzero(termtype, sizeof (termtype)) ;
strcpy (termtype, (char *)getenv("TERM")); /* retrieve TERM type */
diff -Nur nocol-4.2/nsmon/Makefile.mid nocol-4.2.1/nsmon/Makefile.mid
--- nocol-4.2/nsmon/Makefile.mid Fri Feb 14 09:48:07 1997
+++ nocol-4.2.1/nsmon/Makefile.mid Thu Aug 27 23:21:56 1998
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.8 1994/05/16 02:03:00 vikas Exp $
+# $Id: Makefile.mid,v 1.1 1998/08/28 03:21:52 vikas Exp $
#
# Makefile for 'nsmon'
#
diff -Nur nocol-4.2/nsmon/main.c nocol-4.2.1/nsmon/main.c
--- nocol-4.2/nsmon/main.c Fri Jul 31 14:24:01 1998
+++ nocol-4.2.1/nsmon/main.c Thu Aug 27 23:21:12 1998
@@ -1,5 +1,5 @@
/*
- * $Header: /home/vikas/src/nocol/nsmon/RCS/main.c,v 1.12 1998/07/31 18:23:27 vikas Exp $
+ * $Header: /home/vikas/src/nocol/nsmon/RCS/main.c,v 1.13 1998/08/28 03:20:41 vikas Exp $
*/
/*
@@ -20,6 +20,10 @@
/*
* $Log: main.c,v $
+ * Revision 1.13 1998/08/28 03:20:41 vikas
+ * Back to displaying the site name instead of the domain name in the
+ * 'sitename' field (more flexible)
+ *
* Revision 1.12 1998/07/31 18:23:27 vikas
* Now handles multiple domains.
* Displays the domain being queried instead of the 'sitename'
@@ -69,7 +73,7 @@
/* */
#ifndef lint
- static char rcsid[] = "$RCSfile: main.c,v $ $Revision: 1.12 $ $Date: 1998/07/31 18:23:27 $" ;
+ static char rcsid[] = "$RCSfile: main.c,v $ $Revision: 1.13 $ $Date: 1998/08/28 03:20:41 $" ;
#endif
#include "nocol.h" /* common structures */
@@ -339,11 +343,14 @@
continue ;
}
- /* These are pairs, ignore the sitename, display
- * the domain being queried instead.
+ /* These are pairs. Some people might want to
+ * display the domain name instead of the site name...
*/
+#ifdef DISPLAY_DOMAIN
strncpy(v.site.name, querydata, sizeof(v.site.name) - 1);
-/* strncpy(v.site.name, w1, sizeof(v.site.name) - 1); /* */
+#else
+ strncpy(v.site.name, w1, sizeof(v.site.name) - 1); /* */
+#endif
strncpy(v.site.addr, w2, sizeof(v.site.addr) - 1); /* no checks */
if (inet_addr(w2) == -1) /* bad address */
diff -Nur nocol-4.2/ntpmon/ntpmon.c nocol-4.2.1/ntpmon/ntpmon.c
--- nocol-4.2/ntpmon/ntpmon.c Tue Jun 30 16:25:59 1998
+++ nocol-4.2.1/ntpmon/ntpmon.c Thu Aug 13 07:42:06 1998
@@ -1,4 +1,4 @@
-/* $Revision: 1.1 $ */
+/* $Revision: 1.2 $ */
/*+ ntpmon.c
*
@@ -15,6 +15,9 @@
/*
* $Log: ntpmon.c,v $
+ * Revision 1.2 1998/08/13 11:41:51 vikas
+ * Changed goto into a while() loop.
+ *
* Revision 1.1 1998/06/30 20:25:10 vikas
* Initial revision
*
@@ -129,40 +132,41 @@
* we loop until timeout to make sure that we dont get back an old
* response. This is verified by the sequence number we sent...
*/
-again:
- FD_ZERO(&fdvar);
- FD_SET(sockfd, &fdvar);
- if ((n = select(sockfd+1, &fdvar, NULL, NULL, &tval)) <= 0)
+ while (1)
{
- if (n < 0 && errno != EINTR)
+ FD_ZERO(&fdvar);
+ FD_SET(sockfd, &fdvar);
+ if ((n = select(sockfd+1, &fdvar, NULL, NULL, &tval)) <= 0)
{
- perror("select() ");
- return (-1);
+ if (n < 0 && errno != EINTR)
+ {
+ perror("select() ");
+ return (-1);
+ }
+ else
+ {
+ if (debug > 2) fprintf(stderr, "select() timed out\n");
+ return (-1);
+ }
}
- else
+ /* we dont do an FD_ISSET() since only one fd was set... */
+ if ( (n = read(sockfd, &rpkt, sizeof(rpkt)) ) <= 0 )
{
- if (debug > 2) fprintf(stderr, "select() timed out\n");
- return (-1);
+ perror("read");
+ return -1;
}
- }
- /* we dont do an FD_ISSET() since only one fd was set... */
- if ( (n = read(sockfd, &rpkt, sizeof(rpkt)) ) <= 0 )
- {
- perror("read");
- return -1;
- }
- /*
- * Check opcode and sequence number for a match.
- * Could be old data getting to us.
- */
- if (ntohs(rpkt.sequence) != sequence)
- {
+ /*
+ * Check opcode and sequence number for a match.
+ * Could be old data getting to us.
+ */
+ if (ntohs(rpkt.sequence) == sequence)
+ break; /* out of while */
+
if (debug > 2)
fprintf(stderr,"ntpmon: Received sequence number %d, wanted %d\n",
ntohs(rpkt.sequence), sequence);
- goto again;
- }
+ } /* while(1) */
/*
* Check the error code. If non-zero, return it.
@@ -182,19 +186,18 @@
if (debug > 3)
{
- /* write(2, rpkt.data, ntohs(rpkt.count)); /* dump pkt to stderr */
+ /* write(2, rpkt.data, ntohs(rpkt.count)); /* dump pkt to stderr */
}
/*
- * Looking for the string : * "stratum=nn"
- */
+ * Looking for the string : * "stratum=nn"
+ */
if ( (loc = (char *)strstr(rpkt.data, "stratum=")) == NULL )
return (-1);
sscanf(loc + strlen("stratum="), "%d", &stratum); /* */
/* *(loc + 10) = '\0'; /* End string after "stratum=nn" */
/* stratum = atoi(loc + strlen("stratum=")); /* */
-
return stratum;
} /* get_response() */
diff -Nur nocol-4.2/perlnocol/Makefile.mid nocol-4.2.1/perlnocol/Makefile.mid
--- nocol-4.2/perlnocol/Makefile.mid Fri Jul 31 14:43:06 1998
+++ nocol-4.2.1/perlnocol/Makefile.mid Thu Aug 27 23:44:02 1998
@@ -1,4 +1,4 @@
-# $Id: Makefile.mid,v 1.2 1998/07/31 18:43:06 vikas Exp $
+# $Id: Makefile.mid,v 1.6 1998/08/28 03:43:51 vikas Exp $
#
# Need the locations of ROOTDIR, LOGHOST, PERL & PING
@@ -17,7 +17,7 @@
#
PROGS = apcmon armon bgpmon bpmon ciscomon modemmon novellmon nrmon \
nocollib.pl hostmon hostmon-osclients/hostmon-client \
- snmpmon snmpmon-client syslogmon rcisco
+ snmpmon snmpmon-client syslogmon rcisco testlog
all: snmpwalk
@echo "PERLNOCOL modules"
@@ -25,11 +25,11 @@
@for f in $(PROGS) ; do \
if [ -f $$f ]; then \
echo " $$f" | tr -d '\012' ;\
- sed -e '1s@^#!/usr/local/bin/perl@#!$(PERL)@' \
- -e 's@^\($$nocolroot\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)@\1 "$(ROOTDIR)" \3@' \
- -e 's@^\($$piddir\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)@\1 "$(PIDDIR)" \3@' \
- -e 's@^\($$NLOG_HOST\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)@\1 "$(LOGHOST)" \3@' \
- -e 's@^\($$ping\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)@\1 "$(PING)" \3@' \
+ sed -e '1s|^#!/.*/perl|#!$(PERL)|' \
+ -e 's#^\($$nocolroot\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)#\1 "$(ROOTDIR)" \3#' \
+ -e 's#^\($$piddir\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)#\1 "$(PIDDIR)" \3#' \
+ -e 's#^\($$NLOG_HOST\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)#\1 "$(LOGHOST)" \3#' \
+ -e 's#^\($$ping\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)#\1 "$(PING)" \3#' \
$$f >$$f.seds ;\
fi ;\
done ;\
@@ -49,9 +49,9 @@
$(INSTALL) -c -m 755 $$f $(BINDIR)/hostmon-osclients/ ;\
done
-@for f in $(PROGS) ; do \
- $(INSTALL) -c -m 751 $$f.seds $(BINDIR)/$$f ;\
+ $(INSTALL) -c -m 755 $$f.seds $(BINDIR)/$$f ;\
done
- @$(INSTALL) -c -m 751 $(CMUSNMP)/apps/snmpwalk $(BINDIR)/
+ @$(INSTALL) -c -m 755 $(CMUSNMP)/apps/snmpwalk $(BINDIR)/
@$(INSTALL) -c -m 444 $(CMUSNMP)/mibII.txt $(ETCDIR)/
@echo "See $(SRCDIR)/perlnocol/README for further customizations"
diff -Nur nocol-4.2/perlnocol/bgpmon nocol-4.2.1/perlnocol/bgpmon
--- nocol-4.2/perlnocol/bgpmon Tue Nov 29 15:49:17 1994
+++ nocol-4.2.1/perlnocol/bgpmon Mon Aug 17 14:03:11 1998
@@ -1,117 +1,362 @@
-#!/usr/local/bin/perl
+#!/usr/local/bin/perl
#
-# $Header: /home/vikas/netmgt/nocol/src/perlnocol/RCS/bgpmon,v 1.3 1994/11/29 20:48:57 vikas Exp $
+# $Header: /home/vikas/src/nocol/perlnocol/RCS/bgpmon,v 2.1 1998/08/17 18:02:44 vikas Exp $
#
-# bgpmon - perl monitor for BGP processes on cisco's
+# bgpmon - perl monitor for BGP processes
#
-# Runs the command 'show ip bgp summary' on cisco routers and parses
-# the output to see if any peer is 'Idle/Active/Down' state (i.e. not
-# connected). If so, it marks the event as down. (NOTE: cisco router's
-# indicate the time that a BGP peer has been active, so its easy to
-# tell if a peer is not connected).
+# logs into a router and grabs/parses a bgp summary, then displays
+# all down peers. compatible with most routers based on logic given in
+# bgpmon-confg. sample configuration includes CISCO and ASCEND_GRF object
+# definitions.
#
-# Part of the NOCOL monitoring package.
+# i've written my own nocol_main routine primarily because nocollib.pl's
+# main routine doesn't support the flexibility this program will need to
+# report the several different variable types, or handle the long
+# configuration. i still do, however, use nocollib.pl's startup and event
+# handling routines so that this will be compatible with future versions of
+# NOCOL should nocollib.pl change.
#
-# Author: Vikas Aggarwal, vikas@navya.com
+# Author: Jonathan A. Zdziarski, jonz@netrail.net
#
-# Copyright 1994 Vikas Aggarwal, vikas@navya.com
+# Copyright 1998 Jonathan A. Zdziarski, jonz@netrail.net
#
-##
-##
+# This software is distributed as part of the NOCOL/SNIPS package.
#
+# FEATURES:
+# - works with ascend, bay and cisco routers
+# - ability to add your own router logic for different kinds of routers
+# - ability to have different passwords for each router
+# - line-by-line peer configuration, or...
+# - one-step router configuration (supply the router, and bgpmon will
+# grab all the peers off of it, name them, and enter them
+# as individual events in nocol)
+# - router-down assumption (peers are down/unchanged if a router is
+# unreachable)
+# - one-step router updating (if a router was down when bgpmon started,
+# it will attempt to reach the router later and add peers)
+# - different severity settings defined by as number
#
-############################
-## Variables customization # overrides values in the nocollib.pl library
-############################
-$rprog="rcisco"; # Path for rcisco.
-$rpasswd=""; # if NULL, uses the default in rcisco
-$rcommand="show ip bgp summary";
-$varname="BGPpeerDown";
-$varunits="State" ; # the var.units field in EVENT struct
-$sleepint=60*10; # Seconds to sleep between tries.
-############################
-$debug = 0; # set to 1 for debugging output
-$libdebug = 0; # set to 1 for debugging output
-$maxseverity = $E_CRITICAL ;
-$prognm = $0; # save program name
-
-require "nocollib.pl" ;
-
--x $rprog || die("Could not find executable $rprog, exiting");
-
-##
-# Read the config file. Use '\t' as a separator for 'item'
+# CONFIGURATION:
+#
+# - If you specify ASNUM:NAME as the name of a single peer,
+# ASNUM will define the as number of that peer, rather than a bgp
+# summary. This is useful to retain proper severity levels in the
+# event that bgpmon is never able to assertain the as number from
+# a bgp summary (e.g. the router is down when bgpmon is started)
+# - Did a sprintf("%6d", ASN) on all ASN's (internally) to prevent
+# router/config differences
+#
+#
+# STRUCTURES USED:
+# @items = peer \t rtr \t peerip
+# @routers = rtr
+# $router{$name} = type addr passwrd user
+# $object{$type} = port \t commands
+# $comp{$type} = array \t up \t down
+#
+#####
+$nocolroot = '/nocol'; # SET_THIS
+push(@INC, "$nocolroot/bin");
+
+require 5.000;
+require "nocollib.pl";
+
+# bgpmon variables
+$POLLINTERVAL=60*5; # 5 minute polling interval
+$UPDATEINTERVAL=60*120; # Update router peers ever 2 hours
+$severity{'DEFAULT'} = $E_ERROR; # Default severity
+$ASSUME = 0; # Assume all peers down if router is
+ # unreachable
+$DEBUG = 0;
+
+# nocollib.pl variables
+$debug = $DEBUG;
+$libdebug = 0;
+$varunits = "State";
+
+$|=1; # unbuffered stdout
+
+# subroutine: readconf
+# purpose: reads in the master configuration/parses
+# call this only after nocol_startup
sub readconf {
- open(CONFIG,"<$cfile")||die("Couldn't find $cfile, exiting");
- while()
- {
- chop;
- if(/^\s*#/) {next;} # skip comments
- if(/^\s*$/) {next;} # skip blank lines
- if (/\s*(\S+)\s+(\S+)\s*$/)
- {
- $item="$1\t$2" ; # the name and address
- push(@items,$item);
- }
- else {print "Ignoring illegal line: $_\n";}
-
- } # end while(CONFIG)
-
- close(CONFIG);
- if(0>$#items){die("Nothing to monitor in $cfile, exiting")};
- if ($debug) {
- print "Items are:\n"; foreach (@items) { print "\t$_\n" } ;
- }
-} # end: readconf
-
-## Check state of each router
-#
-sub dotest {
- local ($host, $router) = @_ ;
- local ($peer, $state, $peersdown);
- local ($loginok) = 0;
-
- if ($debug) { print "Checking $router\n"; }
- $command="$rprog $router ".' "'."$rpasswd".'" '.'"'."$rcommand".'"';
- if ($debug) {print "(debug) dotest: running command $command\n" ;}
-
- open (ROUTER, "$command |") ;
-
- while() {
- tr/\r\n//d;
- if ( />/ ) {$loginok = 1 ;} # got the 'Router>' prompt
- if ( /^\s*(\d+\.\d+.\d+.\d+).*\s+(\S+)\s*$/ )
- {
-# if ($debug) {print "(debug) processing line: $_\n" ;}
- $peer = $1;
- $state = $2;
- if ($debug) { print "(debug): Peer= $peer, State= $state\n"; }
- if ( $2 =~ /Active|Idle|Down/ ) { ++$peersdown ;}
- }
- elsif ($debug) {
-# print "(debug) skipping line: $_\n" ;
- }
- } # end while
- close (ROUTER);
-
- if ($loginok == 0) {
- print "Login into remote host $router failed\n" ;
- return(-1, 0); # (status, value)
- }
- if ($debug) {print "Peers Down= $peersdown\n" ;}
-
- if ($peersdown) {return (0, $peersdown) ;} # not caring about timeouts
- else { return(1, $peersdown) ;} # no peer is down, status=1
-
-} # end: dotest()
-
-
-
-###
-### main
-###
+ open(CONFIG,"<$cfile") || die("$0: $cfile: $!");
+ while() {
+ chomp;
+ s/\t+/ /g; # replace tabs with spaces
+ s/^\s*(.*?)\s*$/$1/; # trim whitespace
+ next if (/^#/);
+ next if (/^$/);
+
+ my($definition, $parms) = split(/\s+/, $_, 2);
+
+ if ($definition =~ /^object$/i) { # commands to get/parse bgp summary
+ my($name, $port, $array, $up, $commands) = split(/\s+/, $parms, 5);
+ $object{$name} = "$port\t$commands";
+ $comp{$name} = "$array\t$up";
+ $DEBUG && print "$0: new object ($name) = $port, $commands\n";
+ }
+ elsif ($definition =~ /^router_def$/i) { # router name, type, addr, pass
+ my($name, $type, $address, $pass, $user) = split(/\s+/, $parms);
+ $router{$name} = "$type\t$address\t$pass\t$user";
+ $DEBUG && print "$0: new router ($name) is a $type ($address)\n";
+
+ }
+ elsif ($definition =~ /^router$/i) { # monitor all peers on this router
+ push(@routers, join("\t", split(/\s+/, $parms)));
+ }
+ elsif ($definition =~ /^severity$/i) { # set severity level for this as
+ my($as, $severity) = split(/\s+/, $parms);
+ if ($as>0) { $as=sprintf("%6d", $as); $as =~ s/ /0/g; }
+ $DEBUG && print "$0: added severity for as$as - $severity\n";
+ $severity{$as}=$$severity;
+ }
+ elsif ($definition =~ /^peer$/i) { # monitor this peer on the router
+ my($router, $name, $ip) = split(/\s+/, $parms);
+ push(@items, "$name\t$router\t$ip");
+ }
+ elsif ($definition =~ /^assume$/i) { # down or prev status if unreachable
+ my($stat) = split(/\s+/, $parms);
+ if ($stat =~ /^unchanged$/i) { $ASSUME = 1; }
+ elsif ($stat =~ /^down$/i) { $ASSUME = 0; }
+ else { die "$0: unknown status: $stat\n"; }
+ }
+ elsif ($definition =~ /^pollinterval$/i) {
+ ($POLLINTERVAL) = split(/\s+/, $parms);
+ }
+ else { print STDERR "$0: unknown definition: $definition (skipping)\n"; }
+ }
+ close(CONFIG);
+ die "$0: nothing to monitor in $cfile; exiting.\n"
+ if ((0>$#items) && (0>$#routers));
+}
+
+# MAIN ROUTINE
+&nocol_startup; # nocollib.pl initialization
+&readconf; # read in configuration
+&initializepeers; # init all single peers
+&updatepeers; # grab all peers from routers specified
+
+while(1) { # till death do us part
+ my($stime, $deltatime, $updatetime);
+ $stime = time;
+ $updatetime = time unless ($updatetime > 0);
+
+ foreach $router (keys(%router)) {
+ my($router_type, $router_ip, $router_pass, $router_user) =
+ split(/\t/, $router{$router});
+ my($router_port, $router_cmds) = split(/\t/, $object{$router_type});
+ die "$0: no object definition '$router_type'\n"
+ unless ($object{$router_type});
+ die "$0: no comprehension for '$router_type'\n"
+ unless ($comp{$router_type} ne "");
+
+ $router_cmds =~ s/\%PASS(WORD)?\%/$router_pass/gi;
+ $router_cmds =~ s/\%USER(NAME)?\%/$router_user/gi;
+ my(@buffer) = &getbgpsumm($router_ip, $router_port,
+ split(/\:/, $router_cmds));
+
+ # if we get an error (host unreachable, etc), set all peers on that
+ # router down if the assumption is to do so
+ if ($BUFFER[0] eq "*ERROR*") {
+ print STDERR "$0: $ip: $BUFFER[1]\n";
+ next if ($ASSUME == 1);
+ foreach $myitem (@items) {
+ my($item_name, $item_router, $item_ip) = split(/\t/, $myitem);
+ next unless ($item_router eq $router);
+ my($asref) = $ascache{$item_ip};
+ $varname = "BGP/$item_router";
+ $severity = $severity{'DEFAULT'};
+ $severity = $severity{$asref}
+ if (($severity{$asref} ne "") && ($asref));
+ $severity{"$item_router\t$item_ip"} = $severity;
+ &update_event("$item_router\t$item_ip", 0, 0, $severity);
+ $DEBUG && print "$0: update_event: $item_router:$item_ip, 0, 0, " .
+ "$severity\n";
+ }
+ }
-&nocol_main ;
+ foreach $item (@items) {
+ my($item_name, $item_router, $item_ip) = split(/\t/, $item);
+ next unless ($item_router eq $router);
+
+ my($arrayref, $up) = split(/\t/, $comp{$router_type});
+ my($num_status, $num_ip, $num_as) = split(/\,/, $arrayref);
+
+ foreach $buffer (@buffer) {
+ chomp;
+ $buffer =~ s/^\s+//g;
+ $buffer =~ s/\t+/ /g;
+ $buffer =~ s/\s+/ /g;
+ my(@fields) = split(/ /, $buffer);
+ my($status) = $fields[$num_status];
+ my($ipref) = $fields[$num_ip];
+ my($asref) = sprintf("%6d", $fields[$num_as]);
+ $asref =~ s/ /0/g;
+ $ascache{$ipref} = $asref;
+ if ($ipref =~ /(\d+\.\d+\.\d+\.\d+)/) { $ipref = $1; } else { next; }
+ $DEBUG && print "$0: status of $ipref: $status\n";
+ my($peerstatus) = 0; my($value) = 0;
+ foreach(split(/\,/, $up)) { if ($status =~ /^$_$/i) { $value = 10; $peerstatus = 1; } }
+
+ $varname = "BGP/$item_router";
+ $severity = $severity{'DEFAULT'};
+ $severity = $severity{$asref} if (($severity{$asref} ne "") && ($asref));
+ &update_event("$item_router\t$ipref", $peerstatus, $value, $severity);
+ $DEBUG && print "$0: update_event: $item_router:$ipref, $peerstatus, $value, $severity ($asref)\n";
+ } # foreach $buffer (@buffer)
+ } # foreach $item (@items)
+ } # foreach $router (keys %router)
+
+
+ $DEBUG && print "$0: opening $datafile for writing\n";
+ open(OEVENTS,">$datafile") || die "$0: $datafile: $!\n";
+ foreach $item (@items) {
+ my($item_name, $item_router, $item_ip) = split(/\t/, $item);
+ if(!$forget{"$item_router\t$item_ip"}) {
+ &writeevent(OEVENTS, "$item_router\t$item_ip");
+ }
+ }
+ close(OEVENTS);
+ $deltatime = time - $updatetime;
+ if ($UPDATEINTERVAL < $deltatime) {
+ &updatepeers;
+ $updatetime = time;
+ }
+
+ $deltatime = time - $stime;
+ if ($POLLINTERVAL > $deltatime) { sleep($POLLINTERVAL - $deltatime); }
+} # while(1)
+
+
+# subroutine: getbgpsumm
+# purpose: retrieves a bgp summary from a router
+# syntax: &getbgpsumm [hostname] [port] [commands]
+#
+# NOTE: make sure the commands end with an 'exit' command to close the socket
+sub getbgpsumm {
+ my($HOST, $PORT, @COMMANDS) = @_;
+ my(@buffer);
+
+ $debug && print "$0: connecting to $HOST:$PORT\n";
+
+ local ($sock) = &newSocket($HOST, $PORT, 'tcp');
+ return ("*ERROR*", "newSocket: $!") if ($sock < 0);
+ select($sock); $| = 1; select(STDOUT);
+ foreach(@COMMANDS) { $debug && print "$0: sending command: $_\n";
+ print $sock "$_\r\n"; sleep 2; }
+ while(<$sock>) { push(@buffer, $_); }
+ $debug && print "$0: socket closed, $#buffer lines captured.\n";
+ close($sock);
+
+ @buffer;
+} # sub getbgpsumm()
+
+# subroutine: updatepeers
+# purpose: runs through all router objects, and grabs/adds peers to
+# the individual peer list. this is run every so
+# often within the program, incase a router was down when
+# bgpmon was started, so that it is added when it goes up.
+sub updatepeers {
+ foreach $router (@routers) {
+ my($name) = split(/\t/, $router);
+ my($object, $ip, $pass, $user) = split(/\t/, $router{$name});
+ my($buffer);
+ die "$0: unknown router definition: $name\n" unless ($router{$name} ne "");
+ die "$0: unknown object: $object\n" unless ($object{$object} ne "");
+ die "$0: no comprehension for $object\n" unless ($comp{$object} ne "");
+ my($PORT, $COMMAND) = split(/\t/, $object{$object});
+ $COMMAND =~ s/\%PASS(WORD)?\%/$pass/gi;
+ $COMMAND =~ s/\%USER(NAME)?\%/$user/gi;
+ my(@COMMANDS) = split(/\:/, $COMMAND);
+ my(@BUFFER) = &getbgpsumm($ip, $PORT, @COMMANDS);
+ if ($BUFFER[0] eq "*ERROR*") {
+ print STDERR "$0: $ip: $BUFFER[1]\n";
+ next;
+ }
+ my($arrayref, $up) = split(/\t/, $comp{$object});
+ my($num_status, $num_ip, $num_as) = split(/\,/, $arrayref);
+ foreach $buffer (@BUFFER) {
+ chomp;
+ $buffer =~ s/^\s+//g;
+ $buffer =~ s/\t+/ /g;
+ $buffer =~ s/\s+/ /g;
+ my(@fields) = split(/ /, $buffer);
+ $status = $fields[$num_status];
+ $ipref = $fields[$num_ip];
+ $asref = sprintf("%6d", $fields[$num_as]);
+ $asref =~ s/ /0/g;
+ if ($ipref =~ /(\d+\.\d+\.\d+\.\d+)/) { $ipref = $1; } else { next; }
+ $ascache{$ipref} = $asref;
+ my($exists) = 0;
+ foreach $existing_item (@items) {
+ my($existing_name, $existing_routername, $existing_peerip) =
+ split(/\t/, $existing_item);
+ if (($existing_routername eq $name) && ($existing_peerip eq $ipref) && ($existing_routername ne "") && ($existing_peerip ne "")) {
+ $exists = 1;
+ $DEBUG && print "$0: item already exists: $existing_routername:" .
+ "$existing_peerip\n";
+ }
+ } # foreach $existing_item
+ if ($exists != 1) {
+ push(@items, "-\t$name\t$ipref");
+ $DEBUG && print "$0: adding $ipref/$name to items list\n";
+ my($peerhostname);
+ if ($hostcache{$ipref} eq "") {
+ $peerhostname = gethostbyaddr(pack('C4', split(/\./, $ipref)), 2);
+ if ($peerhostname ne "") {
+ my(@fields)=split(/\./, $peerhostname); pop(@fields); pop(@fields);
+ $peerhostname=join(".", @fields);
+ }
+ else { $peerhostname = $ipref; }
+ $hostcache{$ipref}=$peerhostname;
+ } else { $peerhostname = $hostcache{$ipref}; }
+ $varname = "BGP/$name";
+ $severity = $severity{'DEFAULT'};
+ $severity = $severity{$asref} if ($severity{$asref} ne "");
+ $DEBUG && print "$0: initializing: $name:$ipref ($asref) " .
+ "$peerhostname $varname ($severity)\n";
+ $asref =~ s/^0+//;
+ &init_event("$asref:$peerhostname", $ipref, "$name\t$ipref");
+ } # if ($exists)
+ } # foreach $buffer (@BUFFERS)
+ } # foreach $name (@routers)
+} # sub updatepeers()
+
+
+# subroutine: initializepeers
+# purpose: initializes all peers defined in config
+sub initializepeers {
+ foreach $item (@items) {
+ my($item_name, $rname, $item_ip) = split(/\t/, $item);
+ die "$0: unknown router definition: $rname\n" unless ($router{$rname} ne "");
+ $DEBUG && print "$0: $item_name, $rname, $item_ip\n";
+
+ if (($item_name =~ /^\d+\:/) && ($ascache{$item_ip} eq "")) {
+ my($x) = (split(/\:/, $item_name))[0];
+ $x = sprintf("%6d", $x);
+ $x =~ s/ /0/g;
+ $ascache{$item_ip} = $x;
+ $DEBUG && print "$0: setting as$x\n";
+ }
+
+ my($peerhostname);
+ if ($hostcache{$item_ip} eq "") {
+ $peerhostname = gethostbyaddr(pack('C4', split(/\./, $item_ip)), 2);
+ if ($peerhostname ne "") {
+ my(@fields)=split(/\./, $peerhostname); pop(@fields); pop(@fields);
+ $peerhostname=join(".", @fields);
+ }
+ else { $peerhostname = $item_ip; }
+ $hostcache{$ipref}=$peerhostname;
+ }
+ else { $peerhostname = $hostcache{$item_ip}; }
+ $peerhostname = $item_name if ($item_name ne "-");
+ $varname = "BGP/$rname";
+ $DEBUG && print "$0: initializing: $peerhostname $varname ($rname:$item_ip)\n";
+ &init_event($peerhostname, $item_ip, "$rname\t$item_ip");
+ } # foreach $item
+} # sub initializepeers()
diff -Nur nocol-4.2/perlnocol/bgpmon-confg nocol-4.2.1/perlnocol/bgpmon-confg
--- nocol-4.2/perlnocol/bgpmon-confg Sat Oct 30 00:00:53 1993
+++ nocol-4.2.1/perlnocol/bgpmon-confg Fri Aug 14 13:17:18 1998
@@ -1,12 +1,66 @@
-## Config for BGP monitor
+# bgpmon-confg - bgpmon master configuration
#
+## Use this file with bgpmon v2.0 and above.
#
+###
+# - You define router types (objects).
+# - Then, for each of your router, specify its type and login password.
+# - Finally, define which routers you want to monitor and optionally, the
+# peers and max severity based on the AS number.
+###
#
-## Name Address/DNS name
-##
-nomad nomad-gateway
-fenchurch fenchurch-gateway
-trillian trillian-gateway
-goldengate goldengate-gateway
-unclesam unclesam-gateway
+# Set a different polling interval - default 5 mins
+pollinterval 300
+
+## THIS SECTION DOES NOT REQUIRE EDITING NORMALLY
+# OBJECT DEFINITIONS - how to obtain and parse the bgp summary
#
+# IMPORTANT NOTE: the version numbers linked with each object are the
+# versions of firmware that the configuration was
+# tested with. It could very well work with other (especially
+# newer) versions of the firmware, and possibly older versions
+# as well. YOU DO NOT NEED TO ADD A NEW CONFIGURATION FOR YOUR
+# FIRMWARE REVISION UNLESS NONE OF THE EXISTING ONES WORK.
+#
+# TYPE PORT ARYREF UPVAL COMMAND SEQUENCE
+object ASCEND_GRF_1.3.8 616 8,1,3 Established %PASS%:sho bgp sum:exit
+object ASCEND_GRF_1.3.11 616 10,1,3 Established %PASS%:sho bgp sum:exit
+object ASCEND_GRF_1.4.6 616 10,0,2 Established %PASS%:sho bgp sum:exit
+object CISCO_11.x 23 9,0,2 \d+ %PASS%:sh ip bgp sum:exit
+object BAY_1.27 23 4,0,2 Estab %USER%:%PASS%:sho bgp peer:exit
+
+### EDIT THIS FOLLOWING SECTIONS ###
+
+## ROUTER DEFINITIONS - used in conjunction with peer/router statements
+#
+# NAME TYPE IP ADDRESS PASS USER (opt)
+router_def sfo-rtr ASCEND_GRF_1.3.8 205.215.xx.xx password
+router_def pdl-bay BAY_1.27 205.215.xx.xx password netadmin
+router_def bos-gw CISCO_11.x 205.215.xx.xx password
+
+## ROUTERS TO MONITOR - will monitor all bgp peers/sessions on a router
+#
+# NAME
+router sfo-rtr
+router pdl-bay
+
+## SINGLE PEERS TO MONITOR - will monitor only this peer on a router
+# NOTE: you can put a - for the peer name if you wish the name to be
+# determined by DNS.
+#
+# ROUTER NAME PEER NAME PEER IP
+peer bos-gw - 198.32.xx.xx
+peer bos-gw mae-east 198.32.xx.xx
+
+## SEVERITY - defines severity levels based on AS number
+severity DEFAULT E_ERROR
+severity 4006 E_CRITICAL # Netrail (very important)
+severity 3491 E_WARNING # CAIS (so used to seeing it in alarm)
+
+## Assume all peers on a router are unchanged from their last known status in
+# the event that a router cannot be reached. If you wish to assume that all
+# peers would be down in this event, use 'down' as an assumption
+# assume
+ASSUME unchanged
+
+# EOF
diff -Nur nocol-4.2/perlnocol/hostmon nocol-4.2.1/perlnocol/hostmon
--- nocol-4.2/perlnocol/hostmon Fri Jul 31 14:48:06 1998
+++ nocol-4.2.1/perlnocol/hostmon Wed Aug 19 21:59:01 1998
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#
-# $Header: /home/vikas/src/nocol/perlnocol/RCS/hostmon,v 1.7 1998/07/31 18:47:50 vikas Exp $
+# $Header: /home/vikas/src/nocol/perlnocol/RCS/hostmon,v 1.9 1998/08/20 01:58:46 vikas Exp $
#
# Server module for 'hostmon' - monitoring Unix host conditions using NOCOL.
# Connects/gets data from the hostmon-client programs (via telnet or rcp)
@@ -54,7 +54,6 @@
# %curvar{$host} => var's current status, value, thres, maxseverity,
# address, unit
# %prevdatatime{$host} => time of previous data per host
-# %prevuptime{$host} => uptime
# %vardatalines => number of lines per variable read in current hosts data
# Used to extract the worst data value (most critical).
# %isknownvar{$var} => quick boolean to see if variable is known.
@@ -106,6 +105,7 @@
#########################################
-d $TMPDATADIR || mkdir($TMPDATADIR, 0700) || die("Cannot create $TMPDATADIR");
+-w $TMPDATADIR || die("Cannot write to $TMPDATADIR");
-x $rpcping || die("Cannot find $rpcping") ;
-x $ping || die("Cannot find $ping");
@@ -213,7 +213,7 @@
# here if reading a variable line:
# VAR host-regex wthres ethres cthres [reg exp]
# Permit negative integers for 2nd/3rd vals for always failing...
- if ( /^(\S+)\s+(\S+)\s+(\d+)\s+(-?\d+)\s+(-?\d+)\s*(.*)\s*$/ )
+ if ( /^(\S+)\s+(\S+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*(.*)\s*$/ )
{
local ($re) = $2 ; # temp variable
if ($2 eq '*' || $2 eq '+') { $re = '.+' } ; # convert '*' => '.+'
@@ -274,7 +274,7 @@
# zero out the count of datalines for each variable
foreach (keys %thresindex) { $vardatalines{$_} = 0; }
- open (DFILE, $hdfile);
+ open (DFILE, "< $hdfile");
while ()
{
chop ; # This is the *dataline*
@@ -320,7 +320,7 @@
# Note the use of the 'g' operator in splitting out the indexes.
# $debug && print STDERR "(dbg)thresindex{$dvname}= $thresindex{$dvname}\n";
- foreach ( $thresindex{$dvname} =~ /(\d+):?\s*/g )
+ foreach ( $thresindex{$dvname} =~ /(-?\d+):?\s*/g )
{
local ($i) = $_ ; # grab the index into the array
local ($junk, $host_regex, $t1,$t2,$t3, $regex) =
@@ -487,7 +487,7 @@
alarm(15); # 15 second timeout
$rsock = &newSocket($host, $hostmon_port, 'tcp');
if ($rsock != -1) {
- open (HDFILE, "> $hdfile") ;
+ open (HDFILE, "> $hdfile") || die "Cannot write to $hdfile";
select( (select($rsock), $| = 1)[0] ); # set socket unbuffered
while (<$rsock>)
{
diff -Nur nocol-4.2/perlnocol/hostmon-confg nocol-4.2.1/perlnocol/hostmon-confg
--- nocol-4.2/perlnocol/hostmon-confg Sun Apr 13 04:05:50 1997
+++ nocol-4.2.1/perlnocol/hostmon-confg Thu Aug 13 12:19:43 1998
@@ -3,8 +3,12 @@
#
## Regular expressions must NOT HAVE ANY '#' marks in it.
## For multiple lines describing a variable- The LAST line should be the
-## 'default' (or empty) line. Note that the order is important,and the first
-## match stops any more searches.
+## 'default' (or empty) line. Note that the order is important, and the
+## first match stops any more searches.
+
+# You can put a '-1' in any of the thresholds to never let the value
+# reach that threshold (for decreasing values). Put a very hi number
+# for increasing thresholds for same functionality.
# Select the pollinterval to be larger than the cycletime of the
# hostmon.client programs, else this program will get stale data.
diff -Nur nocol-4.2/perlnocol/hostmon-osclients/hostmon-client nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client
--- nocol-4.2/perlnocol/hostmon-osclients/hostmon-client Fri Jul 31 14:48:51 1998
+++ nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client Wed Aug 19 21:10:30 1998
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#
-# $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client,v 2.1 1998/07/31 18:48:43 vikas Exp $
+# $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client,v 2.1 1998/07/31 18:48:43 vikas Exp vikas $
#
# hostmon-client.main
#
@@ -89,16 +89,13 @@
# add to include path for os specific modules. You must set this to
# the installation directory of hostmon-osclients
-push(@INC, ".");
-push(@INC, "hostmon-osclients"); # SET_THIS to actual install location
+($dirname = $0) =~ s@/[^/]*$@@ ;
+push(@INC, $dirname, ".", "hostmon-osclients"); # SET_THIS
# Add to the path. Typically sendmail is under /usr/lib/
$ENV{'PATH'} .= ":/usr/ucb:/usr/bsd:/bin:/usr/bin:/sbin:/usr/sbin" ;
$ENV{'PATH'} .= ":/etc:/usr/etc:/usr/lib:/lib:/slib:/usr/slib" ;
-local ($DATAFILE) = '/etc/motd' ; # default if no $dfile
-
-
## Define the list of permitted hosts that can connect to the port above
# and get data (the name of the host that runs the hostmon server)
# @permithosts = ("abc.foo.com", "129.1.1.134");
@@ -116,7 +113,7 @@
# Depending on version of perl, call 'use Socket' or 'require socket.ph'
# From Netnews posting by jrd@cc.usu.edu (Joe Doupnik)
-local ($AF_INET, $SOCK_STREAM, $SOCK_DGRAM) = (2, 1, 2); # default values
+($AF_INET, $SOCK_STREAM, $SOCK_DGRAM) = (2, 1, 2); # default values
if ( $] =~ /^5\.\d+$/ ) { # perl v5
# print STDERR "debug: Check for perl5 passed...\n";
eval "use Socket";
@@ -145,7 +142,7 @@
local($con, $permit, $junk);
local ($port) = $HOSTMON_PORT ;
local(@permitaddr, $permitaddr); # list built by checkconnect()
- local($dfile) = $DATAFILE unless $dfile ;
+ local($dfile) = '/etc/motd' unless $dfile ;
local($sockaddr) = 'S n a4 x8';
$debug && print STDERR "(debug) telnet read datafile= $dfile\n";
@@ -252,7 +249,7 @@
sub create_telnet_daemon {
local ($myname) = "$0 (telnet_daemon)";
local ($tmppidf) = "/tmp/pidxfr" . $$;
- local ($cmd) = ($osfile =~ /solaris2/) ? "/bin/ps -p" : "ps";
+ local ($cmd) = ($osfile =~ /solaris2|irix6/) ? "/bin/ps -p" : "ps";
if ($childpid) {
foreach (`$cmd $childpid`) {chop; /$childpid\s+/ && return; }
@@ -302,7 +299,10 @@
$debug && print STDERR "OSTYPE = $ostype\n";
# set boolean values for OS's
- if ($ostype =~ /FreeBSD/) {$osfile .= "bsdi";}
+ if ($ostype =~ /AIX/) {$osfile .= "aix";}
+ elsif ($ostype =~ /FreeBSD\s+2\.[2345]+/) {$osfile .= "freebsd";}
+ elsif ($ostype =~ /FreeBSD\s+[34]+/) {$osfile .= "freebsd"; }
+ elsif ($ostype =~ /FreeBSD/) {$osfile .= "bsdi"; } # older versions
elsif ($ostype =~ /BSDI/) {$osfile .= "bsdi"; }
elsif ($ostype =~ /BSD\/OS/) {$osfile .= "bsdi"; }
elsif ($ostype =~ /NetBSD/) {$osfile .= "bsdi"; }
@@ -312,9 +312,9 @@
elsif ($ostype =~ /ULTRIX/) {$osfile .= "ultrix";}
elsif ($ostype =~ /Linux/) {$osfile .= "linux";}
elsif ($ostype =~ /HP-UX/) {$osfile .= "hpux";}
- elsif ($ostype =~ /AIX/) {$osfile .= "aix";}
elsif ($ostype =~ /IRIX\ 4/) {$osfile .= "irix4";}
elsif ($ostype =~ /IRIX\ 5/) {$osfile .= "irix5";}
+ elsif ($ostype =~ /IRIX(64)?\ 6/) {$osfile .= "irix6";}
else {print STDERR "hostmon-client:FATAL, OS $ostype is unknown\n"; die;}
#$debug &&
print "OSTYPE : $ostype\nLoading File : $osfile\n";
@@ -327,7 +327,7 @@
local (@me) =split(/\//,$0);
$me = pop(@me); # not local, since needed by exit routine
local ($p);
- local ($cmd) = ($osfile =~ /solaris2/) ? "ps -p" : "ps";
+ local ($cmd) = ($osfile =~ /solaris2|irix6/) ? "ps -p" : "ps";
if (!$debug) { if ($p=fork) {print "$p\n"; exit;} }
local($pidfile)= "/tmp/$me.pid";
@@ -390,10 +390,10 @@
while () {
$debug && print STDERR "(debug)mailstat: $_" ;
next if (/^[A-Z]+\d+\s+/); # From: this
- next if (/Deferred|warning|timeout/);
+ next if (/deferred|warning|timeout/i);
if (/Mail Queue/) { # Mail Queue (152 requests)
($x,$y,$paren,$qsize) = split(/[ \(]/);
- } else {
+ } elsif (/[@]/) {
chop;
($user,$host) = split(/[@]/);
$host =~ y/A-Z/a-z/; # canonicalize lower
@@ -406,15 +406,18 @@
# to sort the associative array by queue length
local(@hosts) = keys %NTo;
- @hosts = sort byqlen @hosts;
+ @hosts = sort byqlen @hosts; # high values at the top (0,1...)
print "MailQLocal $qsize Length\n";
- local($i) = 0;
- while(<@hosts>)
- { # printing only top 5 hosts
- ($i > 4) && last;
- printf "MailQDest %d Length %s\n", $NTo{$_}, $_;
- $i++;
+ if (@hosts != 0) {
+ for (@hosts[0..4]) # printing only top 5 hosts
+ {
+ if ($_) { printf "MailQDest %d Length %s\n", $NTo{$_}, $_ ; }
+ }
+ }
+ else # blank out the previous list
+ {
+ printf "MailQDest %d Length %s\n", 0, "";
}
#$NTo{"Local_QLen"} = $qsize; # entire queue length on localhost
}
@@ -426,7 +429,7 @@
# It is required by 'sort' in sub mailstat()
sub byqlen {
- $NTo{$a} <=> $NTo{$b}
+ $NTo{$b} <=> $NTo{$a}
}
###
@@ -446,11 +449,10 @@
#defined (&create_telnet_daemon) && &create_telnet_daemon ;
&create_telnet_daemon;
-local ($passno) = 1; # keep track of pass number in loop
-local ($tmpfile) = "$dfile" . ".tmp" ; # create temporary output file
-local ($stime, $deltatime);
-local ($chek_dpass) = int(3600 /$sleeptime); #check telnet daemon every hour
-local ($restart_dpass) = int(24*3600 /$sleeptime); #restart every 24 hours
+$passno = 1; # keep track of pass number in loop
+$tmpfile = "$dfile" . ".tmp" ; # create temporary output file
+$chek_dpass = int(3600 /$sleeptime); # check telnet daemon every hour
+$restart_dpass = int(24*3600 /$sleeptime); #restart every 24 hours
while (1)
{
diff -Nur nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.aix nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.aix
--- nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.aix Fri Jul 31 14:48:57 1998
+++ nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.aix Thu Aug 13 12:17:03 1998
@@ -2,7 +2,7 @@
# ######## hostmon-client.aix #######
#
-## $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client.aix,v 1.1 1998/07/31 18:48:43 vikas Exp $
+## $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client.aix,v 1.2 1998/08/13 16:16:14 vikas Exp $
#
# This file is appended by 'hostmon-client'
#
@@ -144,7 +144,7 @@
{
printf "DFspace_avail %d MB $5\n", int(($1/$blksz)/1000);
print "DFspace_\%used $2 \%full $5\n";
- printf "DFinodes_avail %d inodes $5\n", int($3 * (100 - $4)/( ($4) ? : $4 : 1));
+ printf "DFinodes_avail %d inodes $5\n", int($3 * (100 - $4)/( ($4) ? $4 : 1));
print "DFinodes_\%used $4 \%inodes $5\n";
}
}
diff -Nur nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.freebsd nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.freebsd
--- nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.freebsd Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.freebsd Wed Aug 19 19:35:07 1998
@@ -0,0 +1,353 @@
+#!/usr/local/bin/perl
+
+# ######## hostmon-client.bsdi #######
+#
+## $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client.bsdi,v 0.10 1998/07/31 18:48:43 vikas Exp $
+#
+# This file is appended by 'hostmon-client'
+#
+
+###
+# All the following functions must print out the following:
+# VARIABLE VALUE UNITS COMMENT
+# For variables that are part of a varying maximum, normalize it and give
+# the percentage instead (e.g. free memory, etc.)
+###
+###
+
+## This file is for FreeBSD v2.2.x and newer. Very similar to BSDI version.
+
+# To make sure that df, etc. print out the values in 1K blocksize....
+$ENV{'BLOCKSIZE'} = "1024" ;
+
+### csh% uptime
+# bsdi% uptime
+# 1:14AM up 9 days, 14:53, 2 users, load averages: 2.11, 2.12, 2.13
+###
+sub uptime {
+ local ($cmd) = "uptime";
+ local ($value) = -1 ;
+ local ($uptime) = 0;
+ open (CMD, "$cmd |");
+ while () {
+ $debug && print STDERR "(debug)uptime: $_" ;
+ chop; tr/\r\n//d;
+
+ if ( /^.*up\s+(\d+)\s+day.*,\s*(\d+):(\d+),.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ $uptime = ($1 * 1440) + ($2 * 60) + $3;
+ printf "Uptime %d mins\n", $uptime;
+ printf "Load5 %d load-5min\n", int($5) ;
+ last ;
+ }
+ elsif ( /^.*up\s+(\d+):(\d+),.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ $uptime = ($1 * 60) + $2;
+ printf "Uptime %d mins\n", $uptime;
+ printf "Load5 %d load-5min\n", int($4) ;
+ last ;
+ }
+ elsif ( /^.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ printf "Load5 %d load-5min\n", int($2) ;
+ last ;
+ }
+ else { print STDERR "(debug)uptime() : command format not understood.\n"; }
+ }
+ close (CMD);
+
+# print "Load 9999 load UnParseableInput\n";
+}
+
+### sunos4% pstat -T
+# 367/1017 files
+# 298/693 inodes
+# 97/266 processes
+# 53924/154220 swap
+# BSDI replaces the inodes by a dynamic vnode table and doesn't have a process
+# table.
+#
+# freebsd% pstat -T bsdi% pstat -T
+# 135/360 files 384/650 files
+# 1935 vnodes 556 vnodes
+# 10M/63M swap space 0/49148 swap space (1K-blocks)
+#
+sub pstat {
+
+ # Skip for BSDI version 1.0
+ if ($ostype =~ /BSDI.*1\.0/) { return; } # older BSDI versions
+
+ open (CMD, "pstat -T |");
+ while () {
+ if ($debug) {print STDERR "(debug)pstat: $_" ; }
+
+ chop; tr/\r\n//d;
+
+ if ( /^\s*(\d+)\/(\d+)\s*(files).*$/ ) {
+ printf "FileTable %d %%used\n", int($1 * 100 / $2);}
+ elsif ( /^\s*(\d+)M\/(\d+)M\s+(swap).*$/ ) {
+ printf "SwapSpace %d MBytes\n", $2 - $1;}
+ elsif ( /^\s*(\d+)\/(\d+)\s+(swap).*$/ ) {
+ printf "SwapSpace %d MBytes\n", int( ($2 - $1)/1000 ) ;}
+
+ next;
+ }
+ close (CMD);
+
+} # end &pstat()
+
+### nfsstat
+# Have to calculate deltas in each pass since the nfsstat command does not
+# give us 'rate' over a time period.
+# STORE THE OLD VALUES IN EACH PASS AND CALC DELTA EACH TIME.
+#
+# DWN: Additionally, nfsstat on BSDI does not yet give the ability to
+# restrict the output to client/server or RPC/NFS, so we have to look
+# at the header lines.
+#
+# Timeouts are not the same as retries! Timeouts to reflect problems
+# communicating to the server (nfs server not responding), which in turn
+# is indicated by successive retries on a NFS request. The cause for the
+# retry may be local socket blockage, network loss, or a busy server.
+#
+# sunos4-vikas> nfsstat -rc
+#
+# Client rpc:
+# calls badcalls retrans badxid timeout wait newcred timers
+# 7915078 52102 0 345 52073 0 0 7164
+#
+# bsdi% nfsstat
+# Client Info:
+# Rpc Counts:
+# Getattr Setattr Lookup Readlink Read Write Create Remove
+# 0 0 0 0 0 0 0 0
+# Rename Link Symlink Mkdir Rmdir Readdir Statfs RdirLook
+# 0 0 0 0 0 0 0 0
+# GLease Vacate Evict
+# 0 0 0
+# Rpc Info:
+# TimedOut Invalid X Replies Retries Requests
+# 0 0 0 0 0
+#
+sub nfsstat {
+ local ($cmd) = "nfsstat";
+ local ($dcalls, $dtimeo, $dretries, $tvalue, $rvalue);
+ open (CMD, "$cmd |");
+ while () {
+ chop; tr/\r\n//d;
+ # rate = timeout/calls
+ next until (/TimedOut/) ;
+ if ( /^\s*(\d+)\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s*$/ ) {
+ $debug && print STDERR "(debug)nfsstat: $_\n" ;
+
+ $dcalls = $3 - $onfscalls ; $onfscalls = $3 ;
+ $dretries = $2 - $onfsretries; $onfsretries = $2;
+ $dtimeo = $1 - $otimeo ; $otimeo = $1 ;
+ last ; # no more lines
+ }
+ } # end (while)
+ close (CMD);
+
+ if ($dcalls == 0) { $tvalue = 0 ; $rvalue = 0;}
+ else {
+ $tvalue = int($dtimeo * 100 / $dcalls); # calc timeout rate
+ $rvalue = int($dretries * 100 / $dcalls); # calc retry rate
+ }
+
+ if ($debug) { print STDERR "(debug)nfsstat: $dtimeo/$dcalls\n" ;}
+ print "NFStimeouts $tvalue %timeouts\n";
+ print "NFSretries $rvalue %retries\n";
+
+} # end &nfsstat()
+
+## df
+# Extract space availability stats. Printing out available MBytes and
+# percent full (together they make sense).
+# Note that this command prints out a number of lines with same variable
+# name (one for each disk). The hostmon server picks out the worst of
+# these lines.
+#
+# sun41-vikas> df -t 4.2
+# Filesystem kbytes used avail capacity Mounted on
+# /dev/sd0a 24239 12492 9324 57% /
+# /dev/sd0g 191919 149692 23036 87% /usr
+# /dev/sd3c 1230152 1062490 44647 96% /usr/local
+#
+# bsdi-vikas> df -i -k -t local
+# Filesystem 1K-blocks Used Avail Capacity iused ifree %iused Mounted on
+# /dev/sd0a 7979 5877 1304 82% 631 3207 16% /
+# flsvr:/vol/cvs 953478 699853 158277 82% 0 0 100% /vol/cvs
+#
+sub df {
+
+ open (CMD, "df -i |");
+
+ while () {
+ chop; tr/\r\n//d;
+ if (/^\s*Filesystem/) { next; } # ignore header line
+ if (/^\s*\S+:\/\S*/) { next; } # ignore NFS mounts
+
+ if (/^\s*(\/dev\/.*|mfs:\d+)\s+\d+\s+\d+\s+(\d+)\s+(\d+)%\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\/\S*)\s*$/)
+ {
+ $debug && print STDERR "(debug)df: $_\n" ;
+
+ printf "DFspace_avail %d MB $7\n", int($2/1000);
+ print "DFspace_\%used $3 \%full $7\n";
+ print "DFinodes_avail $5 inodes $7\n";
+ print "DFinodes_\%used $6 \%inodes $7\n";
+ }
+ }
+ close (CMD);
+ return ;
+
+} # end &df()
+
+##
+# bsdi$ iostat -w 5 -c 3
+# tty sd0 sd1 cpu
+# tin tout sps tps msps sps tps msps us ni sy id
+# 0 4 3 0 9.5 0 0 0.0 5 0 1 94
+# 10 10 0 0 0.0 0 0 0.0 0 0 1 99
+#
+# sps sectors transferred per second (512 bytes ?)
+# tps transfers per second
+# msps milliseconds per average seek (including implied seeks)
+##
+sub iostat {
+ local ($cmd) = "iostat";
+ local ($str, $diskno, $numdisks);
+ local (@IOname);
+
+ open (CMD, "$cmd -w 5 -c 3 |");
+
+ while () {
+ chop; tr/\r\n//d;
+ $str = $_ ;
+ if (/\s+msps|tps\s+/) { next; } # ignore header line
+ if (/^\s+[A-z]+/) { # header line containing disk names...
+ if ($debug) { print STDERR "(debug)iostat: $_\n"; }
+ $numdisks = 0;
+ while ( $str =~ /\s*(\w+)\s+/ ) {
+ if ( $1 eq 'tty' ) { $str = $'; next; } # BSDI lists 'tty'
+ if ( $1 eq 'cpu' ) { $str = $'; last; } # 'cpu' is not a disk
+ $str = $' ; # remaining string
+ $IOname[++$numdisks] = $1; # extract the name of disk
+ } # end while()
+ }
+
+ } # end: while()
+ close (CMD);
+
+ # Here we have the last line from the command above
+ if ($debug) { print STDERR "(debug)iostat: $str\n"; }
+ $diskno = 0;
+ while ($str =~ /\s*(\d+)\s+(\d+)\s+(\d+\.\d+)/) # extract bps,tps,msps
+ {
+ ++$diskno; $str = $' ; # remaining string
+ printf "IObps %d kbps $IOname[$diskno]\n", int($1/2); # sectors ->kB
+ print "IOtps $2 tps $IOname[$diskno]\n"; # IO transfers per sec
+ print "IOmsps $3 msps $IOname[$diskno]\n"; # seek time, msecs/seek
+ }
+
+} # end &iostat()
+
+
+## vmstat
+# Extract paging, real-memory, cache hits, CPU load, Context switches.
+# Note: Seems like the fields are fixed length, and sometimes there are
+# no spaces between the output fields.
+# bsdi$ vmstat -w 5 -c 2
+# procs memory page disks faults cpu
+# r b w avm fre flt re pi po fr sr sd0 sd1 in sy cs us sy id
+# 2 0 0 0 456 3 0 0 0 0 0 0 0 119 23 9 5 1 94
+# 0 0 0 0 368 150 22 0 0 0 0 2 0 132 141 21 2 7 91
+#
+## -1- 2 3 4 5 6 7 8 9 -10- 11 12 13 14 15 16
+#
+##
+sub vmstat {
+ local ($i) = 0;
+ local($dline);
+ local ($cmd) = "vmstat";
+
+ open(CMD, "$cmd -w 5 -c 2 |");
+
+ while () { $dline = $_; next; }
+
+ # Here we have the last data line from the command above.
+ if ($debug) { print STDERR "(debug)vmstat: $dline"; }
+ $_ = $dline ;
+ chop; tr/\r\n//d;
+
+ # if any CPU time is 100, vmstat doesnt have any spaces in it.
+ # s/100(\s+\d+){0,2}\s*$/ 100\1/;
+
+ # In freebsd, the processes are always 2 fields (%2d%2d%2d)
+ # and the space before avm can get lost. Hence taking 2 fields
+ # for each process...
+ ### procs # avm # fre # flt # re # pi # po # disks # cs # us # sy # id ######
+ if (/^(..){3}\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)(\s+\d+)+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/)
+ {
+ printf "MemFree %d MB\n", int($3 / 1000); # convert KB to MB
+ print "PageFlt $4 pgflts\n";
+ print "PageRe $5 pages/sec\n";
+ print "PageIn $6 pi\n";
+ print "PageOut $7 po\n";
+ print "CtxtSw $9 rate\n";
+ print "CPUus $10 %user\n";
+ print "CPUsy $11 %system\n";
+ print "CPUidle $12 %idle\n";
+ }
+ close (CMD);
+
+} # end &vmstat()
+
+
+## netstat
+# Extract collision and error rates. Luckily, on SunOS there is an option
+# for printing out the delta values. Since there is no easy way to
+# terminate the command after displaying 5 lines, forcibly close the
+# command stream.
+# Ignore the first few lines, look at the 5th and then forcibly close.
+# Since the command only displays one interface's data, we look at the
+# 'totals' field.
+#
+# The syntax has changed in FreeBSD 2.2.x (older versions were similar to
+# BSDI).
+#
+# FreeBSD 2.2.1> netstat 5
+# input (Total) output
+# packets errs bytes packets errs bytes colls
+# 19 0 2225 8 0 944 0
+# 38 0 4446 16 0 3633 0
+# 27 0 2811 8 0 1531 0
+#
+sub netstat {
+ local ($i) = 0;
+ local ($cmd) = "netstat";
+
+ local($pid) = open (CMD, "$cmd 10 |"); # 10 second sampling
+ while () {
+ if (/^\s+[A-z]+/) { next; } # ignore header lines if any
+ if (++$i < 3) { next ;} # ignore first 3 lines
+ chop; tr/\r\n//d;
+ $debug && print STDERR "(debug)netstat: $_\n" ;
+
+ if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/)
+ {
+ local ($ipkts, $opkts) = ($1, $4);
+
+ if ($ipkts == 0) { $ipkts = 1; } # avoid division by zero
+ if ($opkts == 0) { $opkts = 1; }
+ printf "NetIErr %d PktRate\n", int ($2 * 100 / $ipkts);
+ printf "NetOErr %d PktRate\n", int ($5 * 100 / $opkts);
+ printf "NetColl %d PktRate\n", int ($7 * 100 / $opkts);
+ }
+ kill ('TERM', $pid) ; last ; # no more lines
+ }
+ close (CMD);
+} # end &netstat()
+
+# require this otherwise require &xxxx will issue an error saying true not
+# returned by xxxxx module.
+1;
+
+############### END OF hostmon-client.bsdi ####################
+
diff -Nur nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.irix6 nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.irix6
--- nocol-4.2/perlnocol/hostmon-osclients/hostmon-client.irix6 Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/perlnocol/hostmon-osclients/hostmon-client.irix6 Wed Aug 19 20:44:08 1998
@@ -0,0 +1,288 @@
+#!/usr/local/bin/perl
+
+# ######## hostmon-client.irix6 #######
+#
+# IRIX 6.x (contributed by Frank Crawford )
+#
+## $Header: /home/vikas/src/nocol/perlnocol/hostmon-osclients/RCS/hostmon-client.irix6,v 1.1 1998/08/20 00:43:14 vikas Exp $
+#
+# This file is appended by 'hostmon-client'
+#
+
+# IRIX requires the Socket perl library. Besides, IRIX seems to
+# have changed the values of SOCK_DGRAM, etc.
+#eval 'use Socket' || eval {require "socket.ph"} || require "sys/socket.ph";
+#$AF_INET = PF_INET;
+#$SOCK_STREAM = SOCK_STREAM;
+#$SOCK_DGRAM = SOCK_DGRAM;
+$AF_INET = 2;
+$SOCK_STREAM = 2;
+$SOCK_DGRAM = 1;
+
+###
+# All the following functions must print out the following:
+# VARIABLE VALUE UNITS COMMENT
+# For variables that are part of a varying maximum, normalize it and give
+# the percentage instead (e.g. free memory, etc.)
+###
+###
+
+### csh% uptime
+# 4:26am up 10:09, 2 users, load average: 0.01, 0.07, 0.00
+#
+sub uptime {
+ local ($cmd) = "uptime";
+ local ($value) = -1 ;
+ local ($uptime) = 0;
+ open (CMD, "$cmd |");
+ while () {
+ $debug && print STDERR "(debug)uptime: $_" ;
+ chop; tr/\r\n//d;
+ if ( /^.*up\s+(\d+)\s+day.*,\s*(\d+)\s*mins,.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ )
+ {
+ $uptime = ($1 * 1440) + $2;
+ printf "Uptime %d mins\n", $uptime;
+ printf "Load5 %d load-5min\n", int($4) ;
+ last ;
+ }elsif ( /^.*up\s+(\d+)\s+day.*,\s*(\d+):(\d+),.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ $uptime = ($1 * 1440) + ($2 * 60) + $3;
+ printf "Uptime %d mins\n", $uptime;
+ printf "Load5 %d load-5min\n", int($5) ;
+ last ;
+ }
+ elsif ( /^.*up\s+(\d+):(\d+),.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ $uptime = ($1 * 60) + $2;
+ printf "Uptime %d mins\n", $uptime;
+ printf "Load5 %d load-5min\n", int($4) ;
+ last ;
+ }
+ elsif ( /^.*load\s*average\S*:\s+(\S+),\s+(\S+),\s+(\S+).*$/ ) {
+ printf "Load5 %d load-5min\n", int($2) ;
+ last ;
+ }
+ else { print STDERR "(debug)uptime() : command format not understood.\n"; }
+ }
+ close (CMD);
+
+# print "Load 9999 load UnParseableInput\n";
+}
+
+###
+# pstat NOT SUPPORTED ON IRIX
+# use swap -s
+#
+#total: 77.16m allocated + 1.78g add'l reserved = 1.86g bytes used, 2.35g bytes available
+#
+sub pstat {
+ local($cmd) = "swap -s";
+
+ open(CMD, "$cmd |");
+ while () {
+ if ($debug) { print STDERR "(debug)pstat: $_" ; }
+
+ chop; tr/\r\n//d;
+
+ if ( /^.*, (\d+\.\d+)m bytes available$/ ) {
+ printf "SwapSpace %d MBytes\n", int($1);
+ } elsif ( /^.*, (\d+\.\d+)g bytes available$/ ) {
+ printf "SwapSpace %d MBytes\n", int($1 * 1024);
+ }
+ }
+ close(CMD);
+} # end &pstat()
+
+### nfsstat
+# Have to calculate deltas in each pass since the nfsstat command does not
+# give us 'rate' over a time period.
+# STORE THE OLD VALUES IN EACH PASS AND CALC DELTA EACH TIME.
+#
+# DWN: Additionally, nfsstat on BSDI does not yet give the ability to
+# restrict the output to client/server or RPC/NFS, so we have to look
+# at the header lines.
+#
+# Timeouts are not the same as retries! Timeouts to reflect problems
+# communicating to the server (nfs server not responding), which in turn
+# is indicated by successive retries on a NFS request. The cause for the
+# retry may be local socket blockage, network loss, or a busy server.
+#
+# sunos4-vikas> nfsstat -rc
+#
+# Client rpc:
+# calls badcalls retrans badxid timeout wait newcred timers
+# 7915078 52102 0 345 52073 0 0 7164
+#
+sub nfsstat {
+ local ($cmd) = "/usr/etc/nfsstat";
+ local ($dcalls, $dtimeo, $dretries, $tvalue, $rvalue);
+ open (CMD, "$cmd -rc |"); # '-rc' for client related data only
+ while () {
+ chop; tr/\r\n//d;
+ # rate = timeout/calls
+ if (/^\s*(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+).*$/ ) {
+ $debug && print STDERR "(debug)nfsstat: $_\n" ;
+
+ $dcalls = $1 - $onfscalls ; $onfscalls = $1 ;
+ $dretries = $2 - $onfsretries ; $onfsretries = $2 ;
+ $dtimeo = $3 - $otimeo ; $otimeo = $3 ;
+ last ; # no more lines
+ }
+ } # end (while)
+ close (CMD);
+
+ if ($dcalls == 0) { $tvalue = 0 ; $rvalue = 0;}
+ else {
+ $tvalue = int($dtimeo * 100 / $dcalls); # calc timeout rate
+ $rvalue = int($dretries * 100 / $dcalls); # calc retry rate
+ }
+
+ if ($debug) { print STDERR "(debug)nfsstat: $dtimeo/$dcalls\n" ;}
+ print "NFStimeouts $tvalue %timeouts\n";
+ print "NFSretries $rvalue %retries\n";
+
+} # end &nfsstat()
+
+## df
+# Extract space availability stats. Printing out available MBytes and
+# percent full (together they make sense).
+# Note that this command prints out a number of lines with same variable
+# name (one for each disk). The hostmon server picks out the worst of
+# these lines.
+#
+# irix> df -i -k
+# Filesystem Type kbytes use avail %use iuse ifree %iuse Mounted
+# /dev/root efs 966574 615444 351130 64% 20730 188204 10% /
+# /dev/dsk/dks efs 3013012 1353603 1659409 45% 22444 611754 4% /var
+# /dev/dsk/dks efs 1068340 743093 325247 70% 33267 191579 15% /usr
+#
+sub df {
+
+ open (CMD, "df -i -k -l |");
+
+ while () {
+ chop; tr/\r\n//d;
+ if (/^\s*Filesystem/) { next; } # ignore header line
+ if (/^\/dev\/dsk\/0s3/) { next; } # just skip the SVR4 specific
+ if (/^\/proc/) { next; } # OS type filesystems
+ if (/^\/hinv/) { next; }
+ if (/^\/dev\/fd/) { next; }
+ $debug && print STDERR "(debug)df: $_\n" ;
+
+ if (/^.*\s+(\d+)\s+(\d+)%?\s+\d+\s+(\d+)\s+(\d+)%?\s+(\/\S*)\s*$/)
+ {
+ printf "DFspace_avail %d MB $5\n", int($1/1000);
+ print "DFspace_\%used $2 \%full $5\n";
+ print "DFinodes_avail $3 inodes $5\n";
+ print "DFinodes_\%used $4 \%inodes $5\n";
+ }
+ }
+ close (CMD);
+
+} # end &df()
+
+##
+# iostat not supported on IRIX
+# irix> dkstat 5 1
+# pion.ansto.gov.au total I/O rate, interval: 5 sec, Fri Jul 4 22:31:26 1997
+# dks1d1 dks3d4 dks3d4l1 dks3d4l2
+# 0 0 0 0
+#
+sub iostat {
+ local ($cmd) = "/usr/sbin/dkstat 5 1";
+ local ($count, $IO);
+ local (@IOname);
+
+ open (CMD, "$cmd |");
+ while () {
+ if ($debug) { print STDERR "(debug)iostat: $_\n" ; }
+
+ next unless $count++;
+ chop; tr/\r\n//d;
+
+ if ( /^\s*[a-z]/i ) {
+ @IOname = split(/\s+/);
+ } else {
+ s/^\s*//;
+ for $IO (split(/\s+/)) {
+ printf "IOtps %d tps %s\n", $IO, shift(@IOname);
+ }
+ }
+ }
+ close (CMD);
+} # end &iostat()
+
+
+##
+# vmstat not supported on IRIX (whats with it folks ??)
+# irix5> /usr/sbin/pmkstat -s 1
+## pion.ansto.gov.au load avg: 3.14, interval: 5 sec, Fri Jul 4 22:53:42 1997
+# queue | memory | system | disks | cpu
+#run swp| free page| scall ctxsw intr| rd wr|usr sys idl wt
+# 3 0 125696 0 32 125 451 0 1 75 1 25 0
+#
+sub vmstat {
+ local ($cmd) = "/usr/sbin/pmkstat -s 1";
+ local ($dline);
+ local (@vmstat);
+
+ open(CMD, "$cmd |");
+ while () { $dline = $_ }; close(CMD); # Get the last line;
+
+ $_ = $dline;
+ if ($debug) { print STDERR "(debug)vmstat: $_" ; }
+ chop; tr/\r\n//;
+
+ s/^\s*//;
+ @vmstat = split(/\s+/);
+ if (@vmstat == 13) {
+ printf "MemFree %d MB\n", $vmstat[2];
+ printf "PageOut %d po\n", $vmstat[3];
+ printf "CtxtSw %d rate\n", $vmstat[5];
+ printf "CPUus %d %%user\n", $vmstat[9];
+ printf "CPUsy %d %%system\n", $vmstat[10];
+ printf "CPUidle %d %%idle\n", $vmstat[11];
+ }
+}
+
+## netstat
+# Extract collision and error rates.
+# See comments in hostmon-client.sunos
+#
+# irix> netstat 5
+# input (ec0) output input (Total) output
+# packets errs packets errs colls packets errs packets errs colls
+#
+# 425 0 36 0 0 433 0 44 0 0
+# 510 0 67 0 2 518 0 75 0 2
+#
+sub netstat {
+ local ($i) = 0;
+ local ($cmd) = "netstat";
+
+ local($pid) = open (CMD, "$cmd 10 |"); # 10 second sampling
+ while () {
+ if (/^\s*[A-z]+/) { next; } # ignore header lines if any
+ if (++$i < 3) { next ;} # ignore first 3 lines
+ chop; tr/\r\n//d;
+ $debug && print STDERR "(debug)netstat: $_\n" ;
+
+ if (/^\s*\d+(\s+\d+)*\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/)
+ {
+ local ($ipkts, $opkts) = ($2, $4);
+
+ if ($ipkts == 0) { $ipkts = 1; } # avoid division by zero
+ if ($opkts == 0) { $opkts = 1; }
+ printf "NetIErr %d PktRate\n", int ($3 * 100 / $ipkts);
+ printf "NetOErr %d PktRate\n", int ($5 * 100 / $opkts);
+ printf "NetColl %d PktRate\n", int ($6 * 100 / $opkts);
+ }
+ kill ('TERM', $pid) ; last ; # no more lines
+ }
+ close (CMD);
+} # end &netstat()
+
+# require this otherwise require &xxxx will issue an error saying true not
+# returned by xxxxx module.
+1;
+
+############### END OF hostmon-client.irix ####################
+
diff -Nur nocol-4.2/perlnocol/nocollib.pl nocol-4.2.1/perlnocol/nocollib.pl
--- nocol-4.2/perlnocol/nocollib.pl Fri Jul 31 14:40:59 1998
+++ nocol-4.2.1/perlnocol/nocollib.pl Thu Aug 27 21:12:38 1998
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#
-# $Header: /home/vikas/src/nocol/perlnocol/RCS/nocollib.pl,v 1.9 1998/07/31 18:40:09 vikas Exp $
+# $Header: /home/vikas/src/nocol/perlnocol/RCS/nocollib.pl,v 1.11 1998/08/28 01:12:10 vikas Exp $
#
# nocollib.pl - perl library of NOCOL routines
#
@@ -102,6 +102,11 @@
$varunits = "UNSET" unless $varunits;
$sleepint = 5*60 unless $sleepint;
+## these variables are needed by eventlog()
+$nlogfd = -1;
+$nlogclosetime = -1; # used for deciding when to reopen logfile
+
+
###################################################################
# Support routines for Networking
@@ -161,7 +166,7 @@
socket(SOCK, $AF_INET, $type, $proto) || die "socket: $!";
if (! connect(SOCK, $paddr)) {
close SOCK;
- print STDERR "connect failed: $!";
+ print STDERR "newSocket() connect failed: $!";
return -1;
}
@@ -445,38 +450,33 @@
##
## eventlog()
-#
+# Send the event to NLOG_HOST using UDP.
#
-$NLOG_HOST = "noclog.foo.com" unless $NLOG_HOST ;
-$NLOG_SERVICE = "noclog" unless $NLOG_SERVICE ;
-$NLOG_PORT = 5354 unless $NLOG_PORT ;
-$RETRY_REOPEN = 1*60 ; # try re-opening logging socket every minute
-local ($logfd, $logclosetime) = (-1, -1);
-
sub eventlog {
local($event) = @_ ;
local($bytesleft);
+ local($RETRY_REOPEN) = 1*60 ; # try re-opening logging socket every minute
- if ($logfd < 0)
+ if ($nlogfd < 0)
{
local($lport);
# do not try again until RETRY_REOPEN secs
- if ((time - $logclosetime) < RETRY_REOPEN) { return (-1) ; }
+ if ((time - $nlogclosetime) < $RETRY_REOPEN) { return (-1) ; }
## Get local port number
($junk, $junk, $lport) = getservbyname($NLOG_SERVICE, 'udp');
$lport = $NLOG_PORT unless $lport ;
- $logfd = &newSocket($NLOG_HOST, $lport, 'udp');
- if ($logfd < 0) {
+ $nlogfd = &newSocket($NLOG_HOST, $lport, 'udp');
+ if ($nlogfd < 0) {
print STDERR "eventlog- could not connect to $NLOG_HOST\n";
- $logclosetime = time ; # record time of last attempt
+ $nlogclosetime = time ; # record time of last attempt
return (-1);
}
- select( (select($logfd), $| = 1)[0] ); # make socket unbuffered
+ select( (select($nlogfd), $| = 1)[0] ); # make socket unbuffered
($libdebug > 0) && print STDERR "(libdebug) eventlog: socket opened\n";
} # end: if(socket not open)
@@ -486,19 +486,18 @@
{
local($written);
local($offset) = 0;
- $written = syswrite($logfd, $event, $bytesleft, $offset);
+ $written = syswrite($nlogfd, $event, $bytesleft, $offset);
if ($written <= 0)
{
- ($libdebug > 0) &&
- print STDERR ("(libdebug) eventlog syswrite error: $!\n");
- close($logfd);
+ print STDERR ("(libdebug) eventlog syswrite error: $!\n");
+ close($nlogfd);
+ $nlogfd = -1; # reset
return(-1);
}
$bytesleft -= $written;
$offset += $written
} # end: while($bytesleft)
-
}
@@ -535,8 +534,7 @@
if ($status < 0) # bad status, probably some error
{
- ($libdebug > 0) &&
- print STDERR "$me: dotest failed for $item... skipping\n";
+ print STDERR "$me: dotest failed for $item... skipping\n";
next;
}
else {&update_event($item, $status, $value, $maxseverity);}
@@ -544,7 +542,7 @@
open(OEVENTS,">$datafile");
foreach $item (@items)
{
- if(!$forget{$item})
+ if(!$forget{$item}) # maintained by calling monitor
{
&writeevent(OEVENTS, $item);
}
diff -Nur nocol-4.2/perlnocol/snmpmon-client nocol-4.2.1/perlnocol/snmpmon-client
--- nocol-4.2/perlnocol/snmpmon-client Fri Jul 31 14:46:25 1998
+++ nocol-4.2.1/perlnocol/snmpmon-client Wed Aug 12 13:42:06 1998
@@ -5,7 +5,6 @@
#
# AUTHOR: Vikas Aggarwal, vikas@naya.com
#
-#
# Copyright 1994 Vikas Aggarwal, vikas@navya.com
#
######
@@ -66,11 +65,15 @@
$debug = 0; # set to 1 for debugging output
$libdebug = 0; # set to 1 for debugging output
$prognm = $0; # save program name
-$cfile = "$0" . "-confg" ;
-$cfile =~ s,/bin/,/etc/,; # replace 'bin' in pathname with 'etc'
$sleeptime = 10 ; # in seconds
+$cfile = "$prognm" . "-confg" ;
+$cfile =~ s,^.*/,, ; # get basename (strip directory path)
+$cfile = "$etcdir" . "/$cfile" ;
+
+#########
-d $datadir || mkdir($datadir, 0700) || die("Cannot create $datadir");
+-w $datadir || die("Cannot write to $datadir");
-x $ping || die("Cannot find $ping");
-x $prog || die("Could not find executable $prog, exiting");
-f $mibfile || die("Could not find MIB file $rprog, exiting");
@@ -499,7 +502,10 @@
# PING output= 4 packets transmitted, 3 packets received, 25% packet loss
- if ($ostype =~ /HP-UX/ || $ostype =~ /ULTRIX/) {
+ if ($ping =~ /multiping/) {
+ open(CMD, "$ping -s 100 -c 4 $rhost |");
+ }
+ elsif ($ostype =~ /HP-UX/ || $ostype =~ /ULTRIX/) {
open(CMD, "$ping $rhost 100 4 |");
}
elsif ($ostype =~ /SunOS\s+4/ || $ostype =~ /SunOS\s+5/) {
@@ -508,6 +514,7 @@
else {
open (CMD, "$ping -s 100 -c 4 $rhost |");
}
+
while () {
if ( /\s+(\d+)%\s+packet\s+loss/) {
if ($1 < 50) { $value = 1; } # if 1 lost, then 25%
diff -Nur nocol-4.2/perlnocol/syslogmon nocol-4.2.1/perlnocol/syslogmon
--- nocol-4.2/perlnocol/syslogmon Fri Jul 31 14:43:38 1998
+++ nocol-4.2.1/perlnocol/syslogmon Wed Aug 12 11:54:40 1998
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
-# $Header: /home/vikas/src/nocol/perlnocol/RCS/syslogmon,v 1.2 1998/07/31 18:43:31 vikas Exp $
+# $Header: /home/vikas/src/nocol/perlnocol/RCS/syslogmon,v 1.3 1998/08/12 15:54:29 vikas Exp $
#
# syslogmon - NOCOL perl monitor for syslogs
#
@@ -41,7 +41,7 @@
# Diskerr * warning diskfull\s*(/var\S*)
#
# - Read each line and break them into four fields.
-# - create regexp array from the #4 field
+# - create regexp[] array from the #4 field
# - initialize isdone array. This array is used to prevent logging
# same type of event more than once.
#
@@ -52,9 +52,10 @@
# - Read event by event from IEVENTS
# - for each event read, if event timestamp is older than current time +
# expiretime then dont write the event back, else write to OEVENTS.
+# Reset $isdone to zero
# - At end, truncate file to the length obtained from tell(OEVENTS).
#
-# 3) Logging Events to sysmonlog-output :
+# 3) Logging Events to syslogmon-output :
# =======================================
# - Do Expire-Events
# - For each log file given in the config file get the file size
@@ -70,8 +71,8 @@
# Month Date time host rest till "\n" .............
# Feb 11 17:43:15 freebird /kernel: diskfull /var/tmp/junk
#
-# - go through the regexp array
-# - if the regexp match the last field i.e. rest and host match then
+# - go through the regexp[] array
+# - if the regexp matches the last field i.e. rest and host match then
# - intiliaze and log the event to output file and noclogd daemon.
# - set the isdone flag so that we dont log this event again till
# the expire time is over.
@@ -143,16 +144,16 @@
else { print STDERR "Illegal log file line $_, skipping\n" ;}
next ;
}
-
+ # VAR HOST SEVERITY REGEXP
if (/\s*(\S+)\s+(\S+)\s+(\S+)\s*(.*)\s*$/)
{
+ $item = $1 ; # the VAR name
local ($re) = $2 ; # temp variable
- $item = $1 ; # the name and address
if ($2 eq '*' || $2 eq '+') { $re = '.+' } ; # convert '*' => '.+'
$site{$item} = $re;
- $level{$item} = $3; # Warning level
- $regexp{$item} = $4; # regexp for search
- $isdone{$item} = 0; # reset
+ $level{$item} = $3; # level
+ $regexp{$item} = $4; # regexp for searching log lines
+ $isdone{$item} = 0; # init to zero
push(@items,$item);
} else { print STDERR "Ignoring illegal line: $_\n";}
@@ -209,13 +210,10 @@
local($line) = $_;
(/\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)\s*$/);
$Month = $1; $Date = $2; $time = $3; $host = $4; $rest = $5;
- # get the fields
- #($Month, $Date, $time, $host, @rest) = split(' ');
# check if read data matches regexp
- foreach (keys %regexp) # get the reg exp created from config file
+ foreach $item (@items) # the VAR name
{
- $item = $_; # get the item read
local($site) = $site{$item};
local($regexp) = $regexp{$item}; # to store retrieved reg exp
#sleep(1);
@@ -229,20 +227,23 @@
if ($debug > 2) {
print "(dotest)Event already logged, \'$item\'\n";
}
- last; # skip foreach (keys %regexp)
+ last; # skip foreach ($item)
}
else { $isdone{$item} = 1;} # set the flag
# $debug && print "Logging Line : $line, Item : $item\n";
- # init event and fill values
+ # init event and fill values. The parsed 'regexp' is the
+ # address field.
&init_event($host, $regexp , $i);
- $varname{$i} = $item; # regular expression
+ $varname{$i} = $item;
- if ($level{$item} =~ /info/)
+ # The event gets written directly at the level instead
+ # of escalating gradually like typical nocol monitors
+ if ($level{$item} =~ /info/i)
{ $severity{$i} = $loglevel{$i} = $E_INFO; }
- elsif ($level{$item} =~ /error/)
+ elsif ($level{$item} =~ /error/i)
{ $severity{$i} = $loglevel{$i} = $E_ERROR; }
- elsif ($level{$item} =~ /warning/)
+ elsif ($level{$item} =~ /warning/i)
{ $severity{$i} = $loglevel{$i} = $E_WARNING; }
else { $severity{$i} = $loglevel{$i} = $E_CRITICAL;}
@@ -251,7 +252,7 @@
&eventlog(&packevent($i)); # log event to noclogd
last;
} # if (host and regexp match)
- } # end of foreach (regexp)
+ } # end of foreach (item)
} # end of while()
$offset{$logfile} = tell(LOGFILE); # for next time
@@ -291,7 +292,7 @@
# if event expired then dont write it back.
if ($curtime > ($evttime + $expiretime)) {
- $isdone{$item} = 0;
+ $isdone{$item} = 0; # reset
if ($debug > 2) {
print STDERR "(expire_ev) Expiring Variable: \'$item\'\n";
}
diff -Nur nocol-4.2/perlnocol/testlog nocol-4.2.1/perlnocol/testlog
--- nocol-4.2/perlnocol/testlog Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/perlnocol/testlog Wed Aug 12 11:44:38 1998
@@ -0,0 +1,42 @@
+#!/usr/local/bin/perl
+#
+# $Header$
+#
+# This test program is to check if the Socket routines in nocollib.pl
+# is working.
+#
+# USAGE:
+# ./testlog [num of packets]
+# Run this and see if anything is being logged to 'noclogd' at the
+# info level.
+#
+## global variables required in the nocollib.pl library
+$varname = 'Packet';
+$varunits= 'Count' ;
+$sender = 'TESTlog';
+
+############################
+#push (@INC, '/nocol/bin');
+require "nocollib.pl" ;
+
+$debug = 5; # set to 1 for debugging output
+$libdebug = 5; # set to 1 for debugging output
+$prognm = $0; # save program name
+
+local($item) = 1;
+
+&init_event ('TestSite', 'TestAddr', $item); # fill in initial values
+
+if ($#ARGV >= 0) { $count = int($ARGV[0]); }
+else { $count = 1; }
+
+while ($count > 0)
+{
+ print "$count ";
+ $varvalue{$item} = $count;
+ &eventlog(&packevent($item));
+ --$count;
+}
+
+print "\n";
+print "Did these packets get logged by noclogd at the info level ?\n";
diff -Nur nocol-4.2/portmon/portmon.c nocol-4.2.1/portmon/portmon.c
--- nocol-4.2/portmon/portmon.c Fri Jul 31 14:32:23 1998
+++ nocol-4.2.1/portmon/portmon.c Thu Aug 13 07:32:45 1998
@@ -1,4 +1,4 @@
-/* $Header: /home/vikas/src/nocol/portmon/RCS/portmon.c,v 1.7 1998/07/31 18:32:00 vikas Exp $ */
+/* $Header: /home/vikas/src/nocol/portmon/RCS/portmon.c,v 1.8 1998/08/13 11:31:48 vikas Exp $ */
/* Copyright 1994 Vikas Aggarwal, vikas@navya.com */
@@ -22,6 +22,10 @@
/*
* $Log: portmon.c,v $
+ * Revision 1.8 1998/08/13 11:31:48 vikas
+ * Changed goto into a while() loop. Was core dumping on Solaris with
+ * gcc v2.8.1. Patch sent in by durrell@innocence.com.
+ *
* Revision 1.7 1998/07/31 18:32:00 vikas
* bug in timeout array and increased size of read buffer
*
@@ -51,7 +55,7 @@
/* */
#ifndef lint
-static char rcsid[] = "$Id: portmon.c,v 1.7 1998/07/31 18:32:00 vikas Exp $" ;
+static char rcsid[] = "$Id: portmon.c,v 1.8 1998/08/13 11:31:48 vikas Exp $" ;
#endif
#include "portmon.h"
@@ -117,39 +121,40 @@
if (readconfig(fdout) == -1)
nocol_done();
-redo:
lseek(fdout, (off_t)0, SEEK_SET); /* rewind file */
- c = 0;
- while (hostarray[c].hname)
+ while (1) /* forever */
{
- int status ;
- EVENT v;
-
- read(fdout, &v, sizeof v);
- status = checkports(&(hostarray[c])) ;
- if (status == -1)
- fprintf (stderr, "%s: Error in checkports, skipping site %s\n",
- prognm, hostarray[c].hname);
- else
+ for (c = 0; hostarray[c].hname; ++c)
{
- update_event(&v, status, /* value */ (u_long)status, maxseverity) ;
- lseek(fdout, -(off_t)sizeof(v), SEEK_CUR);
- write(fdout, (char *)&v, sizeof(v));
- }
- ++c;
- }
- lseek(fdout, (off_t)0, SEEK_SET); /* rewind file */
+ int status ;
+ EVENT v;
- if (debug)
- fprintf(stderr, "(debug) %s: sleeping for %d...zzz\n",
- prognm,pollinterval);
+ read(fdout, &v, sizeof v);
+ status = checkports(&(hostarray[c])) ;
+ if (status == -1)
+ fprintf (stderr, "%s: Error in checkports, skipping site %s\n",
+ prognm, hostarray[c].hname);
+ else
+ {
+ update_event(&v, status, /* value */ (u_long)status, maxseverity) ;
+ lseek(fdout, -(off_t)sizeof(v), SEEK_CUR);
+ write(fdout, (char *)&v, sizeof(v));
+ }
+ } /* for () */
+
+ lseek(fdout, (off_t)0, SEEK_SET); /* rewind file */
+
+ if (debug)
+ fprintf(stderr, "(debug) %s: sleeping for %d...zzz\n",
+ prognm,pollinterval);
#ifdef SVR4
- bsdsignal(SIGALRM, SIG_DFL);
+ bsdsignal(SIGALRM, SIG_DFL);
#else
- signal(SIGALRM, SIG_DFL); /* wake-up, in case blocked */
+ signal(SIGALRM, SIG_DFL); /* wake-up, in case blocked */
#endif
- sleep (pollinterval);
- goto redo ;
+ sleep (pollinterval);
+
+ } /* while (forever) */
} /* end: main() */
diff -Nur nocol-4.2/radiusmon/Makefile.mid nocol-4.2.1/radiusmon/Makefile.mid
--- nocol-4.2/radiusmon/Makefile.mid Fri Jul 31 20:35:23 1998
+++ nocol-4.2.1/radiusmon/Makefile.mid Thu Aug 27 23:28:41 1998
@@ -1,4 +1,4 @@
-# $Id: Makefile.mid,v 1.1 1998/07/31 18:52:53 vikas Exp vikas $
+# $Id: Makefile.mid,v 1.2 1998/08/28 03:28:35 vikas Exp $
#
# Makefile for 'ntpmon'
#
diff -Nur nocol-4.2/tpmon/Makefile.mid nocol-4.2.1/tpmon/Makefile.mid
--- nocol-4.2/tpmon/Makefile.mid Tue Mar 11 05:40:38 1997
+++ nocol-4.2.1/tpmon/Makefile.mid Thu Aug 27 23:28:50 1998
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.6 1994/05/23 04:00:38 vikas Exp $
+# $Id: Makefile.mid,v 1.1 1998/08/28 03:28:49 vikas Exp $
#
# Makefile for 'tpmon' (thruput monitor)
#
diff -Nur nocol-4.2/utility/Makefile.mid nocol-4.2.1/utility/Makefile.mid
--- nocol-4.2/utility/Makefile.mid Fri Jul 31 14:37:00 1998
+++ nocol-4.2.1/utility/Makefile.mid Thu Aug 27 23:42:38 1998
@@ -1,11 +1,11 @@
-# $Id: Makefile.mid,v 1.1 1998/07/31 18:37:00 vikas Exp $
+# $Id: Makefile.mid,v 1.4 1998/08/28 03:42:28 vikas Exp $
## To compile all the 'misc' utility programs for nocol
# Need TOP and OPSMAIL for doing substitutions...
#
-SCRIPTS = keepalive_monitors notifier log-maint logstats crontab.nocol \
- docrypt.pl
+SCRIPTS = keepalive_monitors log-maint logstats crontab.nocol \
+ docrypt.pl notifier.pl notifier
PROGS = display_nocol_datafile
OBJS = display_nocol_datafile.o
@@ -30,7 +30,7 @@
@echo "Doing substitutions for ROOTDIR, PIDDIR, OPSMAIL, MAIL, PSFLAGS on: " ;\
for f in $(SCRIPTS) ; do \
echo " $$f" | tr -d '\012' ;\
- sed -e '1s@^#!/.*/perl@#!$(PERL)@' \
+ sed -e '1s|^#!/.*/perl|#!$(PERL)|' \
-e "s#rOOTDIr#$(ROOTDIR)#g" \
-e "s#pIDDIr#$(PIDDIR)#g" \
-e "s#oPSMAIl#$(OPSMAIL)#g" \
@@ -39,6 +39,9 @@
-e "s#hOSt#`hostname`#g" \
-e "s#mAIl#$(MAIL)#g" \
-e "s#pSFLAGs#$(PSFLAGS)#g" \
+ -e 's|^\($$nocolroot\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)|\1 "$(ROOTDIR)" \3|' \
+ -e 's|^\($$email_program\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)|\1 "$(MAIL)" \3|' \
+ -e 's|^\($$OPSMAIL\ *=\ *\)\"\(.*\)\"\(.*SET_THIS.*\)|\1 "$(OPSMAIL)" \3|' \
$$f >$$f.seds ;\
done ;\
echo ""
diff -Nur nocol-4.2/utility/crontab.nocol nocol-4.2.1/utility/crontab.nocol
--- nocol-4.2/utility/crontab.nocol Wed Jul 29 18:32:52 1998
+++ nocol-4.2.1/utility/crontab.nocol Wed Aug 19 18:42:03 1998
@@ -1,9 +1,9 @@
## Crontab for NOCOL
## If you have a user 'nocol', then install this file as that user's cron
#
-15 * * * * rOOTDIr/bin/keepalive_monitors
-30 * * * * rOOTDIr/bin/notifier
-58 23 * * 6 rOOTDIr/bin/log-maint
+15 * * * * rOOTDIr/bin/keepalive_monitors
+0,10,20,30,40,50 * * * * rOOTDIr/bin/notifier.pl
+58 23 * * 6 rOOTDIr/bin/log-maint
#
## for html pages, run every minute
* * * * * [ -x rOOTDIr/bin/genweb.pl ] && rOOTDIr/bin/genweb.pl >/dev/null
diff -Nur nocol-4.2/utility/keepalive_monitors nocol-4.2.1/utility/keepalive_monitors
--- nocol-4.2/utility/keepalive_monitors Fri Jul 31 14:38:15 1998
+++ nocol-4.2.1/utility/keepalive_monitors Wed Aug 12 07:50:03 1998
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Header: /home/vikas/src/nocol/utility/RCS/keepalive_monitors,v 1.12 1998/07/31 18:38:11 vikas Exp $
+# $Header: /home/vikas/src/nocol/utility/RCS/keepalive_monitors,v 1.13 1998/08/12 11:49:59 vikas Exp $
#
# Make sure that the various nocol programs are doing their job and are
# not dead. Mails out the old errors file to the OPSMAIL folks.
@@ -86,13 +86,15 @@
if [ -f ${PIDDIR}/${p}.pid ]; then
PID=`head -1 ${PIDDIR}/${p}.pid`
- if [ -z $PID ]; then
- ps ${PSNUMFLAGS} $PID | grep ${p} >/dev/null 2>&1
- fi
else
+ PID=""
+ fi
+ if [ -z $PID ]; then
pgmname=`basename $p`;
ps ${PSFLAGS} 2>&1 |grep -v grep |egrep "$pgmname( |\$)" >/dev/null 2>&1
#ps ${PSFLAGS} |grep -v grep |egrep "${BIN}/${p}([ ]*|\$)" >/dev/null 2>&1
+ else
+ ps ${PSNUMFLAGS} $PID | grep ${p} >/dev/null 2>&1
fi
if [ $? = 1 ]; then # process is dead, restart
diff -Nur nocol-4.2/utility/notifier-confg nocol-4.2.1/utility/notifier-confg
--- nocol-4.2/utility/notifier-confg Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/utility/notifier-confg Wed Aug 19 19:04:37 1998
@@ -0,0 +1,61 @@
+# $Header: /home/vikas/src/nocol/utility/RCS/notifier-confg,v 1.2 1998/08/19 23:04:11 vikas Exp $
+#
+# Config file for 'notifier.pl'.
+#
+# Maps people to events (SITE:address combinations) for notification. Reads
+# updates from the 'updates' file maintained by webnocol.
+#
+# AUTHOR:
+# Adrian Close (adrian@aba.net.au)
+# Modifications- vikas@navya.com
+#
+# FORMAT:
+# Fields separated by spaces, one entry per line.
+# Paging/email entries are comma separated
+#
+# You can skip the ':varname' if you want. If you skip the event age, it
+# implies zero (no wait time, do as soon as site is down).
+#
+# Event ID Repeat paging on Paging destination(s)
+# the hour?
+# SITE:addr:varname (0=no, 1=yes) ::
+#
+# e.g.
+#
+# my.gw.net:192.168.1.1:ICMP-echo 1 bob@notifyme.com:email:5, nocol:email:0, 61417600300:page:120
+#
+# This above example sends email to bob after site is down for 5 minutes,
+# sends email to 'nocol' right away, and pages 61417600300 after 120 minutes
+###
+
+#
+# Default notification (all events not specifically listed will use this)
+#
+default 1 adrian:page:5, mwp:page:60, mattp:page:120, nocol-ops@aba.net.au:email:0
+
+# For testing purposes
+JustTesting:203.21.85.14 1 adrian:page
+TESTONLY-Ignore:192.168.1.254 1 adrian@aba.net.au:email
+AnotherTEST:192.168.1.254 1 adrian:page
+
+# Sofres (mini)servers
+sofres-nexus:203.25.255.3 0 adrian:page,mwp:page,mdonald@sofresimr.com:email,leachbj@aba.net.au:email
+sofres-miniserver:203.25.255.10 0 adrian:page,mwp:page,mdonald@sofresimr.com:email,leachbj@aba.net.au:email
+
+# ISDN Links
+ISDN-StVincent:203.25.254.10 1 61412232761.redrock:page,nocol:page
+ISDN-Ocean:203.25.254.14 1 61419311010.telstra:page,nocol:page,0413738187.redrock:page
+#ISDN-CPE:203.13.225.195 1 nocol:page
+#ISDN-CityOfMelb:203.25.254.22 1 nocol:page
+#ISDN-DoSD:203.25.254.38 1 nocol:page
+#ISDN-YarraCity:203.25.254.42 1 nocol:page
+PPP-Adacel:203.25.254.174 1 61411535163.redrock:page,nocol:page
+
+# Co-located clients
+infinet:203.36.26.66 1 61418322122.telstra:page,nocol:page
+#connect4:203.25.255.7 1 ?
+#CityOfMelb:203.36.26.65 1 ?
+equityworld-gw:203.25.255.2 1 61419852628.telstra:page,nocol:page
+
+# NRMA servers
+
diff -Nur nocol-4.2/utility/notifier.pl nocol-4.2.1/utility/notifier.pl
--- nocol-4.2/utility/notifier.pl Wed Dec 31 20:00:00 1969
+++ nocol-4.2.1/utility/notifier.pl Thu Aug 20 13:22:41 1998
@@ -0,0 +1,264 @@
+#!/usr/local/bin/perl
+#
+# $Header$
+#
+# notifier.pl for NOCOL
+#
+# Search for SET_THIS and set the value of $pager_program.
+#
+# Run this script every 5-10 minutes from crontab. Adjust $crontime
+# accordingly.
+#
+# CAVEATS:
+# Only looks at CRITICAL events.
+# Sends one email/page per event instead of grouping them together
+#
+# AUTHOR:
+# Adrian Close (adrian@aba.net.au), 1998
+# vikas@navya.com - Cleaned up for release
+#
+$nocolroot='/nocol'; # SET_THIS
+push (@INC, "$nocolroot/bin");
+
+# require 5.000;
+# require "Time::Local"; # in perl v5
+require "timelocal.pl"; # convert May 1998 into unix timestamp
+require "nocollib.pl";
+
+# set nocollib.pl debug level
+$libdebug = 0;
+$debug = 0;
+
+# Set locations of extra configuration files. 'updatesfile' is maintained
+# by 'webnocol'
+# $updatesfile = "$etcdir/exceptions";
+$updatesfile = "$etcdir/updates";
+$cfile = "$etcdir/notifier-confg";
+
+## Locations of helper programs
+$pager_program = "/usr/local/sendpage/bin/sendpage"; # SET_THIS
+$email_program = "/usr/ucb/mail"; # SET_THIS
+
+-x $pager_program || undef ($pager_program);
+-x $email_program or die "Cannot find $email_program.\n";
+
+## the default user who should get email if there is NO config file.
+# remember to put a backslash in front of the '@'
+#$OPSMAIL = "ops\@localhost";
+$OPSMAIL = "nocol-ops\@abc.domain"; # SET_THIS
+
+# The notifier should run every $crontime seconds (or less) to catch all
+# events and avoid extra pages, email etc. This is the time 'window' used
+# for catching new critical events (or repeats).
+$crontime = 600; # seconds # SET_THIS
+
+# Repeat notification interval
+# (notify again for events that are a multiple of $repeat_interval secs old)
+# Something like an hour is probably sane (i.e. 3600 secs)
+$repeat_interval = 3600; # seconds
+
+##
+# Read configuration file
+#
+# site:addr:variable \t repeat \t mail:user:3600,page:user:0
+# where
+# notify-action = method:to:min-age
+#
+sub readconf {
+
+ if (! open (CONFIG, "< $cfile")) {
+ print STDERR "Unable to open $cfile.\n" if ($debug);
+
+ $hrlyrepeat{'default'} = 1;
+ $notify{'default'} = [ $OPSMAIL . ":email" . ":0" ];
+ return;
+ }
+
+ while ()
+ {
+ chomp;
+ next if ( /^\s*\#/ || /^\s*$/ ); # comments & blank lines
+
+ if (/^(\S+)\s+([0-1])\s+(.+)/)
+ {
+ $hrlyrepeat{$1} = $2;
+ $notify{$1} = [ split (/\,/, $3) ] ; # hash of array values
+ }
+ } # while config
+ close (CONFIG);
+
+} # sub readconf()
+
+##
+# Read updates file (earlier called exceptions) for special comments on a
+# site. This file is maintained by webnocol and its syntax is:
+#
+# sitename:siteaddr:variable \t status
+# If the status begins with a (H), then the site is hidden/ignored.
+#
+sub readupdates {
+
+ if (open (UPDATESFILE, $updatesfile))
+ {
+ while ()
+ {
+ chomp;
+ next if (/^\s*\#/); # skip comments
+ next if (/^\s*$/); # skip blank lines
+ $update{$1} = $2 if (/^(\S+)\s+(.+)/); # Build $update array
+ }
+ close (UPDATESFILE);
+ }
+
+} #&readupdates
+
+
+##
+# Process Current Events
+#
+
+sub processevents {
+
+ # get all data files from NOCOL data directory
+ # (extract only those files that have '-output' as prefix)
+
+ opendir(DATADIR, "$datadir") || die "\nCannot open input directory $datadir";
+ @datafiles = sort(grep(/.+-output/i, readdir(DATADIR)));
+ closedir(DATADIR);
+
+ foreach $datafile (@datafiles)
+ {
+ open (DATAINPUT, "< $datadir/$datafile") || die "Cannot open $datafile.\n";
+ $debug && print STDERR "Processing file: $datafile\n";
+
+ # Get current month and year
+