diff --git a/AUTHORS.md b/AUTHORS.md index bae7770ff..0fc344279 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -67,4 +67,5 @@ Contributors to LibreNMS: - Richard Hartmann (RichiH) - Robert Gornall (rgormley) +- Richard Kojedzinszky (rkojedzinszky) [1]: http://observium.org/ "Observium web site" diff --git a/daily.php b/daily.php index e5e06884b..8569f1c9a 100644 --- a/daily.php +++ b/daily.php @@ -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); } diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index 316017855..03788f90d 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -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 ''; } } 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..58381a978 --- /dev/null +++ b/html/includes/graphs/application/ceph_osd_performance.inc.php @@ -0,0 +1,25 @@ + '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/common.php b/includes/common.php index 248285600..2f7a7aedc 100644 --- a/includes/common.php +++ b/includes/common.php @@ -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)); +} diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php new file mode 100644 index 000000000..08413c881 --- /dev/null +++ b/includes/polling/applications/ceph.inc.php @@ -0,0 +1,71 @@ +', $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');