#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
int main(void)
{
char *op[2] = {"read", "write"};
srand(time(0)); //use current time as seed for random generator
int pause, linect, rout, r = 0;
// Print header
printf("source,cmd,path,IOs,lat.ns,min.lat.ns,max.lat.ns,bytes,max_bytes\n");
// Loop until killed producing pseudo randomly generated NFS metric samples
while (1) {
rout = rand();
pause = time(0)%10;
linect = rout%100;
// We expect that about 5 percent of the time rout%100 will fall between
// 30 and 35. When this happens we want to make our pause unusually long
// which we set to rout%100 here, instead of using: pause = time(0)%10;
if (rout%100 >= 30 && rout%100 < 35) pause = rout%100;
while (linect-- > 0) {
r = rand();
// columns: str,str,str,int,int,int,int,int,int
printf("10.1.100.2,%s,/storage/p01/global/x%d,%d,%d,%d,%d,%d,%d\n",
op[r%2 == 0], r%30, r%99<<3, r/2, r, r, r, r);
}
sleep(pause);
}
return 0;
}