Commit 0a4176c1 authored by Timothy Stack's avatar Timothy Stack

Various nfstrace changes that have been sitting in my tree for awhile.

	* GNUmakefile.in: Do fs-install in the sensors subdir so the
	nfstracer gets installed.

	* sensors/and/and-emulab.priorities: Add some more daemon uid's to
	be excluded from auto-nicing.

	* sensors/and/and.c: Ignore invalid uids/gids in the config file
	instead of dying.

	* sensors/nfstrace/GNUmakefile: Makefile used to generate
	nfsdb-create.sql.

	* sensors/nfstrace/GNUmakefile.in: Some more installation stuff.

	* sensors/nfstrace/nfsdb-create.sql: SQL used to create the nfsdb
	database.

	* sensors/nfstrace/nfsdump2db: Bunch of bug fixes and cleanup.

	* sensors/nfstrace/nfsdump2db.8, sensors/nfstrace/nfstrace.7,
	sensors/nfstrace/nfstrace.proxy.8: Start at some man pages.

	* sensors/nfstrace/nfstrace.init.in: Try to detect the interface
	to listen on, not perfect though.  Add a restart handler that just
	restarts nfsdump2db.  Some other cleanup.

	* sensors/nfstrace/nfstrace.proxy: Some optimizations for
	resolving file names.

	* sensors/nfstrace/nfsdump2/*: Only print summaries of read/write
	packets and start a separate thread to read from the bpf socket.

	* tbsetup/tbswap.in: Stop transferring nfs accesses to boss' db
	until we figure out what we want to do with it.
parent be649889
......@@ -92,6 +92,7 @@ endif
fs-install:
@$(MAKE) -C tbsetup fs-install
@$(MAKE) -C sensors fs-install
opsfs-install: ops-install fs-install
@echo "Combined ops/fs install done."
......
......@@ -42,8 +42,10 @@
#
# daemon entry -- for the portmapper and such, also ignore jabber.
#
daemon * * * 0 0 0
jabber * * * 0 0 0
daemon * * * 0 0 0
jabber * * * 0 0 0
mysql * * * 0 0 0
nfstrace * * * 0 0 0
#
# The main elvind server.
......
/*
AND auto nice daemon - renice programs according to their CPU usage.
Copyright (C) 1999-2004 Patrick Schemitz <schemitz@users.sourceforge.net>
Copyright (C) 1999-2005 Patrick Schemitz <schemitz@users.sourceforge.net>
http://and.sourceforge.net/
This program is free software; you can redistribute it and/or modify
......@@ -422,7 +422,7 @@ void read_priorities ()
} else {
and_printf(0,"Priority database line %i with invalid UID: %s\n",
line_count, uid_s);
bad_count++;
// bad_count++;
continue;
}
/* Identify GID */
......@@ -435,7 +435,7 @@ void read_priorities ()
} else {
and_printf(0,"Priority database line %i with invalid GID: %s\n",
line_count, gid_s);
bad_count++;
// bad_count++;
continue;
}
/* figure parent mode */
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
#
# This makefile is different than all the others...
#
# It is intended to be run in place in the cvs tree to update the files,
# and doesn't install or build anything else. This is why it doesn't go
# through configure, etc.
#
# The easy way: do 'gmake all'
# You can also run the individual targets too.
all: db-create
db-create:
@rm -f ./.tmp-db-create.sql ./.tmp-create-diff
@sudo -u nfstrace -H mysqldump -d nfsdb > ./.tmp-db-create.sql
@-diff ./nfsdb-create.sql ./.tmp-db-create.sql > ./.tmp-create-diff
@if test -s ./.tmp-create-diff; \
then \
cat ./.tmp-create-diff; \
echo "NOTE: Don't forget to update nfsdb-migrate.txt!"; \
mv ./.tmp-db-create.sql ./nfsdb-create.sql; \
fi
@rm -f ./.tmp-create-diff ./.tmp-db-create.sql
......@@ -11,6 +11,8 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = sensors/nfstrace
NFSTRACESUPPORT = @NFSTRACESUPPORT@
include $(OBJDIR)/Makeconf
all: nfstrace.proxy nfsdump2db nfsdump nfstrace.init
......@@ -27,6 +29,8 @@ INSTALL_SBIN=$(PREFIX)/sbin
INSTALL_MAN=$(PREFIX)/man
PW=/usr/sbin/pw
NFSTRACE_HOME=/var/nfstrace
NFSTRACE_DBDIR=/var/db/nfstrace
$(SRCDIR)/nfsdump2/config.status:
cd $(SRCDIR)/nfsdump2 && ./configure
......@@ -39,31 +43,100 @@ $(SRCDIR)/nfsdump2/nfsdump: $(SRCDIR)/nfsdump2/config.status make.nfsdump
nfsdump: $(SRCDIR)/nfsdump2/nfsdump
cp $(SRCDIR)/nfsdump2/nfsdump .
client client-install:
client client-install control-install:
control-install: all
-mkdir -p $(INSTALL_DIR)/sbin
-mkdir -p $(INSTALL_DIR)/etc
-mkdir -p $(INSTALL_DIR)/etc/rc.d
$(NFSTRACE_HOME):
sudo mkdir -m 0750 $(NFSTRACE_HOME)
add-nfstrace-user: $(NFSTRACE_HOME)
@if ! id nfstrace > /dev/null 2>&1; then \
sudo $(PW) useradd nfstrace -d /nonexistent \
sudo $(PW) useradd nfstrace -d $(NFSTRACE_HOME) \
-s /sbin/nologin -u 50,200 \
-c "NFS Tracing Daemon"; \
fi
@if ! $(PW) groupshow bpf; then \
sudo $(PW) groupadd bpf; \
@if ! id -Gn mysql | grep nfstrace > /dev/null 2>&1; then \
sudo $(PW) usermod -n mysql -G "`id -Gn mysql` nfstrace"; \
fi
sudo chown nfstrace $(NFSTRACE_HOME)
sudo chgrp wheel $(NFSTRACE_HOME)
sudo chgrp nfstrace /dev/bpf0
sudo chmod g+r /dev/bpf0
$(NFSTRACE_DBDIR):
sudo mkdir -m 0750 -p $@
sudo chown nfstrace $@
sudo chgrp nfstrace $@
$(NFSTRACE_HOME)/dbpass:
head -c 32 /dev/urandom | md5 -q | head -c 8 > $@
sudo chown nfstrace $@
sudo chgrp wheel $@
sudo chmod o-r $@
@if test ! -s $@; then \
echo "error: generated empty password..."; \
rm $@; \
exit 1; \
fi
@if test ! -d /var/nfstrace; then \
sudo mkdir -m 0750 /var/nfstrace; \
$(NFSTRACE_HOME)/.my.cnf: $(NFSTRACE_HOME)/dbpass
echo "[client]" > $@
echo "user=nfstrace" >> $@
echo "password=`cat $(NFSTRACE_HOME)/dbpass`" >> $@
echo "[mysqldump]" >> $@
echo "user=nfstrace" >> $@
echo "password=`cat $(NFSTRACE_HOME)/dbpass`" >> $@
sudo chown nfstrace $@
sudo chgrp wheel $@
sudo chmod o-r $@
# XXX Needs to be updated to properly create the DB and user.
create-db: $(NFSTRACE_HOME)/.my.cnf $(NFSTRACE_DBDIR)
@if ! id mysql > /dev/null 2>&1; then \
:; \
elif sudo -u nfstrace -H mysqldump -d nfsdb > nfsdb-dump.sql; then \
perl $(TESTBED_SRCDIR)/utils/schemadiff nfsdb-dump.sql \
$(SRCDIR)/nfsdb-create.sql > nfsdb.diff; \
if test -s nfsdb.diff; then \
echo "error: nfsdb is out of sync"; \
cat nfsdb.diff; \
exit 1; \
fi \
else \
echo "create database nfsdb" | sudo -u root mysql; \
sudo -u nfstrace -H mysql nfsdb < $(SRCDIR)/nfsdb-create.sql; \
fi
sudo chown nfstrace /var/nfstrace
ifeq ($(NFSTRACESUPPORT),1)
fs-install: all add-nfstrace-user create-db
-mkdir -p $(INSTALL_DIR)/sbin
-mkdir -p $(INSTALL_DIR)/etc
-mkdir -p $(INSTALL_DIR)/etc/rc.d
$(INSTALL) -m 0755 nfsdump $(DESTDIR)$(INSTALL_SBINDIR)
$(INSTALL) -m 0755 $(SRCDIR)/nfsdump2db $(DESTDIR)$(INSTALL_SBINDIR)
$(INSTALL) -m 0755 $(SRCDIR)/nfstrace.proxy $(DESTDIR)$(INSTALL_SBINDIR)
$(INSTALL) -m 0755 nfstrace.init $(INSTALL_DIR)/etc/rc.d/nfstrace
-mkdir -p $(INSTALL_DIR)/man/man8
$(INSTALL) -m 0644 $(SRCDIR)/nfstrace.proxy.8 \
$(INSTALL_DIR)/man/man8/nfstrace.proxy.8
$(INSTALL) -m 0644 $(SRCDIR)/nfsdump2db.8 \
$(INSTALL_DIR)/man/man8/nfsdump2db.8
-mkdir -p $(INSTALL_DIR)/man/man7
$(INSTALL) -m 0644 $(SRCDIR)/nfstrace.7 \
$(INSTALL_DIR)/man/man7/nfstrace.7
install: all
$(INSTALL) -m 0755 nfsdump $(DESTDIR)$(INSTALL_SBIN)
$(INSTALL) -m 0755 $(SRCDIR)/nfsdump2db $(DESTDIR)$(INSTALL_SBIN)
$(INSTALL) -m 0755 $(SRCDIR)/nfstrace.proxy $(DESTDIR)$(INSTALL_SBIN)
$(INSTALL) -m 0755 nfstrace.init $(DESTDIR)$(INSTALL_ETC)/rc.d/nfstrace
-mkdir -p $(INSTALL_DIR)/opsdir/man/man8
$(INSTALL) -m 0644 $(SRCDIR)/nfstrace.proxy.8 \
$(INSTALL_DIR)/opsdir/man/man8/nfstrace.proxy.8
$(INSTALL) -m 0644 $(SRCDIR)/nfsdump2db.8 \
$(INSTALL_DIR)/opsdir/man/man8/nfsdump2db.8
-mkdir -p $(INSTALL_DIR)/opsdir/man/man7
$(INSTALL) -m 0644 $(SRCDIR)/nfstrace.7 \
$(INSTALL_DIR)/opsdir/man/man7/nfstrace.7
else
fs-install install:
endif
-- MySQL dump 8.23
--
-- Host: localhost Database: nfsdb
---------------------------------------------------------
-- Server version 3.23.58-log
--
-- Table structure for table `create_replies`
--
CREATE TABLE create_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fh varchar(96) NOT NULL default '',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `creates`
--
CREATE TABLE creates (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
mode int(5) default NULL,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `file_access`
--
CREATE TABLE file_access (
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
last_access double NOT NULL default '0',
PRIMARY KEY (node_ip,fh),
KEY last_access (last_access),
KEY fh (fh)
) TYPE=MyISAM;
--
-- Table structure for table `file_checkpoint`
--
CREATE TABLE file_checkpoint (
timestamp double NOT NULL default '0',
fh varchar(96) NOT NULL default '',
ftype int(3) default NULL,
mode int(5) default NULL,
nlink int(5) default NULL,
uid int(5) default NULL,
gid int(5) default NULL,
size int(10) default NULL,
rdev int(10) default NULL,
fsid int(10) default NULL,
fileid int(10) default NULL,
atime double default NULL,
mtime double default NULL,
ctime double default NULL,
PRIMARY KEY (fh)
) TYPE=MyISAM;
--
-- Table structure for table `file_dropped`
--
CREATE TABLE file_dropped (
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
last_remove double NOT NULL default '0',
PRIMARY KEY (node_ip,fh),
KEY last_remove (last_remove),
KEY fh (fh)
) TYPE=MyISAM;
--
-- Table structure for table `file_writes`
--
CREATE TABLE file_writes (
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
last_access double NOT NULL default '0',
PRIMARY KEY (node_ip,fh),
KEY fh (fh),
KEY last_access (last_access)
) TYPE=MyISAM;
--
-- Table structure for table `handle_map`
--
CREATE TABLE handle_map (
fh varchar(96) NOT NULL default '',
parent varchar(96) NOT NULL default '',
fn text NOT NULL,
timestamp double NOT NULL default '0',
valid int(1) NOT NULL default '0',
PRIMARY KEY (fh,parent,fn(255)),
KEY fh (fh),
KEY parent (parent,fn(255)),
KEY parent_2 (parent),
KEY valid (valid)
) TYPE=MyISAM;
--
-- Table structure for table `link_access`
--
CREATE TABLE link_access (
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text NOT NULL,
last_access double NOT NULL default '0',
PRIMARY KEY (node_ip,fh),
KEY last_access (last_access),
KEY fh (fh)
) TYPE=MyISAM;
--
-- Table structure for table `lookup_replies`
--
CREATE TABLE lookup_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fh varchar(96) NOT NULL default '',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp)
) TYPE=MyISAM;
--
-- Table structure for table `lookup_replies_tmp`
--
CREATE TABLE lookup_replies_tmp (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fh varchar(96) NOT NULL default '',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp)
) TYPE=MyISAM;
--
-- Table structure for table `lookups`
--
CREATE TABLE lookups (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp)
) TYPE=MyISAM;
--
-- Table structure for table `lookups_tmp`
--
CREATE TABLE lookups_tmp (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp)
) TYPE=MyISAM;
--
-- Table structure for table `mkdir_replies`
--
CREATE TABLE mkdir_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fh varchar(96) NOT NULL default '',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `mkdirs`
--
CREATE TABLE mkdirs (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
mode int(5) default NULL,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `mknods`
--
CREATE TABLE mknods (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `mount_replies`
--
CREATE TABLE mount_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fh text,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `mounts`
--
CREATE TABLE mounts (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fn text,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `node_ids`
--
CREATE TABLE node_ids (
node_id varchar(32) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
pid varchar(32) NOT NULL default '',
eid varchar(32) NOT NULL default '',
PRIMARY KEY (node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `packet_stats`
--
CREATE TABLE packet_stats (
table_name varchar(32) NOT NULL default '',
stamp datetime NOT NULL default '0000-00-00 00:00:00',
packet_count int(10) NOT NULL default '0',
PRIMARY KEY (table_name,stamp)
) TYPE=MyISAM;
--
-- Table structure for table `readlink_replies`
--
CREATE TABLE readlink_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
fn text,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `readlinks`
--
CREATE TABLE readlinks (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `reads`
--
CREATE TABLE reads (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
amount int(10) default NULL,
euid int(5) default NULL,
egid int(5) default NULL,
total int(10) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp)
) TYPE=MyISAM;
--
-- Table structure for table `remove_replies`
--
CREATE TABLE remove_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp,status)
) TYPE=MyISAM;
--
-- Table structure for table `removes`
--
CREATE TABLE removes (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
fh varchar(96) NOT NULL default '',
fn text,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY fn (fn(255))
) TYPE=MyISAM;
--
-- Table structure for table `rename_handle_map`
--
CREATE TABLE rename_handle_map (
fh varchar(96) NOT NULL default '',
parent varchar(96) NOT NULL default '',
fn text NOT NULL,
timestamp double NOT NULL default '0',
PRIMARY KEY (parent,fn(255))
) TYPE=MyISAM;
--
-- Table structure for table `rename_replies`
--
CREATE TABLE rename_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `renames`
--
CREATE TABLE renames (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
from_fh varchar(96) NOT NULL default '',
from_fn text,
to_fh varchar(96) NOT NULL default '',
to_fn text,
euid int(5) default NULL,
egid int(5) default NULL,
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip)
) TYPE=MyISAM;
--
-- Table structure for table `rmdir_replies`
--
CREATE TABLE rmdir_replies (
timestamp double NOT NULL default '0',
id varchar(16) NOT NULL default '',
node_ip varchar(64) NOT NULL default '',
status int(3) NOT NULL default '0',
PRIMARY KEY (timestamp,id,node_ip),
KEY id (id,node_ip),
KEY timestamp (timestamp,status)
) TYPE=MyISAM;
--
-- Table structure for table `rmdirs`
--