Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / disk / xfs @ a420c4eb

Historique | Voir | Annoter | Télécharger (5,36 ko)

1
#!/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
  }
24
    else
25
  {
26
    print "no (/proc/fs/xfs/stat not found)\n";
27
  }
28
  exit 0;
29
}
30

    
31
my %runtime_stats = (
32
  "extent_alloc" => ["xs_allocx","xs_allocb","xs_freex","xs_freeb"],
33
  "abt" => ["xs_abt_lookup","xs_abt_compare","xs_abt_insrec","xs_abt_delrec"],
34
  "blk_map" => ["xs_blk_mapr","xs_blk_mapw","xs_blk_unmap","xs_add_exlist","xs_del_exlist","xs_look_exlist","xs_cmp_exlist"],
35
  "bmbt" => ["xs_bmbt_lookup","xs_bmbt_compare","xs_bmbt_insrec","xs_bmbt_delrec"],
36
  "dir" => ["xs_dir_lookup","xs_dir_create","xs_dir_remove","xs_dir_getdents"],
37
  "trans" => ["xs_trans_sync","xs_trans_async","xs_trans_empty"],
38
  "ig" => ["xs_ig_attempts","xs_ig_found","xs_ig_frecycle","xs_ig_missed","xs_ig_dup","xs_ig_reclaims","xs_ig_attrchg"],
39
  "log" => ["xs_log_writes","xs_log_blocks","xs_log_noiclogs","xs_log_force","xs_log_force_sleep"],
40
  "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"],
41
  "xstrat" => ["xs_xstrat_quick","xs_xstrat_split"],
42
  "rw" => ["xs_write_calls","xs_read_calls"],
43
  "attr" => ["xs_attr_get","xs_attr_set","xs_attr_remove","xs_attr_list"],
44
  "icluster" => ["xs_iflush_count","xs_icluster_flushcnt","xs_icluster_flushinode"],
45
  "vnodes" => ["vn_active","vn_alloc","vn_get","vn_hold","vn_rele","vn_reclaim","vn_remove","vn_free"],
46
  "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"],
47
  "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"],
48
  "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"],
49
  "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"],
50
  "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"],
51
  "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"],
52
  "qm" => ["xs_qm_dquot","xs_qm_dquot_unused"],
53
  "xpc" => ["xs_xstrat_bytes","xs_write_bytes","xs_read_bytes"],
54
  "debug" => ["debug"]
55
);
56

    
57
my %config = (
58
  "read" => {
59
    title => 'XFS read statistics',
60
    vtitle => 'calls',
61
    params => ["xs_read_calls","xs_dir_lookup","xs_attr_get","xs_attr_list","xs_dir_getdents"],
62
    draw => ["AREA","AREA","STACK","STACK","STACK"]
63
  },
64
  "write" => {
65
    title => 'XFS write statistics',
66
    vtitle => 'calls',
67
    params => ["xs_write_calls","xs_dir_create","xs_attr_set","xs_attr_remove","xs_dir_remove"],
68
    draw => ["AREA","AREA","STACK","STACK","STACK"]
69
  },
70
  "other" => {
71
    title => 'XFS transaction&log statistics',
72
    vtitle => 'calls',
73
    params => ["xs_trans_async","xs_log_writes","xs_log_noiclogs","xs_xstrat_quick","xs_xstrat_split","xs_trans_sync","xs_trans_empty"],
74
    draw => ["AREA","AREA","STACK","AREA","STACK","LINE","LINE"]
75
  },
76
);
77

    
78
open (IN, '<', '/proc/fs/xfs/stat');
79

    
80
my $collected_stats;
81

    
82
while (<IN>) {
83
  my @array = split /\s+/, $_;
84
  chomp @array;
85
  my $string_name = shift @array;
86
  my %hash;
87
  my $keys = $runtime_stats{$string_name};
88

    
89
  @hash{@$keys} = @array;
90
  $collected_stats->{$string_name}=\%hash;
91
};
92

    
93
close(IN);
94

    
95
foreach my $func ( keys %config ) {
96
  print "multigraph xfs_$func\n";
97

    
98
  if (defined $ARGV[0] and $ARGV[0] eq 'config') {
99
    print "graph_title $config{$func}->{title}\n";
100
    print "graph_args --base 1000\n";
101
    print "graph_vlabel $config{$func}->{vtitle}\n";
102
    print "graph_category disk\n";
103
    my $iter = 0;
104
    foreach my $param (@{$config{$func}->{params}}) {
105
      print "$param.type DERIVE\n";
106
      print "$param.label $param\n";
107
      print "$param.draw $config{$func}->{draw}[$iter]\n";
108
      print "$param.min 0\n";
109
      $iter += 1;
110
    };
111
  } else {
112
    foreach my $param (@{$config{$func}->{params}}) {
113
      print "$param.value ". get_key($param) ."\n";
114
    };
115
  };
116
}
117

    
118
sub get_key {
119
  my $key = shift;
120
  foreach my $group (keys %{$collected_stats}) {
121
    if (exists $collected_stats->{$group}->{$key}) {
122
    return $collected_stats->{$group}->{$key};
123
    };
124
  };
125
};
126