diff options
| author | Pim van den Berg | 2014-05-03 19:17:16 +0200 |
|---|---|---|
| committer | Pim van den Berg | 2014-05-12 21:32:24 +0200 |
| commit | 0a547add2f4cc264380d2dab2c472efe5a1d7094 (patch) | |
| tree | 55bb43a3e31c5814848d61eea92c8438e4a37886 /plugin/apache.php | |
| parent | type/base: set default title to "Plugin Type (PluginInstance) (Category)" (diff) | |
| download | apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.zip apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.gz apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.bz2 apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.xz | |
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.
Diffstat (limited to 'plugin/apache.php')
| -rw-r--r-- | plugin/apache.php | 167 |
1 files changed, 0 insertions, 167 deletions
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 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | # Collectd Apache plugin | ||
| 4 | |||
| 5 | require_once 'conf/common.inc.php'; | ||
| 6 | require_once 'type/Default.class.php'; | ||
| 7 | |||
| 8 | ## LAYOUT | ||
| 9 | # apache[-X]/apache_bytes-X.rrd | ||
| 10 | # apache[-X]/apache_connections-X.rrd | ||
| 11 | # apache[-X]/apache_idle_workers-X.rrd | ||
| 12 | # apache[-X]/apache_requests-X.rrd | ||
| 13 | # apache[-X]/apache_scoreboard-X.rrd | ||
| 14 | |||
| 15 | $obj = new Type_Default($CONFIG, $_GET); | ||
| 16 | |||
| 17 | switch ($obj->args['type']) { | ||
| 18 | case 'apache_bytes': | ||
| 19 | $obj->data_sources = array('value'); | ||
| 20 | $obj->legend = array( | ||
| 21 | 'value' => sprintf('%s/s', ucfirst($CONFIG['network_datasize'])), | ||
| 22 | ); | ||
| 23 | $obj->colors = array( | ||
| 24 | 'value' => '0000ff', | ||
| 25 | ); | ||
| 26 | $obj->rrd_title = sprintf('Webserver Traffic%s', | ||
| 27 | !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); | ||
| 28 | $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['network_datasize'])); | ||
| 29 | $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; | ||
| 30 | break; | ||
| 31 | case 'apache_connections': | ||
| 32 | $obj->data_sources = array('value'); | ||
| 33 | $obj->legend = array( | ||
| 34 | 'value' => 'Conns/s', | ||
| 35 | ); | ||
| 36 | $obj->colors = array( | ||
| 37 | 'value' => '00b000', | ||
| 38 | ); | ||
| 39 | $obj->rrd_title = sprintf('Webserver Connections%s', | ||
| 40 | !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); | ||
| 41 | $obj->rrd_vertical = 'Conns/s'; | ||
| 42 | break; | ||
| 43 | case 'apache_idle_workers': | ||
| 44 | $obj->data_sources = array('value'); | ||
| 45 | $obj->legend = array( | ||
| 46 | 'value' => 'Workers', | ||
| 47 | ); | ||
| 48 | $obj->colors = array( | ||
| 49 | 'value' => '0000ff', | ||
| 50 | ); | ||
| 51 | $obj->rrd_title = sprintf('Webserver Idle Workers%s', | ||
| 52 | !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); | ||
| 53 | $obj->rrd_vertical = 'Workers'; | ||
| 54 | break; | ||
| 55 | case 'apache_requests': | ||
| 56 | $obj->data_sources = array('value'); | ||
| 57 | $obj->legend = array( | ||
| 58 | 'value' => 'Requests/s', | ||
| 59 | ); | ||
| 60 | $obj->colors = array( | ||
| 61 | 'value' => '00b000', | ||
| 62 | ); | ||
| 63 | $obj->rrd_title = sprintf('Webserver Requests%s', | ||
| 64 | !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); | ||
| 65 | $obj->rrd_vertical = 'Requests/s'; | ||
| 66 | break; | ||
| 67 | case 'apache_scoreboard': | ||
| 68 | require_once 'type/GenericStacked.class.php'; | ||
| 69 | $obj = new Type_GenericStacked($CONFIG, $_GET); | ||
| 70 | $obj->data_sources = array('value'); | ||
| 71 | $obj->order = array( | ||
| 72 | 'open', | ||
| 73 | 'idle_cleanup', | ||
| 74 | 'finishing', | ||
| 75 | 'logging', | ||
| 76 | 'closing', | ||
| 77 | 'dnslookup', | ||
| 78 | 'keepalive', | ||
| 79 | 'sending', | ||
| 80 | 'reading', | ||
| 81 | 'starting', | ||
| 82 | 'waiting', | ||
| 83 | |||
| 84 | 'connect', | ||
| 85 | 'hard_error', | ||
| 86 | 'close', | ||
| 87 | 'response_end', | ||
| 88 | 'write', | ||
| 89 | 'response_start', | ||
| 90 | 'handle_request', | ||
| 91 | 'read_post', | ||
| 92 | 'request_end', | ||
| 93 | 'read', | ||
| 94 | 'request_start', | ||
| 95 | ); | ||
| 96 | $obj->legend = array( | ||
| 97 | 'open' => 'Open (empty)', | ||
| 98 | 'waiting' => 'Waiting', | ||
| 99 | 'starting' => 'Starting up', | ||
| 100 | 'reading' => 'Reading request', | ||
| 101 | 'sending' => 'Sending reply', | ||
| 102 | 'keepalive' => 'Keepalive', | ||
| 103 | 'dnslookup' => 'DNS Lookup', | ||
| 104 | 'closing' => 'Closing', | ||
| 105 | 'logging' => 'Logging', | ||
| 106 | 'finishing' => 'Finishing', | ||
| 107 | 'idle_cleanup' => 'Idle cleanup', | ||
| 108 | |||
| 109 | 'connect' => 'Connect (empty)', | ||
| 110 | 'close' => 'Close', | ||
| 111 | 'hard_error' => 'Hard error', | ||
| 112 | 'read' => 'Read', | ||
| 113 | 'read_post' => 'Read POST', | ||
| 114 | 'write' => 'Write', | ||
| 115 | 'handle_request' => 'Handle request', | ||
| 116 | 'request_start' => 'Request start', | ||
| 117 | 'request_end' => 'Request end', | ||
| 118 | 'response_start' => 'Response start', | ||
| 119 | 'response_end' => 'Response end', | ||
| 120 | ); | ||
| 121 | $obj->colors = array( | ||
| 122 | 'open' => 'e0e0e0', | ||
| 123 | 'waiting' => 'ffb000', | ||
| 124 | 'starting' => 'ff00ff', | ||
| 125 | 'reading' => '0000ff', | ||
| 126 | 'sending' => '00e000', | ||
| 127 | 'keepalive' => '0080ff', | ||
| 128 | 'dnslookup' => 'ff0000', | ||
| 129 | 'closing' => '000080', | ||
| 130 | 'logging' => 'a000a0', | ||
| 131 | 'finishing' => '008080', | ||
| 132 | 'idle_cleanup' => 'ffff00', | ||
| 133 | |||
| 134 | 'connect' => 'e0e0e0', | ||
| 135 | 'close' => '008080', | ||
| 136 | 'hard_error' => 'ff0000', | ||
| 137 | 'read' => 'ff00ff', | ||
| 138 | 'read_post' => '00e000', | ||
| 139 | 'write' => '000080', | ||
| 140 | 'handle_request' => '0080ff', | ||
| 141 | 'request_start' => 'ffb000', | ||
| 142 | 'request_end' => '0000ff', | ||
| 143 | 'response_start' => 'ffff00', | ||
| 144 | 'response_end' => 'a000a0', | ||
| 145 | ); | ||
| 146 | $obj->rrd_title = sprintf('Webserver Scoreboard%s', | ||
| 147 | !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); | ||
| 148 | $obj->rrd_vertical = 'Slots'; | ||
| 149 | break; | ||
| 150 | } | ||
| 151 | |||
| 152 | $obj->rrd_format = '%5.1lf'; | ||
| 153 | |||
| 154 | # backwards compatibility | ||
| 155 | if ($CONFIG['version'] < 5) { | ||
| 156 | $obj->data_sources = array('count'); | ||
| 157 | if (count($obj->legend) == 1) { | ||
| 158 | $obj->legend['count'] = $obj->legend['value']; | ||
| 159 | unset($obj->legend['value']); | ||
| 160 | } | ||
| 161 | if (count($obj->colors) == 1) { | ||
| 162 | $obj->colors['count'] = $obj->colors['value']; | ||
| 163 | unset($obj->colors['value']); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | $obj->rrd_graph(); | ||
