#!/bin/sh # Process the log file written by disklog. # Output has one line per disk, giving the disk name followed by the total number of sectors # reads and written respectively. Sectors are 512 bytes. # Discard all but the last record for each boot-time/disk combination, and then sum the read and # write numbers. awk ' { boottime=$1; diskname=$2; if (boottimes[diskname]) { if (boottime != boottimes[diskname]) { total_reads[diskname] += reads[diskname]; total_writes[diskname] += writes[diskname]; } } else { total_reads[diskname] = 0; total_writes[diskname] = 0; } boottimes[diskname] = boottime; reads[diskname] = $3; writes[diskname] = $4; } END { for (diskname in total_reads) { total_reads[diskname] += reads[diskname]; total_writes[diskname] += writes[diskname]; print diskname, total_reads[diskname], total_writes[diskname]; } }' "$@"