Editing Talk:Monitoring /proc/user beancounters with nagios

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 3: Line 3:
 
== Introduction ==
 
== Introduction ==
  
This script gives a warning if any parameter in a virtual environment (VZ) exceeds 80% of resources.
+
To be added locally on the VZ HN to <code> /etc/crontab </code> to script <code> resource.sh </code>
  
== packages basic installation ==
+
== Package Install base ==
 
<pre>
 
<pre>
 
   aptitude install nail gawk  
 
   aptitude install nail gawk  
Line 11: Line 11:
  
 
== nail configuration ==
 
== nail configuration ==
  Configures  <code> /etc/nailrc </code> or <code> ~/.mailrc </code> files.
+
To configure file <code> /etc/nailrc </code> or <code> ~/.mailrc </code>
 
<pre>
 
<pre>
 
set smtp=smtp.server.org
 
set smtp=smtp.server.org
Line 18: Line 18:
 
</pre>
 
</pre>
  
== configuration ==
+
== Script Alarm ==
 
 
Copy the script and configure the <code> /etc/crontab </code>
 
 
 
== Script resource ==
 
  
 
<source lang=bash>
 
<source lang=bash>
 
#!/bin/bash resource.sh
 
#!/bin/bash resource.sh
 
# Copyright (C) 2008 Mgual
 
# Copyright (C) 2008 Mgual
# Distributed under to GNU General Public License v2
+
# Distributed under to GNU General Public License v3
# v0.1 2008-08-13
+
# v0.2 2008-08-13
# Ajuntament de Benicarló
+
# Miquel Gual Torner
 
 
  
  
 
#!/bin/bash
 
#!/bin/bash
  
 +
echo "" | gawk -vVZ='ID' -vRESOURCE='Parametre' -vPBARRIER='%bar' -vPLIMIT='%lim' '
 +
                {
 +
                        printf "%3s %-20s %3s %3s \n", VZ, RESOURCE , PBARRIER, PLIMIT  > "/tmp/beancounters"
 +
                }
 +
        '
  
 
+
gawk '
gawk ' BEGIN {
 
                printf "%3s %-20s %3s %3s \n", "ID", "Parameter", "%bar", "%lim" > "/tmp/beancounters"
 
        }
 
 
 
 
         /dummy/||/Version/||/uid/ { next }
 
         /dummy/||/Version/||/uid/ { next }
 
         ! /:/ {
 
         ! /:/ {
Line 70: Line 66:
 
                 printf "%-20s %3d %3d ", RESOURCE , PBARRIER, PLIMIT
 
                 printf "%-20s %3d %3d ", RESOURCE , PBARRIER, PLIMIT
 
                 if (PBARRIER>=80)  {
 
                 if (PBARRIER>=80)  {
                         printf " Warning "
+
                         printf " Perill "
 
                         printf "%3d %-20s %3d %3d Perill\n", VZ, RESOURCE , PBARRIER, PLIMIT >> "/tmp/beancounters"
 
                         printf "%3d %-20s %3d %3d Perill\n", VZ, RESOURCE , PBARRIER, PLIMIT >> "/tmp/beancounters"
 
                 }
 
                 }
Line 78: Line 74:
  
 
echo "---------------------------------------------------" >> /tmp/beancounters
 
echo "---------------------------------------------------" >> /tmp/beancounters
echo "" | gawk -vVZ='ID' -vRESOURCE='Use Disc%' '
+
echo "" | gawk -vVZ='ID' -vRESOURCE='Use%' '
 
               {
 
               {
 
                         printf "%3s %-20s \n", VZ, RESOURCE  >> "/tmp/beancounters"
 
                         printf "%3s %-20s \n", VZ, RESOURCE  >> "/tmp/beancounters"
Line 94: Line 90:
  
 
echo "---------------------------------------------------" >> /tmp/beancounters
 
echo "---------------------------------------------------" >> /tmp/beancounters
echo "" | gawk -vVZ='ID' -vRESOURCE='IUse Disc%' '
+
echo "" | gawk -vVZ='ID' -vRESOURCE='IUse%' '
 
               {
 
               {
 
                         printf "%3s %-20s \n", VZ, RESOURCE  >> "/tmp/beancounters"
 
                         printf "%3s %-20s \n", VZ, RESOURCE  >> "/tmp/beancounters"
Line 107: Line 103:
  
 
if [[ "$(cat /tmp/beancounters | wc -l)" != "5"  ]] ; then
 
if [[ "$(cat /tmp/beancounters | wc -l)" != "5"  ]] ; then
         cat /tmp/beancounters  |  nail -s "Server:resource.sh Warning " user@smtp-server.org
+
         cat /tmp/beancounters  |  nail -s Server:resource.sh perill@smtp-server.org
 
fi
 
fi

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)