Projet

Général

Profil

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

root / plugins / virtualization / xen_vbd @ e5ce7492

Historique | Voir | Annoter | Télécharger (3,21 ko)

1
#!/usr/bin/perl
2
#
3
# 2007-06-01    Zoltan HERPAI <wigyori@uid0.hu>
4
#
5
# Credits goes for:
6
# Adam Crews for his xen_cpu plugin
7
# Mario Manno for his xen_traffic_all plugin
8
#
9
# Script to monitor the I/O usage of Xen domains
10
# Version 0.1
11
#
12
#%# family=auto
13
#%# capabilities=autoconf
14

    
15
# Location of xm tools
16
$XM = '/usr/sbin/xm';
17
$XMTOP = '/usr/sbin/xentop';
18

    
19
# ah, parameters coming in 
20
if ( defined($ARGV[0]))
21
{
22
        if ($ARGV[0] eq 'config') { $arg = 'config'; }
23
        if ($ARGV[0] eq 'autoconf') { $arg = 'autoconf'; }
24
        
25
        if ( $arg eq 'autoconf' ) 
26
        {
27
                if ( -e $XM && -e $XMTOP )
28
                {
29
                        print "yes\n";
30
                        exit 0;
31
                }
32
                else
33
                {
34
                        print "no ($XM and/or $XMTOP not found\n";
35
                        exit 0;
36
                }
37
        }
38
        
39
        if ( $arg eq 'config' )
40
        {
41
                %cnf = (
42
                        'graph_title' => 'Xen Domain I/O usage',
43
                        'graph_args' => '--base 1024 -l 0',
44
                        'graph_vlabel' => 'read (-), write (+)',
45
                        'graph_category' => 'xen',
46
                        'graph_info' => 'Display the I/O operations for each domain',
47
                );
48
                
49
                @domains = `$XM list`;
50
                shift(@domains); # we don't need the header line
51
                
52
                foreach $domain ( @domains )
53
                {
54
                        ($dom, undef) = split(/\s/, $domain);
55
                        $dom =~ s/[-.]/_/g;
56
                        
57
                        $cnf{ $dom.'RD' . '.label' } = 'read';
58
                        $cnf{ $dom.'RD' . '.type' } = 'COUNTER';
59
                        $cnf{ $dom.'RD' . '.graph' } = 'no';
60
                        $cnf{ $dom.'RD' . '.cdef' } = $dom.'RD,8,*';
61
                        
62
                        $cnf{ $dom.'WR' . '.label' } = $dom;
63
                        $cnf{ $dom.'WR' . '.type' } = 'COUNTER';
64
                        $cnf{ $dom.'WR' . '.negative' } = $dom.'RD';
65
                        $cnf{ $dom.'WR' . '.cdef' } = $dom.'WR,8,*';
66
                        
67
                        if ( "$cnt" == "0" )
68
                        {
69
                                $cnf { "$dom" . '.draw' } = 'AREA';
70
                        }
71
                        $cnt++;
72
                }
73
                
74
                foreach $key ( sort(keys(%cnf)) )
75
                {
76
                        print "$key $cnf{$key}\n";
77
                }
78
                exit 0;
79
                
80
        }
81
}
82

    
83

    
84
# No args, get rolling
85
{
86
        local $/ = undef;
87
        @chunks = split(/^xentop - .*$/m, `$XMTOP -b -i1`);
88
}
89

    
90
@stats = split (/\n/, pop(@chunks));
91

    
92
shift(@stats);
93
shift(@stats);
94
shift(@stats);
95
shift(@stats);
96

    
97
foreach $domain (@stats)
98
{
99
        $domain =~ s/^\s+//;
100
        @tmp = split(/\s+/, $domain);
101
        
102
        $domname = $tmp[0];
103
        $domname =~ s/[-.]/_/g;
104
        $vbdrd = $tmp[14];
105
        $vbdwr = $tmp[15];
106
        
107
        $vals{$domname."RD"}{'value'} = $vbdrd;
108
        $vals{$domname."WR"}{'value'} = $vbdwr;
109
}
110

    
111
foreach $key ( sort(keys(%vals)) )
112
{
113
        print "$key.value " . ($vals{$key}{'value'}) . "\n";
114
}
115