- rhbz 43294: the kernel provides no io stats, configure to compensate

- rhbz 133077: logrotate fixed to continue accounting during rotate
- rhbz 141802: lastcomm was not handling all forms of --strict-match
- rhbz 141971: rpm -e no longer leaves /var/lock/subsys/psacct
- rhbz 43294: sa will never report any io because the kernel doesn't
    provide it. Tweaked configure.in to ignore ac_io in acct.h
This commit is contained in:
ccb 2005-02-07 17:21:14 +00:00
parent f55e500b0c
commit 8ca63119e0
3 changed files with 204 additions and 5 deletions

View File

@ -0,0 +1,118 @@
diff -uNr acct-6.3.2.orig/lastcomm.c acct-6.3.2/lastcomm.c
--- acct-6.3.2.orig/lastcomm.c 2004-08-30 21:15:47.000000000 -0400
+++ acct-6.3.2/lastcomm.c 2004-08-30 21:45:05.000000000 -0400
@@ -40,6 +40,9 @@
# include <time.h>
# endif
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <pwd.h>
@@ -63,6 +66,8 @@
char *program_name; /* name of the program, for usage & errs */
+static unsigned int hzval;
+
/* Here are various lists for the user to specify entries that they
want to see. */
@@ -91,6 +96,7 @@
int c;
int other_pacct_file_specified = 0; /* nonzero if the user used the
`-f' or `--file' flag */
+ hzval = sysconf(_SC_CLK_TCK);
program_name = argv[0];
@@ -318,7 +324,7 @@
btime = (time_t) rec->ac_btime;
printf (" %-8.8s %-8.8s %6.2f secs %-16.16s\n",
this_uid, this_dev,
- ((ut + st) / (double) AHZ),
+ ((ut + st) / (double) hzval),
ctime (&btime));
}
}
diff -uNr acct-6.3.2.orig/sa.c acct-6.3.2/sa.c
--- acct-6.3.2.orig/sa.c 2004-08-30 21:15:47.000000000 -0400
+++ acct-6.3.2/sa.c 2004-08-30 21:47:49.000000000 -0400
@@ -233,6 +233,7 @@
"***other" category */
int always_yes = 0; /* nonzero means always answer yes to
a query */
+static unsigned int hzval;
/* prototypes */
@@ -266,6 +267,7 @@
{
int c;
+ hzval = sysconf(_SC_CLK_TCK);
program_name = argv[0];
/* Cache the page size of the machine for the PAGES_TO_KB macro */
@@ -551,7 +553,7 @@
if (debugging_enabled)
{
- fprintf (stddebug, "AHZ -> %d\n", AHZ);
+ fprintf (stddebug, "hzval -> %d\n", hzval);
fprintf (stddebug, "getpagesize() -> %d\n", getpagesize ());
fprintf (stddebug, "system_page_size == %.2f\n", system_page_size);
}
@@ -901,7 +903,7 @@
/* Christoph Badura <bad@flatlin.ka.sub.org> says:
*
* The k*sec statistic is computed as
- * ((ac_utime+ac_stime)*pages_to_kbytes(ac_mem))/AHZ. Of course you
+ * ((ac_utime+ac_stime)*pages_to_kbytes(ac_mem))/hzval. Of course you
* need to expand the comp_t values.
*
* PAGES_TO_KBYTES(x) simply divides x by (getpagesize()/1024). Of
@@ -1103,33 +1105,33 @@
{
#ifdef HAVE_ACUTIME
# ifdef ACUTIME_COMPT
- double ut = comp_t_2_double (rec->ac_utime) / (double) AHZ;
+ double ut = comp_t_2_double (rec->ac_utime) / (double) hzval;
# else
- double ut = (double) rec->ac_utime / (double) AHZ;
+ double ut = (double) rec->ac_utime / (double) hzval;
# endif
#endif
#ifdef HAVE_ACSTIME
# ifdef ACSTIME_COMPT
- double st = comp_t_2_double (rec->ac_stime) / (double) AHZ;
+ double st = comp_t_2_double (rec->ac_stime) / (double) hzval;
# else
- double st = (double) rec->ac_stime / (double) AHZ;
+ double st = (double) rec->ac_stime / (double) hzval;
# endif
#endif
#ifdef HAVE_ACETIME
# ifdef ACETIME_COMPT
- double et = comp_t_2_double (rec->ac_etime) / (double) AHZ;
+ double et = comp_t_2_double (rec->ac_etime) / (double) hzval;
# else
- double et = (double) rec->ac_etime / (double) AHZ;
+ double et = (double) rec->ac_etime / (double) hzval;
# endif
#endif
#ifdef HAVE_ACIO
# ifdef ACIO_COMPT
- double di = comp_t_2_double (rec->ac_io) / (double) AHZ;
+ double di = comp_t_2_double (rec->ac_io) / (double) hzval;
# else
- double di = (double) rec->ac_io / (double) AHZ;
+ double di = (double) rec->ac_io / (double) hzval;
# endif
#endif

View File

@ -0,0 +1,68 @@
--- acct-6.3.2/lastcomm.c.strictmatch 2005-02-01 17:01:54.000000000 -0500
+++ acct-6.3.2/lastcomm.c 2005-02-02 00:06:41.000000000 -0500
@@ -43,7 +43,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include <pwd.h>
#include "common.h"
@@ -80,7 +82,7 @@
/* protos */
-void main PARAMS((int, char *[]));
+int main PARAMS((int, char *[]));
void give_usage PARAMS((void));
void parse_entries PARAMS((void));
char *devname PARAMS((long));
@@ -90,7 +92,7 @@
/* code */
-void
+int
main (int argc, char *argv[])
{
int c;
@@ -349,12 +351,30 @@
{
/* All categories must have one match. */
- if (all_list
- && hashtab_find (all_list, uid, 0) == NULL
- && hashtab_find (all_list, dev, 0) == NULL
- && hashtab_find (all_list, comm, COMM_LEN) == NULL)
- return 0;
-
+ if (all_list)
+ {
+ struct hashtab_order ho;
+ struct hashtab_elem* he;
+ char *key;
+ int haveall = 1;
+
+ /* walk the all_list hash */
+ he = hashtab_first( all_list, &ho );
+ if( he == NULL ) return 0; /* empty hash??? */
+ while (haveall && he)
+ {
+ key = (char *) hashtab_get_key(he);
+ /* every element must match at least one of {uid,dev,comm}
+ * our parameters
+ */
+ haveall &= !strcmp( key, uid ) || !strcmp( key, dev )
+ || !strncmp( key, comm, COMM_LEN );
+
+ he = hashtab_next( &ho );
+ }
+ return haveall;
+ }
+
if (tty_list && hashtab_find (tty_list, dev, 0) == NULL)
return 0;

View File

@ -12,7 +12,7 @@
Summary: Utilities for monitoring process activities.
Name: psacct
Version: 6.3.2
Release: 31
Release: 34.fc4
License: GPL
Group: Applications/System
Source: ftp://ftp.gnu.org/pub/gnu/acct-6.3.2.tar.gz
@ -23,8 +23,9 @@ Patch0: acct-6.3.2-config.patch
Patch1: acct-6.3.2-exit.patch
# Fixes some broken calls to ctime() on 64bit arch's <mharris@redhat.com>
Patch2: psacct-6.3.2-64bit-fixes.patch
Patch3: psacct-6.3.2-hz.patch
Patch3: psacct-6.3.2-hzval-fixes2.patch
Patch4: acct-6.3.2-pts.patch
Patch5: psacct-6.3.2-strictmatch.patch
Buildroot: %{_tmppath}/%{name}-%{version}-root
Prereq: /sbin/install-info
@ -53,6 +54,7 @@ commmands.
%patch2 -p0 -b .64bit-fixes
%patch3 -p1 -b .hz
%patch4 -p1 -b .pts
%patch5 -p1 -b .strictmatch
%build
%if ! %{FHS_compliant}
@ -61,7 +63,7 @@ autoconf
%configure
sed -e "s/\/\* #undef HAVE_LINUX_ACCT_H \*\//#define HAVE_LINUX_ACCT_H/" config.h > config.h.new
mv -f config.h.new config.h
sed -e "s;#define HAVE_ACIO 1;/* #undef HAVE_ACIO */;" config.h.new > config.h
touch texinfo.tex
make
@ -84,10 +86,12 @@ cat > $RPM_BUILD_ROOT/etc/logrotate.d/psacct <<EOF
# Logrotate file for psacct RPM
%{accounting_logdir}/pacct {
prerotate
%{_sbindir}/accton
# prerotate loses accounting records, let's no
#prerotate
# %{_sbindir}/accton
endscript
compress
delatcompress
notifempty
daily
rotate 31
@ -123,6 +127,7 @@ fi
%preun
if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/accounting.info.gz %{_infodir}/dir --entry="* accounting: (accounting). The GNU Process Accounting Suite." 2>/dev/null
/sbin/service psacct stop > /dev/null 2>&1
/sbin/chkconfig --del psacct
fi
@ -154,6 +159,14 @@ fi
%{_infodir}/accounting.info.gz
%changelog
* Thu Feb 3 2005 Charles Bennett <ccb@redhat.com> 6.3.2-33.fc4
- rhbz 133077: logrotate fixed to continue accounting during rotate
- rhbz 141802: lastcomm was not handling all forms of --strict-match
- rhbz 141971: rpm -e no longer leaves /var/lock/subsys/psacct
- rhbz 43294: sa will never report any io because the kernel doesn't
provide it. Tweaked to ignore ac_io in acct.h
- integrate lastcomm hz patch from RH support
* Wed Sep 1 2004 root <ccb@redhat.com> - 6.3.2-31
- integrate JFenlason's hz patch, improve pts device reporting