Created
March 25, 2021 09:09
-
-
Save seidler2547/762fb4c6d1cfa333f9f730eb017c47ac to your computer and use it in GitHub Desktop.
Revisions
-
seidler2547 created this gist
Mar 25, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/awk -E BEGIN { while ((getline <"/proc/meminfo") > 0 ) { gsub(/:/,""); gsub(/\(/,"_"); gsub(/\)/,""); a[$1]=$2; u[$1]=toupper($3); } swapfactor=(ENVIRON["swapfactor"]~/^[0-9]+$/)?ENVIRON["swapfactor"]:0.5; critical=(ENVIRON["critical"]~/^[0-9]+$/)?ENVIRON["critical"]:10; warning=(ENVIRON["warning"]~/^[0-9]+$/)?ENVIRON["warning"]:20; } END { ma=a["MemAvailable"]; mt=a["MemTotal"]; sf=a["SwapFree"]; if (mt<10000 || ma<10) exit 3; mr=100*(ma+(sf*swapfactor))/mt; ec=0; printf "Memory "; if (mr<critical) { printf "CRITICAL"; ec=2; } else if (mr<warning) { printf "WARNING"; ec=1; } else printf "OK"; printf ", %.1f%% (%d/%d MB + %d MB swap) available|",(ma*100/mt),(ma/1024),(mt/1024),(sf/1024); for (k in a) printf k"="a[k]u[k]";;; "; print ""; exit ec; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ object CheckCommand "mem_full" { command = [ "/var/lib/nagios/check_mem_full", ] env = { swapfactor = "$memory_swapfactor$" warning = "$memory_warning$" critical = "$memory_critical$" } arguments = { } vars.memory_swapfactor = "" vars.memory_warning = "" vars.memory_critical = "" }