From 965867228e1486fcc6587874a7811d0466c892f3 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Thu, 17 Jan 2002 15:41:25 +0000 Subject: [PATCH] added TrueUnix (dec_osf1) support --- contrib/plugins/spong-client/check_vmstat | 41 +++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/contrib/plugins/spong-client/check_vmstat b/contrib/plugins/spong-client/check_vmstat index 6f09143..0b8678f 100755 --- a/contrib/plugins/spong-client/check_vmstat +++ b/contrib/plugins/spong-client/check_vmstat @@ -8,7 +8,7 @@ $CHECKFUNCS{'vmstat'} = \&check_vmstat; # No parameter level checks will be defined in this # version. That will come in later versions -# $Id: check_vmstat,v 1.1 2002/01/11 20:40:52 sljohnson Exp $ +# $Id: check_vmstat,v 1.2 2002/01/17 15:41:25 sljohnson Exp $ use Spong::SafeExec qw(safe_exec); @@ -19,12 +19,13 @@ $VMSTAT = 'foobar'; # Try to determine which platform we are running on # die if we don't have a platform implemented $osname = $Config{'osname'}; -if ( $osname =~ /linux|aix/ ) { +if ( $osname =~ /linux|aix|dec_osf/ ) { } { $VMSTAT = '/usr/bin/vmstat 5 2', last if $osname eq 'aix'; $VMSTAT = '/usr/bin/vmstat 5 2', last if $osname eq 'linux'; + $VMSTAT = '/usr/bin/vmstat 5 2', last if $osname eq 'dec_osf'; # Die if we haven't implementeda given OS platform die('check_vmstat: $osname is a not an impletmented OS Platform') @@ -145,6 +146,42 @@ sub check_vmstat { $message = $message . "Command output:\n" . join('',@msg); +# main::debug("check_vmstat: message = \n$message"); + } + elsif ( $osname eq 'dec_osf' ) { + # Stuff the last line into the line buffer + $_ = $msg[$#msg]; + $chomp; + if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+)\s+(\d+[KM]?)\s+(\d+[KM]?)\s+(\d+)\s+(\d+)\s+(\d+)/ ) + { + my($t); + $proc_run = $1; $proc_block = $2; + $free = $5; + $pi = $11; $po = $12; + $cs = $15; + if ($cs =~ /(\d+)K/) { $cs = $1 * 1000; } + # cpu wait is included in cpu_sy + $cpu_us = $16; $cpu_sy = $17; $cpu_id = $18; + $free =~ m/(\d+)([KM]*)/; ($mem_free,$t) = ($1,$2); + $mem_free = $mem_free * 1000 if $t eq 'K'; + $mem_free = ($mem_free * 8 )/1000 ; # convert to MB, 1 page = 8K + } + + $message = + "mem_free = $mem_free\n" . + "proc_run = $proc_run\n" . + "proc_block = $proc_block\n" . +# "si = 0\n" . # AIX doesn't swap +# "so = 0\n" . + "pi = $pi\n" . + "po = $po\n" . + "cs = $cs\n" . + "cpu_us = $cpu_us\n" . + "cpu_sy = $cpu_sy\n" . + "cpu_id = $cpu_id\n"; + + $message = $message . "Command output:\n" . join('',@msg); + # main::debug("check_vmstat: message = \n$message"); } -- 2.30.2