Merge pull request #2412 from tuxis-ie/master

Add Ceph support
This commit is contained in:
Neil Lathwood
2015-11-10 08:08:17 -04:00
9 changed files with 335 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
<?php
$ds_in = 'apply_ms';
$ds_out = 'commit_ms';
$in_text = 'Apply';
$out_text = 'Commit';
$ceph_osd_rrd = ceph_rrd('osd');
if (is_file($ceph_osd_rrd)) {
$rrd_filename = $ceph_osd_rrd;
}
$colour_area_in = 'FF3300';
$colour_line_in = 'FF0000';
$colour_area_out = 'FF6633';
$colour_line_out = 'CC3300';
$colour_area_in_max = 'FF6633';
$colour_area_out_max = 'FF9966';
$unit_text = 'Miliseconds';
require 'includes/graphs/generic_duplex.inc.php';

View File

@@ -0,0 +1,56 @@
<?php
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('df');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$rrd_options .= ' -l 0 -b 1024 ';
$rrd_options .= " 'COMMENT:Bytes Min Cur Max\\n'";
$usedc = 'CC0000';
$availc = '008C00';
$totalc = 'e5e5e5';
if ($vars['pool'] != "c") {
$rrd_options .= " DEF:poolfree=$rrd_filename:avail:AVERAGE ";
$rrd_options .= " DEF:poolused=$rrd_filename:used:AVERAGE ";
$rrd_options .= " CDEF:pooltotal=poolused,poolfree,+ ";
$rrd_options .= " LINE1:poolused#".$usedc;
$rrd_options .= " LINE1:poolfree#".$availc.'::STACK';
$rrd_options .= " AREA:poolused#".$usedc.'30:Used ';
$rrd_options .= " GPRINT:poolused:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolused:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolused:MAX:%7.2lf%sB\n';
$rrd_options .= " AREA:poolfree#".$availc.'30:Free:STACK';
$rrd_options .= " GPRINT:poolfree:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolfree:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolfree:MAX:%7.2lf%sB\n';
$rrd_options .= " LINE1:pooltotal#000000:Total";
$rrd_options .= " GPRINT:pooltotal:MIN:%6.2lf%sB";
$rrd_options .= " GPRINT:pooltotal:LAST:%7.2lf%sB";
$rrd_options .= ' GPRINT:pooltotal:MAX:%7.2lf%sB\n';
} else {
$rrd_options .= " DEF:poolsize=$rrd_filename:avail:AVERAGE ";
$rrd_options .= " DEF:poolused=$rrd_filename:used:AVERAGE ";
$rrd_options .= " DEF:poolfree=$rrd_filename:objects:AVERAGE ";
$rrd_options .= " LINE1:poolused#".$usedc;
$rrd_options .= " AREA:poolused#".$usedc.'30:Used';
$rrd_options .= " GPRINT:poolused:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolused:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolused:MAX:%7.2lf%sB\n';
$rrd_options .= " AREA:poolfree#".$availc.'30:Free:STACK';
$rrd_options .= " GPRINT:poolfree:MIN:%7.2lf%sB";
$rrd_options .= ' GPRINT:poolfree:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolfree:MAX:%7.2lf%sB\n';
$rrd_options .= " LINE1:poolsize#000000:Total";
$rrd_options .= " GPRINT:poolsize:MIN:%6.2lf%sB";
$rrd_options .= ' GPRINT:poolsize:LAST:%7.2lf%sB';
$rrd_options .= ' GPRINT:poolsize:MAX:%7.2lf%sB\n';
}

View File

@@ -0,0 +1,26 @@
<?php
$ds_in = 'rbytes';
$in_text = 'Read';
$ds_out = 'wrbytes';
$out_text = 'Write';
$format = 'bytes';
$ceph_pool_rrd = ceph_rrd('pool');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$colour_area_in = 'FF3300';
$colour_line_in = 'FF0000';
$colour_area_out = 'FF6633';
$colour_line_out = 'CC3300';
$colour_area_in_max = 'FF6633';
$colour_area_out_max = 'FF9966';
$unit_text = 'Bytes I/O';
require 'includes/graphs/generic_duplex.inc.php';

View File

@@ -0,0 +1,24 @@
<?php
$scale_min = 0;
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('pool');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$ds = 'ops';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 1;
$unit_text = 'Operations';
require 'includes/graphs/generic_simplex.inc.php';

View File

@@ -0,0 +1,22 @@
<?php
$scale_min = 0;
require 'includes/graphs/common.inc.php';
$ceph_pool_rrd = ceph_rrd('df');
if (is_file($ceph_pool_rrd)) {
$rrd_filename = $ceph_pool_rrd;
}
$ds = 'objects';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$unit_text = 'Objects';
require 'includes/graphs/generic_simplex.inc.php';

View File

@@ -0,0 +1,88 @@
<?php
$graphs = array(
'ceph_poolstats' => 'Pool stats',
'ceph_osdperf' => 'OSD Performance',
'ceph_df' => 'Usage',
);
$rrddir = $config['rrd_dir'].'/'.$device['hostname'];
foreach ($graphs as $key => $text) {
echo '<h3>'.$text.'</h3>';
$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 '<h3>'.$pool.' Reads/Writes</h3>';
$graph_array['type'] = 'application_ceph_pool_io';
$graph_array['pool'] = $pool;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
echo '<h3>'.$pool.' IOPS</h3>';
$graph_array['type'] = 'application_ceph_pool_iops';
$graph_array['pool'] = $pool;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
}
}
}
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 '<h3>'.$osd.' Latency</h3>';
$graph_array['type'] = 'application_ceph_osd_performance';
$graph_array['osd'] = $osd;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
}
}
}
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 '<h3>Cluster Usage</h3>';
$graph_array['type'] = 'application_ceph_pool_df';
$graph_array['pool'] = $pool;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
}
else {
echo '<h3>'.$pool.' Usage</h3>';
$graph_array['type'] = 'application_ceph_pool_df';
$graph_array['pool'] = $pool;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
echo '<h3>'.$pool.' Objects</h3>';
$graph_array['type'] = 'application_ceph_pool_objects';
$graph_array['pool'] = $pool;
echo "<tr bgcolor='$row_colour'><td colspan=5>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
}
}
}
}
}

View File

@@ -774,3 +774,24 @@ function can_ping_device($attribs) {
return false;
}
} // end can_ping_device
/**
* Constructs the path to an RRD for the Ceph application
* @param string $gtype The type of rrd we're looking for
* @return string
**/
function ceph_rrd($gtype) {
global $device;
global $vars;
global $config;
if ($gtype == "osd") {
$var = $vars['osd'];
}
else {
$var = $vars['pool'];
}
$rrd = join('-', array('app', 'ceph', $vars['id'], $gtype, $var)).'.rrd';
return join('/', array($config['rrd_dir'], $device['hostname'], $rrd));
}

View File

@@ -0,0 +1,71 @@
<?php
if (!empty($agent_data['app']['ceph'])) {
$ceph_rrddir = join('/', array($config['rrd_dir'], $device['hostname']));
foreach (explode('<', $agent_raw) as $section) {
if (empty($section))
continue;
list($section, $data) = explode('>', $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));
}
}
}
}

View File

@@ -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');