Open main menu

OpenVZ Virtuozzo Containers Wiki β

Editing Monitoring openvz resources using rrdtool

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 1: Line 1:
 
[[Category: Monitoring]]
 
[[Category: Monitoring]]
  
In this setup we're using [http://oss.oetiker.ch/rrdtool/ rrdtool] to collect data from several openvz hardware nodes to a central [http://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html#IRRD_Server rrd server].
+
In this setup there is a central rrd server that collects data from several openvz hardware nodes
  
 
=== Setting up rrd server ===
 
=== Setting up rrd server ===
Line 23: Line 23:
 
  }
 
  }
  
Add 'rrdsrv' to /etc/services
+
Add service in /etc/services
 
  rrdsrv                13900/tcp
 
  rrdsrv                13900/tcp
  
Line 29: Line 29:
 
=== Collect script ===
 
=== Collect script ===
  
Put the following script on the openvz hardware nodes (ubc_rrd_collect.sh):
+
Put the following script on the openvz hardware nodes:
  
 
  #!/bin/sh
 
  #!/bin/sh
Line 65: Line 65:
 
  done
 
  done
 
   
 
   
  VPSIDS=$(vzlist -H -o veid)
+
  VPSIDS=$(vzlist | awk ' BEGIN { ORS=" "; getline } { print $1 }')
 
   
 
   
 
  PARAMS=$(cat /proc/bc/0/resources | awk '{ print $1 }'| sort -u | xargs)
 
  PARAMS=$(cat /proc/bc/0/resources | awk '{ print $1 }'| sort -u | xargs)
Line 103: Line 103:
 
                 fi
 
                 fi
 
         fi
 
         fi
 
 
        if [ "$update" -eq 1 ]; then
 
                (
 
                        cat /proc/bc/$VPSID/resources | awk -v rrdfile=$RRDFILENAME '
 
                        BEGIN {
 
                                ORS="";
 
                                getline
 
                                keys=$1 "_f"; values=$6;
 
                                keys=keys ":" $1 "_h"; values=values ":" $2;
 
                                keys=keys ":" $1 "_b"; values=values ":" $4;
 
                        }
 
                        {
 
                                keys=keys ":" $1 "_f"; values=values ":" $6;
 
                                keys=keys ":" $1 "_h"; values=values ":" $2;
 
                                keys=keys ":" $1 "_b"; values=values ":" $4;
 
                        }
 
                        END { print "update " rrdfile " -t " keys " N:" values "\n"; } '
 
                ) | $command
 
        fi
 
done
 
 
=== Usage ===
 
 
ubc_rrd_collect.sh [update] [init] [send]
 
 
  update - run this to update rrd files
 
  init  - scan system and create rrd files
 
  send  - use this to send commands to rddtool
 
 
=== Migration and new container ===
 
 
When you have this script running in cron on every hardware node and you're migrating a container from one node to the other the script will automatically detect this and pick it up on the other node.
 
 
When you create a new container you have to run <code>ubc_rrd_collect.sh init send</code> and it will ping rddtool to create a new rrd database. It won't overwrite existing databases because it first checks if a database already exists.
 
 
=== Setting up cron ===
 
 
Run update every 5 minutes:
 
 
*/5    *      *      *      *      /path/to/ubc_rrd_collect.sh update send | grep -v '^OK'
 
 
Run init every hour (or run it manually when needed):
 
0      *      *      *      *      /path/to/ubc_rrd_collect.sh init send | grep -v '^OK'
 

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)