🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #2599

fixing the nnmaster "stall" problem

#2599
From: Richard Steinberger
Date: Thu, 19 Mar 1992 19:54
100 lines
3634 bytes
Kim Storm gave me a few suggestions I used to help deal with the
"stalled nnmaster" problem.  This is a condition that can occur on
NNTP client machines.  The symptom is the message that no updates have
taken place for some time when nn is started.  Kim's suggestion was to
check the age of the directory containing the ACTIVE file.  If it doesn't
stay relatively "young", kill nnmaster and restart it.

Here are two files I used to try to accomplish this:

File 1 is a Bourne shell script that I invoke from cron every 30 minutes.
There is nothing sacred about 30 minutes.  Almost any interval is OK.
File 2 is a C++ file used by file 1 to get the "age" in seconds of a 
file, in this case the /var/spool/nn directory.  This file could
easily be changed to C by replacing the lines with // in them with
standard C comments.  cerr and cout would mutate into fprintf
stderr and stdout.

Warning: I haven't yet seen a case where nnmaster has stalled again.
So, I haven't seen that it is really restarted again properly.  It's
supposed to send me email if this occurs.

--------------file--1-------------------------------------------------------
#!/bin/sh
#
# nnmaster sometimes stalls sometimes.  If the location of the directory
# where ACTIVE lives is not touched regularly, assume a stall.  
# Restart nnmaster.
#
# Ric Steinberger
# 19 March, 1992
#
STALL_AGE_LIMIT=3600             #time limit in seconds
ACTIVE_DIR=/var/spool/nn         #directory containing ACTIVE file
TOOL_DIR=/usr/tools/sys          #directory with get_file_age program

if [ `$TOOL_DIR/get_file_age $ACTIVE_DIR` -lt $STALL_AGE_LIMIT ]; then
	exit 0
fi
#
# nnmaster hasn't updated in at least STALL_AGE_LIMIT seconds
# Might as we restart it.  See /etc/rc.local for boot startup sequence.
# Try it without the -C option (consistency check) for now.
#
if [ -f /usr/local/lib/nn/nnmaster ]; then
        rm -f /usr/local/lib/nn/MPID
        /usr/local/lib/nn/nnmaster -k -l -r 20
fi
mail ric << EOF
nnmaster restarted from cron.
EOF

exit 0

-----------------file--2------------------------------------------------------

// get_file_age - Use stat to print out the age of a file.

// Usage:  get_file_age filename

#include <iostream.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/file.h>

const int EXIT_FAILURE = -1;
const int EXIT_SUCCESS =  0;

main(int argc, char *argv[])
{
  if (argc < 2)
    {
      cerr << "Usage: " << argv[0] << " filename\n";
      exit(EXIT_FAILURE);
    }

  if (access(argv[1],0))
    {
      cerr << "get_file_age: File " << argv[1] << " not found.\n";
      exit(EXIT_FAILURE);
    }

  struct stat sbuf;
  if (stat(argv[1], &sbuf))
    {
      cerr << argv[0] << ": Error return from stat call.\n";
      exit(EXIT_FAILURE);
    }

//  cout << "Status change time: " << sbuf.st_ctime << endl;

  time_t now, tnow;
  now = time(&tnow);

//  cout << "File age (secs): " << now - sbuf.st_ctime << endl;

  cout << now - sbuf.st_ctime << endl;
}
 
Technical Details
Message-ID: <ric.701034863@updike>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!stanford.edu!unix!updike!ric

Show Full Headers
Complete Article Headers
Message-ID: <ric.701034863@updike>
Subject: fixing the nnmaster "stall" problem
Date: Thu, 19 Mar 1992 19:54:23 +0000
From: ric@updike.sri.com (Richard Steinberger)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!stanford.edu!unix!updike!ric
Newsgroups: news.software.nn
Keywords: nnmaster
Sender: news@unix.SRI.COM
Lines: 100