Menu

#2 check_memory on FreeBSD

open
None
5
2000-07-18
2000-06-15
SIP Dude
No

Discussion

  • Nobody/Anonymous

    Logged In: YES
    user_id=41112
    Browser: Mozilla/4.7 [en] (WinNT; I)

    Are there any plans on developing a plugin for checking memory status
    on FreeBSD?

     
  • Nobody/Anonymous

    Logged In: YES
    user_id=1671
    Browser: Mozilla/4.73 [en] (X11; U; Linux 2.2.14-12 i586)

    None at present. I can say that the existing plugin will
    quite possibly never move into the core distribution because
    it seems to be entirely linux specific.

    Have you any thoughts on how you would implement a
    check_memory plugin on BSD - if you can help navigate me
    through BSD memory checking and if there's a way to make it
    somewhat portable, I'd be glad to try and make time to add a
    check_memory plugin to the core plugins.

     
  • Nobody/Anonymous

    Logged In: YES
    user_id=41112
    Browser: Mozilla/4.7 [en] (WinNT; I)

    I'm not sure how this shows on Open- and NetBSD but I'd be surpised
    if it's way off.

    % vmstat | tail -1 | awk '{print $4,$5}'

    will show 'active memory' and 'size of the free list' in units of 1024bytes,
    a minimal perl script can easily do the rest.

    This does however, not take used swapspace into the calculations.

     
  • Nobody/Anonymous

    Logged In: YES
    user_id=41112
    Browser: Mozilla/4.7 [en] (WinNT; I)

    I've made a small perl script regarding this, for those who are interested
    it's available for download at http://tyfon.net/download/check_mem.pl

    Hope it's of some use!

     
  • Nobody/Anonymous

    Logged In: YES
    user_id=1671
    Browser: Mozilla/4.73 [en] (X11; U; Linux 2.2.16-3 i586)

    submitted perl script added to contrib directory

     
  • Hugo Gayosso

    Hugo Gayosso - 2000-07-18
    • assigned_to: nobody --> karldebisschop
    • status: open --> closed
     
  • Nobody/Anonymous

    Logged In: YES
    user_id=631
    Browser: Mozilla/4.73 [en] (X11; U; Linux 2.2.14-12 i686)

    Tested on Red Hat Linux 6.2

    ./check_mem.pl -f -w90 -c95
    sh: swapinfo: command not found

    Maybe it would be good to modify it to check if `-s' was
    used, and if it was not used then do not use `swapinfo'.

    Another good modification would be to check if and where
    those commands are (vmstat, swapinfo).

     
  • Hugo Gayosso

    Hugo Gayosso - 2000-07-18
    • status: closed --> open
     
  • Nobody/Anonymous

    Logged In: YES
    user_id=631
    Browser: Mozilla/4.73 [en] (X11; U; Linux 2.2.16-3 i686)

    I gave a quick (real quick) check to your plug in, and I
    noted two
    things:

    1) Why are you using `awk' when it is a perl plug-in?

    I think that using `awk' inside a perl script is
    redundant. Perl
    can do what `awk' can do in this case. Same for `tail'.

    (I know I should be submitting a patch instead of
    complaining, but
    remember I said a REAL QUICK check :) )

    2) I enabled Taint checking in your perl script and it
    complained:

    ./check_mem.pl -v
    Insecure $ENV{PATH} while running with -T switch at
    ./check_mem.pl line 64.

    Ah!!, but I have a tremendous patch for this!! :)

    Just add the following line after the `use'
    statements:

    $ENV{'PATH'}="";
    $ENV{'ENV'}="";
    $ENV{'BASH_ENV'}="";

    3) The output of vmstat in a Red Hat 6.2 machine:

    procs memory swap io
    system cpu
    r b w swpd free buff cache si so bi bo
    in cs us sy id
    0 0 0 25152 6500 2624 45680 4 4 19 5
    305 466 5 3 92

    FIELD DESCRIPTIONS
    Procs
    r: The number of processes waiting for run time.
    b: The number of processes in uninterruptable sleep.
    w: The number of processes swapped out but otherwise
    runnable. This
    field is calculated, but Linux never desperation
    swaps.

    Memory
    swpd: the amount of virtual memory used (kB).
    free: the amount of idle memory (kB).
    buff: the amount of memory used as buffers (kB).

    Swap
    si: Amount of memory swapped in from disk (kB/s).
    so: Amount of memory swapped to disk (kB/s).

    IO
    bi: Blocks sent to a block device (blocks/s).
    bo: Blocks received from a block device (blocks/s).

    System
    in: The number of interrupts per second, including
    the clock.
    cs: The number of context switches per second.

    CPU
    These are percentages of total CPU time.
    us: user time
    sy: system time
    id: idle time

    My suggestion for a check_mem for GNU/Linux would be to
    parse the
    results of `cat /proc/meminfo':

    total: used: free: shared: buffers: cached:
    Mem: 130863104 125329408 5533696 74297344 2682880
    47554560
    Swap: 278609920 26128384 252481536
    MemTotal: 127796 kB
    MemFree: 5404 kB
    MemShared: 72556 kB
    Buffers: 2620 kB
    Cached: 46440 kB
    BigTotal: 0 kB
    BigFree: 0 kB
    SwapTotal: 272080 kB
    SwapFree: 246564 kB

    That way you don't need any other commands.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.