Output Virtual Block Device requests information for xentop
PATCH 3/3 Output Virtual Block Device requests information for xentop
This patch adds VBD statistical information into xentop.
Our new xentop collects I/O requests from /proc/xen/vbd and displays them.
This is an example output of the new xentop in the case of 4 VMs.
xentop - 15:34:01 Xen 3.0-unstable
5 domains: 1 running, 4 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 2620476k total, 2128040k used, 492436k free CPUs: 2 @ 2992MHz
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID
Domain-0 -----r 117 5.8 1048780 40.0 no limit n/a 2 8 1 429 0 0 0 0 0
VM1 --b--- 13 0.0 262144 10.0 262144 10.0 2 1 0 6 1 0 20373 4 0
VN2 --b--- 16 0.2 261952 10.0 262144 10.0 2 1 2 155 1 0 3075 875 0
VM3 --b--- 15 0.1 261920 10.0 262144 10.0 2 1 0 110 1 0 3079 761 0 VM4 --b--- 15 0.1 261888 10.0 262144 10.0 2 1 0 85 1 0 3068 813 0
Delay Networks vBds VCPUs Repeat header Sort order Quit
As compared with the traditional xentop, new statistical information (VBDS, VBD_OO, VBD_RD and VBD_WR) is added.
In detail mode, outputs of xentop is as follows.
xentop - 15:34:24 Xen 3.0-unstable
5 domains: 1 running, 4 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 2620476k total, 2128036k used, 492440k free CPUs: 2 @ 2992MHz
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID
Domain-0 -----r 119 7.5 1048660 40.0 no limit n/a 2 8 1 459 0 0 0 0 0 VM1 --b--- 13 0.0 262144 10.0 262144 10.0 2 1 0 6 1 0 20373 4 0 VBD 8:21 oo 0 rd 20373 wr 4 VM2 --b--- 16 0.1 261904 10.0 262144 10.0 2 1 2 185 1 0 3075 915 0 VBD 8:22 oo 0 rd 3075 wr 915 VM3 --b--- 15 0.1 262004 10.0 262144 10.0 2 1 0 140 1 0 3079 895 0 VBD 8:23 oo 0 rd 3079 wr 895 VM4 --b--- 15 0.1 261968 10.0 262144 10.0 2 1 0 115 1 0 3068 814 0 VBD 8:24 oo 0 rd 3068 wr 814
Delay Networks vBds VCPUs Repeat header Sort order Quit
Information about each VBD is displayed under a line of corresponding domain.
Thanks,
Satoshi UCHIDA
# HG changeset patch
# User [email protected]
# Node ID 34e046bdb775a2dce50c3f303ed8839075980eed # Parent 36c4ec5bd99fc700544a90ba88f08e7779c9d668 Add VBD information into xentop.
tools/xenstat/xentop/xentop.c +147 -1
@@ -65,6 +65,7 @@ static int compare(unsigned long long, ustatic int compare (unsigned long long ,unsigned long long );static int compare_domains (xenstat_domain **,xenstat_domain **);static unsigned long long tot_net_bytes (xenstat_domain *,int ); +static unsigned long long tot_vbd_reqs (xenstat_domain *,int );/* Field functions */ static int compare_state (xenstat_domain *domain1,xenstat_domain *domain2);
@@ -87,6 +88,14 @@ static void print_net_tx(xenstat_domainstatic void print_net_tx (xenstat_domain *domain);static int compare_net_rx (xenstat_domain *domain1,xenstat_domain *domain2);static void print_net_rx (xenstat_domain *domain); +static int compare_vbds (xenstat_domain *domain1,xenstat_domain *domain2); +static void print_vbds (xenstat_domain *domain); +static int compare_vbd_oo (xenstat_domain *domain1,xenstat_domain *domain2); +static void print_vbd_oo (xenstat_domain *domain); +static int compare_vbd_rd (xenstat_domain *domain1,xenstat_domain *domain2); +static void print_vbd_rd (xenstat_domain *domain); +static int compare_vbd_wr (xenstat_domain *domain1,xenstat_domain *domain2); +static void print_vbd_wr (xenstat_domain *domain);static int compare_ssid (xenstat_domain *domain1,xenstat_domain *domain2);static void print_ssid (xenstat_domain *domain);static int compare_name (xenstat_domain *domain1,xenstat_domain *domain2);
@@ -99,6 +108,7 @@ static void do_domain(xenstat_domain *);static void do_domain (xenstat_domain *);static void do_vcpu (xenstat_domain *);static void do_network (xenstat_domain *); +static void do_vbd (xenstat_domain *);static void top (void );/* Field types */
@@ -116,6 +126,10 @@ typedef enum field_id {FIELD_NETS ,FIELD_NET_TX ,FIELD_NET_RX , +FIELD_VBDS , +FIELD_VBD_OO , +FIELD_VBD_RD , +FIELD_VBD_WR , FIELD_SSID } field_id;
@@ -140,6 +154,10 @@ field fields[] = { { FIELD_NETS, "NETS", 4, compare_nets, print_nets }, { FIELD_NET_TX, "NETTX(k)", 8, compare_net_tx, print_net_tx }, { FIELD_NET_RX, "NETRX(k)", 8, compare_net_rx, print_net_rx }, + { FIELD_VBDS, "VBDS", 4, compare_vbds, print_vbds }, + { FIELD_VBD_OO, "VBD_OO", 8, compare_vbd_oo, print_vbd_oo }, + { FIELD_VBD_RD, "VBD_RD", 8, compare_vbd_rd, print_vbd_rd }, + { FIELD_VBD_WR, "VBD_WR", 8, compare_vbd_wr, print_vbd_wr }, { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid } };
@@ -154,6 +172,7 @@ unsigned int first_domain_index = 0;unsigned int first_domain_index =0 ;unsigned int delay =3 ;int show_vcpus =0 ; +int show_vbds =0 ;int show_networks =0 ;int repeat_header =0 ;#define PROMPT_VAL_LEN 80
@@ -176,6 +195,7 @@ static void usage(const char *program)"-h, --help display this help and exit\n" "-V, --version output version information and exit\n" "-d, --delay=SECONDS seconds between updates (default 3)\n" +"-b, --vbds output vbd block device data\n" "-n, --networks output vif network data\n" "-r, --repeat-header repeat table header before each domain\n" "-v, --vcpus output vcpu data\n"
@@ -276,6 +296,9 @@ static int handle_key(int ch)if (prompt ==NULL ) {/* Not prompting for input; handle interactive commands */ switch (ch) { +case 'b' :case 'B' : + show_vbds ^=1 ; +break ;case 'n' :case 'N' : show_networks ^=1 ;break ;
@@ -574,6 +597,96 @@ static unsigned long long tot_net_bytes(return total; } +/* Compares number of virtual block devices of two domains, +returning -1,0,1 for * <,=,> */ +static int compare_vbds (xenstat_domain *domain1,xenstat_domain *domain2) +{ +return -compare (xenstat_domain_num_vbds (domain1), +xenstat_domain_num_vbds (domain2)); +} + +/* Prints number of virtual block devices statistic */ +static void print_vbds (xenstat_domain *domain) +{ +"%4u" ,xenstat_domain_num_vbds (domain)); +} + +/* Compares number of total VBD OO requests of two domains, +returning -1,0,1 * for <,=,> */ +static int compare_vbd_oo (xenstat_domain *domain1,xenstat_domain *domain2) +{ +return -compare (tot_vbd_reqs (domain1,FIELD_VBD_OO ), +tot_vbd_reqs (domain2,FIELD_VBD_OO )); +} + +/* Prints number of total VBD OO requests statistic */ +static void print_vbd_oo (xenstat_domain *domain) +{ +"%8llu" ,tot_vbd_reqs (domain,FIELD_VBD_OO )); +} + +/* Compares number of total VBD READ requests of two domains, +returning -1,0,1 * for <,=,> */ +static int compare_vbd_rd (xenstat_domain *domain1,xenstat_domain *domain2) +{ +return -compare (tot_vbd_reqs (domain1,FIELD_VBD_RD ), +tot_vbd_reqs (domain2,FIELD_VBD_RD )); +} + +/* Prints number of total VBD READ requests statistic */ +static void print_vbd_rd (xenstat_domain *domain) +{ +"%8llu" ,tot_vbd_reqs (domain,FIELD_VBD_RD )); +} + +/* Compares number of total VBD WRITE requests of two domains, +returning -1,0,1 * for <,=,> */ +static int compare_vbd_wr (xenstat_domain *domain1,xenstat_domain *domain2) +{ +return -compare (tot_vbd_reqs (domain1,FIELD_VBD_WR ), +tot_vbd_reqs (domain2,FIELD_VBD_WR )); +} + +/* Prints number of total VBD WRITE requests statistic */ +static void print_vbd_wr (xenstat_domain *domain) +{ +"%8llu" ,tot_vbd_reqs (domain,FIELD_VBD_WR )); +} + +/* Gets number of total VBD requests statistic, +* if flag is FIELD_VBD_OO, then OO requests, +* if flag is FIELD_VBD_RD, then READ requests and +* if flag is FIELD_VBD_WR, then WRITE requests. +*/ +static unsigned long long tot_vbd_reqs (xenstat_domain *domain,int flag) +{ +int i =0 ; +xenstat_vbd *vbd; +unsigned num_vbds =0 ; +unsigned long long total =0 ; + + num_vbds =xenstat_domain_num_vbds (domain); + +for ( i=0 ; i < num_vbds ; i++) { + vbd =xenstat_domain_vbd (domain,i); +switch (flag) { +case FIELD_VBD_OO : + total +=xenstat_vbd_oo_reqs (vbd); +break ; +case FIELD_VBD_RD : + total +=xenstat_vbd_rd_reqs (vbd); +break ; +case FIELD_VBD_WR : + total +=xenstat_vbd_wr_reqs (vbd); +break ; +default : +break ; + } + } + +return total; +} +/* Compares security id (ssid) of two domains, returning -1,0,1 for <,=,> */ static int compare_ssid (xenstat_domain *domain1,xenstat_domain *domain2) {
@@ -670,6 +783,11 @@ void do_bottom_line(void)attr_addstr (show_networks ?COLOR_PAIR (1 ) :0 ,"etworks" );addstr (" " ); +attr_addstr (show_vbds ?COLOR_PAIR (1 ) :0 ,"v" ); +addch (A_REVERSE |'B' ); +attr_addstr (show_vbds ?COLOR_PAIR (1 ) :0 ,"ds" ); +addstr (" " ); +/* vcpus */ addch (A_REVERSE |'V' );attr_addstr (show_vcpus ?COLOR_PAIR (1 ) :0 ,"CPUs" );
@@ -758,6 +876,28 @@ void do_network(xenstat_domain *domain) } } + +/* Output all VBD information */ +void do_vbd (xenstat_domain *domain) +{ +int i =0 ; +xenstat_vbd *vbd; +unsigned num_vbds =0 ; + + num_vbds =xenstat_domain_num_vbds (domain); + +for (i=0 ; i< num_vbds; i++) { + vbd =xenstat_domain_vbd (domain,i); + +"VBD %2u:%2u oo %8llu rd %8llu wr %8llu\n" , +xenstat_vbd_major (vbd), +xenstat_vbd_minor (vbd), +xenstat_vbd_oo_reqs (vbd), +xenstat_vbd_rd_reqs (vbd), +xenstat_vbd_wr_reqs (vbd)); + } +} +static void top (void ) {xenstat_domain **domains;
@@ -801,6 +941,8 @@ static void top(void)do_vcpu (domains[i]);if (show_networks)do_network (domains[i]); +if (show_vbds) +do_vbd (domains[i]); }do_bottom_line ();
@@ -815,12 +957,13 @@ int main(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "networks", no_argument, NULL, 'n' }, + { "vbds", no_argument, NULL, 'b' }, { "repeat-header", no_argument, NULL, 'r' }, { "vcpus", no_argument, NULL, 'v' }, { "delay", required_argument, NULL, 'd' }, { 0, 0, 0, 0 }, }; -const char *sopts ="hVbnvd:" ; +const char *sopts ="hVbnrvd:" ;if (atexit (cleanup) !=0 )fail ("Failed to install cleanup handler.\n" );
@@ -838,6 +981,9 @@ int main(int argc, char **argv)case 'n' : show_networks =1 ;break ; +case 'b' : + show_vbds =1 ; +break ;case 'r' : repeat_header =1 ;break ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel