root / plugins / virtualization / vmware / fusion_ @ e3899a30
Historique | Voir | Annoter | Télécharger (4,7 ko)
| 1 |
#!/usr/bin/env perl |
|---|---|
| 2 |
# -*- perl -*- |
| 3 |
|
| 4 |
=head1 NAME |
| 5 |
|
| 6 |
fusion_ a Plugin for displaying VMWare Fusion Stats |
| 7 |
|
| 8 |
=head1 INTERPRETATION |
| 9 |
|
| 10 |
This plugin displays the following charts: |
| 11 |
|
| 12 |
1) pcpu |
| 13 |
2) pmem |
| 14 |
3) mem |
| 15 |
|
| 16 |
You can set the modes with naming the softlink: |
| 17 |
|
| 18 |
1) fusion_pcpu |
| 19 |
2) fusion_pmem |
| 20 |
3) fusion_mem |
| 21 |
|
| 22 |
This Plugin uses ps for gaining the data: |
| 23 |
|
| 24 |
> ps -A -c -o pcpu,pmem,rss=,comm,args -r | grep vmware-vmx |
| 25 |
5,0 19,5 3271768 innoq-winxp.vmx vmware-vmx |
| 26 |
4,6 10,7 1801768 Gateway.vmx vmware-vmx |
| 27 |
2,3 5,8 976288 Jenkins.vmx vmware-vmx |
| 28 |
2,0 22,6 3784144 Mac_OS_X_10.9.vmx vmware-vmx |
| 29 |
0,0 0,0 620 grep vmware-vmx grep |
| 30 |
|
| 31 |
So the Output should be pretty standard about all MacOS/Fusion Versions. |
| 32 |
|
| 33 |
=head1 CONFIGURATION |
| 34 |
|
| 35 |
No Configuration necessary! |
| 36 |
|
| 37 |
TODO: |
| 38 |
still a bug with getting pcpu,pmem,rss=,comm as an output, have filter it with if( $vm[3] =~ /(?<!comm)$/) |
| 39 |
|
| 40 |
=head1 AUTHOR |
| 41 |
|
| 42 |
Philipp Haussleiter <philipp@haussleiter.de> (email) |
| 43 |
|
| 44 |
=head1 LICENSE |
| 45 |
|
| 46 |
GPLv2 |
| 47 |
|
| 48 |
=cut |
| 49 |
|
| 50 |
# MAIN |
| 51 |
use warnings; |
| 52 |
use strict; |
| 53 |
use File::Basename; |
| 54 |
|
| 55 |
# pcpu, pmem, mem |
| 56 |
my $type = basename($0); |
| 57 |
$type =~ s/fusion_//; |
| 58 |
|
| 59 |
my $cmd = "ps -A -c -o pcpu,pmem,rss=,args,comm -r | grep vmware-vmx"; |
| 60 |
my $output = `$cmd`; |
| 61 |
my @lines=split(/\n/,$output); |
| 62 |
|
| 63 |
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 64 |
my $lcount = 0; |
| 65 |
my $base_config = "graph_category Virtualization\n"; |
| 66 |
|
| 67 |
if( $type eq "pcpu" ) {
|
| 68 |
print $base_config; |
| 69 |
print "graph_args --base 1000 -l 0 -u 100 -r\n"; |
| 70 |
print "graph_scale no\n"; |
| 71 |
print "graph_title CPU usage in % per VM\n"; |
| 72 |
print "graph_vlabel % of CPU usage\n"; |
| 73 |
print "graph_info The Graph shows the CPU usage in % per VM\n"; |
| 74 |
foreach my $line(@lines) {
|
| 75 |
if( $line =~ /(?<!grep)$/) {
|
| 76 |
my @vm = (); |
| 77 |
my $count = 0; |
| 78 |
my @array=split(/ /,$line); |
| 79 |
foreach my $entry(@array) {
|
| 80 |
if( length($entry) > 2 ){
|
| 81 |
$vm[$count]=$entry; |
| 82 |
$count++; |
| 83 |
} |
| 84 |
} |
| 85 |
$vm[3] =~ s/\.vmx//; |
| 86 |
my $cat = clean_vmname($vm[3]); |
| 87 |
if( $cat =~ /(?<!comm)$/) {
|
| 88 |
if( $lcount > 0 ){
|
| 89 |
print $cat,"_pcpu.draw STACK\n"; |
| 90 |
} else {
|
| 91 |
print $cat,"_pcpu.draw AREA\n"; |
| 92 |
} |
| 93 |
$lcount++; |
| 94 |
print $cat,"_pcpu.label $vm[3]\n"; |
| 95 |
print $cat,"_pcpu.type GAUGE\n"; |
| 96 |
} |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if( $type eq "pmem" ) {
|
| 102 |
print $base_config; |
| 103 |
print "graph_args --base 1000 -l 0 -u 100 -r\n"; |
| 104 |
print "graph_scale no\n"; |
| 105 |
print "graph_title Memory usage in % per VM\n"; |
| 106 |
print "graph_vlabel % of Memory usage\n"; |
| 107 |
print "graph_info The Graph shows the Memory usage in % per VM\n"; |
| 108 |
foreach my $line(@lines) {
|
| 109 |
if( $line =~ /(?<!grep)$/ ) {
|
| 110 |
my @vm = (); |
| 111 |
my $count = 0; |
| 112 |
my @array=split(/ /,$line); |
| 113 |
foreach my $entry(@array) {
|
| 114 |
if( length($entry) > 2 ){
|
| 115 |
$vm[$count]=$entry; |
| 116 |
$count++; |
| 117 |
} |
| 118 |
} |
| 119 |
$vm[3] =~ s/\.vmx//; |
| 120 |
my $cat = clean_vmname($vm[3]); |
| 121 |
if( $cat =~ /(?<!comm)$/) {
|
| 122 |
if( $lcount > 0 ){
|
| 123 |
print $cat,"_pmem.draw STACK\n"; |
| 124 |
} else {
|
| 125 |
print $cat,"_pmem.draw AREA\n"; |
| 126 |
} |
| 127 |
$lcount++; |
| 128 |
print $cat,"_pmem.label $vm[3]\n"; |
| 129 |
print $cat,"_pmem.type GAUGE\n"; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
if( $type eq "mem" ) {
|
| 136 |
print $base_config; |
| 137 |
print "graph_args --base 1024 -r --lower-limit 0\n"; |
| 138 |
print "graph_title absolute Memory usage per VM\n"; |
| 139 |
print "graph_vlabel Memory usage\n"; |
| 140 |
print "graph_info The Graph shows the absolute Memory usage per VM\n"; |
| 141 |
foreach my $line(@lines) {
|
| 142 |
if( $line =~ /(?<!grep)$/ ) {
|
| 143 |
my @vm = (); |
| 144 |
my $count = 0; |
| 145 |
my @array=split(/ /,$line); |
| 146 |
foreach my $entry(@array) {
|
| 147 |
if( length($entry) > 2 ){
|
| 148 |
$vm[$count]=$entry; |
| 149 |
$count++; |
| 150 |
} |
| 151 |
} |
| 152 |
$vm[3] = clean_vmname($vm[3]); |
| 153 |
if( $vm[3] =~ /(?<!comm)$/) {
|
| 154 |
if( $lcount > 0 ){
|
| 155 |
print "$vm[3]_mem.draw STACK\n"; |
| 156 |
} else {
|
| 157 |
print "$vm[3]_mem.draw AREA\n"; |
| 158 |
} |
| 159 |
print "$vm[3]_mem.label $vm[3]\n"; |
| 160 |
print "$vm[3]_mem.type GAUGE\n"; |
| 161 |
$lcount++; |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
} else {
|
| 168 |
foreach my $line(@lines) {
|
| 169 |
if( $line =~ /(?<!grep)$/ ) {
|
| 170 |
my @vm = (); |
| 171 |
my $count = 0; |
| 172 |
my @array=split(/ /,$line); |
| 173 |
foreach my $entry(@array) {
|
| 174 |
if( length($entry) > 2 ){
|
| 175 |
$vm[$count]=$entry; |
| 176 |
$count++; |
| 177 |
} |
| 178 |
} |
| 179 |
$vm[3] = clean_vmname($vm[3]); |
| 180 |
if( $vm[3] =~ /(?<!comm)$/) {
|
| 181 |
if( $type eq "pcpu" ) {
|
| 182 |
print "$vm[3]_pcpu.value $vm[0]\n"; |
| 183 |
} |
| 184 |
if( $type eq "pmem" ) {
|
| 185 |
print "$vm[3]_pmem.value $vm[1]\n"; |
| 186 |
} |
| 187 |
if( $type eq "mem" ) {
|
| 188 |
my $value = ($vm[2]*1024); |
| 189 |
print "$vm[3]_mem.value $value\n"; |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
sub clean_vmname {
|
| 197 |
my $vm_name = $_[0]; |
| 198 |
$vm_name =~ s/\.vmx//; |
| 199 |
$vm_name =~ s/\./\_/g; |
| 200 |
return $vm_name; |
| 201 |
} |
