From a4eb4391c53b70121c0ff29bb40b92ee99c094c0 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Tue, 10 Nov 2015 11:06:03 +0100 Subject: [PATCH 1/4] Add Ceph support --- .../application/ceph_osd_performance.inc.php | 27 ++++++ .../graphs/application/ceph_pool_df.inc.php | 58 +++++++++++++ .../graphs/application/ceph_pool_io.inc.php | 28 ++++++ .../graphs/application/ceph_pool_iops.inc.php | 26 ++++++ .../application/ceph_pool_objects.inc.php | 24 ++++++ html/pages/device/apps/ceph.inc.php | 85 +++++++++++++++++++ includes/polling/applications/ceph.inc.php | 69 +++++++++++++++ includes/polling/unix-agent.inc.php | 3 +- 8 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 html/includes/graphs/application/ceph_osd_performance.inc.php create mode 100644 html/includes/graphs/application/ceph_pool_df.inc.php create mode 100644 html/includes/graphs/application/ceph_pool_io.inc.php create mode 100644 html/includes/graphs/application/ceph_pool_iops.inc.php create mode 100644 html/includes/graphs/application/ceph_pool_objects.inc.php create mode 100644 html/pages/device/apps/ceph.inc.php create mode 100644 includes/polling/applications/ceph.inc.php diff --git a/html/includes/graphs/application/ceph_osd_performance.inc.php b/html/includes/graphs/application/ceph_osd_performance.inc.php new file mode 100644 index 000000000..f089041bc --- /dev/null +++ b/html/includes/graphs/application/ceph_osd_performance.inc.php @@ -0,0 +1,27 @@ + 'Pool stats', + 'ceph_osdperf' => 'OSD Performance', + 'ceph_df' => 'Usage', +); + +$rrddir = $config['rrd_dir'].'/'.$device['hostname']; + +foreach ($graphs as $key => $text) { + echo '

'.$text.'

'; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + + if ($key == "ceph_poolstats") { + foreach (glob($rrddir."/app-ceph-".$app['app_id']."-pool-*") as $rrd_filename) { + if (preg_match("/.*-pool-(.+)\.rrd$/", $rrd_filename, $pools)) { + $pool = $pools[1]; + echo '

'.$pool.' Reads/Writes

'; + $graph_array['type'] = 'application_ceph_pool_io'; + $graph_array['pool'] = $pool; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + + echo '

'.$pool.' IOPS

'; + $graph_array['type'] = 'application_ceph_pool_iops'; + $graph_array['pool'] = $pool; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + } + } + } elseif ($key == "ceph_osdperf") { + foreach (glob($rrddir."/app-ceph-".$app['app_id']."-osd-*") as $rrd_filename) { + if (preg_match("/.*-osd-(.+)\.rrd$/", $rrd_filename, $osds)) { + $osd = $osds[1]; + echo '

'.$osd.' Latency

'; + $graph_array['type'] = 'application_ceph_osd_performance'; + $graph_array['osd'] = $osd; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + } + } + } elseif ($key == "ceph_df") { + foreach (glob($rrddir."/app-ceph-".$app['app_id']."-df-*") as $rrd_filename) { + if (preg_match("/.*-df-(.+)\.rrd$/", $rrd_filename, $pools)) { + $pool = $pools[1]; + if ($pool == "c") { + echo '

Cluster Usage

'; + $graph_array['type'] = 'application_ceph_pool_df'; + $graph_array['pool'] = $pool; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + } else { + echo '

'.$pool.' Usage

'; + $graph_array['type'] = 'application_ceph_pool_df'; + $graph_array['pool'] = $pool; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + + echo '

'.$pool.' Objects

'; + $graph_array['type'] = 'application_ceph_pool_objects'; + $graph_array['pool'] = $pool; + + echo ""; + include 'includes/print-graphrow.inc.php'; + echo ''; + } + } + } + } + +} diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php new file mode 100644 index 000000000..711433843 --- /dev/null +++ b/includes/polling/applications/ceph.inc.php @@ -0,0 +1,69 @@ +', $section); + if ($section == "poolstats") { + foreach (explode("\n", $data) as $line) { + if (empty($line)) + continue; + list($pool,$ops,$wrbytes,$rbytes) = explode(':', $line); + $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-pool-'.$pool.'.rrd'; + if (!is_file($ceph_rrd)) { + rrdtool_create( + $ceph_rrd, + '--step 300 \ + DS:ops:GAUGE:600:0:U \ + DS:wrbytes:GAUGE:600:0:U \ + DS:rbytes:GAUGE:600:0:U '.$config['rrd_rra'] + ); + } + + print "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; + rrdtool_update($ceph_rrd, array("ops" => $ops, "wrbytes" => $wrbytes, "rbytes" => $rbytes)); + } + } elseif ($section == "osdperformance") { + foreach (explode("\n", $data) as $line) { + if (empty($line)) + continue; + list($osd,$apply,$commit) = explode(':', $line); + $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-osd-'.$osd.'.rrd'; + if (!is_file($ceph_rrd)) { + rrdtool_create( + $ceph_rrd, + '--step 300 \ + DS:apply_ms:GAUGE:600:0:U \ + DS:commit_ms:GAUGE:600:0:U '.$config['rrd_rra'] + ); + } + + print "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; + rrdtool_update($ceph_rrd, array("apply_ms" => $apply, "commit_ms" => $commit)); + } + } elseif ($section == "df") { + foreach (explode("\n", $data) as $line) { + if (empty($line)) + continue; + list($pool,$avail,$used,$objects) = explode(':', $line); + $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-df-'.$pool.'.rrd'; + if (!is_file($ceph_rrd)) { + rrdtool_create( + $ceph_rrd, + '--step 300 \ + DS:avail:GAUGE:600:0:U \ + DS:used:GAUGE:600:0:U \ + DS:objects:GAUGE:600:0:U '.$config['rrd_rra'] + ); + } + + print "Ceph Pool DF: $pool, Avail: $avail, Used: $used, Objects: $objects\n"; + rrdtool_update($ceph_rrd, array("avail" => $avail, "used" => $used, "objects" => $objects)); + } + } + } +} diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 0bdfae836..18d30e58e 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -51,6 +51,7 @@ if ($device['os_group'] == 'unix') { $agentapps = array( "apache", + "ceph", "mysql", "nginx", "bind", @@ -104,7 +105,7 @@ if ($device['os_group'] == 'unix') { if (file_exists("includes/polling/applications/$key.inc.php")) { d_echo("Enabling $key for ".$device['hostname']." if not yet enabled\n"); - if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox'))) { + if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph'))) { if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') { echo "Found new application '$key'\n"; dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications'); From 24550b0c023b7e9c8f61c8a3e08b8e12b1155e54 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Tue, 10 Nov 2015 11:44:14 +0100 Subject: [PATCH 2/4] Fix if-then-else --- html/pages/device/apps/ceph.inc.php | 9 ++++++--- includes/polling/applications/ceph.inc.php | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/html/pages/device/apps/ceph.inc.php b/html/pages/device/apps/ceph.inc.php index bf7668afa..988d64803 100644 --- a/html/pages/device/apps/ceph.inc.php +++ b/html/pages/device/apps/ceph.inc.php @@ -36,7 +36,8 @@ foreach ($graphs as $key => $text) { echo ''; } } - } elseif ($key == "ceph_osdperf") { + } + elseif ($key == "ceph_osdperf") { foreach (glob($rrddir."/app-ceph-".$app['app_id']."-osd-*") as $rrd_filename) { if (preg_match("/.*-osd-(.+)\.rrd$/", $rrd_filename, $osds)) { $osd = $osds[1]; @@ -49,7 +50,8 @@ foreach ($graphs as $key => $text) { echo ''; } } - } elseif ($key == "ceph_df") { + } + elseif ($key == "ceph_df") { foreach (glob($rrddir."/app-ceph-".$app['app_id']."-df-*") as $rrd_filename) { if (preg_match("/.*-df-(.+)\.rrd$/", $rrd_filename, $pools)) { $pool = $pools[1]; @@ -61,7 +63,8 @@ foreach ($graphs as $key => $text) { echo ""; include 'includes/print-graphrow.inc.php'; echo ''; - } else { + } + else { echo '

'.$pool.' Usage

'; $graph_array['type'] = 'application_ceph_pool_df'; $graph_array['pool'] = $pool; diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php index 711433843..08413c881 100644 --- a/includes/polling/applications/ceph.inc.php +++ b/includes/polling/applications/ceph.inc.php @@ -27,7 +27,8 @@ if (!empty($agent_data['app']['ceph'])) { print "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; rrdtool_update($ceph_rrd, array("ops" => $ops, "wrbytes" => $wrbytes, "rbytes" => $rbytes)); } - } elseif ($section == "osdperformance") { + } + elseif ($section == "osdperformance") { foreach (explode("\n", $data) as $line) { if (empty($line)) continue; @@ -45,7 +46,8 @@ if (!empty($agent_data['app']['ceph'])) { print "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; rrdtool_update($ceph_rrd, array("apply_ms" => $apply, "commit_ms" => $commit)); } - } elseif ($section == "df") { + } + elseif ($section == "df") { foreach (explode("\n", $data) as $line) { if (empty($line)) continue; From 669eb872a59426ceb660bfcfba838fee55603774 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Tue, 10 Nov 2015 11:44:30 +0100 Subject: [PATCH 3/4] Implement a function to fix the rrd path --- .../graphs/application/ceph_common.inc.php | 17 +++++++++++++++++ .../application/ceph_osd_performance.inc.php | 6 +++--- .../graphs/application/ceph_pool_df.inc.php | 4 ++-- .../graphs/application/ceph_pool_io.inc.php | 6 +++--- .../graphs/application/ceph_pool_iops.inc.php | 5 ++--- .../application/ceph_pool_objects.inc.php | 5 ++--- 6 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 html/includes/graphs/application/ceph_common.inc.php diff --git a/html/includes/graphs/application/ceph_common.inc.php b/html/includes/graphs/application/ceph_common.inc.php new file mode 100644 index 000000000..8b996592f --- /dev/null +++ b/html/includes/graphs/application/ceph_common.inc.php @@ -0,0 +1,17 @@ + Date: Tue, 10 Nov 2015 12:33:52 +0100 Subject: [PATCH 4/4] Move the ceph_rrd function to includes/common.inc.php --- .../graphs/application/ceph_common.inc.php | 17 --------------- .../application/ceph_osd_performance.inc.php | 2 -- .../graphs/application/ceph_pool_df.inc.php | 2 -- .../graphs/application/ceph_pool_io.inc.php | 2 -- .../graphs/application/ceph_pool_iops.inc.php | 1 - .../application/ceph_pool_objects.inc.php | 1 - includes/common.php | 21 +++++++++++++++++++ 7 files changed, 21 insertions(+), 25 deletions(-) delete mode 100644 html/includes/graphs/application/ceph_common.inc.php diff --git a/html/includes/graphs/application/ceph_common.inc.php b/html/includes/graphs/application/ceph_common.inc.php deleted file mode 100644 index 8b996592f..000000000 --- a/html/includes/graphs/application/ceph_common.inc.php +++ /dev/null @@ -1,17 +0,0 @@ -