Giter Site home page Giter Site logo

nagios-plugins's Introduction

nagios-plugins's People

Contributors

aieri avatar dasm avatar gabrielcocenza avatar justinellison avatar justintime avatar martinwe-adfinis avatar napsty avatar parthkolekar avatar wwuck avatar zearan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nagios-plugins's Issues

Memory usage/measuring on FreeBSD

Hi,
On a FreeBSD system, vmstat is used to calculate the memory values. Unfortunately the values are way off from the reality.
I added a FreeBSD section which uses the values from sysctl to calculate more or less correct usage values.

152     elsif ( $uname =~ /FreeBSD/ ) {
153       # The FreeBSD case. 2013-03-19 www.claudiokuenzler.com
154       # free mem = Inactive*Page Size + Cache*Page Size + Free*Page Size
155       my $pagesize = `sysctl vm.stats.vm.v_page_size`;
156       $pagesize =~ s/[^0-9]//g;
157       my $mem_inactive = 0;
158       my $mem_cache = 0; 
159       my $mem_free = 0;
160       my $mem_total = 0;
161       my $free_memory = 0;
162         my @meminfo = `/sbin/sysctl vm.stats.vm`;
163         foreach (@meminfo) {
164             chomp;
165             if (/^vm.stats.vm.v_inactive_count:\s+(\d+)/) {
166             $mem_inactive = ($1 * $pagesize);
167             }
168             elsif (/^vm.stats.vm.v_cache_count:\s+(\d+)/) {
169             $mem_cache = ($1 * $pagesize);
170             }
171             elsif (/^vm.stats.vm.v_free_count:\s+(\d+)/) {
172             $mem_free = ($1 * $pagesize);
173             }
174             elsif (/^vm.stats.vm.v_page_count:\s+(\d+)/) {
175             $mem_total = ($1 * $pagesize);
176             }
177         }   
178         $free_memory = $mem_inactive + $mem_cache + $mem_free;
179         $free_memory_kb = ( $free_memory / 1024); 
180         $total_memory_kb = ( $mem_total / 1024);
181         $used_memory_kb = $total_memory_kb - $free_memory_kb;
182         $caches_kb = ($mem_cache / 1024);
183     }
184     elsif ( $uname =~ /SunOS/ ) {

Bad data

I tried the plugin but the data sent by the plugin are wrong.

It send me 32% used but on my server with the command htop I have only 360Mo used on 4049Mo.

My command is ./check_mem.pl -u -w 80 -c 90

My OS is Debian

Regards :)

AIX loaned memory

Hello,

there is missing option for loaned memory in AIX.
I did some changes in code:
vmstat -vh
and
if ($counter_name eq 'Number of 4k page frames loaned') {
$free_memory_kb += $1*4;
}

    elsif ( $uname =~ /AIX/ ) {
        my @meminfo = `/usr/bin/vmstat -vh`;
        foreach (@meminfo) {
            chomp;
            if (/^\s*([0-9.]+)\s+(.*)/) {
                my $counter_name = $2;
                if ($counter_name eq 'memory pages') {
                    $total_memory_kb = $1*4;
                }
                if ($counter_name eq 'free pages') {
                    $free_memory_kb = $1*4;
                }
                if ($counter_name eq 'file pages') {
                    $caches_kb = $1*4;
                }
                if ($counter_name eq 'Number of 4k page frames loaned') {
                    $free_memory_kb += $1*4;
                }
            }
        }
        $used_memory_kb = $total_memory_kb - $free_memory_kb;
    }

critical and warning wrong parameter

perl check_mem.pl -f -C -c 80 -w 90
CRITICAL - 52.6% (3155456 kB) free!|TOTAL=5993368KB;;;; USED=2837912KB;599336;1198673;; FREE=3155456KB;;;; CACHES=2926140KB;;;;

-c should be higher percent
-w lower than critical

or might interpreting wrong way

PNP4Nagios PHP file doesn't work

Hey,

Great script!

However, I'm unable to get the included PHP script to work with PNP4Nagios.
It complains about an invalid vname "total".

Am I doing something wrong?
Meanwhile, I'm staying with the default template, but I would have liked to use yours!

Thanks

Template check_mem.php does not provide array $def[].

The template file is missing the opening php-tag. Here is a unified diff to patch this:

--- org 2012-09-14 10:41:09.000000000 +0200
+++ check_mem.php       2012-09-14 10:41:59.000000000 +0200
@@ -1,3 +1,4 @@
+<?php
 #
 # check_mem.pl PNP4Nagios template
 # v1.1 2011-12-20
@@ -31,4 +32,4 @@
 # $def[1] .= "GPRINT:cache:LAST:\"%2.2lf ".$UNIT[4]." curr\" ";
 # $def[1] .= "GPRINT:cache:MAX:\"%2.2lf ".$UNIT[4]." max\" ";
 # $def[1] .= "GPRINT:cache:MIN:\"%2.2lf ".$UNIT[4]." min\\n\" ";
-?>
\ No newline at end of file
+?>

Return code of -1 is not valid

Starting at line 36 of check_mem.pl, you hardcode return values like this:

36 %exit_codes = ('UNKNOWN' , 3,
37 'OK' , 0,
38 'WARNING' , 1,
39 'CRITICAL', 2,
40 );

... but the official Nagios documentation suggests -1 is not valid for UNKNOWN! http://nagios.sourceforge.net/docs/3_0/pluginapi.html

May I suggest:
36 %exit_codes = ('OK' , 0,
37 'WARNING' , 1,
38 'CRITICAL', 2,
39 'UNKNOWN' , 3,
40 );

UOM KB vs KiB

Hello,

I am currently facing a strange issue with the UOM of the performance data.
The perl script currently returns the values with the KB unit.
The Icingaweb is showing them correctly as 512GB while the Grafana rendering is showing them either as 500GB (bytes(IEC)) or 537GB (bytes(SI)).
For Grafana I was able to generate a workaround when changing the UOM to KiB (SI).
But Icingaweb now shows the performance data as 536,870,912.00 kib and does not convert it to MiB or GiB anymore.

Example output (just change KiB to KB and vice versa):

# check_mem.pl -w 95 -c 98 -u -C
OK - 51.6% (276939100 kB) used.|TOTAL=536870912KiB;;;; USED=276939100KiB;510027366;526133493;; FREE=259931812KiB;;;; CACHES=259714116KiB;;;;

Any ideas, on how to get the correct 512G(i)B for Icingaweb AND Grafana?
Can we get an option for the UOM?

Kind regards
Frank

Cache reported as negative

Hi!

For some time, I was facing issue that check_mem was reporting high memory usage, while free reported that memory usage was ok. On closer inspection, I found that the cache reported by check_mem was negative:

# /usr/local/nagios/libexec/check_mem -u -C -w 90 -c 95
WARNING - 92.9% (11695180 kB) used!|TOTAL=12582912KB;;;; USED=11695180KB;11324620;11953766;; FREE=887732KB;;;; CACHES=-2709560KB;;;;

The negative cache value is what causes the issue; if I choose to ignore cache dont get the warning:

# /usr/local/nagios/libexec/check_mem -u -w 90 -c 95
OK - 71.5% (8997588 kB) used.|TOTAL=12582912KB;;;; USED=8997588KB;11324620;11953766;; FREE=3585324KB;;;; CACHES=-2692876KB;;;;

Its a linux system, details are as follows:

# cat /proc/meminfo
MemTotal:       12582912 kB
MemFree:         3591364 kB
Cached:           518712 kB
Buffers:               0 kB
Active:          4081284 kB
Inactive:        1503948 kB
Active(anon):    3923484 kB
Inactive(anon):  1143036 kB
Active(file):     157800 kB
Inactive(file):   360912 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               248 kB
Writeback:             0 kB
AnonPages:       5066520 kB
Shmem:           3292220 kB
Slab:             114076 kB
SReclaimable:      61008 kB
SUnreclaim:        53068 kB
# uname -sr
Linux 2.6.32-042stab120.16

=========================

Tried it on a different system with a more modern kernel, output is as follows:

# cat /proc/meminfo 
MemTotal:        8171680 kB
MemFree:          282784 kB
MemAvailable:    7199936 kB
Buffers:          640576 kB
Cached:          5530204 kB
SwapCached:          236 kB
Active:          4675496 kB
Inactive:        2069064 kB
Active(anon):     267576 kB
Inactive(anon):   443140 kB
Active(file):    4407920 kB
Inactive(file):  1625924 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:        524284 kB
SwapFree:         510304 kB
Dirty:              8688 kB
Writeback:             0 kB
AnonPages:        573612 kB
Mapped:           153592 kB
Shmem:            136924 kB
Slab:            1034884 kB
SReclaimable:     986028 kB
SUnreclaim:        48856 kB
KernelStack:        5856 kB
PageTables:        32552 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     4610124 kB
Committed_AS:    1730916 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
DirectMap4k:       14200 kB
DirectMap2M:     2082816 kB
DirectMap1G:     8388608 kB
# uname -sr
Linux 4.9.15-x86_64

Looks to be an issue with the Shmem usage in the code:
https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl#L159

Values could be to big for INT

We have systems with more than 2TB RAM.
If free or used memory is too big for an integer, this fails:
# Round to the nearest KB
$free_memory_kb = sprintf('%d',$free_memory_kb);
$used_memory_kb = sprintf('%d',$used_memory_kb);
$caches_kb = sprintf('%d',$caches_kb);

I changed it to:
# Round to the nearest KB
$free_memory_kb = sprintf('%.0f',$free_memory_kb);
$used_memory_kb = sprintf('%.0f',$used_memory_kb);
$caches_kb = sprintf('%.0f',$caches_kb);

Cacti hackery

Hello,
You mentionned some hackery to get the perfdata in Cacti, can you share your tricks (As I'm not a Cacti guru it will save me a lot of time) ?

Thank you

Patrick

check_mem.pl returns negative result when count OS caches as FREE memory

check_mem returns negative memory usage when counting OS caches as FREE memory (with -C option). Looks like caches_kb is calculated via caches_kb = MemAvailable+Buffers+Cached+SReclaimable -Shmem. It doesn't make sense to me that MemAvailable counted as caches_kb.

$./check_mem.pl -u -w 97 -c 98 -h -C
OK - -51.6% (-545413716 kB) used.|TOTAL=1056743416KB;;;; USED=-545413716KB;1025041113;1035608547;; FREE=1602157132KB;;;; CACHES=949089652KB;;;; HUGEPAGES=0KB;;;;

$ cat /proc/meminfo
MemTotal: 1056743416 kB
MemFree: 653040840 kB
MemAvailable: 799941548 kB
Buffers: 1322236 kB
Cached: 147247296 kB
SwapCached: 69164 kB
Active: 247599804 kB
Inactive: 127356048 kB
Active(anon): 217507076 kB
Inactive(anon): 13677308 kB
Active(file): 30092728 kB
Inactive(file): 113678740 kB
Unevictable: 731616 kB
Mlocked: 731616 kB
SwapTotal: 8388604 kB
SwapFree: 8078076 kB
Dirty: 3924 kB
Writeback: 0 kB
AnonPages: 227051912 kB
Mapped: 1620780 kB
Shmem: 8695952 kB
Slab: 18680892 kB
SReclaimable: 9278192 kB
SUnreclaim: 9402700 kB
KernelStack: 215648 kB
PageTables: 901956 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 536760312 kB
Committed_AS: 367436936 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 22505472 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 20934888 kB
DirectMap2M: 794740736 kB
DirectMap1G: 260046848 kB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.