2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 #include "cmogstored.h"
9 eor = '\n' @ { iostat->dev_tip = 0; };
10 ignored_line := ( (any-'\n')* eor ) @ {
12 iostat->ready = false;
18 # Linux device mapper: dm-N
19 device_name = ([a-zA-Z0-9/\-]+){1,71} $ {
20 if (iostat->dev_tip < (sizeof(iostat->dev)-1))
21 iostat->dev[iostat->dev_tip++] = fc;
23 utilization = ([0-9\.]+){1,7} > { iostat->util_tip = 0; }
25 if (iostat->util_tip < (sizeof(iostat->util)-1))
26 iostat->util[iostat->util_tip++] = fc;
35 # Skip the middle section for now, some folks may use
36 # await/svctm here. Not sure how standardized those
37 # fields are on non-Linux platforms...
44 mog_iostat_line_done(iostat);
47 main := (stats $! { fhold; fgoto ignored_line; })+;
52 void mog_iostat_init(struct mog_iostat *iostat)
55 struct mog_queue *queue = iostat->queue;
57 memset(iostat, 0, sizeof(struct mog_iostat));
60 iostat->queue = queue;
64 mog_iostat_parse(struct mog_iostat *iostat, char *buf, size_t len)
66 char *p, *pe, *eof = NULL;
69 if (cs == iostat_parser_first_final)
70 return MOG_PARSER_DONE;
79 if (cs == iostat_parser_error)
80 return MOG_PARSER_ERROR;
82 assert(p <= pe && "buffer overflow after iostat parse");
84 if (cs == iostat_parser_first_final)
85 return MOG_PARSER_DONE;
87 return MOG_PARSER_CONTINUE;