403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.142
Web Server : LiteSpeed
System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
User : azfilmst ( 1070)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/thread-self/root/lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/lib64/nagios/plugins/check_meminfo
#!/bin/bash
# Nagios check_meminfo script
# 2023 (C) WorldHost Group
# Author: Tsvetan Gerov <tsvetan@wordlhost.group>
# Version 0.2

MEMINFO="/proc/meminfo"

# Default values
MEMWARNING="90"
MEMCRITICAL="95"
SWAPWARNING="70"
SWAPCRITICAL="80"
APPSWARNING="60"
APPSCRITICAL="70"

Help() {
   # Display Help
   echo "check_meminfo"
   echo
   echo "Syntax: check_meminfo [-w|-c|-W|-C]-a|-s|-h"
   echo "options:"
   echo "w     Warning percentage for memory"
   echo "c     Critical percentage for memory".
   echo "W     Warning percentage for swap"
   echo "C     Critical percentage for swap"
   echo "a     Warning percentage for apps"
   echo "s     Critical percentage for apps"
   echo "h     Print this help"
   echo
   exit
}

getMemory() {
    awk '/^MemTotal:/ {total = $2;}
        /^MemFree:/ {free = $2;}
        /^MemAvailable:/ {avail = $2;}
        /^Buffers:/ {buffers = $2;}
        /^Cached:/ {cached = $2;
            if (avail == "") avail = free + buffers + cached;
            printf "%d\n", (total - avail) / total * 100;}' $MEMINFO
}

getSwap() {
    TOTALSWAP=$(grep SwapTotal /proc/meminfo  | awk '{print$2}')
    if [ $TOTALSWAP -eq "0" ]; then
       echo "0"
    else
      awk '/^SwapCached:/ {cached = $2;}
       	  /^SwapTotal:/ {total = $2;}
       	  /^SwapFree:/ {free = $2;
              printf "%d\n", (total - free - cache) / total * 100}' $MEMINFO
    fi
}

getApps() {
    awk '/^MemTotal:/ {total = $2;}
        /^MemFree:/ {free = $2;}
        /^Buffers:/ {buffer = $2;}
        /^Cached:/ {cached = $2;}
        /^Slab:/ {slab = $2;}
        /^PageTables:/ {pagetables = $2;}
        /^SwapCached:/ {swapcache = $2;
            printf "%d\n", (total - free - buffer -cached - slab - pagetables - swapcache) / total * 100}' $MEMINFO
}

while getopts w:c:W:C:a:s:h flag
do
    case "${flag}" in
        w) MEMWARNING=${OPTARG};;
        c) MEMCRITICAL=${OPTARG};;
        W) SWAPWARNING=${OPTARG};;
        C) SWAPCRITICAL=${OPTARG};;
        a) APPSWARNING=${OPTARG};;
        s) APPSCRITICAL=${OPTARG};;
        h) Help;;

    esac
done


# CRITICAL
if [ $(getMemory) -gt $MEMCRITICAL ]; then
    echo "CRITICAL: RAM Usage: $(getMemory)/100%"
    exit 2
elif [ $(getApps) -gt $APPSCRITICAL ]; then
    echo "CRITICAL: Memory APPs Usage: $(getApps)/100%"
    exit 2    
elif [ $(getSwap) -gt $SWAPCRITICAL ]; then
    echo "CRITICAL: SWAP Usage: $(getSwap)/100%"
    exit 2    
# WARNING
elif [ $(getMemory) -gt $MEMWARNING ]; then
    echo "WARNING: RAM Usage: $(getMemory)/100%"
    exit 1
elif [ $(getApps) -gt $APPSWARNING ]; then
    echo "WARNING: Memory APPs: $(getApps)/100%"
    exit 1
elif [ $(getSwap) -gt $SWAPWARNING ]; then
    echo "WARNING: SWAP Usage: $(getSwap)/100%"
    exit 1    
# OK
else
    echo "OK: RAM: $(getMemory)/100%  APPS: $(getApps)/100%  SWAP: $(getSwap)/100%"
    exit 0
fi

Youez - 2016 - github.com/yon3zu
LinuXploit