|
@@ -3,6 +3,12 @@
|
|
|
/**
|
|
|
* @file
|
|
|
* APC instrumentation for Munin
|
|
|
+ *
|
|
|
+ * @author Frederic G. MARAND
|
|
|
+ *
|
|
|
+ * @copyright (c) 2011 Ouest Systèmes Informatiques
|
|
|
+ *
|
|
|
+ * Licensed under the General Public License version 2 or later.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -12,45 +18,53 @@
|
|
|
* An array of Munin probes informations, index by probe name.
|
|
|
*/
|
|
|
function munin_apc_munin_api_info() {
|
|
|
+ $int = array(
|
|
|
+ '#graph_printf' => '%d',
|
|
|
+ );
|
|
|
+
|
|
|
$ret = array(
|
|
|
'munin_apc' => array(
|
|
|
'#title' => t('PHP APC'),
|
|
|
- '#description' => t('Collect cache information for the Alternative PHP Cache'),
|
|
|
- 'uptime' => array(
|
|
|
- '#title' => t('Up-time of APC instance'),
|
|
|
- '#type' => MUNIN_API_GAUGE
|
|
|
+ '#info' => t('Collect cache information for the Alternative PHP Cache'),
|
|
|
+ 'total_size' => $int + array(
|
|
|
+ '#label' => t('Bytes allocated'),
|
|
|
+ '#type' => MUNIN_API_GAUGE,
|
|
|
+ '#info' => t('Number of bytes allocated to APC.')
|
|
|
),
|
|
|
- 'total_size' => array(
|
|
|
- '#title' => t('Number of bytes allocated to APC'),
|
|
|
- '#type' => MUNIN_API_COUNTER,
|
|
|
+ 'used_size' => $int + array(
|
|
|
+ '#label' => t('Bytes in use'),
|
|
|
+ '#type' => MUNIN_API_GAUGE,
|
|
|
+ '#info' => t('Number of bytes actually used by APC, either cached or deleted'),
|
|
|
),
|
|
|
- 'used_size' => array(
|
|
|
- '#title' => t('Number of bytes currently used by APC, either cached or deleted'),
|
|
|
- '#type' => MUNIN_API_COUNTER,
|
|
|
+ 'uptime' => $int + array(
|
|
|
+ '#label' => t('Up-time of APC instance'),
|
|
|
+ '#type' => MUNIN_API_GAUGE,
|
|
|
+ '#info' => t('Seconds since last APC restart.'),
|
|
|
),
|
|
|
- 'num_hits' => array(
|
|
|
- '#title' => t('The number of hits since the last restart'),
|
|
|
+ 'num_hits' => $int + array(
|
|
|
+ '#label' => t('Hits since last restart'),
|
|
|
'#type' => MUNIN_API_COUNTER,
|
|
|
),
|
|
|
- 'num_misses' => array(
|
|
|
- '#title' => t('The number of misses since the last restart'),
|
|
|
+ 'num_misses' => $int + array(
|
|
|
+ '#label' => t('Misses since last restart'),
|
|
|
'#type' => MUNIN_API_COUNTER,
|
|
|
),
|
|
|
- 'hit_rate' => array(
|
|
|
- '#title' => t('This hit/miss ratio since the last restart'),
|
|
|
- '#type' => MUNIN_API_GAUGE,
|
|
|
- ),
|
|
|
- 'num_insertions' => array(
|
|
|
- '#title' => t('The number of insertions since the last restart'),
|
|
|
+ 'num_inserts' => $int + array(
|
|
|
+ '#label' => t('Insertions since last restart'),
|
|
|
'#type' => MUNIN_API_COUNTER,
|
|
|
),
|
|
|
- 'cache_entries' => array(
|
|
|
- '#title' => t('The number of cache entries'),
|
|
|
+// 'hit_rate' => $int + array(
|
|
|
+// '#label' => t('Hit/miss ratio since last restart'),
|
|
|
+// '#type' => MUNIN_API_GAUGE,
|
|
|
+// ),
|
|
|
+ 'cache_entries' => $int + array(
|
|
|
+ '#label' => t('Number of cache entries'),
|
|
|
'#type' => MUNIN_API_GAUGE,
|
|
|
),
|
|
|
- 'deleted_entries' => array(
|
|
|
- '#title' => t('The number of deleted entries lingering'),
|
|
|
+ 'deleted_entries' => $int + array(
|
|
|
+ '#label' => t('Number of deleted entries'),
|
|
|
'#type' => MUNIN_API_GAUGE,
|
|
|
+ '#info' => t('Deleted entries lingering until the garbage collection TTL elapses'),
|
|
|
),
|
|
|
),
|
|
|
);
|
|
@@ -62,15 +76,23 @@ function munin_apc_munin_api_info() {
|
|
|
* Implements hook_munin_api_fetch().
|
|
|
*/
|
|
|
function munin_apc_munin_api_fetch() {
|
|
|
- return array(
|
|
|
- 'uptime' => 1,
|
|
|
- );
|
|
|
-}
|
|
|
+ $info = apc_sma_info();
|
|
|
+ $ret = array();
|
|
|
|
|
|
-/**
|
|
|
- * Implements hook_munin_api_config().
|
|
|
- */
|
|
|
-function munin_apc_munin_api_config() {
|
|
|
- return array(
|
|
|
- );
|
|
|
-}
|
|
|
+ // SMA Info
|
|
|
+ $total = $info['num_seg'] * $info['seg_size'];
|
|
|
+ $ret['total_size'] = (int) $total;
|
|
|
+ $ret['used_size'] = (int) ($total - $info['avail_mem']);
|
|
|
+
|
|
|
+ // Cache info
|
|
|
+ $info = apc_cache_info();
|
|
|
+ $ret['uptime'] = time() - $info['start_time'];
|
|
|
+ foreach (array('num_hits', 'num_misses', 'num_inserts') as $field) {
|
|
|
+ $ret[$field] = $info[$field];
|
|
|
+ }
|
|
|
+
|
|
|
+ $ret['cache_entries'] = count($info['cache_list']);
|
|
|
+ $ret['deleted_entries'] = count($info['deleted_list']);
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+}
|