"'%d'", ); $ret = array( '#title' => t('Drupal'), '#description' => t('Graphs about Drupal core'), 'munin_core' => array( '#title' => t('Core user-related statistics'), '#info' => t('Core statistics regarding users and sessions.'), 'anon_current' => $int + array( '#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_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 number of users with status = 0'), '#graph' => 'no', ), 'user_active_count' => $int + array( '#label' => t('Users'), '#type' => MUNIN_API_GAUGE, '#info' => t('The number of users. Blocked users display as negative.'), '#negative' => 'user_blocked_count', ), ), '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, '#graph' => 'no', ), 'node_count' => $int + array( '#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('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, ), ), ); return $ret; } /** * Implements hook_munin_api_fetch(). * * TODO Reduce the number of queries by integrating the filters. */ function munin_core_munin_api_fetch($graph_name) { 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]; $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; 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 {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)); $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)); } return $ret; }