Kaynağa Gözat

Reduced queries in munin_core, added INSTALL.txt

- content queries for pub/unpub are now unified
- new INSTALL.txt file
Marand 13 yıl önce
ebeveyn
işleme
cd6f65af78

+ 67 - 0
INSTALL.txt

@@ -0,0 +1,67 @@
+Installing the Drupal Munin server
+----------------------------------
+
+1 Install Munin and the module
+------------------------------
+
+The module is designed for Munin 1.4.4 and above. Use the normal Munin deployment for your platform.
+
+It is known to work, albeit with some warnings and limitations, on Munin 1.2.6 (Ubuntu 9.04/Karmic).
+
+On Debian/Ubuntu, you will find configuration in /etc/munin 
+
+Install the module on Drupal, and enable the submodules you wish to use. 
+Default submodules are provided to monitor Drupal core (content, users), and the 
+PHP APC opcode cache. 
+
+
+2 Declare the plugin to Munin
+-----------------------------
+
+A sample plugin is provided with the module as plugins/munin-drupal_, which you
+can either use as such or customize as needed. The sample plugin uses CURL to
+contact your Drupal site to obtain its data. 
+
+You will usually copy it to a directory in your $PATH, like /usr/local/bin, or 
+createa link to it from that directory, like:
+
+  ln -s <drupal>/sites/all/modules/munin_api/plugins/munin-drupal_ /usr/local/bin/munin-drupal_
+ 
+
+3 Configure the plugin in Munin
+-------------------------------
+
+Edit the /etc/munin/plugin-conf/munin-node file to declare the plugin
+
+Add a section for your plugin. If you are using the sample plugin provided with
+the module, it needs to know the hostname of the site to monitor, which is not 
+always the same site as your Munin instance.
+
+  [drupal_*]
+  env.HOST mysitename.mydomain.tld
+
+
+4 Check
+-------
+
+Once declaration and configuration are done, you need to force munin-node to
+update its configuration. On Ubuntu 10.10, for instance, use:
+
+  sudo service munin-node reload
+
+Assuming you enabled Drupal core and APC monitoring. You can then check the module configuration:
+
+  munin-run drupal_core config
+  munin-run drupal_apc config  
+  
+Then check their data:
+ 
+  munin-run drupal_core
+  munin-run drupal_apc  
+  
+5 Modify configuration
+----------------------
+
+Any time you enable/disable a Munin submodule or modify its settings, you will
+need to force a munin-node configuration reload so that the server knows what to 
+plot.

+ 2 - 2
modules/munin_apc/munin_apc.info

@@ -17,6 +17,6 @@ package = Administration
 core = 6.x
 
 project = "munin_api"
-datestamp = "1296210387"
+datestamp = "1296219892"
 project status url = http://features.osinet.eu/fserver
-version = "6.x-1.0-dev"
+version = "6.x-1.0-dev11a2801"

+ 2 - 2
modules/munin_core/munin_core.info

@@ -17,6 +17,6 @@ package = Administration
 core = 6.x
 
 project = "munin_api"
-datestamp = "1296210387"
+datestamp = "1296219892"
 project status url = http://features.osinet.eu/fserver
-version = "6.x-1.0-dev"
+version = " 6.x-1.0-dev11a2801"

+ 45 - 12
modules/munin_core/munin_core.module

@@ -123,21 +123,54 @@ function munin_core_munin_api_fetch($graph_name) {
       break;
 
     case 'munin_core_content':
-      $sq = 'SELECT COUNT(*) cnt FROM {node} n WHERE n.status = 1';
+      $ret = array(
+        'node_count_unpub' => 0,
+        'node_count' => 0,
+        'comment_count_unpub' => 0,
+        'comment_count' => 0,
+      );
+
+      $sq = 'SELECT COUNT(*) cnt, n.status FROM {node} n GROUP BY n.status';
       // No db_rewrite_sql(): this is an administrative mechanism
-      $ret['node_count'] = 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 {comments} c WHERE c.status = 0';
-      // No db_rewrite_sql(): this is an administrative mechanism
-      $ret['comment_count'] = db_result(db_query($sq));
+      $q = db_query($sq);
+      while ($o = db_fetch_object($q)) {
+        switch ($o->status) {
+          case 0:
+            $ret['node_count_unpub'] = $o->cnt;
+            break;
+
+          case 1:
+            $ret['node_count'] = $o->cnt;
+            break;
+
+          default:
+            watchdog('munin_core', 'Nodes with status @status reported: @count', array(
+              '@status' => $o->status,
+              '@count'  => $o->cnt,
+            ), WATCHDOG_NOTICE);
+        }
+      }
 
-      $sq = 'SELECT COUNT(*) cnt FROM {comments} c WHERE c.status = 1';
+      $sq = 'SELECT COUNT(*) cnt, c.status FROM {comments} c GROUP BY c.status';
+      $q = db_query($sq);
       // No db_rewrite_sql(): this is an administrative mechanism
-      $ret['comment_count_unpub'] = db_result(db_query($sq));
+      while ($o = db_fetch_object($q)) {
+        switch ($o->status) {
+          case 1:
+            $ret['comment_count_unpub'] = $o->cnt;
+            break;
+
+          case 0:
+            $ret['comment_count'] = $o->cnt;
+            break;
+
+          default:
+            watchdog('munin_core', 'Comments with status @status reported: @count', array(
+              '@status' => $o->status,
+              '@count'  => $o->cnt,
+            ), WATCHDOG_NOTICE);
+        }
+      }
 
       $sq = 'SELECT COUNT(*) FROM {term_data}';
       $ret['term_count'] = db_result(db_query($sq));

+ 2 - 2
munin_api.info

@@ -17,6 +17,6 @@ package = Administration
 core = 6.x
 
 project = "munin_api"
-datestamp = "1296210387"
+datestamp = "1296219892"
 project status url = http://features.osinet.eu/fserver
-version = "6.x-1.0-dev"
+version = " 6.x-1.0-dev11a2801"