From 836e7ef23b9cf6bdb35317602a691983af4a119a Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Wed, 11 Jun 2008 20:17:59 +0000
Subject: [PATCH] added first report to sreport

---
 src/common/Makefile.am                        |   1 +
 src/common/Makefile.in                        |  37 +-
 .../print.c => common/print_fields.c}         |  49 +--
 .../print.h => common/print_fields.h}         |  26 +-
 src/sacctmgr/Makefile.am                      |   1 -
 src/sacctmgr/Makefile.in                      |   5 +-
 src/sacctmgr/account_functions.c              |  33 +-
 src/sacctmgr/association_functions.c          |  29 +-
 src/sacctmgr/cluster_functions.c              |  21 +-
 src/sacctmgr/common.c                         |  63 +---
 src/sacctmgr/sacctmgr.c                       | 107 +++---
 src/sacctmgr/sacctmgr.h                       |  28 +-
 src/sacctmgr/user_functions.c                 |  33 +-
 src/sreport/Makefile.am                       |   2 +-
 src/sreport/Makefile.in                       |  11 +-
 src/sreport/assoc_reports.c                   |  40 +++
 src/sreport/assoc_reports.h                   |  46 +++
 src/sreport/cluster_reports.c                 | 325 ++++++++++++++++++
 src/sreport/cluster_reports.h                 |  47 +++
 src/sreport/common.c                          | 204 +++++++++++
 src/sreport/common.h                          |   0
 src/sreport/sreport.c                         |  31 +-
 src/sreport/sreport.h                         |  16 +-
 23 files changed, 872 insertions(+), 283 deletions(-)
 rename src/{sacctmgr/print.c => common/print_fields.c} (82%)
 rename src/{sacctmgr/print.h => common/print_fields.h} (82%)
 delete mode 100644 src/sreport/common.h

diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 8d61a722ee3..b1a86ac2276 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -49,6 +49,7 @@ libcommon_la_SOURCES = 			\
 	parse_spec.c parse_spec.h	\
 	plugin.c plugin.h		\
 	plugrack.c plugrack.h		\
+	print_fields.c print_fields.h	\
 	read_config.c read_config.h	\
 	node_select.c node_select.h	\
 	env.c env.h      		\
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index ae339dd578e..10ada442258 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -85,12 +85,12 @@ am__libcommon_la_SOURCES_DIST = assoc_mgr.c assoc_mgr.h xmalloc.c \
 	safeopen.c safeopen.h bitstring.c bitstring.h mpi.c mpi.h \
 	pack.c pack.h parse_config.c parse_config.h parse_spec.c \
 	parse_spec.h plugin.c plugin.h plugrack.c plugrack.h \
-	read_config.c read_config.h node_select.c node_select.h env.c \
-	env.h slurm_cred.h slurm_cred.c slurm_errno.c \
-	slurm_protocol_api.c slurm_protocol_api.h \
-	slurm_protocol_pack.c slurm_protocol_pack.h \
-	slurm_protocol_util.c slurm_protocol_util.h \
-	slurm_protocol_socket_implementation.c \
+	print_fields.c print_fields.h read_config.c read_config.h \
+	node_select.c node_select.h env.c env.h slurm_cred.h \
+	slurm_cred.c slurm_errno.c slurm_protocol_api.c \
+	slurm_protocol_api.h slurm_protocol_pack.c \
+	slurm_protocol_pack.h slurm_protocol_util.c \
+	slurm_protocol_util.h slurm_protocol_socket_implementation.c \
 	slurm_protocol_socket_common.h slurm_protocol_common.h \
 	slurm_protocol_interface.h slurm_protocol_defs.c \
 	slurm_protocol_defs.h slurm_rlimits_info.h \
@@ -112,17 +112,18 @@ am_libcommon_la_OBJECTS = assoc_mgr.lo xmalloc.lo xassert.lo \
 	xstring.lo xsignal.lo forward.lo strlcpy.lo list.lo net.lo \
 	fd.lo log.lo cbuf.lo safeopen.lo bitstring.lo mpi.lo pack.lo \
 	parse_config.lo parse_spec.lo plugin.lo plugrack.lo \
-	read_config.lo node_select.lo env.lo slurm_cred.lo \
-	slurm_errno.lo slurm_protocol_api.lo slurm_protocol_pack.lo \
-	slurm_protocol_util.lo slurm_protocol_socket_implementation.lo \
-	slurm_protocol_defs.lo slurm_rlimits_info.lo slurmdbd_defs.lo \
-	uid.lo util-net.lo slurm_auth.lo jobacct_common.lo \
-	slurm_accounting_storage.lo slurm_jobacct_gather.lo \
-	slurm_jobcomp.lo switch.lo arg_desc.lo malloc.lo getopt.lo \
-	getopt1.lo $(am__objects_1) slurm_selecttype_info.lo \
-	slurm_resource_info.lo hostlist.lo slurm_step_layout.lo \
-	checkpoint.lo parse_time.lo job_options.lo global_defaults.lo \
-	timers.lo stepd_api.lo proc_args.lo
+	print_fields.lo read_config.lo node_select.lo env.lo \
+	slurm_cred.lo slurm_errno.lo slurm_protocol_api.lo \
+	slurm_protocol_pack.lo slurm_protocol_util.lo \
+	slurm_protocol_socket_implementation.lo slurm_protocol_defs.lo \
+	slurm_rlimits_info.lo slurmdbd_defs.lo uid.lo util-net.lo \
+	slurm_auth.lo jobacct_common.lo slurm_accounting_storage.lo \
+	slurm_jobacct_gather.lo slurm_jobcomp.lo switch.lo arg_desc.lo \
+	malloc.lo getopt.lo getopt1.lo $(am__objects_1) \
+	slurm_selecttype_info.lo slurm_resource_info.lo hostlist.lo \
+	slurm_step_layout.lo checkpoint.lo parse_time.lo \
+	job_options.lo global_defaults.lo timers.lo stepd_api.lo \
+	proc_args.lo
 am__EXTRA_libcommon_la_SOURCES_DIST = unsetenv.c unsetenv.h
 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
 libcommon_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -363,6 +364,7 @@ libcommon_la_SOURCES = \
 	parse_spec.c parse_spec.h	\
 	plugin.c plugin.h		\
 	plugrack.c plugrack.h		\
+	print_fields.c print_fields.h	\
 	read_config.c read_config.h	\
 	node_select.c node_select.h	\
 	env.c env.h      		\
@@ -525,6 +527,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugrack.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugstack.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_fields.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc_args.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_config.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safeopen.Plo@am__quote@
diff --git a/src/sacctmgr/print.c b/src/common/print_fields.c
similarity index 82%
rename from src/sacctmgr/print.c
rename to src/common/print_fields.c
index e852a4dfd3a..92592eedba8 100644
--- a/src/sacctmgr/print.c
+++ b/src/common/print_fields.c
@@ -35,10 +35,11 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#include "src/sacctmgr/print.h"
+#include "src/common/print_fields.h"
 #include "src/common/parse_time.h"
-int parsable_print = 0;
-int have_header = 1;
+
+int print_fields_parsable_print = 0;
+int print_fields_have_header = 1;
 
 extern void destroy_print_field(void *object)
 {
@@ -50,12 +51,12 @@ extern void destroy_print_field(void *object)
 	}
 }
 
-extern void print_header(List print_fields_list)
+extern void print_fields_header(List print_fields_list)
 {
 	ListIterator itr = NULL;
 	print_field_t *object = NULL;
 
-	if(!print_fields_list || !have_header) 
+	if(!print_fields_list || !print_fields_have_header) 
 		return;
 
 	itr = list_iterator_create(print_fields_list);
@@ -64,7 +65,7 @@ extern void print_header(List print_fields_list)
 	}
 	list_iterator_reset(itr);
 	printf("\n");
-	if(parsable_print)
+	if(print_fields_parsable_print)
 		return;
 	while((object = list_next(itr))) {
 		(object->print_routine)(SLURM_PRINT_UNDERSCORE, object, 0);
@@ -73,7 +74,7 @@ extern void print_header(List print_fields_list)
 	printf("\n");	
 }
 
-extern void print_date(void)
+extern void print_fields_date(void)
 {
 	time_t now;
 
@@ -82,37 +83,37 @@ extern void print_date(void)
 
 }
 
-extern void print_str(type_t type, print_field_t *field, char *value)
+extern void print_fields_str(type_t type, print_field_t *field, char *value)
 {
 	char *print_this = value;
 
 	switch(type) {
 	case SLURM_PRINT_HEADLINE:
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", field->name);
 		else
 			printf("%-*.*s ", field->len, field->len, field->name);
 		break;
 	case SLURM_PRINT_UNDERSCORE:
-		if(!parsable_print)
+		if(!print_fields_parsable_print)
 			printf("%-*.*s ", field->len, field->len, 
 			       "---------------------------------------");
 		break;
 	case SLURM_PRINT_VALUE:
 		if(!print_this) {
-			if(parsable_print)
+			if(print_fields_parsable_print)
 				print_this = "";
 			else
 				print_this = " ";
 		}
 
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", print_this);
 		else
 			printf("%-*.*s ", field->len, field->len, print_this);
 		break;
 	default:
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", "n/a");
 		else
 			printf("%-*s ", field->len, "n/a");
@@ -120,36 +121,36 @@ extern void print_str(type_t type, print_field_t *field, char *value)
 	}
 }
 
-extern void print_uint(type_t type, print_field_t *field, uint32_t value)
+extern void print_fields_uint(type_t type, print_field_t *field, uint32_t value)
 {
 	switch(type) {
 	case SLURM_PRINT_HEADLINE:
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", field->name);
 		else
 			printf("%-*.*s ", field->len, field->len, field->name);
 		break;
 	case SLURM_PRINT_UNDERSCORE:
-		if(!parsable_print)
+		if(!print_fields_parsable_print)
 			printf("%-*.*s ", field->len, field->len, 
 			       "---------------------------------------");
 		break;
 	case SLURM_PRINT_VALUE:
 		/* (value == unset)  || (value == cleared) */
 		if((value == NO_VAL) || (value == INFINITE)) {
-			if(parsable_print)
+			if(print_fields_parsable_print)
 				printf("|");	
 			else				
 				printf("%-*s ", field->len, " ");
 		} else {
-			if(parsable_print)
+			if(print_fields_parsable_print)
 				printf("%u|", value);	
 			else
 				printf("%*u ", field->len, value);
 		}
 		break;
 	default:
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", "n/a");
 		else
 			printf("%-*.*s ", field->len, field->len, "n/a");
@@ -157,24 +158,24 @@ extern void print_uint(type_t type, print_field_t *field, uint32_t value)
 	}
 }
 
-extern void print_time(type_t type, print_field_t *field, uint32_t value)
+extern void print_fields_time(type_t type, print_field_t *field, uint32_t value)
 {
 	switch(type) {
 	case SLURM_PRINT_HEADLINE:
-		if(parsable_print)
+		if(print_fields_parsable_print)
 			printf("%s|", field->name);
 		else
 			printf("%-*.*s ", field->len, field->len, field->name);
 		break;
 	case SLURM_PRINT_UNDERSCORE:
-		if(!parsable_print)
+		if(!print_fields_parsable_print)
 			printf("%-*.*s ", field->len, field->len, 
 			       "---------------------------------------");
 		break;
 	case SLURM_PRINT_VALUE:
 		/* (value == unset)  || (value == cleared) */
 		if((value == NO_VAL) || (value == INFINITE)) {
-			if(parsable_print)
+			if(print_fields_parsable_print)
 				printf("|");	
 			else
 				printf("%-*s ", field->len, " ");
@@ -182,7 +183,7 @@ extern void print_time(type_t type, print_field_t *field, uint32_t value)
 			char time_buf[32];
 			mins2time_str((time_t) value, 
 				      time_buf, sizeof(time_buf));
-			if(parsable_print)
+			if(print_fields_parsable_print)
 				printf("%s|", time_buf);
 			else
 				printf("%*s ", field->len, time_buf);
diff --git a/src/sacctmgr/print.h b/src/common/print_fields.h
similarity index 82%
rename from src/sacctmgr/print.h
rename to src/common/print_fields.h
index a4f0bf76046..6d840ebc846 100644
--- a/src/sacctmgr/print.h
+++ b/src/common/print_fields.h
@@ -1,5 +1,5 @@
 /*****************************************************************************\
- *  print.h - definitions for all printing functions.
+ *  printfields.h - definitions for all printing functions.
  *****************************************************************************
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Copyright (C) 2002-2007 The Regents of the University of California.
@@ -35,8 +35,8 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#ifndef __SACCTMGR_PRINT_H__
-#define __SACCTMGR_PRINT_H__
+#ifndef __PRINT_FIELDS_H__
+#define __PRINT_FIELDS_H__
 
 #if HAVE_CONFIG_H
 #  include "config.h"
@@ -63,9 +63,9 @@
 
 #include <slurm/slurm.h>
 
+#include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
-#include "src/common/slurm_accounting_storage.h"
-#include "src/common/jobacct_common.h"
+#include "src/common/list.h"
 
 typedef enum {
 	SLURM_PRINT_HEADLINE,
@@ -80,14 +80,16 @@ typedef struct {
 	uint16_t type; /* defined in the local function */
 } print_field_t;
 
-extern int parsable_print;
-extern int have_header;
+extern int print_fields_parsable_print;
+extern int print_fields_have_header;
 
 extern void destroy_print_field(void *object);
-extern void print_header(List print_fields_list);
-extern void print_date(void);
-extern void print_str(type_t type, print_field_t *field, char *value);
-extern void print_uint(type_t type, print_field_t *field, uint32_t value);
-extern void print_time(type_t type, print_field_t *field, uint32_t value);
+extern void print_fields_header(List print_fields_list);
+extern void print_fields_date(void);
+extern void print_fields_str(type_t type, print_field_t *field, char *value);
+extern void print_fields_uint(type_t type, print_field_t *field,
+			      uint32_t value);
+extern void print_fields_time(type_t type, print_field_t *field,
+			      uint32_t value);
 
 #endif
diff --git a/src/sacctmgr/Makefile.am b/src/sacctmgr/Makefile.am
index bf354ad3ed9..c495e0e102f 100644
--- a/src/sacctmgr/Makefile.am
+++ b/src/sacctmgr/Makefile.am
@@ -11,7 +11,6 @@ sacctmgr_SOURCES =	\
 	association_functions.c	\
 	cluster_functions.c	\
 	common.c                \
-	print.c	print.h	        \
 	sacctmgr.c sacctmgr.h	\
 	user_functions.c	
 
diff --git a/src/sacctmgr/Makefile.in b/src/sacctmgr/Makefile.in
index 585445fa5aa..072c2a16538 100644
--- a/src/sacctmgr/Makefile.in
+++ b/src/sacctmgr/Makefile.in
@@ -72,8 +72,7 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 am_sacctmgr_OBJECTS = account_functions.$(OBJEXT) \
 	association_functions.$(OBJEXT) cluster_functions.$(OBJEXT) \
-	common.$(OBJEXT) print.$(OBJEXT) sacctmgr.$(OBJEXT) \
-	user_functions.$(OBJEXT)
+	common.$(OBJEXT) sacctmgr.$(OBJEXT) user_functions.$(OBJEXT)
 sacctmgr_OBJECTS = $(am_sacctmgr_OBJECTS)
 am__DEPENDENCIES_1 =
 sacctmgr_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
@@ -273,7 +272,6 @@ sacctmgr_SOURCES = \
 	association_functions.c	\
 	cluster_functions.c	\
 	common.c                \
-	print.c	print.h	        \
 	sacctmgr.c sacctmgr.h	\
 	user_functions.c	
 
@@ -358,7 +356,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/association_functions.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cluster_functions.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacctmgr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_functions.Po@am__quote@
 
diff --git a/src/sacctmgr/account_functions.c b/src/sacctmgr/account_functions.c
index c128420f201..876d82beb22 100644
--- a/src/sacctmgr/account_functions.c
+++ b/src/sacctmgr/account_functions.c
@@ -37,7 +37,6 @@
 \*****************************************************************************/
 
 #include "src/sacctmgr/sacctmgr.h"
-#include "src/sacctmgr/print.h"
 
 static int _set_cond(int *start, int argc, char *argv[],
 		     acct_account_cond_t *acct_cond,
@@ -703,72 +702,72 @@ extern int sacctmgr_list_account(int argc, char *argv[])
 			field->type = PRINT_ACCOUNT;
 			field->name = xstrdup("Account");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Cluster", object, 1)) {
 			field->type = PRINT_CLUSTER;
 			field->name = xstrdup("Cluster");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Description", object, 1)) {
 			field->type = PRINT_DESC;
 			field->name = xstrdup("Descr");
 			field->len = 20;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("FairShare", object, 1)) {
 			field->type = PRINT_FAIRSHARE;
 			field->name = xstrdup("FairShare");
 			field->len = 9;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("ID", object, 1)) {
 			field->type = PRINT_ID;
 			field->name = xstrdup("ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
 			field->type = PRINT_MAXC;
 			field->name = xstrdup("MaxCPUSecs");
 			field->len = 11;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxJobs", object, 4)) {
 			field->type = PRINT_MAXJ;
 			field->name = xstrdup("MaxJobs");
 			field->len = 7;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxNodes", object, 4)) {
 			field->type = PRINT_MAXN;
 			field->name = xstrdup("MaxNodes");
 			field->len = 8;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxWall", object, 4)) {
 			field->type = PRINT_MAXW;
 			field->name = xstrdup("MaxWall");
 			field->len = 11;
-			field->print_routine = print_time;
+			field->print_routine = print_fields_time;
 		} else if(!strncasecmp("Organization", object, 1)) {
 			field->type = PRINT_ORG;
 			field->name = xstrdup("Org");
 			field->len = 20;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("QOS", object, 1)) {
 			field->type = PRINT_QOS;
 			field->name = xstrdup("QOS");
 			field->len = 9;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("ParentID", object, 7)) {
 			field->type = PRINT_PID;
 			field->name = xstrdup("Par ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("ParentName", object, 7)) {
 			field->type = PRINT_PNAME;
 			field->name = xstrdup("Par Name");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("User", object, 1)) {
 			field->type = PRINT_USER;
 			field->name = xstrdup("User");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else {
 			printf("Unknown field '%s'\n", object);
 			xfree(field);
@@ -780,7 +779,7 @@ extern int sacctmgr_list_account(int argc, char *argv[])
 
 	itr = list_iterator_create(acct_list);
 	itr2 = list_iterator_create(print_fields_list);
-	print_header(print_fields_list);
+	print_fields_header(print_fields_list);
 
 	while((acct = list_next(itr))) {
 		if(acct->assoc_list && list_count(acct->assoc_list)) {
@@ -971,8 +970,6 @@ extern int sacctmgr_list_account(int argc, char *argv[])
 		}
 	}
 
-	printf("\n");
-
 	list_iterator_destroy(itr2);
 	list_iterator_destroy(itr);
 	list_destroy(acct_list);
diff --git a/src/sacctmgr/association_functions.c b/src/sacctmgr/association_functions.c
index fda26526888..c7ae5a630f3 100644
--- a/src/sacctmgr/association_functions.c
+++ b/src/sacctmgr/association_functions.c
@@ -37,7 +37,6 @@
 \*****************************************************************************/
 
 #include "src/sacctmgr/sacctmgr.h"
-#include "src/sacctmgr/print.h"
 
 static int _set_cond(int *start, int argc, char *argv[],
 		     acct_association_cond_t *association_cond,
@@ -253,62 +252,62 @@ extern int sacctmgr_list_association(int argc, char *argv[])
 			field->type = PRINT_ACCOUNT;
 			field->name = xstrdup("Account");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Cluster", object, 1)) {
 			field->type = PRINT_CLUSTER;
 			field->name = xstrdup("Cluster");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("FairShare", object, 1)) {
 			field->type = PRINT_FAIRSHARE;
 			field->name = xstrdup("FairShare");
 			field->len = 9;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("ID", object, 1)) {
 			field->type = PRINT_ID;
 			field->name = xstrdup("ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
 			field->type = PRINT_MAXC;
 			field->name = xstrdup("MaxCPUSecs");
 			field->len = 11;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxJobs", object, 4)) {
 			field->type = PRINT_MAXJ;
 			field->name = xstrdup("MaxJobs");
 			field->len = 7;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxNodes", object, 4)) {
 			field->type = PRINT_MAXN;
 			field->name = xstrdup("MaxNodes");
 			field->len = 8;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxWall", object, 4)) {
 			field->type = PRINT_MAXW;
 			field->name = xstrdup("MaxWall");
 			field->len = 11;
-			field->print_routine = print_time;
+			field->print_routine = print_fields_time;
 		} else if(!strncasecmp("ParentID", object, 7)) {
 			field->type = PRINT_PID;
 			field->name = xstrdup("Par ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("ParentName", object, 7)) {
 			field->type = PRINT_PNAME;
 			field->name = xstrdup("Par Name");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Partition", object, 4)) {
 			field->type = PRINT_PART;
 			field->name = xstrdup("Partition");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("User", object, 1)) {
 			field->type = PRINT_USER;
 			field->name = xstrdup("User");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else {
 			printf("Unknown field '%s'\n", object);
 			xfree(field);
@@ -320,7 +319,7 @@ extern int sacctmgr_list_association(int argc, char *argv[])
 
 	itr = list_iterator_create(assoc_list);
 	itr2 = list_iterator_create(print_fields_list);
-	print_header(print_fields_list);
+	print_fields_header(print_fields_list);
 
 	while((assoc = list_next(itr))) {
 		while((field = list_next(itr2))) {
@@ -383,8 +382,6 @@ extern int sacctmgr_list_association(int argc, char *argv[])
 		printf("\n");
 	}
 
-	printf("\n");
-
 	list_iterator_destroy(itr2);
 	list_iterator_destroy(itr);
 	list_destroy(assoc_list);
diff --git a/src/sacctmgr/cluster_functions.c b/src/sacctmgr/cluster_functions.c
index f214ed4d2b5..f3baedd52d8 100644
--- a/src/sacctmgr/cluster_functions.c
+++ b/src/sacctmgr/cluster_functions.c
@@ -38,7 +38,6 @@
 \*****************************************************************************/
 
 #include "src/sacctmgr/sacctmgr.h"
-#include "src/sacctmgr/print.h"
 
 static int _set_cond(int *start, int argc, char *argv[],
 		     List cluster_list,
@@ -356,42 +355,42 @@ extern int sacctmgr_list_cluster(int argc, char *argv[])
 			field->type = PRINT_CLUSTER;
 			field->name = xstrdup("Cluster");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("ControlHost", object, 8)) {
 			field->type = PRINT_CHOST;
 			field->name = xstrdup("Control Host");
 			field->len = 12;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("ControlPort", object, 8)) {
 			field->type = PRINT_CPORT;
 			field->name = xstrdup("Control Port");
 			field->len = 12;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("FairShare", object, 1)) {
 			field->type = PRINT_FAIRSHARE;
 			field->name = xstrdup("FairShare");
 			field->len = 9;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
 			field->type = PRINT_MAXC;
 			field->name = xstrdup("MaxCPUSecs");
 			field->len = 11;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxJobs", object, 4)) {
 			field->type = PRINT_MAXJ;
 			field->name = xstrdup("MaxJobs");
 			field->len = 7;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxNodes", object, 4)) {
 			field->type = PRINT_MAXN;
 			field->name = xstrdup("MaxNodes");
 			field->len = 8;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxWall", object, 4)) {
 			field->type = PRINT_MAXW;
 			field->name = xstrdup("MaxWall");
 			field->len = 11;
-			field->print_routine = print_time;
+			field->print_routine = print_fields_time;
 		} else {
 			printf("Unknown field '%s'\n", object);
 			xfree(field);
@@ -403,7 +402,7 @@ extern int sacctmgr_list_cluster(int argc, char *argv[])
 
 	itr = list_iterator_create(cluster_list);
 	itr2 = list_iterator_create(print_fields_list);
-	print_header(print_fields_list);
+	print_fields_header(print_fields_list);
 
 	while((cluster = list_next(itr))) {
 		while((field = list_next(itr2))) {
@@ -454,8 +453,6 @@ extern int sacctmgr_list_cluster(int argc, char *argv[])
 		printf("\n");
 	}
 
-	printf("\n");
-
 	list_iterator_destroy(itr2);
 	list_iterator_destroy(itr);
 	list_destroy(cluster_list);
diff --git a/src/sacctmgr/common.c b/src/sacctmgr/common.c
index 36b2041259d..ee4033af8ed 100644
--- a/src/sacctmgr/common.c
+++ b/src/sacctmgr/common.c
@@ -174,68 +174,6 @@ extern void addto_char_list(List char_list, char *names)
 	list_iterator_destroy(itr);
 } 
 
-extern void destroy_sacctmgr_action(void *object)
-{
-	sacctmgr_action_t *action = (sacctmgr_action_t *)object;
-	
-	if(action) {
-		if(action->list)
-			list_destroy(action->list);
-			
-		switch(action->type) {
-		case SACCTMGR_ACTION_NOTSET:
-		case SACCTMGR_USER_CREATE:
-		case SACCTMGR_ACCOUNT_CREATE:
-		case SACCTMGR_CLUSTER_CREATE:
-		case SACCTMGR_ASSOCIATION_CREATE:
-			/* These only have a list so there isn't
-			 * anything else to free 
-			 */
-			break;
-		case SACCTMGR_USER_MODIFY:
-			destroy_acct_user_rec(action->rec);
-			destroy_acct_user_cond(action->cond);
-			break;
-		case SACCTMGR_USER_DELETE:
-			destroy_acct_user_cond(action->cond);
-			break;
-		case SACCTMGR_ACCOUNT_MODIFY:
-			destroy_acct_account_rec(action->rec);
-			destroy_acct_account_cond(action->cond);
-			break;
-		case SACCTMGR_ACCOUNT_DELETE:
-			destroy_acct_account_cond(action->cond);
-			break;
-		case SACCTMGR_CLUSTER_MODIFY:
-			destroy_acct_cluster_rec(action->rec);
-			destroy_acct_cluster_cond(action->cond);
-			break;
-		case SACCTMGR_CLUSTER_DELETE:
-			destroy_acct_cluster_cond(action->cond);
-			break;
-		case SACCTMGR_ASSOCIATION_MODIFY:
-			destroy_acct_association_rec(action->rec);
-			destroy_acct_association_cond(action->cond);
-			break;
-		case SACCTMGR_ASSOCIATION_DELETE:
-			destroy_acct_association_cond(action->cond);
-			break;
-		case SACCTMGR_COORD_CREATE:
-			xfree(action->rec);
-			destroy_acct_user_cond(action->cond);
-			break;
-		case SACCTMGR_COORD_DELETE:
-			xfree(action->rec);
-			destroy_acct_user_cond(action->cond);
-			break;	
-		default:
-			error("unknown action %d", action->type);
-			break;
-		}
-		xfree(action);
-	}
-}
-
 extern int notice_thread_init()
 {
 	pthread_attr_t attr;
@@ -603,3 +541,4 @@ extern int get_uint(char *in_value, uint32_t *out_value, char *type)
 		*out_value = (uint32_t) num;
 	return SLURM_SUCCESS;
 }
+
diff --git a/src/sacctmgr/sacctmgr.c b/src/sacctmgr/sacctmgr.c
index c56e76ddec2..3e5d31ffc20 100644
--- a/src/sacctmgr/sacctmgr.c
+++ b/src/sacctmgr/sacctmgr.c
@@ -39,7 +39,6 @@
 \*****************************************************************************/
 
 #include "src/sacctmgr/sacctmgr.h"
-#include "src/sacctmgr/print.h"
 #include "src/common/xsignal.h"
 
 #define OPT_LONG_HIDE   0x102
@@ -143,10 +142,10 @@ main (int argc, char *argv[])
 			one_liner = 1;
 			break;
 		case (int)'n':
-			have_header = 0;
+			print_fields_have_header = 0;
 			break;
 		case (int)'p':
-			parsable_print = 1;
+			print_fields_parsable_print = 1;
 			break;
 		case (int)'q':
 			quiet_flag = 1;
@@ -197,7 +196,6 @@ main (int argc, char *argv[])
 
 	acct_storage_g_close_connection(&db_conn);
 	slurm_acct_storage_fini();
-	printf("\n");
 	exit(exit_code);
 }
 
@@ -1168,55 +1166,55 @@ static void _load_file (int argc, char *argv[])
 
 	admin_field.name = "Admin";
 	admin_field.len = 9;
-	admin_field.print_routine = print_str;
+	admin_field.print_routine = print_fields_str;
 
 	name_field.name = "Name";
 	name_field.len = 10;
-	name_field.print_routine = print_str;
+	name_field.print_routine = print_fields_str;
 		
 	parent_field.name = "Parent";
 	parent_field.len = 10;
-	parent_field.print_routine = print_str;
+	parent_field.print_routine = print_fields_str;
 	
 	acct_field.name = "Account";
 	acct_field.len = 10;
-	acct_field.print_routine = print_str;
+	acct_field.print_routine = print_fields_str;
 	
 	dacct_field.name = "Def Acct";
 	dacct_field.len = 10;
-	dacct_field.print_routine = print_str;
+	dacct_field.print_routine = print_fields_str;
 	
 	desc_field.name = "Descr";
 	desc_field.len = 10;
-	desc_field.print_routine = print_str;
+	desc_field.print_routine = print_fields_str;
 	
 	org_field.name = "Org";
 	org_field.len = 10;
-	org_field.print_routine = print_str;
+	org_field.print_routine = print_fields_str;
 	
 	qos_field.name = "QOS";
 	qos_field.len = 9;
-	qos_field.print_routine = print_str;
+	qos_field.print_routine = print_fields_str;
 	
 	fs_field.name = "FairShare";
 	fs_field.len = 10;
-	fs_field.print_routine = print_uint;
+	fs_field.print_routine = print_fields_uint;
 
 	mc_field.name = "MaxCPUSecs";
 	mc_field.len = 10;
-	mc_field.print_routine = print_uint;
+	mc_field.print_routine = print_fields_uint;
 
 	mj_field.name = "MaxJobs";
 	mj_field.len = 7;
-	mj_field.print_routine = print_uint;
+	mj_field.print_routine = print_fields_uint;
 
 	mn_field.name = "MaxNodes";
 	mn_field.len = 8;
-	mn_field.print_routine = print_uint;
+	mn_field.print_routine = print_fields_uint;
 
 	mw_field.name = "MaxWall";
 	mw_field.len = 7;
-	mw_field.print_routine = print_time;
+	mw_field.print_routine = print_fields_time;
 		
 	START_TIMER;
 	if(rc == SLURM_SUCCESS && list_count(acct_list)) {
@@ -1228,17 +1226,17 @@ static void _load_file (int argc, char *argv[])
 		list_append(print_fields_list, &org_field);
 		list_append(print_fields_list, &qos_field);
 
-		print_header(print_fields_list);
+		print_fields_header(print_fields_list);
 
 		itr = list_iterator_create(acct_list);
 		while((acct = list_next(itr))) {
-			print_str(SLURM_PRINT_VALUE, &name_field, 
+			print_fields_str(SLURM_PRINT_VALUE, &name_field, 
 				  acct->name);
-			print_str(SLURM_PRINT_VALUE, &desc_field, 
+			print_fields_str(SLURM_PRINT_VALUE, &desc_field, 
 				  acct->description);
-			print_str(SLURM_PRINT_VALUE, &org_field, 
+			print_fields_str(SLURM_PRINT_VALUE, &org_field, 
 				  acct->organization);
-			print_str(SLURM_PRINT_VALUE, &qos_field, 
+			print_fields_str(SLURM_PRINT_VALUE, &qos_field, 
 				  acct_qos_str(acct->qos));
 			printf("\n");
 		}
@@ -1261,23 +1259,24 @@ static void _load_file (int argc, char *argv[])
 		list_append(print_fields_list, &mn_field);
 		list_append(print_fields_list, &mw_field);
 
-		print_header(print_fields_list);
+		print_fields_header(print_fields_list);
 		
 		itr = list_iterator_create(acct_assoc_list);
 		while((assoc = list_next(itr))) {
-			print_str(SLURM_PRINT_VALUE, &name_field, assoc->acct);
-			print_str(SLURM_PRINT_VALUE, &parent_field, 
-				  assoc->parent_acct);
-			print_uint(SLURM_PRINT_VALUE, &fs_field, 
-				   assoc->fairshare);
-			print_uint(SLURM_PRINT_VALUE, &mc_field, 
-				   assoc->max_cpu_secs_per_job);
-			print_uint(SLURM_PRINT_VALUE, &mj_field, 
-				   assoc->max_jobs);
-			print_uint(SLURM_PRINT_VALUE, &mn_field, 
-				   assoc->max_nodes_per_job);
-			print_time(SLURM_PRINT_VALUE, &mw_field,
-				   assoc->max_wall_duration_per_job);
+			print_fields_str(SLURM_PRINT_VALUE, &name_field,
+					 assoc->acct);
+			print_fields_str(SLURM_PRINT_VALUE, &parent_field, 
+					 assoc->parent_acct);
+			print_fields_uint(SLURM_PRINT_VALUE, &fs_field, 
+					  assoc->fairshare);
+			print_fields_uint(SLURM_PRINT_VALUE, &mc_field, 
+					  assoc->max_cpu_secs_per_job);
+			print_fields_uint(SLURM_PRINT_VALUE, &mj_field, 
+					  assoc->max_jobs);
+			print_fields_uint(SLURM_PRINT_VALUE, &mn_field, 
+					  assoc->max_nodes_per_job);
+			print_fields_time(SLURM_PRINT_VALUE, &mw_field,
+					  assoc->max_wall_duration_per_job);
 			printf("\n");
 		}
 		list_iterator_destroy(itr);
@@ -1297,17 +1296,19 @@ static void _load_file (int argc, char *argv[])
 		list_append(print_fields_list, &qos_field);
 		list_append(print_fields_list, &admin_field);
 
-		print_header(print_fields_list);
+		print_fields_header(print_fields_list);
 
 		itr = list_iterator_create(user_list);
 		while((acct = list_next(itr))) {
-			print_str(SLURM_PRINT_VALUE, &name_field, user->name);
-			print_str(SLURM_PRINT_VALUE, &dacct_field, 
-				  user->default_acct);
-			print_str(SLURM_PRINT_VALUE, &qos_field, 
-				  acct_qos_str(user->qos));
-			print_str(SLURM_PRINT_VALUE, &admin_field,
-				  acct_admin_level_str(user->admin_level));
+			print_fields_str(SLURM_PRINT_VALUE, &name_field,
+					 user->name);
+			print_fields_str(SLURM_PRINT_VALUE, &dacct_field, 
+					 user->default_acct);
+			print_fields_str(SLURM_PRINT_VALUE, &qos_field, 
+					 acct_qos_str(user->qos));
+			print_fields_str(SLURM_PRINT_VALUE, &admin_field,
+					 acct_admin_level_str(
+						 user->admin_level));
 			printf("\n");
 		}
 		list_iterator_destroy(itr);
@@ -1330,21 +1331,23 @@ static void _load_file (int argc, char *argv[])
 		list_append(print_fields_list, &mn_field);
 		list_append(print_fields_list, &mw_field);
 
-		print_header(print_fields_list);
+		print_fields_header(print_fields_list);
 		
 		itr = list_iterator_create(user_assoc_list);
 		while((assoc = list_next(itr))) {
-			print_str(SLURM_PRINT_VALUE, &name_field, assoc->user);
-			print_str(SLURM_PRINT_VALUE, &acct_field, assoc->acct);
-			print_uint(SLURM_PRINT_VALUE, &fs_field, 
+			print_fields_str(SLURM_PRINT_VALUE, &name_field,
+					 assoc->user);
+			print_fields_str(SLURM_PRINT_VALUE, &acct_field,
+					 assoc->acct);
+			print_fields_uint(SLURM_PRINT_VALUE, &fs_field, 
 				   assoc->fairshare);
-			print_uint(SLURM_PRINT_VALUE, &mc_field, 
+			print_fields_uint(SLURM_PRINT_VALUE, &mc_field, 
 				   assoc->max_cpu_secs_per_job);
-			print_uint(SLURM_PRINT_VALUE, &mj_field, 
+			print_fields_uint(SLURM_PRINT_VALUE, &mj_field, 
 				   assoc->max_jobs);
-			print_uint(SLURM_PRINT_VALUE, &mn_field, 
+			print_fields_uint(SLURM_PRINT_VALUE, &mn_field, 
 				   assoc->max_nodes_per_job);
-			print_uint(SLURM_PRINT_VALUE, &mw_field,
+			print_fields_uint(SLURM_PRINT_VALUE, &mw_field,
 				   assoc->max_wall_duration_per_job);
 			printf("\n");
 		}
diff --git a/src/sacctmgr/sacctmgr.h b/src/sacctmgr/sacctmgr.h
index 00b665f568c..7796bb7241c 100644
--- a/src/sacctmgr/sacctmgr.h
+++ b/src/sacctmgr/sacctmgr.h
@@ -81,37 +81,11 @@
 #include "src/common/parse_time.h"
 #include "src/common/slurm_accounting_storage.h"
 #include "src/common/xstring.h"
+#include "src/common/print_fields.h"
 
 #define CKPT_WAIT	10
 #define	MAX_INPUT_FIELDS 128
 
-typedef enum {
-	SACCTMGR_ACTION_NOTSET,
-	SACCTMGR_USER_CREATE,
-	SACCTMGR_USER_MODIFY,
-	SACCTMGR_USER_DELETE,
-	SACCTMGR_ACCOUNT_CREATE,
-	SACCTMGR_ACCOUNT_MODIFY,
-	SACCTMGR_ACCOUNT_DELETE,
-	SACCTMGR_CLUSTER_CREATE,
-	SACCTMGR_CLUSTER_MODIFY,
-	SACCTMGR_CLUSTER_DELETE,
-	SACCTMGR_ASSOCIATION_CREATE,
-	SACCTMGR_ASSOCIATION_MODIFY,
-	SACCTMGR_ASSOCIATION_DELETE,
-	SACCTMGR_COORD_CREATE,
-	SACCTMGR_COORD_DELETE
-} sacctmgr_action_type_t;
-
-typedef struct {
-	sacctmgr_action_type_t type;
-	void *cond; /* if the action has a condition typecast to an
-		     * account_*_cond_t * */
-	void *rec; /* if the action has a record typecast to an
-		    * account_*_rec_t * or char * for type COORD */
-	List list; /* if the action has a list */
-} sacctmgr_action_t;
-
 extern char *command_name;
 extern int exit_code;	/* sacctmgr's exit code, =1 on any error at any time */
 extern int exit_flag;	/* program to terminate if =1 */
diff --git a/src/sacctmgr/user_functions.c b/src/sacctmgr/user_functions.c
index a42924cd670..dfc4883ce18 100644
--- a/src/sacctmgr/user_functions.c
+++ b/src/sacctmgr/user_functions.c
@@ -37,7 +37,6 @@
 \*****************************************************************************/
 
 #include "src/sacctmgr/sacctmgr.h"
-#include "src/sacctmgr/print.h"
 
 static int _set_cond(int *start, int argc, char *argv[],
 		     acct_user_cond_t *user_cond,
@@ -745,72 +744,72 @@ extern int sacctmgr_list_user(int argc, char *argv[])
 			field->type = PRINT_ACCOUNT;
 			field->name = xstrdup("Account");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("AdminLevel", object, 2)) {
 			field->type = PRINT_ADMIN;
 			field->name = xstrdup("Admin");
 			field->len = 9;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Cluster", object, 1)) {
 			field->type = PRINT_CLUSTER;
 			field->name = xstrdup("Cluster");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("Default", object, 1)) {
 			field->type = PRINT_DACCT;
 			field->name = xstrdup("Def Acct");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("FairShare", object, 1)) {
 			field->type = PRINT_FAIRSHARE;
 			field->name = xstrdup("FairShare");
 			field->len = 9;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("ID", object, 1)) {
 			field->type = PRINT_ID;
 			field->name = xstrdup("ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
 			field->type = PRINT_MAXC;
 			field->name = xstrdup("MaxCPUSecs");
 			field->len = 11;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxJobs", object, 4)) {
 			field->type = PRINT_MAXJ;
 			field->name = xstrdup("MaxJobs");
 			field->len = 7;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxNodes", object, 4)) {
 			field->type = PRINT_MAXN;
 			field->name = xstrdup("MaxNodes");
 			field->len = 8;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("MaxWall", object, 4)) {
 			field->type = PRINT_MAXW;
 			field->name = xstrdup("MaxWall");
 			field->len = 11;
-			field->print_routine = print_time;
+			field->print_routine = print_fields_time;
 		} else if(!strncasecmp("QOS", object, 1)) {
 			field->type = PRINT_QOS;
 			field->name = xstrdup("QOS");
 			field->len = 9;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("ParentID", object, 7)) {
 			field->type = PRINT_PID;
 			field->name = xstrdup("Par ID");
 			field->len = 6;
-			field->print_routine = print_uint;
+			field->print_routine = print_fields_uint;
 		} else if(!strncasecmp("Partition", object, 4)) {
 			field->type = PRINT_PART;
 			field->name = xstrdup("Partition");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else if(!strncasecmp("User", object, 1)) {
 			field->type = PRINT_USER;
 			field->name = xstrdup("User");
 			field->len = 10;
-			field->print_routine = print_str;
+			field->print_routine = print_fields_str;
 		} else {
 			printf("Unknown field '%s'\n", object);
 			xfree(field);
@@ -822,7 +821,7 @@ extern int sacctmgr_list_user(int argc, char *argv[])
 
 	itr = list_iterator_create(user_list);
 	itr2 = list_iterator_create(print_fields_list);
-	print_header(print_fields_list);
+	print_fields_header(print_fields_list);
 
 	while((user = list_next(itr))) {
 		if(user->assoc_list && list_count(user->assoc_list)) {
@@ -1019,8 +1018,6 @@ extern int sacctmgr_list_user(int argc, char *argv[])
 		}
 	}
 
-	printf("\n");
-
 	list_iterator_destroy(itr2);
 	list_iterator_destroy(itr);
 	list_destroy(user_list);
diff --git a/src/sreport/Makefile.am b/src/sreport/Makefile.am
index 787edb25708..ad69982f041 100644
--- a/src/sreport/Makefile.am
+++ b/src/sreport/Makefile.am
@@ -10,7 +10,7 @@ sreport_SOURCES =	\
 	sreport.c sreport.h \
 	cluster_reports.c cluster_reports.h \
 	assoc_reports.c assoc_reports.h	\
-	common.c common.h
+	common.c
 
 sreport_LDADD =  \
 	$(top_builddir)/src/common/libcommon.o -ldl \
diff --git a/src/sreport/Makefile.in b/src/sreport/Makefile.in
index e15b13e502b..5f524356c8e 100644
--- a/src/sreport/Makefile.in
+++ b/src/sreport/Makefile.in
@@ -70,7 +70,8 @@ CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_sreport_OBJECTS = sreport.$(OBJEXT)
+am_sreport_OBJECTS = sreport.$(OBJEXT) cluster_reports.$(OBJEXT) \
+	assoc_reports.$(OBJEXT) common.$(OBJEXT)
 sreport_OBJECTS = $(am_sreport_OBJECTS)
 am__DEPENDENCIES_1 =
 sreport_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
@@ -266,7 +267,10 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir)
 sreport_SOURCES = \
-	sreport.c sreport.h	
+	sreport.c sreport.h \
+	cluster_reports.c cluster_reports.h \
+	assoc_reports.c assoc_reports.h	\
+	common.c
 
 sreport_LDADD = \
 	$(top_builddir)/src/common/libcommon.o -ldl \
@@ -345,6 +349,9 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assoc_reports.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cluster_reports.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sreport.Po@am__quote@
 
 .c.o:
diff --git a/src/sreport/assoc_reports.c b/src/sreport/assoc_reports.c
index e69de29bb2d..40d718f1a97 100644
--- a/src/sreport/assoc_reports.c
+++ b/src/sreport/assoc_reports.c
@@ -0,0 +1,40 @@
+/*****************************************************************************\
+ *  assoc_resports.c - functions for generating association reports
+ *                     from accounting infrastructure.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  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.
+\*****************************************************************************/
+
+#include "assoc_reports.h"
diff --git a/src/sreport/assoc_reports.h b/src/sreport/assoc_reports.h
index e69de29bb2d..bc0946421fd 100644
--- a/src/sreport/assoc_reports.h
+++ b/src/sreport/assoc_reports.h
@@ -0,0 +1,46 @@
+/*****************************************************************************\
+ *  assoc_resports.h - functions for generating association reports
+ *                     from accounting infrastructure.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  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.
+\*****************************************************************************/
+
+#ifndef __SREPORT_ASSOC_REPORTS_H
+#define __SREPORT_ASSOC_REPORTS_H
+
+#include "sreport.h"
+
+
+#endif
diff --git a/src/sreport/cluster_reports.c b/src/sreport/cluster_reports.c
index e69de29bb2d..5d3ba363f04 100644
--- a/src/sreport/cluster_reports.c
+++ b/src/sreport/cluster_reports.c
@@ -0,0 +1,325 @@
+/*****************************************************************************\
+ *  cluster_resports.c - functions for generating cluster reports
+ *                       from accounting infrastructure.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  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.
+\*****************************************************************************/
+
+#include "cluster_reports.h"
+
+enum {
+	PRINT_CLUSTER_NAME,
+	PRINT_CLUSTER_CPUS,
+	PRINT_CLUSTER_ACPU,
+	PRINT_CLUSTER_DCPU,
+	PRINT_CLUSTER_ICPU,
+	PRINT_CLUSTER_OCPU,
+	PRINT_CLUSTER_RCPU,
+	PRINT_CLUSTER_TOTAL
+};
+
+List print_fields_list; /* types are of print_field_t */
+
+static int _set_cond(int *start, int argc, char *argv[],
+		     acct_cluster_cond_t *cluster_cond,
+		     List format_list)
+{
+	int i;
+	int set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i--;
+			break;
+		} else if(!end && !strncasecmp(argv[i], "where", 5)) {
+			continue;
+		} else if(!end) {
+			addto_char_list(cluster_cond->cluster_list, argv[i]);
+			set = 1;
+		} else if (strncasecmp (argv[i], "End", 1) == 0) {
+			cluster_cond->usage_end = parse_time(argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Format", 1) == 0) {
+			if(format_list)
+				addto_char_list(format_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Names", 1) == 0) {
+			addto_char_list(cluster_cond->cluster_list,
+					argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Start", 1) == 0) {
+			cluster_cond->usage_start = parse_time(argv[i]+end);
+			set = 1;
+		} else {
+			printf(" Unknown condition: %s\n"
+			       "Use keyword set to modify value\n", argv[i]);
+		}
+	}
+	(*start) = i;
+
+	return set;
+}
+
+static int _setup_print_fields_list(List format_list)
+{
+	ListIterator itr = NULL;
+	print_field_t *field = NULL;
+	char *object = NULL;
+
+	if(!format_list || !list_count(format_list)) {
+		printf(" error: we need a format list to set up the print.\n");
+		return SLURM_ERROR;
+	}
+
+	if(!print_fields_list)
+		print_fields_list = list_create(destroy_print_field);
+
+	itr = list_iterator_create(format_list);
+	while((object = list_next(itr))) {
+		field = xmalloc(sizeof(print_field_t));
+		if(!strncasecmp("Cluster", object, 2)) {
+			field->type = PRINT_CLUSTER_NAME;
+			field->name = xstrdup("Cluster");
+			field->len = 10;
+			field->print_routine = print_fields_str;
+		} else if(!strncasecmp("cpu_count", object, 2)) {
+			field->type = PRINT_CLUSTER_CPUS;
+			field->name = xstrdup("CPU count");
+			field->len = 10;
+			field->print_routine = print_fields_uint;
+		} else if(!strncasecmp("allocated", object, 1)) {
+			field->type = PRINT_CLUSTER_ACPU;
+			field->name = xstrdup("Allocated");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else if(!strncasecmp("down", object, 1)) {
+			field->type = PRINT_CLUSTER_DCPU;
+			field->name = xstrdup("Down");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else if(!strncasecmp("idle", object, 1)) {
+			field->type = PRINT_CLUSTER_ICPU;
+			field->name = xstrdup("Idle");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else if(!strncasecmp("reserved", object, 1)) {
+			field->type = PRINT_CLUSTER_RCPU;
+			field->name = xstrdup("Reserved");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else if(!strncasecmp("overcommited", object, 1)) {
+			field->type = PRINT_CLUSTER_OCPU;
+			field->name = xstrdup("Over Comm");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else if(!strncasecmp("total", object, 1)) {
+			field->type = PRINT_CLUSTER_TOTAL;
+			field->name = xstrdup("Total Time");
+			if(time_format == SREPORT_TIME_SECS_PER)
+				field->len = 20;
+			else
+				field->len = 12;
+			field->print_routine = sreport_print_time;
+		} else {
+			printf("Unknown field '%s'\n", object);
+			xfree(field);
+			continue;
+		}
+		list_append(print_fields_list, field);		
+	}
+	list_iterator_destroy(itr);
+
+	return SLURM_SUCCESS;
+}
+
+static List _get_cluster_list(int argc, char *argv[], List format_list)
+{
+	acct_cluster_cond_t *cluster_cond = 
+		xmalloc(sizeof(acct_cluster_cond_t));
+	List cluster_list = NULL;
+	int i=0;
+
+	cluster_cond->cluster_list = list_create(slurm_destroy_char);
+	cluster_cond->with_usage = 1;
+	_set_cond(&i, argc, argv, cluster_cond, format_list);
+	
+	cluster_list = acct_storage_g_get_clusters(db_conn, cluster_cond);
+	destroy_acct_cluster_cond(cluster_cond);
+	
+	if(!cluster_list) 
+		printf(" Problem with query.\n");
+
+	return cluster_list;
+}
+
+extern int cluster_utilization(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	ListIterator itr3 = NULL;
+	acct_cluster_rec_t *cluster = NULL;
+
+	print_field_t *field = NULL;
+
+	List cluster_list = NULL;
+	List format_list = list_create(slurm_destroy_char);
+
+	print_fields_list = list_create(destroy_print_field);
+
+	if(!list_count(format_list)) 
+		addto_char_list(format_list, "Cl,a,d,i,r,o");
+	
+
+	if(!(cluster_list = _get_cluster_list(argc, argv, format_list))) {
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	_setup_print_fields_list(format_list);
+	
+	itr = list_iterator_create(cluster_list);
+	itr2 = list_iterator_create(print_fields_list);
+
+	print_fields_header(print_fields_list);
+
+	while((cluster = list_next(itr))) {
+		cluster_accounting_rec_t *accting = NULL;
+		cluster_accounting_rec_t total_acct;
+		uint32_t total_time = 0;
+
+		if(!cluster->accounting_list
+		   || !list_count(cluster->accounting_list))
+			continue;
+
+		memset(&total_acct, 0, sizeof(cluster_accounting_rec_t));
+		
+		itr3 = list_iterator_create(cluster->accounting_list);
+		while((accting = list_next(itr3))) {
+			total_acct.alloc_secs += accting->alloc_secs;
+			total_acct.down_secs += accting->down_secs;
+			total_acct.idle_secs += accting->idle_secs;
+			total_acct.resv_secs += accting->resv_secs;
+			total_acct.over_secs += accting->over_secs;
+			total_acct.cpu_count += accting->cpu_count;
+		}
+		list_iterator_destroy(itr3);
+
+		total_acct.cpu_count /= list_count(cluster->accounting_list);
+
+		total_time = total_acct.alloc_secs + total_acct.down_secs 
+			+ total_acct.idle_secs + total_acct.resv_secs;
+
+		while((field = list_next(itr2))) {
+			switch(field->type) {
+			case PRINT_CLUSTER_NAME:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     cluster->name);		
+				break;
+			case PRINT_CLUSTER_CPUS:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.cpu_count);
+				break;
+			case PRINT_CLUSTER_ACPU:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.alloc_secs,
+						     total_time);
+				break;
+			case PRINT_CLUSTER_DCPU:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.down_secs,
+						     total_time);
+				break;
+			case PRINT_CLUSTER_ICPU:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.idle_secs,
+						     total_time);
+				break;
+			case PRINT_CLUSTER_RCPU:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.resv_secs,
+						     total_time);
+				break;
+			case PRINT_CLUSTER_OCPU:
+					field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_acct.over_secs,
+						     total_time);
+				break;
+			case PRINT_CLUSTER_TOTAL:
+				field->print_routine(SLURM_PRINT_VALUE,
+						     field,
+						     total_time,
+						     total_time);
+				break;
+			default:
+				break;
+			}
+		}
+		list_iterator_reset(itr2);
+		printf("\n");
+	}
+
+	list_iterator_destroy(itr2);
+	list_iterator_destroy(itr);
+	list_destroy(cluster_list);
+
+end_it:
+	list_destroy(print_fields_list);
+
+	return rc;
+}
diff --git a/src/sreport/cluster_reports.h b/src/sreport/cluster_reports.h
index e69de29bb2d..a25f513963d 100644
--- a/src/sreport/cluster_reports.h
+++ b/src/sreport/cluster_reports.h
@@ -0,0 +1,47 @@
+/*****************************************************************************\
+ *  cluster_resports.h - functions for generating cluster reports
+ *                       from accounting infrastructure.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  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.
+\*****************************************************************************/
+
+#ifndef __SREPORT_CLUSTER_REPORTS_H
+#define __SREPORT_CLUSTER_REPORTS_H
+
+#include "sreport.h"
+
+extern int cluster_utilization(int argc, char *argv[]);
+
+#endif
diff --git a/src/sreport/common.c b/src/sreport/common.c
index e69de29bb2d..358581425d0 100644
--- a/src/sreport/common.c
+++ b/src/sreport/common.c
@@ -0,0 +1,204 @@
+/*****************************************************************************\
+ *  common.c - common functions for generating reports
+ *             from accounting infrastructure.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  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.
+\*****************************************************************************/
+
+#include "sreport.h"
+
+extern void sreport_print_time(type_t type, print_field_t *field,
+			       uint32_t value, uint32_t total_time)
+{
+	if(!total_time)
+		total_time = 1;
+
+	switch(type) {
+	case SLURM_PRINT_HEADLINE:
+		if(print_fields_parsable_print)
+			printf("%s|", field->name);
+		else
+			printf("%-*.*s ", field->len, field->len, field->name);
+		break;
+	case SLURM_PRINT_UNDERSCORE:
+		if(!print_fields_parsable_print)
+			printf("%-*.*s ", field->len, field->len, 
+			       "---------------------------------------");
+		break;
+	case SLURM_PRINT_VALUE:
+		/* (value == unset)  || (value == cleared) */
+		if((value == NO_VAL) || (value == INFINITE)) {
+			if(print_fields_parsable_print)
+				printf("|");	
+			else				
+				printf("%-*s ", field->len, " ");
+		} else {
+			char *output = NULL;
+			float percent = (float)value;
+			
+			switch(time_format) {
+			case SREPORT_TIME_SECS:
+				output = xstrdup_printf("%u", value);
+				break;
+			case SREPORT_TIME_PERCENT:
+				percent /= total_time;
+				percent *= 100;
+				output = xstrdup_printf("%.2f%%", percent);
+				break; 
+			case SREPORT_TIME_SECS_PER:
+				percent /= (float)total_time;
+				percent *= 100;
+				output = xstrdup_printf("%u(%.2f%%)",
+							value, percent);
+				break;
+			default:
+				output = xstrdup_printf("%u", value);
+				break;
+			}
+
+			if(print_fields_parsable_print)
+				printf("%s|", output);	
+			else
+				printf("%*s ", field->len, output);
+			xfree(output);
+		}
+		break;
+	default:
+		if(print_fields_parsable_print)
+			printf("%s|", "n/a");
+		else
+			printf("%-*.*s ", field->len, field->len, "n/a");
+		break;
+	}
+}
+
+extern int parse_option_end(char *option)
+{
+	int end = 0;
+	
+	if(!option)
+		return 0;
+
+	while(option[end] && option[end] != '=')
+		end++;
+	if(!option[end])
+		return 0;
+	end++;
+	return end;
+}
+
+/* you need to xfree whatever is sent from here */
+extern char *strip_quotes(char *option, int *increased)
+{
+	int end = 0;
+	int i=0, start=0;
+	char *meat = NULL;
+
+	if(!option)
+		return NULL;
+
+	/* first strip off the ("|')'s */
+	if (option[i] == '\"' || option[i] == '\'')
+		i++;
+	start = i;
+
+	while(option[i]) {
+		if(option[i] == '\"' || option[i] == '\'') {
+			end++;
+			break;
+		}
+		i++;
+	}
+	end += i;
+
+	meat = xmalloc((i-start)+1);
+	memcpy(meat, option+start, (i-start));
+
+	if(increased)
+		(*increased) += end;
+
+	return meat;
+}
+
+extern void addto_char_list(List char_list, char *names)
+{
+	int i=0, start=0;
+	char *name = NULL, *tmp_char = NULL;
+	ListIterator itr = list_iterator_create(char_list);
+
+	if(names && char_list) {
+		if (names[i] == '\"' || names[i] == '\'')
+			i++;
+		start = i;
+		while(names[i]) {
+			if(names[i] == '\"' || names[i] == '\'')
+				break;
+			else if(names[i] == ',') {
+				if((i-start) > 0) {
+					name = xmalloc((i-start+1));
+					memcpy(name, names+start, (i-start));
+
+					while((tmp_char = list_next(itr))) {
+						if(!strcasecmp(tmp_char, name))
+							break;
+					}
+
+					if(!tmp_char)
+						list_append(char_list, name);
+					else 
+						xfree(name);
+					list_iterator_reset(itr);
+				}
+				i++;
+				start = i;
+			}
+			i++;
+		}
+		if((i-start) > 0) {
+			name = xmalloc((i-start)+1);
+			memcpy(name, names+start, (i-start));
+			while((tmp_char = list_next(itr))) {
+				if(!strcasecmp(tmp_char, name))
+					break;
+			}
+			
+			if(!tmp_char)
+				list_append(char_list, name);
+			else 
+				xfree(name);
+		}
+	}	
+	list_iterator_destroy(itr);
+} 
diff --git a/src/sreport/common.h b/src/sreport/common.h
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/src/sreport/sreport.c b/src/sreport/sreport.c
index a215f1fb565..6cea0a9ce37 100644
--- a/src/sreport/sreport.c
+++ b/src/sreport/sreport.c
@@ -37,6 +37,8 @@
 \*****************************************************************************/
 
 #include "src/sreport/sreport.h"
+#include "src/sreport/assoc_reports.h"
+#include "src/sreport/cluster_reports.h"
 #include "src/common/xsignal.h"
 
 #define OPT_LONG_HIDE   0x102
@@ -89,7 +91,7 @@ main (int argc, char *argv[])
 	quiet_flag        = 0;
 	log_init("sacctmgr", opts, SYSLOG_FACILITY_DAEMON, NULL);
 
-	while((opt_char = getopt_long(argc, argv, "hionpqsvV",
+	while((opt_char = getopt_long(argc, argv, "hionpqst:vV",
 			long_options, &option_index)) != -1) {
 		switch (opt_char) {
 		case (int)'?':
@@ -107,18 +109,21 @@ main (int argc, char *argv[])
 		case (int)'o':
 			one_liner = 1;
 			break;
-/* 		case (int)'n': */
-/* 			have_header = 0; */
-/* 			break; */
-/* 		case (int)'p': */
-/* 			parsable_print = 1; */
-/* 			break; */
+		case (int)'n':
+			print_fields_have_header = 0;
+			break;
+		case (int)'p':
+			print_fields_parsable_print = 1;
+			break;
 		case (int)'q':
 			quiet_flag = 1;
 			break;
 		case (int)'s':
 			with_assoc_flag = 1;
 			break;
+		case (int)'t':
+			_set_time_format(optarg);
+			break;
 		case (int)'v':
 			quiet_flag = -1;
 			break;
@@ -162,7 +167,6 @@ main (int argc, char *argv[])
 
 	acct_storage_g_close_connection(&db_conn);
 	slurm_acct_storage_fini();
-	printf("\n");
 	exit(exit_code);
 }
 
@@ -327,9 +331,8 @@ _process_command (int argc, char *argv[])
 			fprintf (stderr,
 				 "too few arguments for keyword:%s\n",
 				 argv[0]);
-		}		
-		_set_time_format(argv[1]);
-		quiet_flag = -1;
+		} else		
+			_set_time_format(argv[1]);
 	} else if (strncasecmp (argv[0], "verbose", 4) == 0) {
 		if (argc > 1) {
 			exit_code = 1;
@@ -346,6 +349,8 @@ _process_command (int argc, char *argv[])
 				 argv[0]);
 		}		
 		_print_version();
+	} else if ((strncasecmp (argv[0], "cu", 2) == 0)) {
+		cluster_utilization((argc - 1), &argv[1]);
 	} else {
 		exit_code = 1;
 		fprintf (stderr, "invalid keyword: %s\n", argv[0]);
@@ -360,10 +365,6 @@ static int _set_time_format(char *format)
 		time_format = SREPORT_TIME_SECS_PER;
 	} else if (strncasecmp (format, "Sec", 1) == 0) {
 		time_format = SREPORT_TIME_SECS;
-	} else if (strncasecmp (format, "FormattedPer", 12) == 0) {
-		time_format = SREPORT_TIME_FORMATTED_PER;
-	} else if (strncasecmp (format, "Formatted", 1) == 0) {
-		time_format = SREPORT_TIME_FORMATTED;
 	} else if (strncasecmp (format, "Percent", 1) == 0) {
 		time_format = SREPORT_TIME_PERCENT;
 	} else {
diff --git a/src/sreport/sreport.h b/src/sreport/sreport.h
index 67880acf45d..97f113b7f62 100644
--- a/src/sreport/sreport.h
+++ b/src/sreport/sreport.h
@@ -81,6 +81,7 @@
 #include "src/common/parse_time.h"
 #include "src/common/slurm_accounting_storage.h"
 #include "src/common/xstring.h"
+#include "src/common/print_fields.h"
 
 #define CKPT_WAIT	10
 #define	MAX_INPUT_FIELDS 128
@@ -88,11 +89,22 @@
 typedef enum {
 	SREPORT_TIME_SECS,
 	SREPORT_TIME_PERCENT,
-	SREPORT_TIME_FORMATTED,
 	SREPORT_TIME_SECS_PER,
-	SREPORT_TIME_FORMATTED_PER
 } sreport_time_format_t;
 
 extern sreport_time_format_t time_format;
+extern char *command_name;
+extern int exit_code;	/* sacctmgr's exit code, =1 on any error at any time */
+extern int exit_flag;	/* program to terminate if =1 */
+extern int input_words;	/* number of words of input permitted */
+extern int quiet_flag;	/* quiet=1, verbose=-1, normal=0 */
+extern void *db_conn;
+extern uint32_t my_uid;
+
+extern void sreport_print_time(type_t type, print_field_t *field,
+			       uint32_t value, uint32_t total_time);
+extern int parse_option_end(char *option);
+extern char *strip_quotes(char *option, int *increased);
+extern void addto_char_list(List char_list, char *names);
 
 #endif /* HAVE_SREPORT_H */
-- 
GitLab