This commit is contained in:
vizay
2015-11-11 12:28:07 +01:00
17 changed files with 363 additions and 21 deletions
+1
View File
@@ -67,4 +67,5 @@ Contributors to LibreNMS:
- Richard Hartmann <richih@debian.org> (RichiH)
- Robert Gornall <roblnm@khobbits.co.uk (KHobbits)
- Rob Gormley <robert@gormley.me> (rgormley)
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
[1]: http://observium.org/ "Observium web site"
+1
View File
@@ -37,6 +37,7 @@ The ' . $config['project_name'] . ' team.';
echo 'Current size: '.($pool_size / 1024 / 1024).' MiB'.PHP_EOL;
echo 'Minimum Required: '.($pool_used / 1024 / 1024).' MiB'.PHP_EOL;
echo 'To ensure integrity, we\'re not going to pull any updates until the buffersize has been adjusted.'.PHP_EOL;
echo 'Config proposal: "innodb_buffer_pool_size = '.pow(2,ceil(log(($pool_used / 1024 / 1024),2))).'M"'.PHP_EOL;
}
exit(2);
}
@@ -41,33 +41,36 @@ function authenticate($username, $password) {
return $user_authenticated;
} else {
}
else {
// group membership is not required and user is valid
return 1;
};
} else {
}
}
else {
return 0;
}
} else {
}
else {
echo ldap_error($ds);
}
return 0;
}
function reauthenticate($sess_id, $token) {
function reauthenticate() {
// not supported so return 0
return 0;
}
function passwordscanchange($username='') {
function passwordscanchange() {
// not supported so return 0
return 0;
}
function changepassword($username, $newpassword) {
function changepassword() {
// not supported so return 0
return 0;
}
@@ -79,7 +82,7 @@ function auth_usermanagement() {
}
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
function adduser() {
// not supported so return 0
return 0;
}
@@ -127,7 +130,7 @@ function get_userid($username) {
global $config, $ds;
$attributes = array('objectsid');
$result = ldap_search($ds, $config['auth_ad_base_dn'],
$search = ldap_search($ds, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ds, $search);
@@ -139,7 +142,7 @@ function get_userid($username) {
}
function deluser($username) {
function deluser() {
// not supported so return 0
return 0;
}
@@ -148,6 +151,7 @@ function deluser($username) {
function get_userlist() {
global $config, $ds;
$userlist = array();
$userhash = array();
$ldap_groups = get_group_list();
@@ -218,7 +222,8 @@ function get_fullname($username) {
$entries = ldap_get_entries($ds, $result);
if ($entries['count'] > 0) {
$membername = $entries[0]['name'][0];
} else {
}
else {
$membername = $username;
}
@@ -262,7 +267,8 @@ function get_dn($samaccountname) {
$entries = ldap_get_entries($ds, $result);
if ($entries['count'] > 0) {
return $entries[0]['dn'];
} else {
}
else {
return '';
}
}
@@ -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';
@@ -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';
}
@@ -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';
@@ -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';
@@ -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';
+1 -1
View File
@@ -87,7 +87,7 @@ $rrd_options .= ' VDEF:tot=octets,TOTAL';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($format == 'octets' || $format == 'bytes') {
$units = 'Bps';
@@ -57,7 +57,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
@@ -68,7 +68,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($legend == 'no' || $legend == '1') {
@@ -66,7 +66,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
@@ -77,7 +77,7 @@ if ($i) {
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($legend == 'no' || $legend == '1') {
@@ -111,7 +111,7 @@ if (!$nototal) {
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
$rrd_options .= ' VDEF:totin=inoctets,TOTAL';
$rrd_options .= ' VDEF:totout=outoctets,TOTAL';
@@ -111,7 +111,7 @@ if ($_GET['previous'] == 'yes') {
$rrd_options .= ' CDEF:doutbitsX=doutBX,8,*';
$rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT';
$rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT';
$rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutXn=doutbitsX,-1,* VDEF:d95thoutXn95=d95thoutXn,95,PERCENT CDEF:d95thoutXn95n=doutbitsX,doutbitsX,-,d95thoutXn95,-1,*,+ VDEF:d95thoutX=d95thoutXn95n,FIRST';
}
if ($_GET['previous'] == 'yes') {
@@ -132,7 +132,7 @@ if (!$args['nototal']) {
$rrd_options .= ' CDEF:doutbits=doutB,8,*';
$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT';
$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT';
$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT';
$rrd_options .= ' CDEF:d95thoutn=doutbits,-1,* VDEF:d95thoutn95=d95thoutn,95,PERCENT CDEF:d95thoutn95n=doutbits,doutbits,-,d95thoutn95,-1,*,+ VDEF:d95thout=d95thoutn95n,FIRST';
$rrd_options .= ' VDEF:totin=inB,TOTAL';
$rrd_options .= ' VDEF:avein=inbits,AVERAGE';
$rrd_options .= ' VDEF:totout=outB,TOTAL';
+88
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>';
}
}
}
}
}
+21
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));
}
@@ -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));
}
}
}
}
+2 -1
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');