diff --git a/.gitignore b/.gitignore index 543f45a..40929c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -conf/config.local.php +conf/*local* plugin/local/*.json diff --git a/conf/config.php b/conf/config.php index ec55d30..36e1205 100644 --- a/conf/config.php +++ b/conf/config.php @@ -33,6 +33,7 @@ $CONFIG['showload'] = true; $CONFIG['showmem'] = false; $CONFIG['showtime'] = false; +$CONFIG['perline'] = 1; $CONFIG['term'] = array( '2hour' => 3600 * 2, diff --git a/graph.php b/graph.php index f1696fa..46bcb94 100644 --- a/graph.php +++ b/graph.php @@ -72,6 +72,10 @@ require_once 'type/GenericIO.class.php'; $obj = new Type_GenericIO($CONFIG, GET()); break; + case 'filled': + require_once 'type/GenericFilled.class.php'; + $obj = new Type_GenericFilled($CONFIG, GET()); + break; case 'uptime': require_once 'type/Uptime.class.php'; $obj = new Type_Uptime($CONFIG, GET()); diff --git a/inc/html.inc.php b/inc/html.inc.php index 7312601..7d016a8 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -122,6 +122,7 @@ function html_end($footer = false) { EOT; } if ($CONFIG['graph_type'] == 'canvas') { + $html_weburl = htmlentities($CONFIG['weburl']); if ($CONFIG['rrd_fetch_method'] == 'async') { $js_async = 'true'; } else { @@ -229,17 +230,35 @@ function host_summary($cat, $hosts) { $row_style = array(0 => "even", 1 => "odd"); $host_counter = 0; + $line_counter = 0; + + if($CONFIG['perline']) { + printf('
'); + } foreach($hosts as $host) { - $host_counter++; - printf('
', $row_style[$host_counter % 2]); - printf('', + if($CONFIG['perline']) { + $foo = $host_counter % $CONFIG['perline']; + echo "\n"; + if($host_counter % $CONFIG['perline'] == 0) { + printf('
', $row_style[$line_counter % 2]); + } + } else { + printf('
', $row_style[$line_counter % 2]); + } + + + # printf('', + printf('', htmlentities($CONFIG['weburl']), urlencode($host), htmlentities($host)); - echo "
"; + + if ($CONFIG['showload'] || $CONFIG['showmem'] || $CONFIG['showtime']) { + echo "
"; + } if ($CONFIG['showload']) { require_once 'type/Default.class.php'; @@ -307,8 +326,24 @@ function host_summary($cat, $hosts) { } } - print "
\n"; + if($CONFIG['perline']) { + if(($host_counter % $CONFIG['perline'] ) == $CONFIG['perline'] - 1) { + print "
\n"; + $line_counter++; + } + $host_counter++; + } else { + print "
\n"; + $line_counter++; + if ($CONFIG['showload'] || $CONFIG['showmem'] || $CONFIG['showtime']) { + echo "
\n"; + } + } } + + if($CONFIG['perline']) { + printf('
'); + } echo "\n"; echo "\n"; diff --git a/layout/style.css b/layout/style.css index 768c0c6..40d451a 100644 --- a/layout/style.css +++ b/layout/style.css @@ -64,8 +64,8 @@ h2 { } a:link, a:visited, a:active { - text-decoration: none; - color: #222; + text-decoration: none; + color: #222; } a:hover { @@ -78,11 +78,11 @@ a:hover { } .row.even { -/* background: #eeeeee; */ +/* background: #aaaaaa; */ } .row.odd { -/* background: #cccccc; */ +/* background: #cccccc; */ } .row label { @@ -161,7 +161,7 @@ hr { .selected:link, .selected:visited, .selected:active { font-style: italic; - color: #4D79B5; + color: #4D79B5; } .time-range li { @@ -194,7 +194,7 @@ legend { code { font-family: Consolas,"Liberation Mono",Menlo,Courier,monospace; - background-color: rgba(0,0,0,0.1); + background-color: rgba(0,0,0,0.1); padding: 0 0.2em; } @@ -202,3 +202,47 @@ code { font-size: 0.7em; opacity: 0.6; } + +.divCell { + float:left;/*fix for buggy browsers*/ + display:table-column; + width:20em; +/* background-color:#ccc; */ +} + +.divTable { + display: table; + width:auto; + background-color:#fff; +/* border:1px solid #666666; */ + border-spacing:5px;/*cellspacing:poor IE support for this*/ + /* border-collapse:separate;*/ +} + +.divRow { + display:table-row; + width:auto; +} + +.divRow:nth-of-type(odd) { + background: #ccc; +} + +.divRow label { + float: left; + width: 20em; +} + +.divRow .hostinfo { + float: left; +} + +.divRow .field { + float: left; + width: 3.4em; +} + +.divRow .field.wide { + width: 8em; +} + diff --git a/plugin/aggregation.json b/plugin/aggregation.json new file mode 100644 index 0000000..f2e48dc --- /dev/null +++ b/plugin/aggregation.json @@ -0,0 +1,43 @@ +{ + "cpu": { + "title": "Total CPU usage on {{HOST}}", + "vertical": "Percent", + "rrdtool_opts": ["-u", "100"], + "type": "stacked", + "legend": { + "idle": { + "name": "Idle", + "color": "e8e8e8" + }, + "nice": { + "name": "Nice", + "color": "00e000" + }, + "user": { + "name": "User", + "color": "0000ff" + }, + "wait": { + "name": "Wait-IO", + "color": "ffb000" + }, + "system": { + "name": "System", + "color": "ff0000" + }, + "softirq": { + "name": "SoftIRQ", + "color": "ff00ff" + }, + "interrupt": { + "name": "IRQ", + "color": "a000a0" + }, + "steal": { + "name": "Steal", + "color": "000000" + } + }, + "legend_format": "%5.2lf" + } +} diff --git a/plugin/cpu.json b/plugin/cpu.json index 6f74654..3c39345 100644 --- a/plugin/cpu.json +++ b/plugin/cpu.json @@ -2,7 +2,7 @@ "cpu": { "title": "CPU-{{PI}} usage on {{HOST}}", "vertical": "Jiffies", - "rrdtool_opts": ["-u", "100"], + "rrdtool_opts": ["-u","100","-r"], "type": "stacked", "legend": { "idle": { diff --git a/plugin/interface_lif.json b/plugin/interface_lif.json new file mode 100644 index 0000000..e17ba95 --- /dev/null +++ b/plugin/interface_lif.json @@ -0,0 +1,51 @@ +{ + "if_octets": { + "title": "Interface Traffic ({{PI}}) on {{HOST}}", + "vertical": "{{ND}} per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s", + "datasize": true + }, + "if_errors": { + "title": "Interface Errors ({{PI}}) on {{HOST}}", + "vertical": "Errors per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + }, + "if_packets": { + "title": "Interface Packets ({{PI}}) on {{HOST}}", + "vertical": "Packets per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + } +} diff --git a/plugin/interface_port.json b/plugin/interface_port.json new file mode 100644 index 0000000..e17ba95 --- /dev/null +++ b/plugin/interface_port.json @@ -0,0 +1,51 @@ +{ + "if_octets": { + "title": "Interface Traffic ({{PI}}) on {{HOST}}", + "vertical": "{{ND}} per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s", + "datasize": true + }, + "if_errors": { + "title": "Interface Errors ({{PI}}) on {{HOST}}", + "vertical": "Errors per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + }, + "if_packets": { + "title": "Interface Packets ({{PI}}) on {{HOST}}", + "vertical": "Packets per second", + "type": "io", + "legend": { + "rx": { + "name": "Receive", + "color": "0000ff" + }, + "tx": { + "name": "Transmit", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + } +} diff --git a/plugin/iops_vol.json b/plugin/iops_vol.json new file mode 100644 index 0000000..10aac8a --- /dev/null +++ b/plugin/iops_vol.json @@ -0,0 +1,18 @@ +{ + "disk_ops": { + "title": "Disk Operations ({{PI}}) on {{HOST}}", + "vertical": "Ops per second", + "type": "io", + "legend": { + "read": { + "name": "Read", + "color": "0000ff" + }, + "write": { + "name": "Write", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + } +} diff --git a/plugin/latency_vol.json b/plugin/latency_vol.json new file mode 100644 index 0000000..694c76a --- /dev/null +++ b/plugin/latency_vol.json @@ -0,0 +1,27 @@ +{ + "netapp_vol_latency": { + "title": "Disk time per operation ({{PI}}) on {{HOST}}", + "vertical": "Avg. Time/Op", + "type": "io", + "legend": { + "read_ops": { + "name": "Read", + "color": "0000ff" + }, + "write_ops": { + "name": "Write", + "color": "00b000" + }, + "read_latency": { + "name": "Read Latency", + "color": "00b0aa" + }, + "write_latency": { + "name": "Write Latency", + "color": "00b0dd" + } + }, + "legend_format": "%5.1lf%ss", + "scale": 0.001 + } +} diff --git a/plugin/memory.json b/plugin/memory.json index f495b04..93c8576 100644 --- a/plugin/memory.json +++ b/plugin/memory.json @@ -8,6 +8,13 @@ "name": "Free", "color": "00e000" }, + "used": { + "name": "Used", + "color": "ff0000" + }, + "kernel": { + "name": "Kernel" + }, "inactive": { "name": "Inactive", "color": "00b000" @@ -20,6 +27,10 @@ "name": "Cache", "color": "0000ff" }, + "arc": { + "name": "ARC Cache", + "color": "0000ff" + }, "buffered": { "name": "Buffered", "color": "ffb000" @@ -40,6 +51,14 @@ "name": "Active", "color": "ff00ff" }, + "unusable": { + "name": "Unusable", + "color": "00b000" + }, + "locked": { + "name": "Locked", + "color": "ff00ff" + }, "wired": { "name": "Wired", "color": "ff0000" diff --git a/plugin/netlink.json b/plugin/netlink.json index 51c1d9d..2bf5400 100644 --- a/plugin/netlink.json +++ b/plugin/netlink.json @@ -27,7 +27,7 @@ "legend_format": "%5.1lf%s" }, "if_errors": { - "title": "Interface Errors ({{PI}}) on {{HOST}}", + "title": "Errors ({{PI}}) on {{HOST}}", "vertical": "Errors/s", "type": "io", "legend": { @@ -55,7 +55,7 @@ "legend_format": "%5.1lf%s" }, "if_octets": { - "title": "Interface Traffic ({{PI}}) on {{HOST}}", + "title": "Traffic ({{PI}}) on {{HOST}}", "vertical": "{{ND}}/second", "type": "io", "legend": { @@ -72,7 +72,7 @@ "datasize": true }, "if_packets": { - "title": "Interface Packets ({{PI}}) on {{HOST}}", + "title": "Packets ({{PI}}) on {{HOST}}", "vertical": "Packets/s", "type": "io", "legend": { @@ -88,7 +88,7 @@ "legend_format": "%5.1lf%s" }, "if_rx_errors": { - "title": "Interface receive errors ({{PI}}) on {{HOST}}", + "title": "Receive errors ({{PI}}) on {{HOST}}", "vertical": "Errors/s", "type": "stacked", "legend": { @@ -120,7 +120,7 @@ "legend_format": "%5.1lf%s" }, "if_tx_errors": { - "title": "Interface transmit errors ({{PI}}) on {{HOST}}", + "title": "Transmit errors ({{PI}}) on {{HOST}}", "vertical": "Errors/s", "type": "stacked", "legend": { diff --git a/plugin/traffic_vol.json b/plugin/traffic_vol.json new file mode 100644 index 0000000..b51b304 --- /dev/null +++ b/plugin/traffic_vol.json @@ -0,0 +1,18 @@ +{ + "disk_octets": { + "title": "Disk Traffic ({{PI}}) on {{HOST}}", + "vertical": "Bytes per second", + "type": "io", + "legend": { + "read": { + "name": "Read", + "color": "0000ff" + }, + "write": { + "name": "Write", + "color": "00b000" + } + }, + "legend_format": "%5.1lf%s" + } +} diff --git a/plugin/zfs_arc.json b/plugin/zfs_arc.json new file mode 100644 index 0000000..f58e759 --- /dev/null +++ b/plugin/zfs_arc.json @@ -0,0 +1,26 @@ +{ + "cache_size": { + "title": "ARC Usage on {{HOST}}", + "vertical": "Bytes", + "type": "filled", + "legend": { + "c": { + "name": "Target" + }, + "arc": { + "name": "Cur Size" + }, + "c_min": { + "name": "Min" + }, + "c_max": { + "name": "Max" + }, + "L2": { + "name": "L2 Size" + } + }, + "legend_format": "%5.0lf%sB", + "base": "1024" + } +} diff --git a/plugin/zfs_arc.php b/plugin/zfs_arc.php new file mode 100644 index 0000000..d066b42 --- /dev/null +++ b/plugin/zfs_arc.php @@ -0,0 +1,99 @@ +rrd_format = '%5.1lf%s'; + +switch($obj->args['type']) { + case 'arc_counts': + $obj->data_sources = array( + 'demand_data', + 'demand_metadata', + 'prefetch_data', + 'prefetch_metadata', + ); + $obj->colors = array( + 'hits-demand_data' => 'ff0000', + 'misses-demand_data' => '880000', + 'hits-demand_metadata' => '00ff00', + 'misses-demand_metadata' => '00aa00', + 'hits-prefetch_data' => '0000ff', + 'misses-prefetch_data' => '00f0f0', + 'hits-prefetch_metadata' => 'ff00ff', + 'misses-prefetch_metadata' => '888800', + ); + $obj->ds_names = array( + 'hits-demand_data' => 'data hits', + 'misses-demand_data' => 'metadata misses', + 'hits-demand_metadata' => 'metadata hits', + 'misses-demand_metadata' => 'metadata misses', + 'hits-prefetch_data' => 'prefetch data hits', + 'misses-prefetch_data' => 'prefetch data misses', + 'hits-prefetch_metadata' => 'prefetch metadata hits', + 'misses-prefetch_metadata' => 'prefetch metadata misses', + ); + $obj->rrd_title = 'arc counts'; + $obj->rrd_vertical = 'count'; + break; + case 'cache_size': +# $obj->data_sources = array('current','target','minlimit','maxlimit'); +# $obj->order = array( +# 'current', +# 'target', +# 'minlimit', +# 'maxlimit', +# ); + $obj->rrd_title = 'Arc size'; + $obj->rrd_vertical = 'bytes'; + break; + case 'arc_l2_bytes': + $obj->data_sources = array( + 'write', + 'read', + ); + $obj->ds_names = array( + 'write' => 'Write', + 'read' => 'Read', + ); + $obj->colors = array( + 'write' => 'ff0000', + 'read' => '0000ff', + ); + $obj->rrd_title = 'Arc L2 bytes'; + $obj->rrd_vertical = 'bytes'; + break; + case 'arc_l2_size': + $obj->data_sources = array( + 'value', + ); + $obj->ds_names = array( + 'value' => 'Bytes', + ); + $obj->colors = array( + 'value' => '0000ff', + ); + $obj->rrd_title = 'Arc L2 size'; + $obj->rrd_vertical = 'bytes'; + break; + case 'arc_ratio': + $obj->data_sources = array('value'); + $obj->rrd_title = 'Arc ratio'; + $obj->rrd_vertical = 'ratio'; + break; +} +collectd_flush($obj->identifiers); +$obj->rrd_graph(); diff --git a/type/Base.class.php b/type/Base.class.php index 4b23eaf..a769d60 100644 --- a/type/Base.class.php +++ b/type/Base.class.php @@ -105,7 +105,7 @@ function parse_get($_get) { 'type' => isset($_get['t']) ? $_get['t'] : null, 'tinstance' => isset($_get['ti']) ? $_get['ti'] : null, ); - $this->seconds = isset($_get['s']) ? $_get['s'] : null; + $this->seconds = isset($_get['s']) ? $_get['s'] : null; } function validate_color($color) { @@ -172,7 +172,6 @@ function rrd_files() { $instance = strpos($basename,'-') ? substr($basename, strpos($basename,'-') + 1) : 'value'; - $this->tinstances[] = $instance; $this->files[$instance] = $filename; $this->identifiers[$instance] = preg_replace( @@ -193,8 +192,8 @@ function get_filenames() { strlen($this->args['pinstance']) ? '-' : '', $this->args['pinstance'], $this->args['type'], strlen($this->args['tinstance']) ? '-' : '', $this->args['tinstance'] - ); - $identifier = preg_replace("/([*?[])/", '[$1]', $identifier); + ); + $identifier = preg_replace("/([*?[])/", '[$1]', $identifier); $wildcard = strlen($this->args['tinstance']) ? '.' : '[-.]*'; @@ -329,7 +328,7 @@ function rrd_get_sources() { if(is_array($this->data_sources) && count($this->data_sources)==1 && in_array('value', $this->data_sources)) { # use tinstances as sources $sources = $this->tinstances; - } else { + } else { # use data_sources as sources $sources = $this->data_sources; } diff --git a/type/GenericFilled.class.php b/type/GenericFilled.class.php new file mode 100644 index 0000000..09c2951 --- /dev/null +++ b/type/GenericFilled.class.php @@ -0,0 +1,78 @@ +rrd_options(); + + $sources = $this->rrd_get_sources(); + + $raw = null; + if ($this->scale) + $raw = '_raw'; + $i=0; + foreach ($this->tinstances as $tinstance) { + foreach ($this->data_sources as $ds) { + $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds); + $rrdgraph[] = sprintf('DEF:avg_%s_raw=%s:%s:AVERAGE', crc32hex($sources[$i]), $this->parse_filename($this->files[$tinstance]), $ds); + $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds); + $i++; + } + } + if ($this->scale) { + $i=0; + foreach ($this->tinstances as $tinstance) { + foreach ($this->data_sources as $ds) { + $rrdgraph[] = sprintf('CDEF:min_%s=min_%1$s_raw,%s,*', crc32hex($sources[$i]), $this->scale); + $rrdgraph[] = sprintf('CDEF:avg_%s=avg_%1$s_raw,%s,*', crc32hex($sources[$i]), $this->scale); + $rrdgraph[] = sprintf('CDEF:max_%s=max_%1$s_raw,%s,*', crc32hex($sources[$i]), $this->scale); + if ($i == 1) + $rrdgraph[] = sprintf('CDEF:avg_%s_neg=avg_%1$s_raw,%s%s,*', crc32hex($sources[$i]), $this->negative_io ? '-' : '', $this->scale); + if ($this->percentile) + $rrdgraph[] = sprintf('VDEF:pct_%1$s=avg_%1$s,%2$s,PERCENT', crc32hex($sources[$i]), $this->percentile); + $i++; + } + } + } + + $rrdgraph[] = sprintf('CDEF:overlap=avg_%s,avg_%s_neg,LT,avg_%1$s,avg_%2$s_neg,IF', + crc32hex($sources[0]), crc32hex($sources[1])); + + $i = 0; + foreach($sources as $source) { + $rrdgraph[] = sprintf('AREA:avg_%s%s#%s', crc32hex($source), $i == 1 ? '_neg' : '', $this->get_faded_color($this->colors[$source])); + $i++; + } + + $rrdgraph[] = sprintf('AREA:overlap#%s', + $this->get_faded_color( + $this->get_faded_color($this->colors[$sources[0]]), + $this->get_faded_color($this->colors[$sources[1]]) + ) + ); + + $i = 0; + foreach($sources as $source) { + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; + $rrdgraph[] = sprintf('LINE1:avg_%s%s#%s:%s', crc32hex($source), $i == 1 ? '_neg' : '', $this->colors[$source], $this->rrd_escape($legend)); + $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:%s Min,', crc32hex($source), $this->rrd_format); + $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:%s Avg,', crc32hex($source), $this->rrd_format); + $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:%s Max,', crc32hex($source), $this->rrd_format); + $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:%s Last\l', crc32hex($source), $this->rrd_format); + $i++; + } + + if ($this->percentile) { + $rrdgraph[] = 'COMMENT: \l'; + foreach($sources as $source) { + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; + $rrdgraph[] = sprintf('HRULE:pct_%s#%s:%sth Percentile %s', crc32hex($source), $this->get_faded_color($this->colors[$source], '000000', 0.6), $this->percentile, $this->rrd_escape($legend)); + $rrdgraph[] = sprintf('GPRINT:pct_%s:%s\l', crc32hex($source), $this->rrd_format); + } + } + + return $rrdgraph; + } +}