Added config test for mnttab again.

Added option -s (max sleep time)
Added script stats.sh to generate stats.
This commit is contained in:
hjp 2001-02-21 16:02:46 +00:00
parent 2a61341c39
commit 0fa08b24ed
3 changed files with 32 additions and 7 deletions

View File

@ -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

View File

@ -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 <ant/io.h>
#include <ant/globals.h>
#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

7
ddm/stats.sh Executable file
View File

@ -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