Nagios Monitoring Linux host monitoring memory scripts

Source: Internet
Author: User

Description

The work consists of two parts of the monitoring side (123) and the monitored end (iv)

One, add script in Nrpe.cfg

Add Command index in NRPE.CFG

COMMAND[CHECK_USED_MEM]=/USR/LOCAL/NAGIOS/LIBEXEC/CHECK_USED_MEM.SH 80 90

Description: Actual memory usage exceeds 80% warning; more than 90% critical warnings

Second, add the specific script

Reference Script check_used_mem.sh

Warn=$1Critical=$2 All= ' Free | Sed-n'2p'| Awk'{print $}'' used= ' Free | Sed-n'3p'| Awk'{print $}'' Let"c= $used *100/$all"if[[$c-Lt $warn]] Then Echo"used Mem/total < $warn% [used: $used, total: $total: $all]"Exit 0elif[[$c-Lt $critical]] Then Echo"used mem/total≥ $warn% [used: $used, total: $total: $all]"Exit1ElseEcho"used mem/total≥ $critical% [used: $used, total: $total: $all]"Exit2fi

Explain:

1. $ $ and $ are the first to second parameters of the input, for example:

del.sh script content is

#/bin/bashecho $1
    • SH del.sh a #第一个参数是a
    • chmod a+x./del.sh a #第一个参数是a

2. Free to view memory usage

 [[Email protected]_202_12/]# free - M total used  free   sh ared buffers Cachedmem:  3072  2459  612  0  207  1803 -/+ buffers/cache: 447 2624  swap:  1913  0  1913  
    • Total Memory: 3072
    • Used number of memory used: 2459
    • Free Memory Number: 612
    • GKFX is currently obsolete. No, always 0.
    • Buffers:buffer Cache Memory: 13220
    • Cached:page Cache Memory: 2720160

Relationship: total = used + Free

Line 3rd:
The meaning of-/+ Buffers/cache:
-buffers/cache Memory: 447 (equals 1th row of used-buffers-cached)
+buffers/cache Memory: 2624 (equals 1th line of Free + buffers + cached)
Note: The amount of memory here is a little bit out of size after calculating it with the above formula (you don't know what the reason is).

The visible-buffers/cache reflects the memory that is actually eaten by the program, and +buffers/cache reflects the total amount of memory that can be appropriated.

3. Sed-n ' 2p ' refers to finding the second line

4. awk ' {print $} refers to the second column, which is separated by a space by default. You can specify the delimiter with-f

$echo 1b234b+awk'b'{ Print$'234

5. Utility [[]],< used to compare strings;-lt to compare numbers

Third, restart Nrpe
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
Iv. adding monitoring items to the monitoring side
Define Service {        use                             generic-service        host_name                       100.61.  73.2,73.3        service_description             memory        Check_command                   Check_nrpe! check_used_mem        notifications_enabled           1        }

Nagios Monitoring Linux host monitoring memory scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.