MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /usr/local/src/munin-1.2.6/node/node.d.aix/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/src/munin-1.2.6/node/node.d.aix/swap.in
#!@@PERL@@
#
# Developed 05/28/2003 by Mike Discenza
# mike.discenza@dillards.com
#
# $Log$
# Revision 1.1  2004/01/02 18:50:00  jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
#
# Plugin to monitor memory usage on AIX.
#
#   DESCRIPTION
#   ===========
#      This will measure the total amount of swap/paging space available
#      on the server, and will also measure how much of that swap space
#      is being used.  It uses /usr/sbin/lsps to find all this out.  If
#      you have more than one paging space they will be added together,
#      so will the total amount of space used.  This is the total amount
#      used after all.
#      
#   RESTRICTIONS
#   ============
#      None known.  Should be able to run as anyone.
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - only used by munin-config)
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#%# family=contrib
#%# capabilities=autoconf

use strict;
use POSIX;

if($ARGV[0] && $ARGV[0] eq "autoconf")
  {
    if(-e "/usr/sbin/lsps" && -X "/usr/sbin/lsps")
      {
        print "yes\n";
        exit 0;
      }
    else
      {
        print "no\n";
        exit 1;
      }
  }

if($ARGV[0] && $ARGV[0] eq "config")
  {
    print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit ".getTotalSwapBytes()."\n";
    print "graph_title Swap usage\n";
    print "graph_order used total\n";
    print "used.label used\n";
    print "used.draw STACK\n";
    print "total.label total\n";
    print "total.draw AREA\n";
    exit 0
  }

my(@swapInfo) = getSwapSpace();
print "total.value $swapInfo[0]\n";
print "used.value $swapInfo[1]\n";
  
sub getSwapSpace
{
  my($line,@lineArray,$amountUsed,$totalSpace);
  open SWAPINFO, "/usr/sbin/lsps -a|tail +2|";
  while($line = <SWAPINFO>)
    {
      @lineArray = split(/ +/,$line);
      $totalSpace += (substr($lineArray[3],0,-2) * 1024) * 1024;
      $amountUsed += ((substr($lineArray[3],0,-2) * ($lineArray[4]/100)) * 1024) * 1024;
    }
  return (ceil($totalSpace),ceil($amountUsed));
}

sub getTotalSwapBytes
{
  my($line,@lineArray,$totalSpace);
  open SWAPINFO, "/usr/sbin/lsps -a|tail +2|";
  while($line = <SWAPINFO>)
    {
      @lineArray = split(/ +/,$line);
      $totalSpace += (substr($lineArray[3],0,-2) * 1024) * 1024;
    }
  return (ceil($totalSpace));
}

Anon7 - 2021