root / plugins / other / dar_swap @ 4bb97ae7
Historique | Voir | Annoter | Télécharger (1,82 ko)
| 1 | 4bb97ae7 | J.T. Sage | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | # -*- perl -*- |
||
| 3 | |||
| 4 | =head1 NAME |
||
| 5 | |||
| 6 | dar_swap - Munin plugin to monitor darwin swap in/out. |
||
| 7 | |||
| 8 | =head1 APPLICABLE SYSTEMS |
||
| 9 | |||
| 10 | Should work on any darwin (Mac OS X) system with the 'vm_stat' command. |
||
| 11 | |||
| 12 | =head1 CONFIGURATION |
||
| 13 | |||
| 14 | None needed |
||
| 15 | |||
| 16 | =head1 INTERPRETATION |
||
| 17 | |||
| 18 | The plugin runs the vm_stat command a shows the number of pages swapped |
||
| 19 | in/out per second. |
||
| 20 | |||
| 21 | =head1 BUGS |
||
| 22 | |||
| 23 | None right now. |
||
| 24 | |||
| 25 | =head1 MAGIC MARKERS |
||
| 26 | |||
| 27 | #%# family=auto |
||
| 28 | #%# capabilities=autoconf |
||
| 29 | |||
| 30 | =head1 VERSION |
||
| 31 | |||
| 32 | v.0.0.1 |
||
| 33 | |||
| 34 | =head1 AUTHOR |
||
| 35 | |||
| 36 | Copyright (C) 2010. |
||
| 37 | |||
| 38 | Original version by J.T.Sage (at) gmail (dot) com. |
||
| 39 | |||
| 40 | =head1 LICENSE |
||
| 41 | |||
| 42 | GPLv2 |
||
| 43 | |||
| 44 | =cut |
||
| 45 | |||
| 46 | use Munin::Plugin; |
||
| 47 | |||
| 48 | if ( defined($ARGV[0])) {
|
||
| 49 | if ($ARGV[0] eq 'autoconf') {
|
||
| 50 | $uname = `uname`; |
||
| 51 | if ( not ( $uname =~ /Darwin/ ) ) { print "no (not a Darwin System)\n"; }
|
||
| 52 | else {
|
||
| 53 | if ( not -x "/usr/bin/vm_stat" ) { print "no (vm_stat not found)\n"; }
|
||
| 54 | else {
|
||
| 55 | print "yes\n"; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | exit 0; |
||
| 59 | } |
||
| 60 | |||
| 61 | if ( $ARGV[0] eq "config" ) {
|
||
| 62 | print "graph_title Swap in/out\n"; |
||
| 63 | print "graph_args -l 0 --base 1000\n"; |
||
| 64 | print "graph_vlabel pages per \${graph_period} in (-) / out (+)\n";
|
||
| 65 | print "graph_category system\n"; |
||
| 66 | print "swap_in.label swap\nswap_in.type DERIVE\nswap_in.max 100000\nswap_in.min 0\nswap_in.graph no\n"; |
||
| 67 | print "swap_out.label swap\nswap_out.type DERIVE\nswap_out.max 100000\nswap_out.min 0\nswap_out.negative swap_in\n"; |
||
| 68 | exit 0; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | @vmstat = `vm_stat`; |
||
| 73 | for ( $i = 1; $i < $#vmstat; $i++ ) {
|
||
| 74 | $line = $vmstat[$i]; |
||
| 75 | $label = $line; |
||
| 76 | $label =~ s/"//g; |
||
| 77 | $label =~ s/(\w+)\:.+$/$1/; |
||
| 78 | $label =~ s/\n//g; |
||
| 79 | $name = $label; |
||
| 80 | $name =~ tr/A-Z/a-z/; |
||
| 81 | $name =~ s/[^A-Za-z0-9_]/_/g; |
||
| 82 | $data = $line; |
||
| 83 | $data =~ s/.+?(\d+)\./$1/; |
||
| 84 | $data =~ s/\n//g; |
||
| 85 | $data = int(($data / 1000) + .5); |
||
| 86 | if ( $name eq "pageins" ) {
|
||
| 87 | print "swap_in.value " . $data . "\n"; |
||
| 88 | } |
||
| 89 | if ( $name eq "pageouts" ) {
|
||
| 90 | print "swap_out.value " . $data . "\n"; |
||
| 91 | } |
||
| 92 | |||
| 93 | } |
||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | # vim:syntax=perl |
