Browse Source

Use of negative values for a more condensed presentation with less caption lines.

FGM 13 years ago
parent
commit
ab218748ba
2 changed files with 82 additions and 39 deletions
  1. 1 0
      modules/munin_apc/munin_apc.module
  2. 81 39
      modules/munin_core/munin_core.module

+ 1 - 0
modules/munin_apc/munin_apc.module

@@ -73,6 +73,7 @@ function munin_apc_munin_api_info() {
       '#title'     => t('APC Uptime'),
       '#info'      => t('Uptime information for the Alternative PHP Cache.'),
       '#graph_vlabel' => t('Uptime in days'),
+      '#graph_scale'  => 'no',
 
       'uptime'     => $int + array(
         '#label'     => t('Up-time of APC instance'),

+ 81 - 39
modules/munin_core/munin_core.module

@@ -19,7 +19,7 @@
  */
 function munin_core_munin_api_info() {
   $int = array(
-    '#graph_printf' => '%d',
+    '#graph_printf' => "'%d'",
   );
 
   $ret = array(
@@ -27,42 +27,67 @@ function munin_core_munin_api_info() {
     '#description'  => t('Graphs about Drupal core'),
 
     'munin_core' => array(
-      '#title'     => t('Drupal core'),
-      '#info'      => t('Collect core information from a Drupal instance. All counters are integer-rounded.'),
+      '#title'     => t('Core user-related statistics'),
+      '#info'      => t('Core statistics regarding users and sessions.'),
 
-      'user_current' => $int + array(
-        '#label'     => t('Logged-in sessions'),
-        '#type'      => MUNIN_API_GAUGE,
-        '#info'      => t('The number of logged-in sessions not older than 5 minutes. Only meaningful if you are not using an alternate sessions implementation not using the sessions table.'),
-      ),
       'anon_current' => $int + array(
-        '#label'     => t('Anonymous sessions'),
+        '#label'     => t('Sessions, anon'),
         '#type'      => MUNIN_API_GAUGE,
         '#info'      => t('The number of anonymous sessions not older than 5 minutes. Only meaningful if you are not using an alternate sessions implementation not using the sessions table.'),
+        '#graph'    => 'no',
       ),
-      'user_count' => $int + array(
-        '#label'    => t('Number of users'),
+      'user_current' => $int + array(
+        '#label'     => t('Sessions'),
+        '#type'      => MUNIN_API_GAUGE,
+        '#info'      => t('The number of sessions not older than 5 minutes. Only meaningful if you are not using an alternate sessions implementation not using the sessions table. Anonymous sessions dispaly as negative.'),
+        '#negative'  => 'anon_current',
+      ),
+
+      'user_blocked_count' => $int + array(
+        '#label'    => t('Users, blocked'),
         '#type'     => MUNIN_API_GAUGE,
-        '#info'     => t('The total number of users, whatever their status'),
+        '#info'     => t('The number of users with status = 0'),
+        '#graph'    => 'no',
       ),
       'user_active_count' => $int + array(
-        '#label'    => t('Number of active users'),
+        '#label'    => t('Users'),
         '#type'     => MUNIN_API_GAUGE,
-        '#info'     => t('The number of users with status = 1'),
+        '#info'     => t('The number of users. Blocked users display as negative.'),
+        '#negative' => 'user_blocked_count',
       ),
-      'user_blocked_count' => $int + array(
-        '#label'    => t('Number of blocked users'),
+    ),
+
+    'munin_core_content' => array(
+      '#title'     => t('Core content statistics'),
+      '#info'      => t('Information about nodes, comments and terms.'),
+      '#graph_vlabel' => t('Number of entries'),
+
+      'node_count_unpub' => $int + array(
+        '#label'    => t('Nodes, unpublished'),
         '#type'     => MUNIN_API_GAUGE,
-        '#info'     => t('The number of users with status = 0'),
+        '#graph'    => 'no',
       ),
-
       'node_count' => $int + array(
-        '#label'    => t('Number of published nodes.'),
+        '#label'    => t('Nodes'),
+        '#info'     => t('Unpublished nodes display as negative.'),
         '#type'     => MUNIN_API_GAUGE,
+        '#negative' => 'node_count_unpub',
       ),
 
+      'comment_count_unpub' => $int + array(
+        '#label'    => t('Comments, unpublished'),
+        '#type'     => MUNIN_API_GAUGE,
+        '#graph'    => 'no',
+      ),
       'comment_count' => $int + array(
-        '#label'    => t('Number of published comments.'),
+        '#label'    => t('Comments'),
+        '#info'     => t('Unpublished comments display as negative.'),
+        '#type'     => MUNIN_API_GAUGE,
+        '#negative' => 'comment_count_unpub',
+      ),
+
+      'term_count' => $int + array(
+        '#label'    => t('Terms'),
         '#type'     => MUNIN_API_GAUGE,
       ),
     ),
@@ -74,32 +99,49 @@ function munin_core_munin_api_info() {
 /**
  * Implements hook_munin_api_fetch().
  *
- * Only one graph, so we can ignore the $graph_name parameter.
+ * TODO Reduce the number of queries by integrating the filters.
  */
 function munin_core_munin_api_fetch($graph_name) {
-  $sq = 'SELECT COUNT(u.uid) cnt, u.status FROM {users} u GROUP BY 2';
-  $result = db_query($sq);
-  while ($row = db_fetch_object($result)) {
-    $users[$row->status] = $row->cnt;
-  }
+  switch ($graph_name) {
+    case 'munin_core':
+      $sq = 'SELECT COUNT(u.uid) cnt, u.status FROM {users} u GROUP BY 2';
+      $result = db_query($sq);
+      while ($row = db_fetch_object($result)) {
+        $users[$row->status] = $row->cnt;
+      }
+
+      $ret['user_active_count'] = $users[1];
+      $ret['user_blocked_count'] = $users[0];
+      $ret['user_count'] = $users[0] + $users[1];
+
 
-  $ret['user_active_count'] = $users[1];
-  $ret['user_blocked_count'] = $users[0];
-  $ret['user_count'] = $users[0] + $users[1];
+      $sq = 'SELECT COUNT(*) cnt FROM {sessions} s WHERE s.uid != 0 AND s.timestamp >= UNIX_TIMESTAMP() - 5*60';
+      $ret['user_current'] = db_result(db_query($sq));
 
+      $sq = 'SELECT COUNT(*) cnt FROM {sessions} s WHERE s.uid = 0 AND s.timestamp >= UNIX_TIMESTAMP() - 5*60';
+      $ret['anon_current'] = db_result(db_query($sq));
+      break;
 
-  $sq = 'SELECT COUNT(*) cnt FROM {sessions} s WHERE s.uid != 0 AND s.timestamp >= UNIX_TIMESTAMP() - 5*60';
-  $ret['user_current'] = db_result(db_query($sq));
+    case 'munin_core_content':
+      $sq = 'SELECT COUNT(*) cnt FROM {node} n WHERE n.status = 1';
+      // No db_rewrite_sql(): this is an administrative mechanism
+      $ret['node_count'] = db_result(db_query($sq));
 
-  $sq = 'SELECT COUNT(*) cnt FROM {sessions} s WHERE s.uid = 0 AND s.timestamp >= UNIX_TIMESTAMP() - 5*60';
-  $ret['anon_current'] = db_result(db_query($sq));
+      $sq = 'SELECT COUNT(*) cnt FROM {node} n WHERE n.status = 0';
+      // No db_rewrite_sql(): this is an administrative mechanism
+      $ret['node_count_unpub'] = db_result(db_query($sq));
 
-  $sq = 'SELECT COUNT(*) cnt FROM {node} n WHERE n.status = 1';
-  // No db_rewrite_sql(): this is an administrative mechanism
-  $ret['node_count'] = db_result(db_query($sq));
+      $sq = 'SELECT COUNT(*) cnt FROM {comments} c WHERE c.status = 0';
+      // No db_rewrite_sql(): this is an administrative mechanism
+      $ret['comment_count'] = db_result(db_query($sq));
+
+      $sq = 'SELECT COUNT(*) cnt FROM {comments} c WHERE c.status = 1';
+      // No db_rewrite_sql(): this is an administrative mechanism
+      $ret['comment_count_unpub'] = db_result(db_query($sq));
+
+      $sq = 'SELECT COUNT(*) FROM {term_data}';
+      $ret['term_count'] = db_result(db_query($sq));
+  }
 
-  $sq = 'SELECT COUNT(*) cnt FROM {comments} c WHERE c.status = 0';
-  // No db_rewrite_sql(): this is an administrative mechanism
-  $ret['comment_count'] = db_result(db_query($sq));
   return $ret;
 }