"Fossies" - the Fresh Open Source Software Archive

Member "munin-2.0.52/plugins/node.d.aix/swap.in" (20 Nov 2019, 2089 Bytes) of package /linux/misc/munin-2.0.52.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!@@PERL@@
    2 # -*- perl -*-
    3 
    4 =head1 NAME
    5 
    6 swap - Plugin to monitor memory usage on AIX
    7 
    8 =head1 COFIGURATION
    9 
   10 No configuration
   11 
   12 =head1 NOTES
   13 
   14 This will measure the total amount of swap/paging space available on
   15 the server, and will also measure how much of that swap space is being
   16 used.  It uses /usr/sbin/lsps to find all this out.  If you have more
   17 than one paging space they will be added together, so will the total
   18 amount of space used.  This is the total amount used after all.
   19 
   20 =head1 AUTHOR
   21 
   22 Developed 05/28/2003 by Mike Discenza <mike.discenza@dillards.com>
   23 
   24 =head1 LICENSE
   25 
   26 GPLv2
   27 
   28 =head1 MAGIC MARKERS
   29 
   30  #%# family=contrib
   31  #%# capabilities=autoconf
   32 
   33 =cut
   34 
   35 use strict;
   36 use POSIX;
   37 
   38 if($ARGV[0] && $ARGV[0] eq "autoconf")
   39   {
   40     if(-e "/usr/sbin/lsps" && -X "/usr/sbin/lsps")
   41       {
   42         print "yes\n";
   43         exit 0;
   44       }
   45     else
   46       {
   47         print "no\n";
   48         exit 0;
   49       }
   50   }
   51 
   52 if($ARGV[0] && $ARGV[0] eq "config")
   53   {
   54     print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit ".getTotalSwapBytes()."\n";
   55     print "graph_title Swap usage\n";
   56     print "graph_order used total\n";
   57     print "graph_category system\n";
   58     print "used.label used\n";
   59     print "used.draw STACK\n";
   60     print "total.label total\n";
   61     print "total.draw AREA\n";
   62     exit 0
   63   }
   64 
   65 my(@swapInfo) = getSwapSpace();
   66 print "total.value $swapInfo[0]\n";
   67 print "used.value $swapInfo[1]\n";
   68 
   69 sub getSwapSpace
   70 {
   71   my($line,@lineArray,$amountUsed,$totalSpace);
   72   open SWAPINFO, "/usr/sbin/lsps -a|tail +2|";
   73   while($line = <SWAPINFO>)
   74     {
   75       @lineArray = split(/ +/,$line);
   76       $totalSpace += (substr($lineArray[3],0,-2) * 1024) * 1024;
   77       $amountUsed += ((substr($lineArray[3],0,-2) * ($lineArray[4]/100)) * 1024) * 1024;
   78     }
   79   return (ceil($totalSpace),ceil($amountUsed));
   80 }
   81 
   82 sub getTotalSwapBytes
   83 {
   84   my($line,@lineArray,$totalSpace);
   85   open SWAPINFO, "/usr/sbin/lsps -a|tail +2|";
   86   while($line = <SWAPINFO>)
   87     {
   88       @lineArray = split(/ +/,$line);
   89       $totalSpace += (substr($lineArray[3],0,-2) * 1024) * 1024;
   90     }
   91   return (ceil($totalSpace));
   92 }