r1 - 10 May 2007 - 08:27:06 - NetClimeYou are here: Wiki >  AppLogic2 Web > AdvCustomCounters
led-green December 24 - AppLogic 2.4.7 is now available and is the latest production release!

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)

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 © 2005-2008 3tera, Inc. All Rights Reserved.
%