--- create_vmstat_Default.pl 2003/10/28 15:18:20 1.1 +++ create_vmstat_Default.pl 2003/10/28 16:00:35 1.2 @@ -12,18 +12,18 @@ use strict; use Data::Dumper; -# define temp cache file -- this is (mybe) security risk! This file name -# is easily guessable and it's called via cat from cricket -my $cache = '/tmp/vmstat-\%auto-target-name\%'; - +# variant (-s for vmstat -s) +my $is_s = shift @ARGV; +my $target_type = "vmstat"; +$target_type = "vmstat-stat" if ($is_s); -my $target = qq( +my $target_def_fmt = qq( Target --default-- directory-desc = "Report virtual memory statistics" short-desc = "Virtual memory" - target-type = vmstat + target-type = %s # by default don't use ssh ssh="" @@ -72,6 +72,7 @@ # definition for VM mode (copy/paster from vmstat man page :-) my $ds_type = { + # vmstat 'si' => 'ABSOLUTE', 'so' => 'ABSOLUTE', 'bi' => 'ABSOLUTE', @@ -110,9 +111,42 @@ wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero. ); +# definition for vmstat -s created using vmstat -s -S K | cut -c15- +# with editing for units (encosed in []) +$definition = qq( +Memory +tm: [kB] total memory +um: [kB] used memory +am: [kB] active memory +im: [kB] inactive memory +fm: [kB] free memory +bm: [kB] buffer memory +sc: [kB] swap cache +ts: [kB] total swap +us: [kB] used swap +fs: [kB] free swap +Ticks +nnct: non-nice user cpu ticks [ticks] +nct: nice user cpu ticks [ticks] +sct: system cpu ticks [ticks] +ict: idle cpu ticks [ticks] +ioct: IO-wait cpu ticks [ticks] +Pages +ppi: pages paged in [pages] +ppo: pages paged out [pages] +psi: pages swapped in [pages] +pso: pages swapped out [pages] +Other +int: interrupts +ccs: CPU context switches +bt: boot time +fork: forks +) if ($is_s); + my @ds; my @views; my $view_ds; +my $ds_unit; my $desc; # start parsing at which element @@ -126,36 +160,33 @@ # view definition $curr_view = $1; push @views, $curr_view; - } elsif (/^\s+(\w+):\s+(.+)$/) { + } elsif (/^\s*(\w+):\s+(.+)$/) { # source name: description my ($ds,$description) = ($1,$2); $ds_max++; push @ds,$ds; push @{$view_ds->{$curr_view}},$ds; + if ($description =~ s/\s*\[([^\]]+)\]\s*//) { + $ds_unit->{$ds} = $1; + } $desc->{$ds} = $description; } else { print STDERR "unparsable line: $_\n"; } } -# variant (-s for vmstat -s) -my $is_s = 0; - -my $ssh = shift @ARGV; -if ($ssh && $ssh eq "-s") { - $ssh = shift @ARGV; - $is_s = 1; -} - # don't use value 0 it's empty! -my $vmstat = qq(\%ssh\% vmstat 1 2 | tail -1 | sed 's/ */\\\\n/'g | tee $cache); +my $vmstat = qq(\%ssh\% vmstat 1 2 | tail -1 | sed 's/ */\\\\n/'g); my $ds_start = 1; -#my $vmstats = qq(vmstat -s -S K); +if ($is_s) { + $vmstat = qq(\%ssh\% vmstat -s -S K); + $ds_start = 0; +} # dump Target -print $target; +printf($target_def_fmt,$target_type); # dump targetType @@ -164,7 +195,7 @@ $view_str .= "$_: ".join(" ",@{$view_ds->{$_}}).", "; } $view_str =~ s/, $//; -printf($targetType_fmt, 'vmstat', join(", ",@ds), $view_str); +printf($targetType_fmt, $target_type, join(", ",@ds), $view_str); # dump dataSource @@ -193,6 +224,6 @@ # dump graph(s) foreach my $ds (@ds) { - printf($graph_fmt, $ds, 'LINE3', $desc->{$ds}, $ds); + printf($graph_fmt, $ds, 'LINE3', $desc->{$ds}, $ds_unit->{$ds} || ""); }