diff --git a/ddm/cfg/mnttab.sh b/ddm/cfg/mnttab.sh index ff19bea..b52cffd 100644 --- a/ddm/cfg/mnttab.sh +++ b/ddm/cfg/mnttab.sh @@ -3,7 +3,7 @@ for i in /etc/mnttab /etc/mtab do if [ -f $i ] then - echo '#define MNTTAB "'$i'"' + echo '#define PATH_MNTTAB "'$i'"' exit 0 fi done diff --git a/ddm/ddm.c b/ddm/ddm.c index d498025..f1c2513 100644 --- a/ddm/ddm.c +++ b/ddm/ddm.c @@ -1,5 +1,5 @@ char ddm_c_rcs_id[] = - "$Id: ddm.c,v 1.5 2000-09-07 10:12:35 hjp Exp $"; + "$Id: ddm.c,v 1.6 2001-02-21 16:02:46 hjp Exp $"; /* * ddm - disk delay monitor * @@ -24,8 +24,12 @@ char ddm_c_rcs_id[] = #include #include +#include "cfg/mnttab.h" + + typedef enum { MODE_NONE, MODE_ARGS, MODE_MNTTAB, MODE_DIRFILE } modeT; + static double gettimestamp(void) { struct timeval tm; @@ -34,7 +38,7 @@ static double gettimestamp(void) { } static void usage(void) { - fprintf(stderr, "Usage: %s [-d dirfile | -m mnttab | directory ... ]\n", + fprintf(stderr, "Usage: %s [-d dirfile | -m mnttab | directory ... ] [-s max_sleep_time]\n", cmnd); exit(1); } @@ -57,11 +61,14 @@ int main(int argc, char**argv) { int nr_dirs; int c; char *filename = NULL; + double maxsleeptime = 3600; cmnd = argv[0]; - while ((c = getopt(argc, argv, "d:m:")) != EOF) { + while ((c = getopt(argc, argv, "d:m:s:")) != EOF) { switch (c) { + char *p; + case 'd': mode = MODE_DIRFILE; filename = optarg; @@ -70,6 +77,10 @@ int main(int argc, char**argv) { mode = MODE_MNTTAB; filename = optarg; break; + case 's': + maxsleeptime = strtod(optarg, &p); + if (p == optarg || *p) usage(); + break; case '?': usage(); default: @@ -80,7 +91,7 @@ int main(int argc, char**argv) { if (mode == MODE_NONE) { if (optind == argc) { mode = MODE_MNTTAB; - filename = MNTTAB; + filename = PATH_MNTTAB; } else { mode = MODE_ARGS; dirs = argv + optind; @@ -91,6 +102,8 @@ int main(int argc, char**argv) { } + srand(time(NULL)); + for (;;) { int i; int sleeptime; @@ -181,7 +194,7 @@ int main(int argc, char**argv) { chdir("/"); - sleeptime = rand() * 3600.0 / RAND_MAX; + sleeptime = rand() * maxsleeptime / RAND_MAX; printtimestamp("sleeping %d seconds\n", sleeptime); sleep(sleeptime); } @@ -192,7 +205,12 @@ int main(int argc, char**argv) { /* * $Log: ddm.c,v $ - * Revision 1.5 2000-09-07 10:12:35 hjp + * Revision 1.6 2001-02-21 16:02:46 hjp + * Added config test for mnttab again. + * Added option -s (max sleep time) + * Added script stats.sh to generate stats. + * + * Revision 1.5 2000/09/07 10:12:35 hjp * Added alternate ways to specify directories to be monitored. * * Revision 1.4 2000/06/04 16:33:21 hjp diff --git a/ddm/stats.sh b/ddm/stats.sh new file mode 100755 index 0000000..5c70cb2 --- /dev/null +++ b/ddm/stats.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# simple statistics (min, avg, max) for ddm output + +awk -F : '{ n[$4] ++; s[$4] += $3; if ($3 < min[$4]) min[$4] = $3; if ($3 > max[$4]) max[$4] = $3; } +END { for (i in n) { printf "%10.6f %10.6f %10.6f %s\n", min[i], s[i]/n[i], max[i], i } }' "$@" | sort -n +2 +