Forum OpenACS Q&A: can't grep nsd with ps aux...

Collapse
Posted by David Kuczek on
This is probably a silly thing.

But when I do a "ps aux" I get the list with all the processes
displayed among which I find couple of:

/home/aolserver/bin/nsd -u nsadmin -g web -i -t
/home/aolserver/nsd.tcl

But if I do ps aux | grep nsd I get nothing displayed!

When I do a ps aux | grep aolserver I get couple of the following
displayed:

/home/aolserver/b

It looks like something is cut of...

This way my restart-aolserver script is not really working as it
doesn't find nsd.

killall -9 nsd is working though!

Any comments? Or would you like to have some of the stuff that I
smoked 😉

Thanks

Collapse
Posted by Jeff Davis on
On linux "ps aux" will give different results than
"ps aux | cat"; If you do "ps auxww | grep nsd" you will see the full command.  ps tries to figure out how wide your screen is and truncates the line there.  For pipes it seems to assume 80 characters by default absent the w flag.
Collapse
Posted by David Kuczek on
Great,

it is working now.

Thanks

Can anyone use ps to see the commandline of swapped out nsd's? I tried the "c" option, as the man page suggests, but ps auxc, ps auxcww, etc. don't work for me.

I worked around this a while ago by altering restart-aolserverto use the servername.nspid files. This way even swapped out nsd's can be restarted. I'll post it if anyone's interested.

Collapse
Posted by Jonathan Ellis on
From man ps:
Programs swapped out to disk will be shown without command line arguments, and unless the c option is given, in brackets.
Looks like you're out of luck with a ps-based approach. You should probably submit the fixed restart-aolserver to the sdm as well as posting it here; this sounds like a good fix to have.
Collapse
Posted by Tom Jackson on

You might try using the daemontools package to control AOLserver. I have a short HOWTO at http://zmbh.com/discussion/svc/aolserver+daemontools.html that might help. It also has some specific help for replacing restart-aolserver.

Collapse
Posted by Arjun Sanyal on
Duh! I used to read English fairly well...

I've uploaded it to new-file-storage and SDM.

Collapse
Posted by Andrew Piskorski on
Those of you using restart-aolserver are still using the one that does a "ps -ef" to figure out what process to kill? Yuck! Here's the version I use, which is based on a version from ArsDigita. (I ran the code through ns_quotehtml, so hopefully it will display without lossage here on the BBoard. ('m a little worried about the backslashes though... I think Don said that is fixed now?)

#!/usr/bin/perl
#
# $Id: restart-aolserver,v 1.2 2001/07/20 08:57:30 andy Exp $
#
## Restarts an AOLserver. Takes as its only argument the name of the server to kill.
## bquinn 6/16/2000 with help from {ryanlee, doug}@arsdigita
## This is a perl script because it needs to run setuid root,
## and perl has fewer security gotchas than most shells.
##
## Make sure that $PIDFILE points to the right location.


use strict;
undef %ENV;
$ENV{'PATH'} = '/sbin:/bin';

if (scalar(@ARGV) == 0) {
     die "Don't run this without any arguments!";
}

my $server = shift;
$server =~ /^([w-]*)$/;
my $service_name = $1;
my $PIDFILE = "/web/aol3/log/nspid.$service_name";
my $pid;

$< = $>; # set realuid to effective uid (root)

# Get the PID of the process to kill.

open(IN,"$PIDFILE") || die "No such server
";
while(<IN>) {
    chomp($_);
    $pid=$_;
}
close(IN) || die "Problem closing PID file
";

# Remove the PID file.  We have to delete the file to make sure that a subsequent call 
# to this script will kill some other process.  We delete the file before the process dies
# because if the service is set to respawn then we may delete the new pid file.

# This removing of the PID file is NOT necessary, and in leads to bugs
# as it will remove the PID file even if the kill of the process then
# fails.  Therefore, comment it out entirely.  --atp@piskorski.com,
# 2001/06/27

#my $cmd ="rm -f $PIDFILE";
#$cmd =~ /^(.*)$/;
#my $untaint_cmd = $1;
#`$untaint_cmd`;

# Issue the kill
$pid =~ /^(.*)$/;
my $untaint_pid = $1;
print "Killing $untaint_pid
";
kill 9, $untaint_pid;

# TODO: This is not so good.  We should be trying a normal kill first,
# and then ONLY using kill -9 if the normal kill fails.
# --atp@piskorski.com, 2001/06/27
Collapse
Posted by Andrew Piskorski on
Oops, the backslashes were still eaten up by Postgres. Guess I should have stuck the script into new-file-storage instead, as I just notice Arjun said he did for his version. Sorry...

I compared our two scripts very briefly. Both have some good and bad things that the other doesn't have, but I doubt it really matters, they both probably work fine. (And of course, using daemontools is a better solution anyway.)

(Since it wasn't clear to me where to put it, I didn't bother uploading my version to new-file-storage. Somebody holler if you want it, but just grabbing Arjun's should be fine.)

Collapse
Posted by David Walker on
My computer (Redhat Linux 7.0) cuts off the end of the line for the 'ps aux' command unless I make it 'ps aux -w'

If you have set up aolserver to start from inittab then issuing an ns_shutdown from a web page somewhere accomplishes a fine restart.
Collapse
Posted by Andrew Piskorski on
Egads, I just realized that I'm posting to a thread that was last live
in June.  That's what I get from blindly following links from my email
alerts without paying proper attention to who posted what when.
Obviously, you folks had long since addressed this problem before I
stuck my nose into it at all.