srecord VNStatData( S lastMonthTotal, S thisMonthTotal, S thisMonthEstimated, S yesterdayTotal, S todayTotal, S todayEstimated ) {} static VNStatData parse_vnstat(S output) { LS lines = lines(output); new VNStatData data; int i = indexOfContaining(lines, "monthly"); if (i >= 0) { i = indexOfContaining(lines, i, "---")+1; i = indexOfContaining(lines, i, "---")+1; LS lastMonth = splitAtVerticalBar(get(lines, i-3)); LS thisMonth = splitAtVerticalBar(get(lines, i-2)); LS estimated = splitAtVerticalBar(get(lines, i)); data.lastMonthTotal = get(lastMonth, 2); data.thisMonthTotal = get(thisMonth, 2); data.thisMonthEstimated = get(estimated, 2); } i = indexOfContaining(lines, "daily"); if (i >= 0) { i = indexOfContaining(lines, i, "---")+1; i = indexOfContaining(lines, i, "---")+1; LS yesterday = splitAtVerticalBar(get(lines, i-3)); LS today = splitAtVerticalBar(get(lines, i-2)); LS estimated = splitAtVerticalBar(get(lines, i)); data.yesterdayTotal = get(yesterday, 2); data.todayTotal = get(today, 2); data.todayEstimated = get(estimated, 2); } ret data; }