root / plugins / disk / xfs @ 8589c6df
Historique | Voir | Annoter | Télécharger (5,37 ko)
| 1 | 2a035109 | Evgeni Cherdancev | #!/usr/bin/perl |
|---|---|---|---|
| 2 | # |
||
| 3 | # Plugin for collecting xfs statistics. |
||
| 4 | # |
||
| 5 | # Note: |
||
| 6 | # Stats are read from /proc/fs/xfs/stat. |
||
| 7 | # |
||
| 8 | # Parameters: |
||
| 9 | # config |
||
| 10 | # autoconf |
||
| 11 | # |
||
| 12 | #%# family=auto |
||
| 13 | #%# capabilities=autoconf |
||
| 14 | |||
| 15 | use strict; |
||
| 16 | use warnings; |
||
| 17 | |||
| 18 | if ($ARGV[0] and $ARGV[0] eq "autoconf") |
||
| 19 | {
|
||
| 20 | if (-r "/proc/fs/xfs/stat") |
||
| 21 | {
|
||
| 22 | print "yes\n"; |
||
| 23 | exit 0; |
||
| 24 | } |
||
| 25 | else |
||
| 26 | {
|
||
| 27 | print "/proc/fs/xfs/stat not found\n"; |
||
| 28 | exit 1; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | my %runtime_stats = ( |
||
| 33 | "extent_alloc" => ["xs_allocx","xs_allocb","xs_freex","xs_freeb"], |
||
| 34 | "abt" => ["xs_abt_lookup","xs_abt_compare","xs_abt_insrec","xs_abt_delrec"], |
||
| 35 | "blk_map" => ["xs_blk_mapr","xs_blk_mapw","xs_blk_unmap","xs_add_exlist","xs_del_exlist","xs_look_exlist","xs_cmp_exlist"], |
||
| 36 | "bmbt" => ["xs_bmbt_lookup","xs_bmbt_compare","xs_bmbt_insrec","xs_bmbt_delrec"], |
||
| 37 | "dir" => ["xs_dir_lookup","xs_dir_create","xs_dir_remove","xs_dir_getdents"], |
||
| 38 | "trans" => ["xs_trans_sync","xs_trans_async","xs_trans_empty"], |
||
| 39 | "ig" => ["xs_ig_attempts","xs_ig_found","xs_ig_frecycle","xs_ig_missed","xs_ig_dup","xs_ig_reclaims","xs_ig_attrchg"], |
||
| 40 | "log" => ["xs_log_writes","xs_log_blocks","xs_log_noiclogs","xs_log_force","xs_log_force_sleep"], |
||
| 41 | "push_ail" => ["xs_try_logspace","xs_sleep_logspace","xs_push_ail","xs_push_ail_success","xs_push_ail_pushbuf","xs_push_ail_pinned","xs_push_ail_locked","xs_push_ail_flushing","xs_push_ail_restarts","xs_push_ail_flush"], |
||
| 42 | "xstrat" => ["xs_xstrat_quick","xs_xstrat_split"], |
||
| 43 | "rw" => ["xs_write_calls","xs_read_calls"], |
||
| 44 | "attr" => ["xs_attr_get","xs_attr_set","xs_attr_remove","xs_attr_list"], |
||
| 45 | "icluster" => ["xs_iflush_count","xs_icluster_flushcnt","xs_icluster_flushinode"], |
||
| 46 | "vnodes" => ["vn_active","vn_alloc","vn_get","vn_hold","vn_rele","vn_reclaim","vn_remove","vn_free"], |
||
| 47 | "buf" => ["xb_get","xb_create","xb_get_locked","xb_get_locked_waited","xb_busy_locked","xb_miss_locked","xb_page_retries","xb_page_found","xb_get_read"], |
||
| 48 | "ibt2" => ["xs_ibt_2_lookup","xs_ibt_2_compare","xs_ibt_2_insrec","xs_ibt_2_delrec","xs_ibt_2_newroot","xs_ibt_2_killroot","xs_ibt_2_increment","xs_ibt_2_decrement","xs_ibt_2_lshift","xs_ibt_2_rshift","xs_ibt_2_split","xs_ibt_2_join","xs_ibt_2_alloc","xs_ibt_2_free","xs_ibt_2_moves"], |
||
| 49 | 0b849f0e | Gajdos Tamás | "fibt2" => ["xs_fibt_2_lookup","xs_fibt_2_compare","xs_fibt_2_insrec","xs_fibt_2_delrec","xs_fibt_2_newroot","xs_fibt_2_killroot","xs_fibt_2_increment","xs_fibt_2_decrement","xs_fibt_2_lshift","xs_fibt_2_rshift","xs_fibt_2_split","xs_fibt_2_join","xs_fibt_2_alloc","xs_fibt_2_free","xs_fibt_2_moves"], |
| 50 | 2a035109 | Evgeni Cherdancev | "bmbt2" => ["xs_bmbt_2_lookup","xs_bmbt_2_compare","xs_bmbt_2_insrec","xs_bmbt_2_delrec","xs_bmbt_2_newroot","xs_bmbt_2_killroot","xs_bmbt_2_increment","xs_bmbt_2_decrement","xs_bmbt_2_lshift","xs_bmbt_2_rshift","xs_bmbt_2_split","xs_bmbt_2_join","xs_bmbt_2_alloc","xs_bmbt_2_free","xs_bmbt_2_moves"], |
| 51 | "abtc2" => ["xs_abtc_2_lookup","xs_abtc_2_compare","xs_abtc_2_insrec","xs_abtc_2_delrec","xs_abtc_2_newroot","xs_abtc_2_killroot","xs_abtc_2_increment","xs_abtc_2_decrement","xs_abtc_2_lshift","xs_abtc_2_rshift","xs_abtc_2_split","xs_abtc_2_join","xs_abtc_2_alloc","xs_abtc_2_free","xs_abtc_2_moves"], |
||
| 52 | "abtb2" => ["xs_abtb_2_lookup","xs_abtb_2_compare","xs_abtb_2_insrec","xs_abtb_2_delrec","xs_abtb_2_newroot","xs_abtb_2_killroot","xs_abtb_2_increment","xs_abtb_2_decrement","xs_abtb_2_lshift","xs_abtb_2_rshift","xs_abtb_2_split","xs_abtb_2_join","xs_abtb_2_alloc","xs_abtb_2_free","xs_abtb_2_moves"], |
||
| 53 | "qm" => ["xs_qm_dquot","xs_qm_dquot_unused"], |
||
| 54 | "xpc" => ["xs_xstrat_bytes","xs_write_bytes","xs_read_bytes"], |
||
| 55 | "debug" => ["debug"] |
||
| 56 | ); |
||
| 57 | |||
| 58 | my %config = ( |
||
| 59 | "read" => {
|
||
| 60 | title => 'XFS read statistics', |
||
| 61 | vtitle => 'calls', |
||
| 62 | params => ["xs_read_calls","xs_dir_lookup","xs_attr_get","xs_attr_list","xs_dir_getdents"], |
||
| 63 | draw => ["AREA","AREA","STACK","STACK","STACK"] |
||
| 64 | }, |
||
| 65 | "write" => {
|
||
| 66 | title => 'XFS write statistics', |
||
| 67 | vtitle => 'calls', |
||
| 68 | params => ["xs_write_calls","xs_dir_create","xs_attr_set","xs_attr_remove","xs_dir_remove"], |
||
| 69 | draw => ["AREA","AREA","STACK","STACK","STACK"] |
||
| 70 | }, |
||
| 71 | "other" => {
|
||
| 72 | title => 'XFS transaction&log statistics', |
||
| 73 | vtitle => 'calls', |
||
| 74 | params => ["xs_trans_async","xs_log_writes","xs_log_noiclogs","xs_xstrat_quick","xs_xstrat_split","xs_trans_sync","xs_trans_empty"], |
||
| 75 | draw => ["AREA","AREA","STACK","AREA","STACK","LINE","LINE"] |
||
| 76 | }, |
||
| 77 | ); |
||
| 78 | |||
| 79 | open (IN, '<', '/proc/fs/xfs/stat'); |
||
| 80 | |||
| 81 | my $collected_stats; |
||
| 82 | |||
| 83 | while (<IN>) {
|
||
| 84 | my @array = split /\s+/, $_; |
||
| 85 | chomp @array; |
||
| 86 | my $string_name = shift @array; |
||
| 87 | my %hash; |
||
| 88 | my $keys = $runtime_stats{$string_name};
|
||
| 89 | |||
| 90 | @hash{@$keys} = @array;
|
||
| 91 | $collected_stats->{$string_name}=\%hash;
|
||
| 92 | }; |
||
| 93 | |||
| 94 | close(IN); |
||
| 95 | |||
| 96 | foreach my $func ( keys %config ) {
|
||
| 97 | print "multigraph xfs_$func\n"; |
||
| 98 | |||
| 99 | if (defined $ARGV[0] and $ARGV[0] eq 'config') {
|
||
| 100 | print "graph_title $config{$func}->{title}\n";
|
||
| 101 | print "graph_args --base 1000\n"; |
||
| 102 | print "graph_vlabel $config{$func}->{vtitle}\n";
|
||
| 103 | 2202b1c1 | dipohl | print "graph_category disk\n"; |
| 104 | 2a035109 | Evgeni Cherdancev | my $iter = 0; |
| 105 | foreach my $param (@{$config{$func}->{params}}) {
|
||
| 106 | print "$param.type DERIVE\n"; |
||
| 107 | print "$param.label $param\n"; |
||
| 108 | print "$param.draw $config{$func}->{draw}[$iter]\n";
|
||
| 109 | print "$param.min 0\n"; |
||
| 110 | $iter += 1; |
||
| 111 | }; |
||
| 112 | } else {
|
||
| 113 | foreach my $param (@{$config{$func}->{params}}) {
|
||
| 114 | print "$param.value ". get_key($param) ."\n"; |
||
| 115 | }; |
||
| 116 | }; |
||
| 117 | } |
||
| 118 | |||
| 119 | sub get_key {
|
||
| 120 | my $key = shift; |
||
| 121 | foreach my $group (keys %{$collected_stats}) {
|
||
| 122 | if (exists $collected_stats->{$group}->{$key}) {
|
||
| 123 | return $collected_stats->{$group}->{$key};
|
||
| 124 | }; |
||
| 125 | }; |
||
| 126 | }; |
