#!/bin/bash

. ./config.sh

IOR_PARAMS=$1
NETOUTDIR=$2
HOST="$hostname"
PID=$$

NETOUTFILE="$NETOUTDIR/HOST:$HOST#PID:$PID.txt"

function capture_network_state {
    label=$1
    echo "LABEL $label"
    echo "TIMESTAMP $(date +%s)"
    perfquery -x
    cat /proc/net/dev
    free -m
    cat /proc/fs/lustre/llite/esfs-*/max_cached_mb
}

echo "" > $NETOUTFILE
echo "$( capture_network_state "START" )" &>> $NETOUTFILE
$IOR $IOR_PARAMS
echo "$( capture_network_state "STOP" )" &>> $NETOUTFILE
