From 77124f36b20ba41f2b37dca2dba480d343d7946b Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Wed, 28 May 2008 22:46:41 +0000
Subject: [PATCH] make sstat

---
 NEWS                                |    2 +
 configure                           |    3 +-
 configure.ac                        |    1 +
 doc/man/Makefile.am                 |    1 +
 doc/man/Makefile.in                 |    2 +
 doc/man/man1/sacctmgr.1             |    6 +-
 doc/man/man1/sstat.1                |  262 +++++++
 src/Makefile.am                     |    2 +-
 src/Makefile.in                     |    2 +-
 src/sacct/sacct.c                   |    5 +
 src/sstat/Makefile.am               |   14 +-
 src/sstat/Makefile.in               |   45 +-
 src/sstat/options.c                 |  971 ++---------------------
 src/sstat/print.c                   | 1103 ++++-----------------------
 src/sstat/process.c                 |    2 +-
 src/sstat/sacct.c                   |  206 -----
 src/sstat/{sacct_stat.c => sstat.c} |  108 ++-
 src/sstat/{sacct.h => sstat.h}      |   61 +-
 18 files changed, 639 insertions(+), 2157 deletions(-)
 create mode 100644 doc/man/man1/sstat.1
 delete mode 100644 src/sstat/sacct.c
 rename src/sstat/{sacct_stat.c => sstat.c} (72%)
 rename src/sstat/{sacct.h => sstat.h} (65%)

diff --git a/NEWS b/NEWS
index 7a0170a7cc4..9f9f4f5006a 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ documents those changes that are of interest to users and admins.
  -- In TaskPlugin=task/affinity, fix possible infinite loop for slurmd.
  -- Accounting rollup works for mysql plugin.  Automatic rollup when using 
     slurmdbd.
+ -- Copied job stat logic out of sacct into sstat in the future sacct -stat 
+    will be deprecated.
 
 * Changes in SLURM 1.3.2
 ========================
diff --git a/configure b/configure
index 50e40830c09..e0ef7611418 100755
--- a/configure
+++ b/configure
@@ -26965,7 +26965,7 @@ _ACEOF
 
 
 
-ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile contribs/Makefile contribs/perlapi/Makefile contribs/perlapi/libslurm-perl/Makefile.PL contribs/torque/Makefile contribs/phpext/Makefile contribs/phpext/slurm_php/config.m4 src/Makefile src/api/Makefile src/common/Makefile src/database/Makefile src/sacct/Makefile src/sacctmgr/Makefile src/sreport/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmdbd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/accounting_storage/Makefile src/plugins/accounting_storage/filetxt/Makefile src/plugins/accounting_storage/gold/Makefile src/plugins/accounting_storage/mysql/Makefile src/plugins/accounting_storage/pgsql/Makefile src/plugins/accounting_storage/none/Makefile src/plugins/accounting_storage/slurmdbd/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/checkpoint/ompi/Makefile src/plugins/checkpoint/xlch/Makefile src/plugins/crypto/Makefile src/plugins/crypto/munge/Makefile src/plugins/crypto/openssl/Makefile src/plugins/jobacct_gather/Makefile src/plugins/jobacct_gather/linux/Makefile src/plugins/jobacct_gather/aix/Makefile src/plugins/jobacct_gather/none/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/jobcomp/mysql/Makefile src/plugins/jobcomp/pgsql/Makefile src/plugins/jobcomp/slurmdbd/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_p4/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mpichmx/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
+ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile contribs/Makefile contribs/perlapi/Makefile contribs/perlapi/libslurm-perl/Makefile.PL contribs/torque/Makefile contribs/phpext/Makefile contribs/phpext/slurm_php/config.m4 src/Makefile src/api/Makefile src/common/Makefile src/database/Makefile src/sacct/Makefile src/sacctmgr/Makefile src/sreport/Makefile src/sstat/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmdbd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/accounting_storage/Makefile src/plugins/accounting_storage/filetxt/Makefile src/plugins/accounting_storage/gold/Makefile src/plugins/accounting_storage/mysql/Makefile src/plugins/accounting_storage/pgsql/Makefile src/plugins/accounting_storage/none/Makefile src/plugins/accounting_storage/slurmdbd/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/checkpoint/ompi/Makefile src/plugins/checkpoint/xlch/Makefile src/plugins/crypto/Makefile src/plugins/crypto/munge/Makefile src/plugins/crypto/openssl/Makefile src/plugins/jobacct_gather/Makefile src/plugins/jobacct_gather/linux/Makefile src/plugins/jobacct_gather/aix/Makefile src/plugins/jobacct_gather/none/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/jobcomp/mysql/Makefile src/plugins/jobcomp/pgsql/Makefile src/plugins/jobcomp/slurmdbd/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_p4/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mpichmx/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -27697,6 +27697,7 @@ do
     "src/sacct/Makefile") CONFIG_FILES="$CONFIG_FILES src/sacct/Makefile" ;;
     "src/sacctmgr/Makefile") CONFIG_FILES="$CONFIG_FILES src/sacctmgr/Makefile" ;;
     "src/sreport/Makefile") CONFIG_FILES="$CONFIG_FILES src/sreport/Makefile" ;;
+    "src/sstat/Makefile") CONFIG_FILES="$CONFIG_FILES src/sstat/Makefile" ;;
     "src/salloc/Makefile") CONFIG_FILES="$CONFIG_FILES src/salloc/Makefile" ;;
     "src/sbatch/Makefile") CONFIG_FILES="$CONFIG_FILES src/sbatch/Makefile" ;;
     "src/sattach/Makefile") CONFIG_FILES="$CONFIG_FILES src/sattach/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 385a69f9bdf..ee9068ac6ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,7 @@ AC_CONFIG_FILES([Makefile
 		 src/sacct/Makefile
 		 src/sacctmgr/Makefile
 		 src/sreport/Makefile
+		 src/sstat/Makefile
 		 src/salloc/Makefile 
 		 src/sbatch/Makefile 
 		 src/sattach/Makefile
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 6f26a535585..e8d06ea88ab 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -16,6 +16,7 @@ man1_MANS =            \
 	man1/squeue.1 \
 	man1/sreport.1 \
 	man1/srun.1 \
+	man1/sstat.1 \
 	man1/strigger.1 \
 	man1/sview.1
 
diff --git a/doc/man/Makefile.in b/doc/man/Makefile.in
index 81e6c0a6ac2..109e32167ad 100644
--- a/doc/man/Makefile.in
+++ b/doc/man/Makefile.in
@@ -255,7 +255,9 @@ man1_MANS = \
 	man1/slurm.1 \
 	man1/smap.1 \
 	man1/squeue.1 \
+	man1/sreport.1 \
 	man1/srun.1 \
+	man1/sstat.1 \
 	man1/strigger.1 \
 	man1/sview.1
 
diff --git a/doc/man/man1/sacctmgr.1 b/doc/man/man1/sacctmgr.1
index 4f715d7415f..74b2b16b526 100644
--- a/doc/man/man1/sacctmgr.1
+++ b/doc/man/man1/sacctmgr.1
@@ -1,13 +1,13 @@
 .TH SACCTMGR "1" "May 2008" "sacctmgr 1.3" "Slurm components"
 
 .SH "NAME"
-sacctmgr \- Used view and modify Slurm account information.
+sacctmgr \- Used to view and modify Slurm account information.
 
 .SH "SYNOPSIS"
-\fBssacctmgr\fR [\fIOPTIONS\fR...] [\fICOMMAND\fR...]
+\fBsacctmgr\fR [\fIOPTIONS\fR...] [\fICOMMAND\fR...]
 
 .SH "DESCRIPTION"
-\fBssacctmgr\fR is used to view or modify Slurm account information.
+\fBsacctmgr\fR is used to view or modify Slurm account information.
 The account information is maintained within a database with the interface 
 being provided by \fBslurmdbd\fR (Slurm Database daemon).
 This database can serve as a central storehouse of user and 
diff --git a/doc/man/man1/sstat.1 b/doc/man/man1/sstat.1
new file mode 100644
index 00000000000..d8ca661fc7d
--- /dev/null
+++ b/doc/man/man1/sstat.1
@@ -0,0 +1,262 @@
+.TH SSTAT "1" "May 2008" "sacctmgr 1.3" "Slurm components"
+
+.SH "NAME"
+sstat \- Used to query running job and see various usage information
+of job/step running.
+
+.SH "SYNOPSIS"
+.BR "sstat "
+\fBsstat\fR [\fIOPTIONS\fR...] 
+
+.SH "DESCRIPTION"
+.PP
+Status information for jobs invoked with SLURM.
+.PP
+The 
+.BR "sstat "
+command displays job accounting data stored in the job accounting log 
+file in a variety of forms for your analysis.
+The 
+.BR "sstat "
+command displays information on jobs, job steps, status, and exitcodes by 
+default.
+You can tailor the output with the use of the 
+\f3\-\-fields=\fP 
+option to specify the fields to be shown.
+.PP
+For the root user, the 
+.BR "sstat "
+command displays job status data for any job running on the system.
+.PP
+For the non\-root user, the 
+.BR "sstat "
+command limits the display of job status data to jobs that were 
+launched with their own user identifier (UID) by default.
+
+.SS "Options"
+.TP "10"
+
+.TP "3"
+\(bu
+\f3jobid\fP 
+.IP 
+and 
+\f3\-\-fields=\fP 
+options.
+.IP 
+
+.TP 
+\f3\-F \fP\f2field_list\fP \f3,\fP  \f3\-\-fields\fP\f3=\fP\f2field_list\fP
+Displays the job status data specified by the 
+\f2field_list\fP 
+operand, which is a comma\-separated list of fields.
+Space characters are not allowed in the 
+\f2field_list\fP\c
+\&. 
+.IP 
+See the 
+\f3\-\-help\-fields\fP 
+option for a list of the available fields.
+See the section titled "Job Status Fields" for a description of 
+each field.
+.IP 
+The job accounting data is displayed in the order specified by the 
+\f2field_list\fP 
+operand.
+Thus, the following two commands display the same data but in different order:
+.RS 
+.PP
+.nf 
+.ft 3
+# sstat \-\-fields=jobid,state
+Jobid    State
+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-
+3          COMPLETED
+3.0        COMPLETED
+
+.ft 1
+.fi 
+.RE 
+.RS 
+.PP
+.nf 
+.ft 3
+# sacct \-\-fields=status,jobid
+State     Jobid
+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-
+COMPLETED  3
+COMPLETED  3.0
+
+.ft 1
+.fi 
+.RE 
+.IP 
+The default value for the 
+\f2field_list\fP 
+operand is 
+\f3"jobid,vsize,rss,pages,cputime,ntasks,state"\fP\c
+\&.
+.IP 
+This option has no effect when the 
+\f3\-\-dump\fP 
+option is also specified.
+
+
+.TP 
+\f3\-h \fP\f3,\fP \f3\-\-help\fP
+Displays a general help message.
+.TP 
+\f3\-\-help\-fields\fP
+Displays a list of fields that can be specified with the 
+\f3\-\-fields\fP 
+option.
+.RS 
+.PP
+.nf 
+.ft 3
+Fields available:
+cputime     jobid       ntasks      pages
+rss         state       vsize
+
+.ft 1
+.fi 
+.RE 
+.IP 
+The section titled "Job Accounting Fields" describes these fields.
+
+.TP 
+\f3\-j \fP\f2job(.step)\fP \f3,\fP  \f3\-\-jobs\fP\f3=\fP\f2job(.step)\fP
+Displays information about the specified job(.step) or list of job(.step)s.
+.IP 
+The 
+\f2job(.step)\fP 
+parameter is a comma\-separated list of jobs.
+Space characters are not permitted in this list.
+.IP 
+The default is to display information on all jobs.
+
+.TP 
+\f3\-\-noheader\fP
+Prevents the display of the heading over the output.
+The default action is to display a header.
+.IP 
+This option has no effect when used with the 
+\f3\-\-dump\fP 
+option.
+
+\f3\-S \fP\f3,\fP \f3\-\-stat\fP
+.IP
+Queries the status of a job as the job is running displaying
+the following data:
+.RS 
+.TP "3"
+\(bu
+\f3jobid\fP 
+.TP "3"
+\(bu
+\f3vsize\fP 
+.TP "3"
+\(bu
+\f3rss\fP 
+.TP "3"
+\(bu
+\f3pages\fP 
+.TP "3"
+\(bu
+\f3cputime\fP 
+.TP "3"
+\(bu
+\f3ntasks\fP 
+.TP "3"
+\(bu
+\f3status\fP 
+.RE 
+.IP
+You must also include the \-\-jobs=job(.step) option if no (.step) is 
+given you will recieve the job.0 step.
+
+.TP 
+\f3\-\-usage\fP
+Displays a help message.
+
+.TP 
+\f3\-v \fP\f3,\fP \f3\-\-verbose\fP
+Reports the state of certain variables during processing.
+This option is primarily used for debugging.
+
+.SS "Job Status Fields"
+The following describes each job accounting field:
+.RS 
+.TP
+\f3cputime\fP
+Minimum CPU time of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP 
+\f3jobid\fP 
+The number of the job or job step.
+It is in the form: 
+\f2job.jobstep\fP\c
+\&.
+
+.TP
+\f3ntasks\fP 
+Total number of tasks in job.
+
+.TP
+\f3pages\fP
+Maximum page faults of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP 
+\f3rss\fP 
+Maximum resident set size of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP
+\f3state\fP
+Displays the job state.
+.IP 
+Output can be 
+\f3RUNNING\fP\c
+\&, 
+\f3SUSPENDED\fP\c
+\&,
+\f3COMPLETED\fP\c
+\&, 
+\f3CANCELLED\fP\c
+\&, 
+\f3FAILED\fP\c
+\&, 
+\f3TIMEOUT\fP\c
+\&, or 
+\f3NODE_FAIL\fP\c
+\&.
+
+.TP
+\f3vsize\fP
+Maximum Virtual Memory size of any process followed by its task id along with
+the average of all processes running in the step.
+
+.SH "EXAMPLES"
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "SEE ALSO"
+\fBsacct\fR(1)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9790924e041..a852e7d97c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,5 +2,5 @@
 SUBDIRS = common api database \
 	slurmctld slurmd slurmdbd plugins srun sbcast \
 	scontrol scancel squeue sinfo smap sview salloc \
-	sbatch sattach strigger sacct sacctmgr sreport
+	sbatch sattach strigger sacct sacctmgr sreport sstat
 
diff --git a/src/Makefile.in b/src/Makefile.in
index d1d05ce6f21..a7366a69a61 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -248,7 +248,7 @@ top_srcdir = @top_srcdir@
 SUBDIRS = common api database \
 	slurmctld slurmd slurmdbd plugins srun sbcast \
 	scontrol scancel squeue sinfo smap sview salloc \
-	sbatch sattach strigger sacct sacctmgr sreport
+	sbatch sattach strigger sacct sacctmgr sreport sstat
 
 all: all-recursive
 
diff --git a/src/sacct/sacct.c b/src/sacct/sacct.c
index 962502e3ced..8206aaf844e 100644
--- a/src/sacct/sacct.c
+++ b/src/sacct/sacct.c
@@ -305,6 +305,11 @@ int main(int argc, char **argv)
 			do_list();
 		break;
 	case SACCT_STAT:
+		fprintf(stderr,
+			"This functionality has been replaced with 'sstat' "
+			"in the future please make note this will "
+			"not be supported.");
+		
 		if (params.opt_header) 	/* give them something to look */
 			_print_header();/* at while we think...        */
 		do_stat();
diff --git a/src/sstat/Makefile.am b/src/sstat/Makefile.am
index 4b25bcca7f7..cdb0a0c6ead 100644
--- a/src/sstat/Makefile.am
+++ b/src/sstat/Makefile.am
@@ -1,20 +1,20 @@
-# Makefile for sacct
+# Makefile for sstat
 
 AUTOMAKE_OPTIONS = foreign
 
 INCLUDES = -I$(top_srcdir)
 
-bin_PROGRAMS = sacct
+bin_PROGRAMS = sstat
 
-sacct_LDADD = 	$(top_builddir)/src/common/libcommon.o -ldl \
+sstat_LDADD = 	$(top_builddir)/src/common/libcommon.o -ldl \
 	$(top_builddir)/src/api/libslurmhelper.la
 
-noinst_HEADERS = sacct.c 
-sacct_SOURCES = sacct.c process.c print.c options.c sacct_stat.c
+noinst_HEADERS = sstat.c 
+sstat_SOURCES = sstat.c process.c print.c options.c
 
 force:
-$(sacct_LDADD) : force
+$(sstat_LDADD) : force
 	 @cd `dirname $@` && $(MAKE) `basename $@`
 
-sacct_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+sstat_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
diff --git a/src/sstat/Makefile.in b/src/sstat/Makefile.in
index c3a7b5a9bf0..d752d24b74d 100644
--- a/src/sstat/Makefile.in
+++ b/src/sstat/Makefile.in
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# Makefile for sacct
+# Makefile for sstat
 
 
 VPATH = @srcdir@
@@ -36,8 +36,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-bin_PROGRAMS = sacct$(EXEEXT)
-subdir = src/sacct
+bin_PROGRAMS = sstat$(EXEEXT)
+subdir = src/sstat
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -72,13 +72,13 @@ CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_sacct_OBJECTS = sacct.$(OBJEXT) process.$(OBJEXT) print.$(OBJEXT) \
-	options.$(OBJEXT) sacct_stat.$(OBJEXT)
-sacct_OBJECTS = $(am_sacct_OBJECTS)
-sacct_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
+am_sstat_OBJECTS = sstat.$(OBJEXT) process.$(OBJEXT) print.$(OBJEXT) \
+	options.$(OBJEXT)
+sstat_OBJECTS = $(am_sstat_OBJECTS)
+sstat_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
 	$(top_builddir)/src/api/libslurmhelper.la
-sacct_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sacct_LDFLAGS) \
+sstat_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sstat_LDFLAGS) \
 	$(LDFLAGS) -o $@
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
@@ -92,8 +92,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(sacct_SOURCES)
-DIST_SOURCES = $(sacct_SOURCES)
+SOURCES = $(sstat_SOURCES)
+DIST_SOURCES = $(sstat_SOURCES)
 HEADERS = $(noinst_HEADERS)
 ETAGS = etags
 CTAGS = ctags
@@ -267,12 +267,12 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir)
-sacct_LDADD = $(top_builddir)/src/common/libcommon.o -ldl \
+sstat_LDADD = $(top_builddir)/src/common/libcommon.o -ldl \
 	$(top_builddir)/src/api/libslurmhelper.la
 
-noinst_HEADERS = sacct.c 
-sacct_SOURCES = sacct.c process.c print.c options.c sacct_stat.c
-sacct_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+noinst_HEADERS = sstat.c 
+sstat_SOURCES = sstat.c process.c print.c options.c
+sstat_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -286,9 +286,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/sacct/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/sstat/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/sacct/Makefile
+	  $(AUTOMAKE) --foreign  src/sstat/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -334,9 +334,9 @@ clean-binPROGRAMS:
 	  echo " rm -f $$p $$f"; \
 	  rm -f $$p $$f ; \
 	done
-sacct$(EXEEXT): $(sacct_OBJECTS) $(sacct_DEPENDENCIES) 
-	@rm -f sacct$(EXEEXT)
-	$(sacct_LINK) $(sacct_OBJECTS) $(sacct_LDADD) $(LIBS)
+sstat$(EXEEXT): $(sstat_OBJECTS) $(sstat_DEPENDENCIES) 
+	@rm -f sstat$(EXEEXT)
+	$(sstat_LINK) $(sstat_OBJECTS) $(sstat_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -347,8 +347,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacct.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacct_stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sstat.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -557,7 +556,7 @@ uninstall-am: uninstall-binPROGRAMS
 
 
 force:
-$(sacct_LDADD) : force
+$(sstat_LDADD) : force
 	 @cd `dirname $@` && $(MAKE) `basename $@`
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/sstat/options.c b/src/sstat/options.c
index 330b6254884..a1aafaa40e9 100644
--- a/src/sstat/options.c
+++ b/src/sstat/options.c
@@ -1,5 +1,5 @@
 /*****************************************************************************\
- *  options.c - option functions for sacct
+ *  options.c - option functions for sstat
  *
  *  $Id: options.c 7541 2006-03-18 01:44:58Z da $
  *****************************************************************************
@@ -38,47 +38,14 @@
 \*****************************************************************************/
 
 #include "src/common/read_config.h"
-#include "sacct.h"
+#include "sstat.h"
 #include <time.h>
 
-void _destroy_parts(void *object);
-void _destroy_steps(void *object);
 void _help_fields_msg(void);
 void _help_msg(void);
 void _usage(void);
 void _init_params();
 
-int selected_state[STATE_COUNT];
-List selected_parts = NULL;
-List selected_steps = NULL;
-void *acct_db_conn = NULL;
-
-void _destroy_parts(void *object)
-{
-	char *part = (char *)object;
-	xfree(part);
-}
-
-void _destroy_steps(void *object)
-{
-	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
-	if(step) {
-		xfree(step->job);
-		xfree(step->step);
-		xfree(step);
-	}
-}
-
-void _show_rec(char *f[])
-{
-	int 	i;
-	fprintf(stderr, "rec>");
-	for (i=0; f[i]; i++)
-		fprintf(stderr, " %s", f[i]);
-	fprintf(stderr, "\n");
-	return;
-}
-
 void _help_fields_msg(void)
 {
 	int i;
@@ -96,81 +63,15 @@ void _help_fields_msg(void)
 
 void _help_msg(void)
 {
-	slurm_ctl_conf_t *conf = slurm_conf_lock();
 	printf("\n"
-	       "By default, sacct displays accounting data for all jobs and job\n"
-	       "steps that are present in the log.\n"
-	       "\n"
-	       "Notes:\n"
-	       "\n"
-	       "    * If --dump is specified,\n"
-	       "          * The field selection options (--brief, --fields, ...)\n"
-	       "	    have no effect\n"
-	       "	  * Elapsed time fields are presented as 2 fields, integral\n"
-	       "	    seconds and integral microseconds\n"
-	       "    * If --dump is not specified, elapsed time fields are presented\n"
-	       "      as [[days-]hours:]minutes:seconds.hundredths\n"
-	       "    * The default input file is the file named in the \"jobacct_logfile\"\n"
-	       "      parameter in %s.\n"
-	       "\n"
+	       "By default, sstat displays status data for job/step stated\n"
 	       "Options:\n"
-	       "\n"
-	       "-a, --all\n"
-	       "    Display job accounting data for all users. By default, only\n"
-	       "    data for the current user is displayed for users other than\n"
-	       "    root.\n"
-	       "-b, --brief\n"
-	       "    Equivalent to \"--fields=jobstep,state,error\". This option\n"
-	       "    has no effect if --dump is specified.\n"
-	       "-c, --completion\n"
-	       "    Use job completion instead of accounting data.\n"
 	       "-C, --cluster\n"
-	       "    Only send data about this cluster.\n"
-	       "-d, --dump\n"
-	       "    Dump the raw data records\n"
-	       "--duplicates\n"
-	       "    If SLURM job ids are reset, but the job accounting log file\n"
-	       "    isn't reset at the same time (with -e, for example), some\n"
-	       "    job numbers will probably appear more than once in the\n"
-	       "    accounting log file to refer to different jobs; such jobs\n"
-	       "    can be distinguished by the \"submit\" time stamp in the\n"
-	       "    data records.\n"
-	       "      When data for specific jobs are requested with\n"
-	       "    the --jobs option, we assume that the user\n"
-	       "    wants to see only the most recent job with that number. This\n"
-	       "    behavior can be overridden by specifying --duplicates, in\n"
-	       "    which case all records that match the selection criteria\n"
-	       "    will be returned.\n"
-	       "      When --jobs is not specified, we report\n"
-	       "    data for all jobs that match the selection criteria, even if\n"
-	       "    some of the job numbers are reused. Specify that you only\n"
-	       "    want the most recent job for each selected job number with\n"
-	       "    the --noduplicates option.\n"
-	       "-e <timespec>, --expire=<timespec>\n"
-	       "    Remove jobs from SLURM's current accounting log file (or the\n"
-	       "    file specified with --file) that completed more than <timespec>\n"
-	       "    ago.  If <timespec> is an integer, it is interpreted as\n" 
-	       "    minutes. If <timespec> is an integer followed by \"h\", it is\n"
-	       "    interpreted as a number of hours. If <timespec> is an integer\n"
-	       "    followed by \"d\", it is interpreted as number of days. For\n"
-	       "    example, \"--expire=14d\" means that you wish to purge the job\n"
-	       "    accounting log of all jobs that completed more than 14 days ago.\n" 
+	       "    Job is running on this cluster.\n"
 	       "-F <field-list>, --fields=<field-list>\n"
 	       "    Display the specified data (use \"--help-fields\" for a\n"
 	       "    list of available fields). If no field option is specified,\n"
-	       "    we use \"--fields=jobstep,jobname,partition,alloc_cpus,state,error\".\n"
-	       "-f<file>, --file=<file>\n"
-	       "    Read data from the specified file, rather than SLURM's current\n"
-	       "    accounting log file.\n"
-	       "-l, --long\n"
-	       "    Equivalent to specifying\n"
-	       "    \"--fields=jobstep,usercpu,systemcpu,minflt,majflt,nprocs,\n"
-	       "    alloc_cpus,elapsed,state,exitcode\"\n"
-	       "-O, --formatted_dump\n"
-	       "    Dump accounting records in an easy-to-read format, primarily\n"
-	       "    for debugging.\n"
-	       "-g <gid>, --gid <gid>\n"
-	       "    Select only jobs submitted from the <gid> group.\n"
+	       "    we use \"--fields=jobid,vsize,rss,pages,cputime,ntasks,state\".\n"
 	       "-h, --help\n"
 	       "    Print a general help message.\n"
 	       "--help-fields\n"
@@ -180,43 +81,40 @@ void _help_msg(void)
 	       "    Display information about this job or comma-separated\n"
 	       "    list of jobs. The default is all jobs. Adding .step will\n"
 	       "    display the specfic job step of that job.\n"
-	       "--noduplicates\n"
-	       "    See the discussion under --duplicates.\n"
 	       "--noheader\n"
 	       "    Print (or don't print) a header. The default is to print a\n"
 	       "    header; the option has no effect if --dump is specified\n"
-	       "-p <part_list>, --partition=<part_list>\n"
-	       "    Display or purge information about jobs and job steps in the\n"
-	       "    <part_list> partition(s). The default is all partitions.\n"
-	       "-P --purge\n"
-	       "    Used in conjunction with --expire to remove invalid data\n"
-	       "    from the job accounting log.\n"
-	       "-s <state-list>, --state=<state-list>\n"
-	       "    Select jobs based on their current state: running (r),\n"
-	       "    completed (cd), failed (f), timeout (to), and node_fail (nf).\n"
-	       "-S, --stat\n"
-	       "    Get real time state of a jobstep supplied by the -j\n"
-	       "    option\n" 
-	       "-t, --total\n"
-	       "    Only show cumulative statistics for each job, not the\n"
-	       "    intermediate steps\n"
-	       "-u <uid>, --uid <uid>\n"
-	       "    Select only jobs submitted by the user with uid <uid>.  Only\n"
-	       "    root users are allowed to specify a uid other than their own -1 for all users.\n"
 	       "--usage\n"
 	       "    Pointer to this message.\n"
 	       "-v, --verbose\n"
 	       "    Primarily for debugging purposes, report the state of various\n"
-	       "    variables during processing.\n", conf->slurm_conf);
-
-	slurm_conf_unlock();
+	       "    variables during processing.\n");
 
 	return;
 }
 
 void _usage(void)
 {
-	printf("\nUsage: sacct [options]\n\tUse --help for help\n");
+	printf("\nUsage: sstat [options]\n\tUse --help for help\n");
+}
+
+
+void _do_help(void)
+{
+	switch (params.opt_help) {
+	case 1:
+		_help_msg();
+		break;
+	case 2:
+		_help_fields_msg();
+		break;
+	case 3:
+		_usage();
+		break;
+	default:
+		fprintf(stderr, "sacct bug: params.opt_help=%d\n", 
+			params.opt_help);
+	}
 }
 
 void _init_params()
@@ -267,111 +165,30 @@ int decode_state_char(char *state)
 		return -1; // unknown
 } 
 
-int get_data(void)
-{
-	jobacct_job_rec_t *job = NULL;
-	jobacct_step_rec_t *step = NULL;
-
-	ListIterator itr = NULL;
-	ListIterator itr_step = NULL;
-
-	if(params.opt_completion) {
-		jobs = g_slurm_jobcomp_get_jobs(selected_steps,
-						selected_parts, &params);
-		return SLURM_SUCCESS;
-	} else {
-		jobs = jobacct_storage_g_get_jobs(acct_db_conn,
-						  selected_steps,
-						  selected_parts, &params);
-	}
-
-	if (params.opt_fdump) 
-		return SLURM_SUCCESS;
-
-	if(!jobs)
-		return SLURM_ERROR;
-
-	itr = list_iterator_create(jobs);
-	while((job = list_next(itr))) {
-		if(job->user) {
-			struct	passwd *pw = NULL;		 
-			if ((pw=getpwnam(job->user)))
-				job->uid = pw->pw_uid;
-		}
-		
-		if(!list_count(job->steps)) 
-			continue;
-		
-		itr_step = list_iterator_create(job->steps);
-		while((step = list_next(itr_step)) != NULL) {
-			/* now aggregate the aggregatable */
-			job->alloc_cpus = MAX(job->alloc_cpus, step->ncpus);
-
-			if(step->state < JOB_COMPLETE)
-				continue;
-			job->tot_cpu_sec += step->tot_cpu_sec;
-			job->tot_cpu_usec += step->tot_cpu_usec;
-			job->user_cpu_sec +=
-				step->user_cpu_sec;
-			job->user_cpu_usec +=
-				step->user_cpu_usec;
-			job->sys_cpu_sec +=
-				step->sys_cpu_sec;
-			job->sys_cpu_usec +=
-				step->sys_cpu_usec;
-			/* get the max for all the sacct_t struct */
-			aggregate_sacct(&job->sacct, &step->sacct);
-		}
-		list_iterator_destroy(itr_step);
-	}
-	list_iterator_destroy(itr);
-
-	return SLURM_SUCCESS;
-} 
-
-void parse_command_line(int argc, char **argv)
+void parse_command_line(int argc, char **argv, List selected_steps)
 {
 	extern int optind;
 	int c, i, optionIndex = 0;
-	char *end = NULL, *start = NULL, *acct_type = NULL;
+	char *end = NULL, *start = NULL;
 	jobacct_selected_step_t *selected_step = NULL;
 	ListIterator itr = NULL;
-	struct stat stat_buf;
 	char *dot = NULL;
-	bool brief_output = FALSE, long_output = FALSE;
+	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
 
 	static struct option long_options[] = {
-		{"all", 0,0, 'a'},
-		{"brief", 0, 0, 'b'},
 		{"cluster", 1, 0, 'C'},
-		{"completion", 0, &params.opt_completion, 'c'},
-		{"duplicates", 0, &params.opt_dup, 1},
-		{"dump", 0, 0, 'd'},
-		{"expire", 1, 0, 'e'},
 		{"fields", 1, 0, 'F'},
-		{"file", 1, 0, 'f'},
-		{"formatted_dump", 0, 0, 'O'},
-		{"stat", 0, 0, 'S'},
-		{"gid", 1, 0, 'g'},
-		{"group", 1, 0, 'g'},
 		{"help", 0, &params.opt_help, 1},
 		{"help-fields", 0, &params.opt_help, 2},
 		{"jobs", 1, 0, 'j'},
-		{"long", 0, 0, 'l'},
-		{"big_logfile", 0, &params.opt_lowmem, 1},
-		{"noduplicates", 0, &params.opt_dup, 0},
 		{"noheader", 0, &params.opt_header, 0},
-		{"partition", 1, 0, 'p'},
-		{"purge", 0, 0, 'P'},
-		{"state", 1, 0, 's'},
-		{"total", 0, 0,  't'},
-		{"uid", 1, 0, 'u'},
 		{"usage", 0, &params.opt_help, 3},
-		{"user", 1, 0, 'u'},
 		{"verbose", 0, 0, 'v'},
 		{"version", 0, 0, 'V'},
 		{0, 0, 0, 0}};
 
+	log_init(xbasename(argv[0]), logopt, 0, NULL);
+
 	_init_params();
 
 	if ((i=getuid()))
@@ -381,76 +198,16 @@ void parse_command_line(int argc, char **argv)
 	opterr = 1;		/* Let getopt report problems to the user */
 
 	while (1) {		/* now cycle through the command line */
-		c = getopt_long(argc, argv, "abcC:de:F:f:g:hj:J:lOPp:s:StUu:Vv",
+		c = getopt_long(argc, argv, "C:F:hj:Vv",
 				long_options, &optionIndex);
 		if (c == -1)
 			break;
 		switch (c) {
-		case 'a':
-			params.opt_uid = -1;
-			break;
-		case 'b':
-			brief_output = true;
-			break;
-		case 'c':
-			params.opt_completion = 1;
-			break;
 		case 'C':
 			params.opt_cluster = xstrdup(optarg);
 			break;
-		case 'd':
-			params.opt_dump = 1;
-			break;
-
-		case 'e':
-		{	/* decode the time spec */
-			long	acc=0;
-			params.opt_expire_timespec = xstrdup(optarg);
-			for (i=0; params.opt_expire_timespec[i]; i++) {
-				char	c = params.opt_expire_timespec[i];
-				if (isdigit(c)) {
-					acc = (acc*10)+(c-'0');
-					continue;
-				}
-				switch (c) {
-				case 'D':
-				case 'd':
-					params.opt_expire += 
-						acc*SECONDS_IN_DAY;
-					acc=0;
-					break;
-				case 'H':
-				case 'h':
-					params.opt_expire += 
-						acc*SECONDS_IN_HOUR;
-						acc=0;
-					break;
-				case 'M':
-				case 'm':
-					params.opt_expire += 
-						acc*SECONDS_IN_MINUTE;
-					acc=0;
-					break;
-				default:
-					params.opt_expire = -1;
-					goto bad_timespec;
-				} 
-			}
-			params.opt_expire += acc*SECONDS_IN_MINUTE;
-		bad_timespec:
-			if (params.opt_expire <= 0) {
-				fprintf(stderr,
-					"Invalid timspec for "
-					"--expire: \"%s\"\n",
-					params.opt_expire_timespec);
-				exit(1);
-			}
-		}
-		params.opt_uid = -1;	/* fix default; can't purge by uid */
-		break;
-
 		case 'F':
-			if(params.opt_stat)
+			if(params.opt_field_list)
 				xfree(params.opt_field_list);
 			
 			params.opt_field_list =
@@ -461,32 +218,9 @@ void parse_command_line(int argc, char **argv)
 			strcat(params.opt_field_list, optarg);
 			strcat(params.opt_field_list, ",");
 			break;
-
-		case 'f':
-			params.opt_filein =
-				xrealloc(params.opt_filein, strlen(optarg)+1);
-			strcpy(params.opt_filein, optarg);
-			break;
-
-		case 'g':
-			if (isdigit((int) *optarg))
-				params.opt_gid = atoi(optarg);
-			else {
-				struct group *grp;
-				if ((grp=getgrnam(optarg))==NULL) {
-					fprintf(stderr,
-						"Invalid group id: %s\n",
-						optarg);
-					exit(1);
-				}
-				params.opt_gid=grp->gr_gid;
-			}
-			break;
-
 		case 'h':
 			params.opt_help = 1;
 			break;
-
 		case 'j':
 			if ((strspn(optarg, "0123456789, ") < strlen(optarg))
 			    && (strspn(optarg, ".0123456789, ") 
@@ -503,72 +237,6 @@ void parse_command_line(int argc, char **argv)
 			strcat(params.opt_job_list, optarg);
 			strcat(params.opt_job_list, ",");
 			break;
-
-		case 'l':
-			long_output = true;
-			break;
-
-		case 'O':
-			params.opt_fdump = 1;
-			break;
-
-		case 'P':
-			params.opt_purge = 1;
-			break;
-
-		case 'p':
-			params.opt_partition_list =
-				xrealloc(params.opt_partition_list,
-					 (params.opt_partition_list==NULL? 0 :
-					  strlen(params.opt_partition_list)) +
-					 strlen(optarg) + 1);
-			strcat(params.opt_partition_list, optarg);
-			strcat(params.opt_partition_list, ",");
-			break;
-
-		case 's':
-			params.opt_state_list =
-				xrealloc(params.opt_state_list,
-					 (params.opt_state_list==NULL? 0 :
-					  strlen(params.opt_state_list)) +
-					 strlen(optarg) + 1);
-			strcat(params.opt_state_list, optarg);
-			strcat(params.opt_state_list, ",");
-			break;
-
-		case 'S':
-			if(!params.opt_field_list) {
-				params.opt_field_list = 
-					xmalloc(sizeof(STAT_FIELDS)+1);
-				strcat(params.opt_field_list, STAT_FIELDS);
-				strcat(params.opt_field_list, ",");
-			}
-			params.opt_stat = 1;
-			break;
-
-		case 't':
-			params.opt_total = 1;
-			break;
-
-		case 'U':
-			params.opt_help = 3;
-			break;
-
-		case 'u':
-			if (isdigit((int) *optarg) || atoi(optarg) == -1)
-				params.opt_uid = atoi(optarg);
-			else {
-				struct passwd *pwd;
-				if ((pwd=getpwnam(optarg))==NULL) {
-					fprintf(stderr, 
-						"Invalid user id: %s\n",
-						optarg);
-					exit(1);
-				}
-				params.opt_uid=pwd->pw_uid;
-			}
-			break;
-
 		case 'v':
 			/* Handle -vvv thusly...
 			 * 0 - report only normal messages and errors
@@ -599,110 +267,54 @@ void parse_command_line(int argc, char **argv)
 		}
 	}
 
-	/* Now set params.opt_dup, unless they've already done so */
-	if (params.opt_dup < 0)	/* not already set explicitly */
-		if (params.opt_job_list)
-			/* They probably want the most recent job N if
-			 * they requested specific jobs or steps. */
-			params.opt_dup = 0;
+	if(params.opt_help) {
+		_do_help();
+		exit(0);
+	}
+
+	if (optind < argc) {
+		optarg = argv[optind];
+		if ((strspn(optarg, "0123456789, ") < strlen(optarg))
+		    && (strspn(optarg, ".0123456789, ") 
+			< strlen(optarg))) {
+			fprintf(stderr, "Invalid jobs list: %s\n",
+				optarg);
+			exit(1);
+		}
+		params.opt_job_list =
+			xrealloc(params.opt_job_list,
+				 (params.opt_job_list==NULL? 0 :
+				  strlen(params.opt_job_list)) +
+				 strlen(optarg) + 1);
+		strcat(params.opt_job_list, optarg);
+		strcat(params.opt_job_list, ",");
+	}
+
+	if(!params.opt_field_list) {
+		params.opt_field_list = 
+			xmalloc(sizeof(STAT_FIELDS)+1);
+		strcat(params.opt_field_list, STAT_FIELDS);
+		strcat(params.opt_field_list, ",");
+	}
+
 
 	if (params.opt_verbose) {
 		fprintf(stderr, "Options selected:\n"
 			"\topt_cluster=%s\n"
-			"\topt_completion=%d\n"
-			"\topt_dump=%d\n"
-			"\topt_dup=%d\n"
-			"\topt_expire=%s (%lu seconds)\n"
-			"\topt_fdump=%d\n"
-			"\topt_stat=%d\n"
 			"\topt_field_list=%s\n"
-			"\topt_filein=%s\n"
 			"\topt_header=%d\n"
 			"\topt_help=%d\n"
 			"\topt_job_list=%s\n"
-			"\topt_long=%d\n"
-			"\topt_lowmem=%d\n"
-			"\topt_partition_list=%s\n"
-			"\topt_purge=%d\n"
-			"\topt_state_list=%s\n"
-			"\topt_total=%d\n"
-			"\topt_uid=%d\n"
 			"\topt_verbose=%d\n",
 			params.opt_cluster,
-			params.opt_completion,
-			params.opt_dump,
-			params.opt_dup,
-			params.opt_expire_timespec, params.opt_expire,
-			params.opt_fdump,
-			params.opt_stat,
 			params.opt_field_list,
-			params.opt_filein,
 			params.opt_header,
 			params.opt_help,
 			params.opt_job_list,
-			params.opt_long,
-			params.opt_lowmem,
-			params.opt_partition_list,
-			params.opt_purge,
-			params.opt_state_list,
-			params.opt_total,
-			params.opt_uid,
 			params.opt_verbose);
-	}
+		logopt.stderr_level += params.opt_verbose;
+		log_alter(logopt, 0, NULL);
 
-	/* check if we have accounting data to view */
-	if (params.opt_filein == NULL) {
-		if(params.opt_completion) 
-			params.opt_filein = slurm_get_jobcomp_loc();
-		else
-			params.opt_filein = slurm_get_accounting_storage_loc();
-	}
-
-	if(params.opt_completion) {
-		g_slurm_jobcomp_init(params.opt_filein);
-
-		acct_type = slurm_get_jobcomp_type();
-		if ((strcmp(acct_type, "jobcomp/none") == 0)
-		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
-			fprintf(stderr, "SLURM job completion is disabled\n");
-			exit(1);
-		}
-		xfree(acct_type);
-	} else {
-		slurm_acct_storage_init(params.opt_filein);
-		acct_db_conn = acct_storage_g_get_connection(false, false);
-		
-		acct_type = slurm_get_accounting_storage_type();
-		if ((strcmp(acct_type, "accounting_storage/none") == 0)
-		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
-			fprintf(stderr,
-				"SLURM accounting storage is disabled\n");
-			exit(1);
-		}
-		xfree(acct_type);
-	}
-
-	/* specific partitions requested? */
-	if (params.opt_partition_list) {
-
-		start = params.opt_partition_list;
-		while ((end = strstr(start, ",")) && start) {
-			*end = 0;
-			while (isspace(*start))
-				start++;	/* discard whitespace */
-			if(!(int)*start)
-				continue;
-			acct_type = xstrdup(start);
-			list_append(selected_parts, acct_type);
-			start = end + 1;
-		}
-		if (params.opt_verbose) {
-			fprintf(stderr, "Partitions requested:\n");
-			itr = list_iterator_create(selected_parts);
-			while((start = list_next(itr))) 
-				fprintf(stderr, "\t: %s\n", start);
-			list_iterator_destroy(itr);
-		}
 	}
 
 	/* specific jobs requested? */
@@ -748,77 +360,6 @@ void parse_command_line(int argc, char **argv)
 		}
 	}
 
-	/* specific states (completion state) requested? */
-	if (params.opt_state_list) {
-		start = params.opt_state_list;
-		while ((end = strstr(start, ",")) && start) {
-			int c;
-			*end = 0;
-			while (isspace(*start))
-				start++;	/* discard whitespace */
-			if(!(int)*start)
-				continue;
-			c = decode_state_char(start);
-			if (c == -1)
-				fatal("unrecognized job state value");
-			selected_state[c] = 1;
-			start = end + 1;
-		}
-		if (params.opt_verbose) {
-			fprintf(stderr, "States requested:\n");
-			for(i=0; i< STATE_COUNT; i++) {
-				if(selected_state[i]) {
-					fprintf(stderr, "\t: %s\n", 
-						job_state_string(i));
-					break;
-				}
-			}
-		}
-	}
-
-	/* select the output fields */
-	if(brief_output) {
-		if(params.opt_completion)
-			dot = BRIEF_COMP_FIELDS;
-		else
-			dot = BRIEF_FIELDS;
-		
-		params.opt_field_list =
-			xrealloc(params.opt_field_list,
-				 (params.opt_field_list==NULL? 0 :
-				  sizeof(params.opt_field_list)) +
-				 strlen(dot)+1);
-		strcat(params.opt_field_list, dot);
-		strcat(params.opt_field_list, ",");
-	} 
-
-	if(long_output) {
-		if(params.opt_completion)
-			dot = LONG_COMP_FIELDS;
-		else
-			dot = LONG_FIELDS;
-		
-		params.opt_field_list =
-			xrealloc(params.opt_field_list,
-				 (params.opt_field_list==NULL? 0 :
-				  strlen(params.opt_field_list)) +
-				 strlen(dot)+1);
-		strcat(params.opt_field_list, dot);
-		strcat(params.opt_field_list, ",");
-	} 
-	
-	if (params.opt_field_list==NULL) {
-		if (params.opt_dump || params.opt_expire)
-			goto endopt;
-		if(params.opt_completion)
-			dot = DEFAULT_COMP_FIELDS;
-		else
-			dot = DEFAULT_FIELDS;
-		params.opt_field_list = xmalloc(strlen(dot)+1);
-		strcpy(params.opt_field_list, dot); 
-		strcat(params.opt_field_list, ",");
-	}
-
 	start = params.opt_field_list;
 	while ((end = strstr(start, ","))) {
 		*end = 0;
@@ -838,6 +379,7 @@ void parse_command_line(int argc, char **argv)
 		printfields[nprintfields++] = i;
 		start = end + 1;
 	}
+
 	if (params.opt_verbose) {
 		fprintf(stderr, "%d field%s selected:\n",
 			nprintfields,
@@ -847,387 +389,8 @@ void parse_command_line(int argc, char **argv)
 				"\t%s\n",
 				fields[printfields[i]].name);
 	} 
-endopt:
-	if (optind < argc) {
-		fprintf(stderr, "Error: Unknown arguments:");
-		for (i=optind; i<argc; i++)
-			fprintf(stderr, " %s", argv[i]);
-		fprintf(stderr, "\n");
-		exit(1);
-	}
-	return;
-}
-
-/* Note: do_dump() strives to present data in an upward-compatible
- * manner so that apps written to use data from `sacct -d` in slurm
- * v1.0 will continue to work in v1.1 and later.
- *
- * To help ensure this compatibility,
- * a. The meaning of an existing field never changes
- * b. New fields are appended to the end of a record
- *
- * The "numfields" field of the record can be used as a sub-version
- * number, as it will never decrease for the life of the current
- * record version number (currently 1). For example, if your app needs
- * to use field 28, a record with numfields<28 is too old a version
- * for you, while numfields>=28 will provide what you are expecting.
- */ 
-void do_dump(void)
-{
-	ListIterator itr = NULL;
-	ListIterator itr_step = NULL;
-	jobacct_job_rec_t *job = NULL;
-	jobacct_step_rec_t *step = NULL;
-	struct tm ts;
-	
-	itr = list_iterator_create(jobs);
-	while((job = list_next(itr))) {
-		if (params.opt_uid>=0)
-			if (job->uid != params.opt_uid)
-				continue;
-		if(job->sacct.min_cpu == (float)NO_VAL)
-			job->sacct.min_cpu = 0;
-		
-		if(list_count(job->steps)) {
-			job->sacct.ave_cpu /= list_count(job->steps);
-			job->sacct.ave_rss /= list_count(job->steps);
-			job->sacct.ave_vsize /= list_count(job->steps);
-			job->sacct.ave_pages /= list_count(job->steps);
-		}
-
-		/* JOB_START */
-		if (job->show_full) {
-			gmtime_r(&job->start, &ts);
-			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
-			       job->jobid,
-			       job->partition,
-			       1900+(ts.tm_year),
-			       1+(ts.tm_mon),
-			       ts.tm_mday,
-			       ts.tm_hour,
-			       ts.tm_min,
-			       ts.tm_sec,
-			       (int)job->submit,
-			       job->blockid,	/* block id */
-			       "-");	/* reserved 1 */
-
-			printf("JOB_START 1 16 %d %d %s %d %d %d %s %s\n", 
-			       job->uid,
-			       job->gid,
-			       job->jobname,
-			       job->track_steps,
-			       job->priority,
-			       job->alloc_cpus,
-			       job->nodes,
-			       job->account);
-		}
-		/* JOB_STEP */
-		itr_step = list_iterator_create(job->steps);
-		while((step = list_next(itr_step))) {
-			gmtime_r(&step->start, &ts);
-			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
-			       job->jobid,
-			       job->partition,
-			       1900+(ts.tm_year),
-			       1+(ts.tm_mon),
-			       ts.tm_mday,
-			       ts.tm_hour,
-			       ts.tm_min,
-			       ts.tm_sec,
-			       (int)job->submit,
-			       job->blockid,	/* block id */
-			       "-");	/* reserved 1 */
-			if(step->end == 0)
-				step->end = job->end;
-				
-			gmtime_r(&step->end, &ts);
-			printf("JOB_STEP 1 50 %u %04d%02d%02d%02d%02d%02d ",
-			       step->stepid,
-			       1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
-			            ts.tm_hour, ts.tm_min, ts.tm_sec);
-			printf("%s %d %d %d %d ",
-			       job_state_string_compact(step->state),
-			       step->exitcode,
-			       step->ncpus,
-			       step->ncpus,
-			       step->elapsed);
-			printf("%d %d %d %d %d %d %d %d",
-			       step->tot_cpu_sec,
-			       step->tot_cpu_usec,
-			       (int)step->user_cpu_sec,
-			       (int)step->user_cpu_usec,
-			       (int)step->sys_cpu_sec,
-			       (int)step->sys_cpu_usec,
-			       step->sacct.max_vsize/1024, 
-			       step->sacct.max_rss/1024);
-			/* Data added in Slurm v1.1 */
-			printf("%u %u %.2f %u %u %.2f %d %u %u %.2f "
-			       "%.2f %u %u %.2f %s %s %s\n",
-			       step->sacct.max_vsize_id.nodeid,
-			       step->sacct.max_vsize_id.taskid,
-			       step->sacct.ave_vsize/1024,
-			       step->sacct.max_rss_id.nodeid,
-			       step->sacct.max_rss_id.taskid,
-			       step->sacct.ave_rss/1024,
-			       step->sacct.max_pages,
-			       step->sacct.max_pages_id.nodeid,
-			       step->sacct.max_pages_id.taskid,
-			       step->sacct.ave_pages,
-			       step->sacct.min_cpu,
-			       step->sacct.min_cpu_id.nodeid,
-			       step->sacct.min_cpu_id.taskid,
-			       step->sacct.ave_cpu,
-			       step->stepname,
-			       step->nodes,
-			       job->account);
-		}
-		list_iterator_destroy(itr_step);
-		/* JOB_TERMINATED */
-		if (job->show_full) {
-			gmtime_r(&job->start, &ts);
-			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
-			       job->jobid,
-			       job->partition,
-			       1900+(ts.tm_year),
-			       1+(ts.tm_mon),
-			       ts.tm_mday,
-			       ts.tm_hour,
-			       ts.tm_min,
-			       ts.tm_sec,
-			       (int)job->submit,
-			       job->blockid,	/* block id */
-			       "-");	/* reserved 1 */
-			gmtime_r(&job->end, &ts);
-			printf("JOB_TERMINATED 1 50 %d ",
-			       job->elapsed);
-			printf("%04d%02d%02d%02d%02d%02d ",
-			1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
-			      ts.tm_hour, ts.tm_min, ts.tm_sec); 
-			printf("%s %d %d %d %d ",
-			       job_state_string_compact(job->state),
-			       job->exitcode,
-			       job->alloc_cpus,
-			       job->alloc_cpus,
-			       job->elapsed);
-			printf("%d %d %d %d %d %d %d %d",
-			       job->tot_cpu_sec,
-			       job->tot_cpu_usec,
-			       (int)job->user_cpu_sec,
-			       (int)job->user_cpu_usec,
-			       (int)job->sys_cpu_sec,
-			       (int)job->sys_cpu_usec,
-			       job->sacct.max_vsize/1024, 
-			       job->sacct.max_rss/1024);
-			/* Data added in Slurm v1.1 */
-			printf("%u %u %.2f %u %u %.2f %d %u %u %.2f "
-			       "%.2f %u %u %.2f %s %s %s %d\n",
-			       job->sacct.max_vsize_id.nodeid,
-			       job->sacct.max_vsize_id.taskid,
-			       job->sacct.ave_vsize/1024,
-			       job->sacct.max_rss_id.nodeid,
-			       job->sacct.max_rss_id.taskid,
-			       job->sacct.ave_rss/1024,
-			       job->sacct.max_pages,
-			       job->sacct.max_pages_id.nodeid,
-			       job->sacct.max_pages_id.taskid,
-			       job->sacct.ave_pages,
-			       job->sacct.min_cpu,
-			       job->sacct.min_cpu_id.nodeid,
-			       job->sacct.min_cpu_id.taskid,
-			       job->sacct.ave_cpu,
-			       "-",
-			       job->nodes,
-			       job->account,
-			       job->requid);			
-		}
-	}
-	list_iterator_destroy(itr);		
-}
-
-void do_dump_completion(void)
-{
-	ListIterator itr = NULL;
-	jobcomp_job_rec_t *job = NULL;
-		
-	itr = list_iterator_create(jobs);
-	while((job = list_next(itr))) {
-		printf("JOB %u %s %s %s %s(%u) %u(%s) %u %s %s %s %s",
-		       job->jobid, job->partition, job->start_time,
-		       job->end_time, job->uid_name, job->uid, job->gid,
-		       job->gid_name, job->node_cnt, job->nodelist, 
-		       job->jobname, job->state,
-		       job->timelimit);
-#ifdef HAVE_BG
-		if(job->blockid)
-			printf(" %s %s %s %s %u %s %s",
-			       job->blockid, job->connection, job->reboot,
-			       job->rotate, job->max_procs, job->geo,
-			       job->bg_start_point);
-#endif
-		printf("\n");
-	}
-	list_iterator_destroy(itr);
-}
 
-/* do_expire() -- purge expired data from the accounting log file
- */
-
-void do_expire(int dummy)
-{
-	if (dummy == NO_VAL) {
-		/* just load the symbol, don't want to execute */
-		slurm_reconfigure();
-	}
-
-	if(params.opt_completion) 
-		g_slurm_jobcomp_archive(selected_parts, &params);
-	else
-		jobacct_storage_g_archive(acct_db_conn,
-					  selected_parts, &params);
-}
-
-void do_help(void)
-{
-	switch (params.opt_help) {
-	case 1:
-		_help_msg();
-		break;
-	case 2:
-		_help_fields_msg();
-		break;
-	case 3:
-		_usage();
-		break;
-	default:
-		fprintf(stderr, "sacct bug: params.opt_help=%d\n", 
-			params.opt_help);
-	}
-}
-
-/* do_list() -- List the assembled data
- *
- * In:	Nothing explicit.
- * Out:	void.
- *
- * At this point, we have already selected the desired data,
- * so we just need to print it for the user.
- */
-void do_list(void)
-{
-	int do_jobsteps = 1;
-	
-	ListIterator itr = NULL;
-	ListIterator itr_step = NULL;
-	jobacct_job_rec_t *job = NULL;
-	jobacct_step_rec_t *step = NULL;
-	
-	if (params.opt_total)
-		do_jobsteps = 0;
-	itr = list_iterator_create(jobs);
-	while((job = list_next(itr))) {
-		/* FIX ME: this should be handled while getting the
-		   data, not afterwards.
-		*/
-		if (params.opt_uid >= 0 && (job->uid != params.opt_uid))
-			continue;
-		if (params.opt_gid >= 0 && (job->gid != params.opt_gid))
-			continue;
-		if(job->sacct.min_cpu == NO_VAL)
-			job->sacct.min_cpu = 0;
-
-		if(list_count(job->steps)) {
-			job->sacct.ave_cpu /= list_count(job->steps);
-			job->sacct.ave_rss /= list_count(job->steps);
-			job->sacct.ave_vsize /= list_count(job->steps);
-			job->sacct.ave_pages /= list_count(job->steps);
-		}
-
-		if (job->show_full) {
-			if (params.opt_state_list) {
-				if(!selected_state[job->state])
-					continue;
-			}
-			print_fields(JOB, job);
-		}
-		
-		if (do_jobsteps && (job->track_steps || !job->show_full)) {
-			itr_step = list_iterator_create(job->steps);
-			while((step = list_next(itr_step))) {
-				if (params.opt_state_list) {
-					if(!selected_state[step->state])
-						continue;
-				}
-				if(step->end == 0)
-					step->end = job->end;
-				print_fields(JOBSTEP, step);
-			} 
-			list_iterator_destroy(itr_step);
-		}
-	}
-	list_iterator_destroy(itr);
-}
-
-/* do_list_completion() -- List the assembled data
- *
- * In:	Nothing explicit.
- * Out:	void.
- *
- * At this point, we have already selected the desired data,
- * so we just need to print it for the user.
- */
-void do_list_completion(void)
-{
-	ListIterator itr = NULL;
-	jobcomp_job_rec_t *job = NULL;
-	
-	itr = list_iterator_create(jobs);
-	while((job = list_next(itr))) {
-		if (params.opt_uid >= 0 && (job->uid != params.opt_uid))
-			continue;
-		if (params.opt_gid >= 0 && (job->gid != params.opt_gid))
-			continue;
-		print_fields(JOBCOMP, job);
-	}
-	list_iterator_destroy(itr);
+	return;
 }
 
-void do_stat()
-{
-	ListIterator itr = NULL;
-	uint32_t jobid = 0;
-	uint32_t stepid = 0;
-	jobacct_selected_step_t *selected_step = NULL;
-	
-	itr = list_iterator_create(selected_steps);
-	while((selected_step = list_next(itr))) {
-		jobid = atoi(selected_step->job);
-		if(selected_step->step)
-			stepid = atoi(selected_step->step);
-		else
-			stepid = 0;
-		sacct_stat(jobid, stepid);
-	}
-	list_iterator_destroy(itr);
-}
-void sacct_init()
-{
-	int i=0;
-	selected_parts = list_create(_destroy_parts);
-	selected_steps = list_create(_destroy_steps);
-	for(i=0; i<STATE_COUNT; i++)
-		selected_state[i] = 0;
-}
 
-void sacct_fini()
-{
-	if(jobs)
-		list_destroy(jobs);
-	list_destroy(selected_parts);
-	list_destroy(selected_steps);
-	if(params.opt_completion)
-		g_slurm_jobcomp_fini();
-	else {
-		acct_storage_g_close_connection(&acct_db_conn);
-		slurm_acct_storage_fini();
-	}
-}
diff --git a/src/sstat/print.c b/src/sstat/print.c
index 61a70f8e4f8..0ff252c9d25 100644
--- a/src/sstat/print.c
+++ b/src/sstat/print.c
@@ -37,7 +37,7 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include "sacct.h"
+#include "sstat.h"
 #include "src/common/parse_time.h"
 #include "slurm.h"
 #define FORMAT_STRING_SIZE 34
@@ -81,7 +81,7 @@ void _elapsed_time(long secs, long usecs, char *str)
 		         minutes, seconds, subsec);
 }
 
-void print_fields(type_t type, void *object)
+extern void print_fields(type_t type, void *object)
 {
 	int f, pf;
 	for (f=0; f<nprintfields; f++) {
@@ -95,505 +95,7 @@ void print_fields(type_t type, void *object)
 
 /* Field-specific print routines */
 
-void print_cpu(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char str[FORMAT_STRING_SIZE];
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-15s", "Cpu");
-		break;
-	case UNDERSCORE:
-		printf("%-15s", "---------------");
-		break;
-	case JOB:
-		_elapsed_time(job->tot_cpu_sec, job->tot_cpu_usec, str);
-		printf("%-15s", str);
-		break;
-	case JOBSTEP:
-		_elapsed_time(step->tot_cpu_sec, step->tot_cpu_usec, str);
-		printf("%-15s", str);
-		break;
-	default:
-		printf("%-15s", "n/a");
-		break;
-	} 
-}
-
-void print_elapsed(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char str[FORMAT_STRING_SIZE];
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-15s", "Elapsed");
-		break;
-	case UNDERSCORE:
-		printf("%-15s", "---------------");
-		break;
-	case JOB:
-		_elapsed_time(job->elapsed, 0, str);
-		printf("%-15s", str);
-		break;
-	case JOBSTEP:
-		_elapsed_time(step->elapsed, 0, str);
-		printf("%-15s", str);
-		break;
-	default:
-		printf("%-15s", "n/a");
-		break;
-	} 
-}
-
-void print_exitcode(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char tmp[9];
-	uint16_t term_sig = 0;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-8s", "ExitCode");
-		break;
-	case UNDERSCORE:
-		printf("%-8s", "--------");
-		break;
-	case JOB:
-		if (WIFSIGNALED(job->exitcode))
-			term_sig = WTERMSIG(job->exitcode);
-	
-		snprintf(tmp, sizeof(tmp), "%u:%u",
-			 WEXITSTATUS(job->exitcode), term_sig);
-		printf("%-8s", tmp);
-		break;
-	case JOBSTEP:
-		if (WIFSIGNALED(step->exitcode))
-			term_sig = WTERMSIG(step->exitcode);
-	
-		snprintf(tmp, sizeof(tmp), "%u:%u",
-			 WEXITSTATUS(step->exitcode), term_sig);
-		printf("%-8s", tmp);
-		break;
-	default:
-		printf("%-8s", "n/a");
-		break;
-	} 
-}
-
-void print_gid(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	int32_t gid = -1;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-5s", "Gid");
-		break;
-	case UNDERSCORE:
-		printf("%-5s", "-----");
-		break;
-	case JOB:
-		gid = job->gid;
-		break;
-	case JOBCOMP:
-		printf("%-5u", jobcomp->gid);
-		break;
-	case JOBSTEP:
-		printf("%-5s", " ");
-		break;
-	default:
-		printf("%-5s", "n/a");
-		break;
-	} 
-
-	if(gid != -1) 
-		printf("%-5d", gid);
-}
-
-void print_group(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	int gid = -1;
-	char	*tmp="(unknown)";
-	struct	group *gr = NULL;
-			
-	switch(type) {
-	case HEADLINE:
-		printf("%-9s", "Group");
-		break;
-	case UNDERSCORE:
-		printf("%-9s", "---------");
-		break;
-	case JOB:
-		gid = job->gid;
-		break;
-	case JOBCOMP:
-		printf("%-9s", jobcomp->gid_name);
-		break;
-	case JOBSTEP:
-		printf("%-9s", " ");
-		break;
-	default:
-		printf("%-9s", "n/a");
-		break;
-	}
-	if(gid != -1) {
-		if ((gr=getgrgid(gid)))
-			tmp=gr->gr_name;
-		printf("%-9s", tmp);
-	} 
-}
-
-void print_job(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-8s", "Job");
-		break;
-	case UNDERSCORE:
-		printf("%-8s", "--------");
-		break;
-	case JOB:
-		printf("%-8u", job->jobid);
-		break;
-	case JOBSTEP:
-		printf("%-8s", " ");
-		break;
-	default:
-		printf("%-8s", "n/a");
-		break;
-	} 
-}
-
-void print_name(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-18s", "Jobname");
-		break;
-	case UNDERSCORE:
-		printf("%-18s", "------------------");
-		break;
-	case JOB:
-		if(!job->jobname)
-			printf("%-18s", "unknown");			     
-		else if(strlen(job->jobname)<19)
-			printf("%-18s", job->jobname);
-		else
-			printf("%-15.15s...", job->jobname);
-			
-		break;
-	case JOBCOMP:
-		if(!jobcomp->jobname)
-			printf("%-18s", "unknown");			     
-		else if(strlen(jobcomp->jobname)<19)
-			printf("%-18s", jobcomp->jobname);
-		else
-			printf("%-15.15s...", jobcomp->jobname);
-			
-		break;
-	case JOBSTEP:
-		if(!step->stepname)
-			printf("%-18s", "unknown");			     
-		else if(strlen(step->stepname)<19)
-			printf("%-18s", step->stepname);
-		else
-			printf("%-15.15s...", step->stepname);
-		break;
-	default:
-		printf("%-18s", "n/a");
-		break;
-	} 
-}
-
-void print_jobid(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char outbuf[10];
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-10s", "JobID");
-		break;
-	case UNDERSCORE:
-		printf("%-10s", "----------");
-		break;
-	case JOB:
-		printf("%-10u", job->jobid);
-		break;
-	case JOBCOMP:
-		printf("%-10u", jobcomp->jobid);
-		break;
-	case JOBSTEP:
-		snprintf(outbuf, sizeof(outbuf), "%u.%u",
-			 step->jobid,
-			 step->stepid);
-		printf("%-10s", outbuf);
-		break;
-	default:
-		printf("%-10s", "n/a");
-		break;
-	} 
-
-}
-
-void print_ncpus(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-7s", "Ncpus");
-		break;
-	case UNDERSCORE:
-		printf("%-7s", "-------");
-		break;
-	case JOB:
-		printf("%-7u", job->alloc_cpus);
-		break;
-	case JOBSTEP:
-		printf("%-7u", step->ncpus);
-		break;
-	default:
-		printf("%-7s", "n/a");
-		break;
-	} 
-}
-
-void print_nodes(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-30s", "Nodes");
-		break;
-	case UNDERSCORE:
-		printf("%-30s", "------------------------------");
-		break;
-	case JOB:
-		printf("%-30s", job->nodes);
-		break;
-	case JOBCOMP:
-		printf("%-30s", jobcomp->nodelist);
-		break;
-	case JOBSTEP:
-		printf("%-30s", step->nodes);
-		break;
-	default:
-		printf("%-30s", "n/a");
-		break;
-	} 
-}
-
-void print_nnodes(type_t type, void *object)
-{ 
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	char temp[FORMAT_STRING_SIZE];
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-8s", "Node Cnt");
-		break;
-	case UNDERSCORE:
-		printf("%-8s", "--------");
-		break;
-	case JOBCOMP:
-		convert_num_unit((float)jobcomp->node_cnt, temp, 
-				 sizeof(temp), UNIT_NONE);
-		printf("%-8s", temp);
-		break;
-	default:
-		printf("%-8s", "n/a");
-		break;
-	} 
-}
-
-void print_ntasks(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-7s", "Ntasks");
-		break;
-	case UNDERSCORE:
-		printf("%-7s", "-------");
-		break;
-	case JOB:
-		printf("%-7u", job->alloc_cpus);
-		break;
-	case JOBSTEP:
-		printf("%-7u", step->ncpus);
-		break;
-	default:
-		printf("%-7s", "n/a");
-		break;
-	} 
-}
-
-void print_partition(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-10s", "Partition");
-		break;
-	case UNDERSCORE:
-		printf("%-10s", "----------");
-		break;
-	case JOB:
-		if(!job->partition)
-			printf("%-10s", "unknown");			     
-		else if(strlen(job->partition)<11)
-			printf("%-10s", job->partition);
-		else
-			printf("%-7.7s...", job->partition);
-		
-		break;
-	case JOBCOMP:
-		if(!jobcomp->partition)
-			printf("%-10s", "unknown");			     
-		else if(strlen(jobcomp->partition)<11)
-			printf("%-10s", jobcomp->partition);
-		else
-			printf("%-7.7s...", jobcomp->partition);
-		
-		break;
-	case JOBSTEP:
-		printf("%-10s", " ");
-		break;
-	default:
-		printf("%-10s", "n/a");
-		break;
-	} 
-}
-
-#ifdef HAVE_BG
-void print_blockid(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-16s", "BlockID");
-		break;
-	case UNDERSCORE:
-		printf("%-16s", "----------------");
-		break;
-	case JOB:
-		if(!job->blockid)
-			printf("%-16s", "unknown");			     
-		else if(strlen(job->blockid)<17)
-			printf("%-16s", job->blockid);
-		else
-			printf("%-13.13s...", job->blockid);
-		
-		break;
-	case JOBCOMP:
-		if(!jobcomp->blockid)
-			printf("%-16s", "unknown");			     
-		else if(strlen(jobcomp->blockid)<17)
-			printf("%-16s", jobcomp->blockid);
-		else
-			printf("%-13.13s...", jobcomp->blockid);
-		
-		break;
-	case JOBSTEP:
-		printf("%-16s", " ");
-		break;
-	default:
-		printf("%-16s", "n/a");
-		break;
-	} 
-}
-#endif
-
-void print_pages(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char outbuf[FORMAT_STRING_SIZE];
-	char buf1[FORMAT_STRING_SIZE];
-	char buf2[FORMAT_STRING_SIZE];
-	char buf3[FORMAT_STRING_SIZE];
-	sacct_t sacct;
-	char *nodes = NULL;
-	uint32_t pos;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-34s", "MaxPages/Node:Task - Ave");
-		break;
-	case UNDERSCORE:
-		printf("%-34s", "----------------------------------");
-		break;
-	case JOB:
-		sacct = job->sacct;
-		nodes = job->nodes;
-		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_pages, 
-				 buf1, sizeof(buf1), UNIT_NONE);
-
-		if(job->track_steps)
-			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
-		else {
-			convert_num_unit((float)sacct.ave_pages,
-					 buf2, sizeof(buf2), UNIT_NONE);
-			find_hostname(pos, nodes, buf3);
-			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
-				 buf1,
-				 buf3,
-				 sacct.max_pages_id.taskid, 
-				 buf2);
-		}
-		printf("%-34s", outbuf);
-		break;
-	case JOBSTEP:
-		sacct = step->sacct;
-		nodes = step->nodes;
-		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_pages, buf1, sizeof(buf1),
-				 UNIT_NONE);
-		convert_num_unit((float)sacct.ave_pages, buf2, sizeof(buf2),
-				 UNIT_NONE);
-		find_hostname(pos, nodes, buf3);
-		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
-			 buf1,
-			 buf3,
-			 sacct.max_pages_id.taskid, 
-			 buf2);
-		printf("%-34s", outbuf);
-		break;
-	default:
-		printf("%-34s", "n/a");
-		break;
-	} 
-}
-
-void print_rss(type_t type, void *object)
+extern void print_cputime(type_t type, void *object)
 { 
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
@@ -607,346 +109,110 @@ void print_rss(type_t type, void *object)
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-34s", "MaxRSS/Node:Task - Ave");
+		printf("%-37s", "MinCPUtime/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-34s", "----------------------------------");
+		printf("%-37s", "-------------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
-
-		if(job->track_steps)
-			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
-		else {
-			convert_num_unit((float)sacct.ave_rss, 
-					 buf2, sizeof(buf2), UNIT_NONE);
-			find_hostname(pos, nodes, buf3);
-			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
-				 buf1,
-				 buf3, 
-				 sacct.max_rss_id.taskid, 
-				 buf2);
-		}
-		printf("%-34s", outbuf);
-		break;
-	case JOBSTEP:
-		sacct = step->sacct;
-		nodes = step->nodes;
-		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
-		convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2),
-				 UNIT_NONE);
-		find_hostname(pos, nodes, buf3);
-		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
-			 buf1,
-			 buf3, 
-			 sacct.max_rss_id.taskid, 
-			 buf2);
-		printf("%-34s", outbuf);
-		break;
-	default:
-		printf("%-34s", "n/a");
-		break;
-	} 
-}
-
-void print_state(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-20s", "State");
-		break;
-	case UNDERSCORE:
-		printf("%-20s", "--------------------");
-		break;
-	case JOB:
-		if ( job->state == JOB_CANCELLED) {
-			printf ("%-10s by %6d",
-				job_state_string(job->state), job->requid);
-		}
-		else {
-			printf("%-20s", job_state_string(job->state));
-		}
-		break;
-	case JOBCOMP:
-		printf("%-20s", jobcomp->state);
-		break;
-	case JOBSTEP:
-		if ( step->state == JOB_CANCELLED) {
-			printf ("%-10s by %6d",
-				job_state_string(step->state), step->requid);
-		}
-		else {
-			printf("%-20s", job_state_string(step->state));
-		}
-		break;
-	default:
-		printf("%-20s", "n/a");
-		break;
-	} 
-}
-
-void print_submit(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char time_str[32];
-		
-	switch(type) {
-	case HEADLINE:
-		printf("%-14s", "Submit Time");
-		break;
-	case UNDERSCORE:
-		printf("%-14s", "--------------");
-		break;
-	case JOB:
-		slurm_make_time_str(&job->submit, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-14s", time_str);
-		break;
-	case JOBSTEP:
-		slurm_make_time_str(&step->start, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-14s", time_str);
-		break;
-	default:
-		printf("%-14s", "n/a");
-		break;
-	} 
-}
-
-void print_start(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char time_str[32];
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-19s", "Start Time");
-		break;
-	case UNDERSCORE:
-		printf("%-19s", "--------------------");
-		break;
-	case JOB:
-		slurm_make_time_str(&job->start, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-19s", time_str);
-		break;
-	case JOBCOMP:
-		printf("%-19s", jobcomp->start_time);
-		break;
-	case JOBSTEP:
-		slurm_make_time_str(&step->start, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-19s", time_str);
-		break;
-	default:
-		printf("%-19s", "n/a");
-		break;
-	} 
-}
-
-void print_timelimit(type_t type, void *object)
-{ 
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-10s", "Time Limit");
-		break;
-	case UNDERSCORE:
-		printf("%-10s", "----------");
-		break;
-	case JOBCOMP:
-		printf("%-10s", jobcomp->timelimit);
-		break;
-	default:
-		printf("%-10s", "n/a");
-		break;
-	} 
-}
-
-void print_end(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char time_str[32];
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-19s", "End Time");
-		break;
-	case UNDERSCORE:
-		printf("%-19s", "--------------------");
-		break;
-	case JOB:
-		slurm_make_time_str(&job->end, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-19s", time_str);
-		break;
-	case JOBCOMP:
-		printf("%-19s", jobcomp->end_time);
-		break;
-	case JOBSTEP:
-		slurm_make_time_str(&step->end, 
-				    time_str, 
-				    sizeof(time_str));
-		printf("%-19s", time_str);
-		break;
-	default:
-		printf("%-19s", "n/a");
-		break;
-	} 
-}
-
-void print_systemcpu(type_t type, void *object)
-{
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char str[FORMAT_STRING_SIZE];
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-15s", "SystemCpu");
-		break;
-	case UNDERSCORE:
-		printf("%-15s", "---------------");
-		break;
-	case JOB:
-		_elapsed_time(job->sys_cpu_sec,
-			      job->sys_cpu_usec, str);
-		printf("%-15s", str);
-		break;
-	case JOBSTEP:
-		_elapsed_time(step->sys_cpu_sec,
-			      step->sys_cpu_usec, str);
-		printf("%-15s", str);
-		break;
-	default:
-		printf("%-15s", "n/a");
-		break;
-	} 
-}
-
-void print_uid(type_t type, void *object)
-{ 
-	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
-	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	int32_t uid = -1;
-	struct passwd *pw = NULL;
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%-5s", "Uid");
-		break;
-	case UNDERSCORE:
-		printf("%-5s", "-----");
-		break;
-	case JOB:
-		if(job->user) {
-			if ((pw=getpwnam(job->user)))
-				uid = pw->pw_uid;
-		} else 
-			uid = job->uid;
-		break;
-	case JOBCOMP:
-		printf("%-5u", jobcomp->uid);
+		_elapsed_time((int)sacct.min_cpu, 0, buf1);
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, 
+				 "%s/- - -", buf1);
+		else {
+			_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, 
+				 "%s/%s:%u - %s", 
+				 buf1,
+				 buf3, 
+				 sacct.min_cpu_id.taskid, 
+				 buf2);
+		}
+		printf("%-37s", outbuf);
 		break;
 	case JOBSTEP:
-		printf("%-5s", " ");
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		_elapsed_time((int)sacct.min_cpu, 0, buf1);
+		_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, 
+			 "%s/%s:%u - %s", 
+			 buf1,
+			 buf3, 
+			 sacct.min_cpu_id.taskid, 
+			 buf2);
+		printf("%-37s", outbuf);
+		break;
+	default:
+		printf("%-37s", "n/a");
 		break;
 	} 
-
-	if(uid != -1) 
-		printf("%-5d", uid);
 }
 
-void print_user(type_t type, void *object)
-{ 
+extern void print_jobid(type_t type, void *object)
+{
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
-	int uid = -1;
-	char	*tmp="(unknown)";
-	struct	passwd *pw = NULL;		 
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[10];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-9s", "User");
+		printf("%-10s", "JobID");
 		break;
 	case UNDERSCORE:
-		printf("%-9s", "---------");
+		printf("%-10s", "----------");
 		break;
 	case JOB:
-		if(job->user) 
-			printf("%-9s", job->user);
-		else
-			uid = job->uid;
+		printf("%-10u", job->jobid);
 		break;
 	case JOBCOMP:
-		printf("%-9s", jobcomp->uid_name);
+		printf("%-10u", jobcomp->jobid);
 		break;
 	case JOBSTEP:
-		printf("%-9s", " ");
+		snprintf(outbuf, sizeof(outbuf), "%u.%u",
+			 step->jobid,
+			 step->stepid);
+		printf("%-10s", outbuf);
 		break;
 	default:
-		printf("%-9s", "n/a");
+		printf("%-10s", "n/a");
 		break;
 	} 
-	if(uid != -1) {
-		if ((pw=getpwuid(uid)))
-			tmp=pw->pw_name;
-		printf("%-9s", tmp);
-	}
+
 }
 
-void print_usercpu(type_t type, void *object)
-{
+extern void print_ntasks(type_t type, void *object)
+{ 
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
-	char str[FORMAT_STRING_SIZE];
-	
+
 	switch(type) {
 	case HEADLINE:
-		printf("%-15s", "UserCpu");
+		printf("%-7s", "Ntasks");
 		break;
 	case UNDERSCORE:
-		printf("%-15s", "---------------");
+		printf("%-7s", "-------");
 		break;
 	case JOB:
-		_elapsed_time(job->user_cpu_sec,
-			      job->user_cpu_usec, str);
-		printf("%-15s", str);
+		printf("%-7u", job->alloc_cpus);
 		break;
 	case JOBSTEP:
-		_elapsed_time(step->user_cpu_sec,
-			      step->user_cpu_usec, str);
-		printf("%-15s", str);
+		printf("%-7u", step->ncpus);
 		break;
 	default:
-		printf("%-15s", "n/a");
+		printf("%-7s", "n/a");
 		break;
 	} 
-
 }
 
-void print_vsize(type_t type, void *object)
+extern void print_pages(type_t type, void *object)
 { 
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
@@ -960,7 +226,7 @@ void print_vsize(type_t type, void *object)
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-34s", "MaxVSIZE/Node:Task - Ave");
+		printf("%-34s", "MaxPages/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
 		printf("%-34s", "----------------------------------");
@@ -969,18 +235,19 @@ void print_vsize(type_t type, void *object)
 		sacct = job->sacct;
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_vsize, 
-				 buf1, sizeof(buf1),UNIT_NONE);
+		convert_num_unit((float)sacct.max_pages, 
+				 buf1, sizeof(buf1), UNIT_NONE);
+
 		if(job->track_steps)
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
-			convert_num_unit((float)sacct.ave_vsize,
+			convert_num_unit((float)sacct.ave_pages,
 					 buf2, sizeof(buf2), UNIT_NONE);
 			find_hostname(pos, nodes, buf3);
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
-				 buf3, 
-				 sacct.max_vsize_id.taskid, 
+				 buf3,
+				 sacct.max_pages_id.taskid, 
 				 buf2);
 		}
 		printf("%-34s", outbuf);
@@ -989,15 +256,15 @@ void print_vsize(type_t type, void *object)
 		sacct = step->sacct;
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
-		convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), 
+		convert_num_unit((float)sacct.max_pages, buf1, sizeof(buf1),
 				 UNIT_NONE);
-		convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2),
+		convert_num_unit((float)sacct.ave_pages, buf2, sizeof(buf2),
 				 UNIT_NONE);
 		find_hostname(pos, nodes, buf3);
 		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
-			 buf3, 
-			 sacct.max_vsize_id.taskid, 
+			 buf3,
+			 sacct.max_pages_id.taskid, 
 			 buf2);
 		printf("%-34s", outbuf);
 		break;
@@ -1007,7 +274,7 @@ void print_vsize(type_t type, void *object)
 	} 
 }
 
-void print_cputime(type_t type, void *object)
+extern void print_rss(type_t type, void *object)
 { 
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
@@ -1021,195 +288,151 @@ void print_cputime(type_t type, void *object)
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-37s", "MinCPUtime/Node:Task - Ave");
+		printf("%-34s", "MaxRSS/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-37s", "-------------------------------------");
+		printf("%-34s", "----------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
-		_elapsed_time((int)sacct.min_cpu, 0, buf1);
+		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
+				 UNIT_NONE);
+
 		if(job->track_steps)
-			snprintf(outbuf, FORMAT_STRING_SIZE, 
-				 "%s/- - -", buf1);
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
-			_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+			convert_num_unit((float)sacct.ave_rss, 
+					 buf2, sizeof(buf2), UNIT_NONE);
 			find_hostname(pos, nodes, buf3);
-			snprintf(outbuf, FORMAT_STRING_SIZE, 
-				 "%s/%s:%u - %s", 
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
 				 buf3, 
-				 sacct.min_cpu_id.taskid, 
+				 sacct.max_rss_id.taskid, 
 				 buf2);
 		}
-		printf("%-37s", outbuf);
+		printf("%-34s", outbuf);
 		break;
 	case JOBSTEP:
 		sacct = step->sacct;
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
-		_elapsed_time((int)sacct.min_cpu, 0, buf1);
-		_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
+				 UNIT_NONE);
+		convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2),
+				 UNIT_NONE);
 		find_hostname(pos, nodes, buf3);
-		snprintf(outbuf, FORMAT_STRING_SIZE, 
-			 "%s/%s:%u - %s", 
+		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
 			 buf3, 
-			 sacct.min_cpu_id.taskid, 
+			 sacct.max_rss_id.taskid, 
 			 buf2);
-		printf("%-37s", outbuf);
+		printf("%-34s", outbuf);
 		break;
 	default:
-		printf("%-37s", "n/a");
+		printf("%-34s", "n/a");
 		break;
 	} 
 }
 
-void print_account(type_t type, void *object)
-{
+extern void print_state(type_t type, void *object)
+{ 
 	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-16s", "account");
+		printf("%-20s", "State");
 		break;
 	case UNDERSCORE:
-		printf("%-16s", "----------------");
+		printf("%-20s", "--------------------");
 		break;
 	case JOB:
-		if(!job->account)
-			printf("%-16s", "unknown");
-		else if(strlen(job->account)<17)
-			printf("%-16s", job->account);
-		else
-			printf("%-13.13s...", job->account);
-		break;
-	case JOBSTEP:
-		printf("%-16s", " ");
-	default:
-		printf("%-16s", "n/a");
-		break;
-		break;
-	}
-}
-
-
-#ifdef HAVE_BG
-void print_connection(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-10s", "Connection");
-		break;
-	case UNDERSCORE:
-		printf("%-10s", "----------");
-		break;
-	case JOBCOMP:
-		printf("%-10s", job->connection);
-		break;
-	default:
-		printf("%-10s", "n/a");
-		break;
-	}
-}
-void print_geo(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-8s", "Geometry");
-		break;
-	case UNDERSCORE:
-		printf("%-8s", "--------");
+		if ( job->state == JOB_CANCELLED) {
+			printf ("%-10s by %6d",
+				job_state_string(job->state), job->requid);
+		}
+		else {
+			printf("%-20s", job_state_string(job->state));
+		}
 		break;
 	case JOBCOMP:
-		printf("%-8s", job->geo);
-		break;
-	default:
-		printf("%-8s", "n/a");
-		break;
-	}
-}
-void print_max_procs(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-9s", "Max Procs");
-		break;
-	case UNDERSCORE:
-		printf("%-9s", "---------");
+		printf("%-20s", jobcomp->state);
 		break;
-	case JOBCOMP:
-		printf("%-9d", job->max_procs);
+	case JOBSTEP:
+		if ( step->state == JOB_CANCELLED) {
+			printf ("%-10s by %6d",
+				job_state_string(step->state), step->requid);
+		}
+		else {
+			printf("%-20s", job_state_string(step->state));
+		}
 		break;
 	default:
-		printf("%-9s", "n/a");
+		printf("%-20s", "n/a");
 		break;
-	}
+	} 
 }
-void print_reboot(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
 
-	switch(type) {
-	case HEADLINE:
-		printf("%-6s", "Reboot");
-		break;
-	case UNDERSCORE:
-		printf("%-6s", "------");
-		break;
-	case JOBCOMP:
-		printf("%-6s", job->reboot);
-		break;
-	default:
-		printf("%-6s", "n/a");
-		break;
-	}
-}
-void print_rotate(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+extern void print_vsize(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[FORMAT_STRING_SIZE];
+	char buf1[FORMAT_STRING_SIZE];
+	char buf2[FORMAT_STRING_SIZE];
+	char buf3[FORMAT_STRING_SIZE];
+	sacct_t sacct;
+	char *nodes = NULL;
+	uint32_t pos;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-6s", "Rotate");
+		printf("%-34s", "MaxVSIZE/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-6s", "------");
-		break;
-	case JOBCOMP:
-		printf("%-6s", job->rotate);
-		break;
-	default:
-		printf("%-6s", "n/a");
-		break;
-	}
-}
-void print_bg_start_point(type_t type, void *object)
-{
-	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%-14s", "BG Start Point");
+		printf("%-34s", "----------------------------------");
 		break;
-	case UNDERSCORE:
-		printf("%-14s", "--------------");
+	case JOB:
+		sacct = job->sacct;
+		nodes = job->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_vsize, 
+				 buf1, sizeof(buf1),UNIT_NONE);
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
+		else {
+			convert_num_unit((float)sacct.ave_vsize,
+					 buf2, sizeof(buf2), UNIT_NONE);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+				 buf1,
+				 buf3, 
+				 sacct.max_vsize_id.taskid, 
+				 buf2);
+		}
+		printf("%-34s", outbuf);
 		break;
-	case JOBCOMP:
-		printf("%-14s", job->bg_start_point);
+	case JOBSTEP:
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), 
+				 UNIT_NONE);
+		convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2),
+				 UNIT_NONE);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+			 buf1,
+			 buf3, 
+			 sacct.max_vsize_id.taskid, 
+			 buf2);
+		printf("%-34s", outbuf);
 		break;
 	default:
-		printf("%-14s", "n/a");
+		printf("%-34s", "n/a");
 		break;
-	}
+	} 
 }
-#endif
-
diff --git a/src/sstat/process.c b/src/sstat/process.c
index 52808e35ecb..433433519a9 100644
--- a/src/sstat/process.c
+++ b/src/sstat/process.c
@@ -37,7 +37,7 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include "sacct.h"
+#include "sstat.h"
 
 
 void find_hostname(uint32_t pos, char *hosts, char *host)
diff --git a/src/sstat/sacct.c b/src/sstat/sacct.c
deleted file mode 100644
index 45a0f2b8a9d..00000000000
--- a/src/sstat/sacct.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*****************************************************************************\
- *  sacct.c - job accounting reports for SLURM's jobacct/log plugin
- *****************************************************************************
- *
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-/*
- * HISTORY
- * $Log$
- * Revision 1.8  2006/06/09   ciclouston
- * Added new account entry to begining of fields[].
- *
- * Revision 1.7  2005/06/29 20:41:23  da
- * New Tag HP's patch applied for mutex issue in jobacct.
- *
- * Revision 1.6  2005/06/24 01:19:52  jette
- * Additional documenation for job accounting. Some bug fixes too. All from
- * Andy Riebs/HP.
- *
- * Revision 1.5  2005/06/11 00:49:43  jette
- * Get all the latest accounting software patches.
- *
- * Revision 1.1  2005/06/01 17:26:11  jette
- * Extensive mods checked it for HP work, see NEWS for details.
- *
- * Revision 1.4  2005/05/31 20:28:20  riebs
- * Include "errors" in the default sacct display.
- *
- * Revision 1.3  2005/05/27 17:37:43  riebs
- * Don't discard JOB_START and JOB_END records when selecting on job
- * steps. ("sacct -J 246.1" would report "Error: No JOB_START record for
- * job 246"). This was not a problem when --dump was specified.
- *
- * Revision 1.2  2005/05/19 20:42:11  riebs
- * 1. Fix problem of double-flush of .expired records when scontrol is
- *    unavailable
- * 2. Handle "--expire=1d" as "expire everything through yesterday,"
- *    rather than "expire everything up to  exactly 24 hours ago."
- *
- * Revision 1.1  2005/05/13 20:11:14  riebs
- * Add the jobacct plugins and the sacct utility, and upgrade to
- * slurm-0.4.22-1.
- *
- * Revision 1.9  2005/05/03 12:38:35  riebs
- * Implement "sacct --expire" to facilitate logfile rotation.
- *
- * Revision 1.8  2005/04/15 23:01:39  riebs
- * Check in the changes for dynamic SLURM job accounting (that is, the
- * code to capture runtime data for psize and vsize).
- *
- * Revision 1.7  2005/04/11 21:05:44  riebs
- * Check in a work-around for a getopt_long() bug.
- *
- * Revision 1.6  2005/04/07 18:43:46  riebs
- * Fix a hand full of off-by-one problems, and add --version
- *
- * Revision 1.2  2005/04/07 18:41:42  riebs
- * updat the rev
- *
- * Revision 1.1  2005/04/07 18:33:08  riebs
- * Initial revision
- *
- * Revision 1.5  2005/04/06 19:37:40  riebs
- * Clean up sacct output.
- *
- * Revision 1.4  2005/04/05 15:28:01  riebs
- * - Implement --all
- * - Clean up output formatting for elapsed time
- * - Expand output field for jobname
- *
- * Revision 1.3  2005/04/02 19:46:44  riebs
- * Remove the setuid-related code, initialize job[].cstatus properly, fix
- * formatting of the JOB_STEP record, and fix printing of elapsed time.
- *
- * Revision 1.2  2005/04/01 17:10:43  riebs
- * Replace the Perl version of sacct with sacct.c
- *
- * Revision 1.1  2005/03/31 21:57:45  riebs
- * Initial revision
- *
- * Revision 1.1  2005/03/31 21:19:28  riebs
- * Add the .c version of sacct to CVS in anticipation of retiring the
- * .pl version.
- *
- * Revision 1.8  2005/03/31 19:25:19  riebs
- * Solid version of sacct with all functionality!
- *
- * Revision 1.7  2005/03/31 13:24:41  riebs
- * Good version of formatted_dump implemented.
- *
- * Revision 1.6  2005/03/31 00:33:45  riebs
- * Pretty good implementation of fdump now.
- *
- * Revision 1.5  2005/03/30 23:57:31  riebs
- * Version that handles all print fields.
- *
- * Revision 1.4  2005/03/30 20:51:13  riebs
- * A precautionary version before I radically change
- * the fields struct.
- *
- * Revision 1.3  2005/03/30 18:26:24  riebs
- * Pretty solid version of --dump
- *
- * Revision 1.2  2005/03/29 14:43:20  riebs
- * All data are aggregated; just need to print it now!
- *
- * Revision 1.1  2005/03/28 18:21:26  andy
- * Initial revision
- *
- * Revision 1.1  2005/03/28 16:18:38  riebs
- * Initial revision
- *
- *
- * $EndLog$
- */
-
-#include "sacct.h"
-
-void invalidSwitchCombo(char *good, char *bad);
-void _print_header(void);
-
-/*
- * Globals
- */
-sacct_parameters_t params;
-fields_t fields[] = {{"cputime", print_cputime}, 
-		     {"jobid", print_jobid}, 
-		     {"ntasks", print_ntasks}, 
-		     {"pages", print_pages}, 
-		     {"rss", print_rss},
-		     {"state", print_state}, 
-		     {"vsize", print_vsize}, 
-		     {NULL, NULL}};
-
-List jobs = NULL;
-
-int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
-	nprintfields = 0;
-
-int main(int argc, char **argv)
-{
-	sacct_init();
-	parse_command_line(argc, argv);
-
-	if (params.opt_header) 	/* give them something to look */
-		_print_header();/* at while we think...        */
-	do_stat();
-		
-	sacct_fini();
-	return (rc);
-}
-
-
-void invalidSwitchCombo(char *good, char *bad)
-{
-	fprintf(stderr, "\"%s\" may not be used with %s\n", good, bad);
-	return;
-}
-
-void _print_header(void)
-{
-	int	i,j;
-	for (i=0; i<nprintfields; i++) {
-		if (i)
-			printf(" ");
-		j=printfields[i];
-		(fields[j].print_routine)(HEADLINE, 0);
-	}
-	printf("\n");
-	for (i=0; i<nprintfields; i++) {
-		if (i)
-			printf(" ");
-		j=printfields[i];
-		(fields[j].print_routine)(UNDERSCORE, 0);
-	}
-	printf("\n");
-}
diff --git a/src/sstat/sacct_stat.c b/src/sstat/sstat.c
similarity index 72%
rename from src/sstat/sacct_stat.c
rename to src/sstat/sstat.c
index 427fd1e82aa..58f75d55df9 100644
--- a/src/sstat/sacct_stat.c
+++ b/src/sstat/sstat.c
@@ -1,11 +1,9 @@
 /*****************************************************************************\
- *  sacct_stat.c - stat slurmd for percise job information
- *
- *  $Id: options.c 7541 2006-03-18 01:44:58Z da $
+ *  sstat.c - job accounting reports for SLURM's jobacct/log plugin
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Danny Auble <da@llnl.gov>.
+ *  Written by Morris Jette <jette1@llnl.gov>
  *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
@@ -37,22 +35,65 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include "sacct.h"
-#include <pthread.h>
-#include "src/common/forward.h"
-#include "src/common/slurm_auth.h"
+#include "sstat.h"
 
-jobacct_step_rec_t step;
-	
-int thr_finished = 0;
-	
+void _destroy_steps(void *object);
+void _print_header(void);
 void *_stat_thread(void *args);
-int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id, 
+int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id, 
 		 uint32_t step_id);
 int _process_results();
+int _do_stat(uint32_t jobid, uint32_t stepid);
 
+/*
+ * Globals
+ */
+	sacct_parameters_t params;
+fields_t fields[] = {{"cputime", print_cputime}, 
+		     {"jobid", print_jobid}, 
+		     {"ntasks", print_ntasks}, 
+		     {"pages", print_pages}, 
+		     {"rss", print_rss},
+		     {"state", print_state}, 
+		     {"vsize", print_vsize}, 
+		     {NULL, NULL}};
 
-int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
+List jobs = NULL;
+jobacct_step_rec_t step;
+
+int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
+	nprintfields = 0;
+
+void _destroy_steps(void *object)
+{
+	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
+	if(step) {
+		xfree(step->job);
+		xfree(step->step);
+		xfree(step);
+	}
+}
+
+void _print_header(void)
+{
+	int	i,j;
+	for (i=0; i<nprintfields; i++) {
+		if (i)
+			printf(" ");
+		j=printfields[i];
+		(fields[j].print_routine)(HEADLINE, 0);
+	}
+	printf("\n");
+	for (i=0; i<nprintfields; i++) {
+		if (i)
+			printf(" ");
+		j=printfields[i];
+		(fields[j].print_routine)(UNDERSCORE, 0);
+	}
+	printf("\n");
+}
+
+int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 		 uint32_t step_id)
 {
 	slurm_msg_t msg;
@@ -73,6 +114,7 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 	memset(&step.sacct, 0, sizeof(sacct_t));
 	step.sacct.min_cpu = (float)NO_VAL;
 
+	step.jobid = job_id;
 	step.stepid = step_id;
 	step.nodes = step_layout->node_list;
 	step.stepname = NULL;
@@ -85,7 +127,6 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 	msg.msg_type        = MESSAGE_STAT_JOBACCT;
 	msg.data            = &r;
 	
-	
 	ret_list = slurm_send_recv_msgs(step_layout->node_list, &msg, 0);
 	if (!ret_list) {
 		error("got an error no list returned");
@@ -151,7 +192,7 @@ int _process_results()
 	return SLURM_SUCCESS;
 }
 
-int sacct_stat(uint32_t jobid, uint32_t stepid)
+int _do_stat(uint32_t jobid, uint32_t stepid)
 {
 	slurm_msg_t req_msg;
 	slurm_msg_t resp_msg;
@@ -191,7 +232,7 @@ int sacct_stat(uint32_t jobid, uint32_t stepid)
 		return rc;
 	}
 
-	_sacct_query(step_layout, jobid, stepid);
+	_sstat_query(step_layout, jobid, stepid);
 	
 	_process_results();
 	
@@ -199,3 +240,34 @@ int sacct_stat(uint32_t jobid, uint32_t stepid)
 	
 	return rc;
 }
+
+int main(int argc, char **argv)
+{
+	ListIterator itr = NULL;
+	uint32_t jobid = 0;
+	uint32_t stepid = 0;
+	jobacct_selected_step_t *selected_step = NULL;
+	
+	List selected_steps = list_create(_destroy_steps);
+
+	parse_command_line(argc, argv, selected_steps);
+
+	if (params.opt_header) 	/* give them something to look */
+		_print_header();/* at while we think...        */
+	itr = list_iterator_create(selected_steps);
+	while((selected_step = list_next(itr))) {
+		jobid = atoi(selected_step->job);
+		if(selected_step->step)
+			stepid = atoi(selected_step->step);
+		else
+			stepid = 0;
+		_do_stat(jobid, stepid);
+	}
+	list_iterator_destroy(itr);
+		
+	list_destroy(selected_steps);
+
+	return 0;
+}
+
+
diff --git a/src/sstat/sacct.h b/src/sstat/sstat.h
similarity index 65%
rename from src/sstat/sacct.h
rename to src/sstat/sstat.h
index 2ea89cabbe2..94b971980d5 100644
--- a/src/sstat/sacct.h
+++ b/src/sstat/sstat.h
@@ -1,11 +1,12 @@
 /*****************************************************************************\
- *  sacct.h - header file for sacct
+ *  sstat.h - header file for sstat
  *
- *  $Id: sacct.h 7541 2006-03-18 01:44:58Z da $
+ *  $Id: sstat.h 7541 2006-03-18 01:44:58Z da $
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Danny Auble <da@llnl.gov>.
+ *  Written by Morris Jette <jette1@llnl.gov>
  *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
@@ -36,8 +37,8 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#ifndef _SACCT_H
-#define _SACCT_H
+#ifndef _SSTAT_H
+#define _SSTAT_H
 
 #include <ctype.h>
 #include <errno.h>
@@ -102,61 +103,17 @@ void find_hostname(uint32_t pos, char *hosts, char *host);
 void aggregate_sacct(sacct_t *dest, sacct_t *from);
 
 /* print.c */
+void print_cputime(type_t type, void *object);
 void print_fields(type_t type, void *object);
-void print_cpu(type_t type, void *object);
-void print_elapsed(type_t type, void *object);
-void print_exitcode(type_t type, void *object);
-void print_gid(type_t type, void *object);
-void print_group(type_t type, void *object);
-void print_job(type_t type, void *object);
-void print_name(type_t type, void *object);
 void print_jobid(type_t type, void *object);
-void print_ncpus(type_t type, void *object);
-void print_nodes(type_t type, void *object);
-void print_nnodes(type_t type, void *object);
 void print_ntasks(type_t type, void *object);
-void print_partition(type_t type, void *object);
-void print_blockid(type_t type, void *object);
 void print_pages(type_t type, void *object);
 void print_rss(type_t type, void *object);
 void print_state(type_t type, void *object);
-void print_submit(type_t type, void *object);
-void print_start(type_t type, void *object);
-void print_end(type_t type, void *object);
-void print_systemcpu(type_t type, void *object);
-void print_timelimit(type_t type, void *object);
-void print_uid(type_t type, void *object);
-void print_user(type_t type, void *object);
-void print_usercpu(type_t type, void *object);
 void print_vsize(type_t type, void *object);
-void print_cputime(type_t type, void *object);
-void print_account(type_t type, void *object);
 
-#ifdef HAVE_BG
-void print_connection(type_t type, void *object);
-void print_geo(type_t type, void *object);
-void print_max_procs(type_t type, void *object);
-void print_reboot(type_t type, void *object);
-void print_rotate(type_t type, void *object);
-void print_bg_start_point(type_t type, void *object);
-#endif
 
 /* options.c */
-int decode_state_char(char *state);
-char *decode_state_int(int state);
-int get_data(void);
-void parse_command_line(int argc, char **argv);
-void do_dump(void);
-void do_dump_completion(void);
-void do_expire(int dummy);
-void do_help(void);
-void do_list(void);
-void do_list_completion(void);
-void do_stat(void);
-void sacct_init();
-void sacct_fini();
-
-/* sacct_stat.c */
-extern int sacct_stat(uint32_t jobid, uint32_t stepid);
+void parse_command_line(int argc, char **argv, List selected_steps);
 
 #endif /* !_SACCT_H */
-- 
GitLab