mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Centralised version info + used in output
This commit is contained in:
@@ -27,7 +27,15 @@ $options = getopt('h:m:i:n:d::a::q',array('os:','type:'));
|
|||||||
|
|
||||||
if (!isset($options['q'])) {
|
if (!isset($options['q'])) {
|
||||||
echo $config['project_name_version']." Discovery\n";
|
echo $config['project_name_version']." Discovery\n";
|
||||||
echo get_last_commit()."\n";
|
$versions = version_info(false);
|
||||||
|
echo "Version info:\n";
|
||||||
|
$cur_sha = $versions['local_sha'];
|
||||||
|
echo "Commit SHA: $cur_sha\n";
|
||||||
|
echo "DB Schema: ".$versions['db_schema']."\n";
|
||||||
|
echo "PHP: ".$versions['php_ver']."\n";
|
||||||
|
echo "MySQL: ".$versions['mysql_ver']."\n";
|
||||||
|
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
|
||||||
|
echo "SNMP: ".$versions['netsnmp_ver']."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['h'])) {
|
if (isset($options['h'])) {
|
||||||
|
@@ -145,14 +145,15 @@ echo "
|
|||||||
|
|
||||||
<h3>LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.</h3>
|
<h3>LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.</h3>
|
||||||
<?php
|
<?php
|
||||||
|
$versions = version_info();
|
||||||
$project_name = $config['project_name'];
|
$project_name = $config['project_name'];
|
||||||
$project_version = $config['version'];
|
$project_version = $config['version'];
|
||||||
$apache_version = str_replace('Apache/', '', $_SERVER['SERVER_SOFTWARE']);
|
$apache_version = str_replace('Apache/', '', $_SERVER['SERVER_SOFTWARE']);
|
||||||
$php_version = phpversion();
|
$php_version = $versions['php_ver'];
|
||||||
$mysql_version = dbFetchCell('SELECT version()');
|
$mysql_version = $versions['mysql_ver'];
|
||||||
$netsnmp_version = shell_exec($config['snmpget'].' --version 2>&1');
|
$netsnmp_version = $versions['netsnmp_ver'];
|
||||||
$rrdtool_version = implode(' ', array_slice(explode(' ', shell_exec($config['rrdtool'].' --version |head -n1')), 1, 1));
|
$rrdtool_version = $versions['rrdtool_ver'];
|
||||||
$schema_version = dbFetchCell('SELECT version FROM dbSchema');
|
$schema_version = $versions['db_schema'];
|
||||||
$version = `git rev-parse --short HEAD`;
|
$version = `git rev-parse --short HEAD`;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -807,3 +807,29 @@ function parse_location($location) {
|
|||||||
return array('lat' => $tmp_loc[2], 'lng' => $tmp_loc[3]);
|
return array('lat' => $tmp_loc[2], 'lng' => $tmp_loc[3]);
|
||||||
}
|
}
|
||||||
}//end parse_location()
|
}//end parse_location()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns version info
|
||||||
|
* @return array
|
||||||
|
**/
|
||||||
|
function version_info($remote=true) {
|
||||||
|
global $config;
|
||||||
|
$output = array();
|
||||||
|
if ($remote === true && $config['update_channel'] == 'master') {
|
||||||
|
$api = curl_init();
|
||||||
|
set_curl_proxy($api);
|
||||||
|
curl_setopt($api, CURLOPT_USERAGENT,'LibreNMS');
|
||||||
|
curl_setopt($api, CURLOPT_URL, $config['github_api'].'commits/master');
|
||||||
|
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
$output['github'] = json_decode(curl_exec($api),true);
|
||||||
|
}
|
||||||
|
$output['local_sha'] = chop(`git rev-parse HEAD`);
|
||||||
|
$output['db_schema'] = dbFetchCell('SELECT version FROM dbSchema');
|
||||||
|
$output['php_ver'] = phpversion();
|
||||||
|
$output['mysql_ver'] = dbFetchCell('SELECT version()');
|
||||||
|
$output['rrdtool_ver'] = implode(' ', array_slice(explode(' ', shell_exec($config['rrdtool'].' --version |head -n1')), 1, 1));
|
||||||
|
$output['netsnmp_ver'] = shell_exec($config['snmpget'].' --version 2>&1');
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
}//end version_info()
|
||||||
|
@@ -106,6 +106,7 @@ if (isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT'])) {
|
|||||||
|
|
||||||
$config['project_home'] = 'http://www.librenms.org/';
|
$config['project_home'] = 'http://www.librenms.org/';
|
||||||
$config['project_issues'] = 'https://github.com/librenms/librenms/issues';
|
$config['project_issues'] = 'https://github.com/librenms/librenms/issues';
|
||||||
|
$config['github_api'] = 'https://api.github.com/repos/librenms/librenms/';
|
||||||
$config['site_style'] = 'light';
|
$config['site_style'] = 'light';
|
||||||
// Options are dark or light
|
// Options are dark or light
|
||||||
$config['stylesheet'] = 'css/styles.css';
|
$config['stylesheet'] = 'css/styles.css';
|
||||||
|
@@ -1230,10 +1230,6 @@ function function_check($function) {
|
|||||||
return function_exists($function);
|
return function_exists($function);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_last_commit() {
|
|
||||||
return `git log -n 1|head -n1`;
|
|
||||||
}//end get_last_commit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to determine the address family (IPv4 or IPv6) associated with an SNMP
|
* Try to determine the address family (IPv4 or IPv6) associated with an SNMP
|
||||||
* transport specifier (like "udp", "udp6", etc.).
|
* transport specifier (like "udp", "udp6", etc.).
|
||||||
|
10
poller.php
10
poller.php
@@ -23,7 +23,15 @@ require 'includes/alerts.inc.php';
|
|||||||
|
|
||||||
$poller_start = utime();
|
$poller_start = utime();
|
||||||
echo $config['project_name_version']." Poller\n";
|
echo $config['project_name_version']." Poller\n";
|
||||||
echo get_last_commit()."\n";
|
$versions = version_info(false);
|
||||||
|
echo "Version info:\n";
|
||||||
|
$cur_sha = $versions['local_sha'];
|
||||||
|
echo "Commit SHA: $cur_sha\n";
|
||||||
|
echo "DB Schema: ".$versions['db_schema']."\n";
|
||||||
|
echo "PHP: ".$versions['php_ver']."\n";
|
||||||
|
echo "MySQL: ".$versions['mysql_ver']."\n";
|
||||||
|
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
|
||||||
|
echo "SNMP: ".$versions['netsnmp_ver']."\n";
|
||||||
|
|
||||||
$options = getopt('h:m:i:n:r::d::a::');
|
$options = getopt('h:m:i:n:r::d::a::');
|
||||||
|
|
||||||
|
20
validate.php
20
validate.php
@@ -44,9 +44,6 @@ if (strstr(`php -ln config.php`, 'No syntax errors detected')) {
|
|||||||
else if ($last_lines[1] == '?>') {
|
else if ($last_lines[1] == '?>') {
|
||||||
print_warn("It looks like you have ?> at the end of config.php, it's suggested you remove this");
|
print_warn("It looks like you have ?> at the end of config.php, it's suggested you remove this");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
print_ok('config.php tested ok');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_fail('Syntax error in config.php');
|
print_fail('Syntax error in config.php');
|
||||||
@@ -63,8 +60,25 @@ require_once 'includes/defaults.inc.php';
|
|||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
require_once 'includes/definitions.inc.php';
|
require_once 'includes/definitions.inc.php';
|
||||||
require_once 'includes/functions.php';
|
require_once 'includes/functions.php';
|
||||||
|
require_once 'includes/common.php';
|
||||||
require_once $config['install_dir'].'/includes/alerts.inc.php';
|
require_once $config['install_dir'].'/includes/alerts.inc.php';
|
||||||
|
|
||||||
|
$versions = version_info();
|
||||||
|
echo "Version info:\n";
|
||||||
|
$cur_sha = $versions['local_sha'];
|
||||||
|
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) {
|
||||||
|
print_warn("Your install is out of date: $cur_sha");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "Commit SHA: $cur_sha\n";
|
||||||
|
}
|
||||||
|
echo "DB Schema: ".$versions['db_schema']."\n";
|
||||||
|
echo "PHP: ".$versions['php_ver']."\n";
|
||||||
|
echo "MySQL: ".$versions['mysql_ver']."\n";
|
||||||
|
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
|
||||||
|
echo "SNMP: ".$versions['netsnmp_ver']."\n";
|
||||||
|
|
||||||
|
|
||||||
// Check php modules we use to make sure they are loaded
|
// Check php modules we use to make sure they are loaded
|
||||||
$extensions = array('pcre','curl','session','snmp','mcrypt');
|
$extensions = array('pcre','curl','session','snmp','mcrypt');
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
|
Reference in New Issue
Block a user