r2 - 18 Jun 2008 - 09:25:51 - IvanPeikovYou are here: Wiki >  AppLogic24 Web > AdvCustomCounters
ALERT! AppLogic 2.4 Documentation The latest production release is AppLogic 3.0.30

Monitoring Custom Counters


Overview

Each appliance running the ccad (counter collection agent) daemon allows for custom counters to be defined and collected by 3rd party utilities. This ability is called extension interface and provides appliance creators with option to monitor appliance-specific counter data through the standard MON user interface.

Creating custom Counters

To monitor custom counters you need to add the counters definitions to the ccad configuration and feed the actaul counter values to ccad

Adding counter definitions

The custom counters have to be defined in the optional /etc/ccad.conf configuration file (in UDL format). Whenever you make changes to the configuration, the ccad daemon must be restart for the changes to take effect.

Here is a simple example configuration:

counters Apache
   {
   pace = 1000
   pipe = /tmp/cca

   counter Total_Accesses
      {
      name        = "Total hits"
      desc        = "Total number of hits"
      units       = "#"
      type        = "MAX"
      }


   counter Total_kBytes
      {
      name        = "Total bytes"
      desc        = "Total number of bytes"
      units       = "bytes"
      type        = "MAX"
      }

   counter BusyWorkers
      {
      name        = "Active requests"
      desc        = "Number of active requests"
      units       = "#"
      type        = "MAX"
      }

   counter IdleWorkers
      {
      name        = "Idle servers"
      desc        = "Number of idle servers"
      units       = "#"
      type        = "MAX"
      }

   }

This example defines 4 counters. Each counter entity supports the following attributes:

  • name - Human-readable name of the counter (set to counter entity name by default)
  • desc - Human-readable description of the counter (empty by default)
  • type - Type of the counter (SUM, AVG, MIN or MAX, the default is AVG)
  • units - Units in which the counter values should be interpreted (empty by default)
  • range_lower - The lowest possible value of that counter (smaller values will be cut)
  • range_upper - The highest possible value of that counter (larger values will be cut)
  • alarm_below - The lowest non-alarming value of the counter (smaller values will trigger alarm)
  • alarm_above - The highest non-alarming value of the counter (larger values will trigger alarm)

The root-level counters entity's name is used for Entity name when the counters are later shown in MON. Additionally, the following attributes are meaningful for this entity:

  • pace - Pace (in milliseconds) of the custom counters collection (1000 if not specified)
  • pipe - Path to the named pipe used for collection (/tmp/cca if not specified)

In addition to counter definition method described above, ccad.conf allows counters to be grouped together. This is achieved by placing them one level deeper in group entities as in the following example:

counters Plants
   {
   pace = 2000
   pipe = /my-pipe

   counter tree: desc = "Any tree" , units = "#"

   group Fruits
      {
      desc = "Delicious Fruits!!!"

      counter pears : desc = "Number of pears"   , units = "pears"
      counter apples: desc = "Number of apples"  , units = "apples"
      }

   group Vegetables
      {
      counter potato: desc = "Number of potatoes", units = "potatoes"
      counter tomato: desc = "Number of tomatoes", units = "tomatoes"
      }
   }

This configuration would produce 3 custom counter entities in MON's GUI - Plants, Delicious Fruits!!! and Vegetables with the 5 defined counters distributed among them. Groups support a desc attribute (just like counter entities) that can be used to define a richer group name as opposed to the more constrained group entity name. Note that counter names should be unique across the configuration file otherwise the counter collection would be made impossible for the duplicate counter names (see next section).

Feeding counter data

Once you have the ccad running with the proper counter definitions, you need to feed the actual counter values. To do so, write the counter values to the named pipe create by ccad (specified by the pipe attribute in /etc/ccad.conf, default /tmp/cca).
The proper format is one of the following:
  • counter = value (name and value are separated with =)
  • counter : value (name and value are separated with :)

A counter set should be flushed (to MON) by printing . or form feed character (\f) in the named pipe on a line by itself. A counter collection script (in Bash) could do the following to feed counter to ccad:
echo "Total_Accesses = 31" > /tmp/cca
echo "Total_kBytes = 22241" > /tmp/cca
echo "BusyWorkers = 6" > /tmp/cca
echo "IdleWorkers = 34" > /tmp/cca
echo "." > /tmp/cca

This should be done every pace milliseconds as specified in /etc/ccad.conf

Here is a simple bash loop that would collect the needed data and feed it to ccad. Note that we feed more data than we need as it faster to give all the collected data to ccad (which will ignore the lines that are not counter values) than to parse the data before feeding it to ccad:

while true; do
   curl -s http://in/server-status?auto | sed "s/^Total\ /Total_/g" > /tmp/cca # this parses the data so it matches out counter definitions
   sleep 1 || exit 4        
   echo "." > /tmp/cca
done

Examples

Apache

ALERT! NOTE: the server must have 'extended status' enabled
#!/bin/bash

DEFAULT_PACE=1000
DEFAULT_PIPE=/tmp/cca
CCAD_CONF=/etc/ccad.conf
STATUS_URL='http://in/server-status?auto'
CURL=/usr/bin/curl
SED=/bin/sed
SLEEP=/bin/sleep


function get_value_from_config {
   CONF_VALUE=`grep -oE "$1[[:space:]]*=[[:space:]]*[^[:space:]]+" $CCAD_CONF |cut -d"=" -f 2|tr -d " "`
}

get_value_from_config "pace"
PACE=${CONF_VALUE:-$DEFAULT_PACE}
PACE=$(( $PACE / 1000 ))

get_value_from_config "pipe"
PIPE=${CONF_VALUE:-$DEFAULT_PIPE}
test -p $PIPE || exit 3

while true; do
   $CURL -s "$STATUS_URL" | $SED "s/^Total\ /Total_/g" > $PIPE
   sleep $PACE || exit 4
   echo "." > $PIPE
done

Mysql

#!/bin/bash

DEFAULT_PACE=1000
DEFAULT_PIPE=/tmp/cca
CCAD_CONF=/etc/ccad.conf
MYSQL='/usr/bin/mysql'
TR=/usr/bin/tr
SLEEP=/bin/sleep



function get_value_from_config {
   CONF_VALUE=`grep -oE "$1[[:space:]]*=[[:space:]]*[^[:space:]]+" $CCAD_CONF |cut -d"=" -f 2|tr -d " "`
}

get_value_from_config "pace"
PACE=${CONF_VALUE:-$DEFAULT_PACE}
PACE=$(( $PACE / 1000 ))

get_value_from_config "pipe"
PIPE=${CONF_VALUE:-$DEFAULT_PIPE}
test -p $PIPE || exit 3

while true; do
   $MYSQL -e 'show status'|$TR '[[:blank:]]' '=' > $PIPE
   $SLEEP $PACE || exit 4
   echo "." > $PIPE
done

-- NetClime - 10 May 2007

 
Copyright © CA 2005-2011. All Rights Reserved.
%