Warning: opendir(/var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/sh/3.0.83.2/scripts/): failed to open dir: No such file or directory in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 26

Warning: Invalid argument supplied for foreach() in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 170
Skip to content

Shellscript - Nagios Plugins - Swap & Memory


 
Plugin zum Überwachen des Arbeitsspeichers
 
#!/bin/sh

free -m | grep Mem | while read output;
do
  mem=$(echo $output | awk ‘{print $2}’ )
  used=$(echo $output | awk ‘{ print $3 }’ )
  free=$(echo $output | awk ‘{ print $4 }’ )
  use=`expr $used \* 100 / $mem`

  if [ $use -ge 90 ]; then
    echo "CRITICAL Total Mem: \"$mem\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 2
  elif [ $usep -ge 50 ]; then
    echo "WARNING Total Mem: \"$mem\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 1
  else
    echo "OK Mem: $mem" "Used: $used" "Free: $free"
    exit 0
  fi

done
 
Plugin zum Überwachen des Swap
 
#!/bin/sh
free -m | grep Swap | while read output;
do
  swap=$(echo $output | awk ‘{print $2}’ )
  used=$(echo $output | awk ‘{ print $3 }’ )
  free=$(echo $output | awk ‘{ print $4 }’ )
  use=`expr $used \* 100 / $swap`

  if [ $use -ge 90 ]; then
    echo "CRITICAL Swap: \"$swap\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 2
  elif [ $use -ge 50 ]; then
    echo "WARNING Swap: \"$swap\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 1
  else
    echo "OK Swap: $swap" "Used: $used" "Free: $free"
    exit 0
  fi

done
 

Download: memory.sh swap.sh

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


Textile-formatting allowed
You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options
Imprint | Contact | Privacy Statement

Warning: opendir(/var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/sh/3.0.83.2/scripts/): failed to open dir: No such file or directory in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 26

Warning: Invalid argument supplied for foreach() in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 170