From 0a547add2f4cc264380d2dab2c472efe5a1d7094 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 3 May 2014 19:17:16 +0200 Subject: graph.php: use JSON plugins instead of including PHP plugin files A couple of big changes here. A lot of logic moved to graph.php. The PHP plugin files have been rewritten to JSON. In these JSON files *everything* is optional. Also *NOT* having a JSON plugin file won't block you from having a graph. The JSON will just make the graphs prettier (by having a title, y-axis title, legend, colors, etc..). The Collectd types.db file is parsed and used to determine RRD content. When things are not defined in the JSON it will fallback to a default. --- plugin/apache.php | 167 ------------------------------------------------------ 1 file changed, 167 deletions(-) delete mode 100644 plugin/apache.php (limited to 'plugin/apache.php') diff --git a/plugin/apache.php b/plugin/apache.php deleted file mode 100644 index 6fa9963..0000000 --- a/plugin/apache.php +++ /dev/null @@ -1,167 +0,0 @@ -args['type']) { - case 'apache_bytes': - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => sprintf('%s/s', ucfirst($CONFIG['network_datasize'])), - ); - $obj->colors = array( - 'value' => '0000ff', - ); - $obj->rrd_title = sprintf('Webserver Traffic%s', - !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['network_datasize'])); - $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; - break; - case 'apache_connections': - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => 'Conns/s', - ); - $obj->colors = array( - 'value' => '00b000', - ); - $obj->rrd_title = sprintf('Webserver Connections%s', - !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = 'Conns/s'; - break; - case 'apache_idle_workers': - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => 'Workers', - ); - $obj->colors = array( - 'value' => '0000ff', - ); - $obj->rrd_title = sprintf('Webserver Idle Workers%s', - !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = 'Workers'; - break; - case 'apache_requests': - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => 'Requests/s', - ); - $obj->colors = array( - 'value' => '00b000', - ); - $obj->rrd_title = sprintf('Webserver Requests%s', - !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = 'Requests/s'; - break; - case 'apache_scoreboard': - require_once 'type/GenericStacked.class.php'; - $obj = new Type_GenericStacked($CONFIG, $_GET); - $obj->data_sources = array('value'); - $obj->order = array( - 'open', - 'idle_cleanup', - 'finishing', - 'logging', - 'closing', - 'dnslookup', - 'keepalive', - 'sending', - 'reading', - 'starting', - 'waiting', - - 'connect', - 'hard_error', - 'close', - 'response_end', - 'write', - 'response_start', - 'handle_request', - 'read_post', - 'request_end', - 'read', - 'request_start', - ); - $obj->legend = array( - 'open' => 'Open (empty)', - 'waiting' => 'Waiting', - 'starting' => 'Starting up', - 'reading' => 'Reading request', - 'sending' => 'Sending reply', - 'keepalive' => 'Keepalive', - 'dnslookup' => 'DNS Lookup', - 'closing' => 'Closing', - 'logging' => 'Logging', - 'finishing' => 'Finishing', - 'idle_cleanup' => 'Idle cleanup', - - 'connect' => 'Connect (empty)', - 'close' => 'Close', - 'hard_error' => 'Hard error', - 'read' => 'Read', - 'read_post' => 'Read POST', - 'write' => 'Write', - 'handle_request' => 'Handle request', - 'request_start' => 'Request start', - 'request_end' => 'Request end', - 'response_start' => 'Response start', - 'response_end' => 'Response end', - ); - $obj->colors = array( - 'open' => 'e0e0e0', - 'waiting' => 'ffb000', - 'starting' => 'ff00ff', - 'reading' => '0000ff', - 'sending' => '00e000', - 'keepalive' => '0080ff', - 'dnslookup' => 'ff0000', - 'closing' => '000080', - 'logging' => 'a000a0', - 'finishing' => '008080', - 'idle_cleanup' => 'ffff00', - - 'connect' => 'e0e0e0', - 'close' => '008080', - 'hard_error' => 'ff0000', - 'read' => 'ff00ff', - 'read_post' => '00e000', - 'write' => '000080', - 'handle_request' => '0080ff', - 'request_start' => 'ffb000', - 'request_end' => '0000ff', - 'response_start' => 'ffff00', - 'response_end' => 'a000a0', - ); - $obj->rrd_title = sprintf('Webserver Scoreboard%s', - !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = 'Slots'; - break; -} - -$obj->rrd_format = '%5.1lf'; - -# backwards compatibility -if ($CONFIG['version'] < 5) { - $obj->data_sources = array('count'); - if (count($obj->legend) == 1) { - $obj->legend['count'] = $obj->legend['value']; - unset($obj->legend['value']); - } - if (count($obj->colors) == 1) { - $obj->colors['count'] = $obj->colors['value']; - unset($obj->colors['value']); - } -} - -$obj->rrd_graph(); -- cgit v1.1