diff --git a/doc/Support/FAQ.md b/doc/Support/FAQ.md index 0f171b6c94..5b571f02b2 100644 --- a/doc/Support/FAQ.md +++ b/doc/Support/FAQ.md @@ -189,14 +189,16 @@ You will also need to supply a test unit within `tests/OSDiscoveryTest.php`. Ple #### What information do you need to add a new OS? -Please provide the following output as seperate non-expiring pastebin.com links. +Under the device, click the gear and select Capture. +Please provide the output of Discovery, Poller, and Snmpwalk as separate non-expiring pastebin.com links. -Replace the relevant information in these commands such as HOSTNAME and COMMUNITY. +You can also use the command line to obtain the information. Especially, if snmpwalk results in a large amount of data. +Replace the relevant information in these commands such as HOSTNAME and COMMUNITY. Use `snmpwalk` instead of `snmpbulkwalk` for v1 devices. ```bash ./discovery.php -h HOSTNAME -d -m os ./poller.php -h HOSTNAME -r -f -d -m os -snmpbulkwalk -On -v2c -c COMMUNITY HOSTNAME . +snmpbulkwalk -Onet -v2c -c COMMUNITY HOSTNAME . ``` If possible please also provide what the OS name should be if it doesn't exist already. diff --git a/html/ajax_output.php b/html/ajax_output.php new file mode 100644 index 0000000000..0f518cc00f --- /dev/null +++ b/html/ajax_output.php @@ -0,0 +1,29 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once '../includes/defaults.inc.php'; +require_once '../config.php'; +require_once '../includes/definitions.inc.php'; +require_once 'includes/functions.inc.php'; +require_once '../includes/functions.php'; +require_once 'includes/authenticate.inc.php'; + +set_debug($_REQUEST['debug']); +$id = mres($_REQUEST['id']); + +if (isset($id)) { + if (file_exists("includes/output/$id.inc.php")) { + include_once "includes/output/$id.inc.php"; + } +} diff --git a/html/includes/output/capture.inc.php b/html/includes/output/capture.inc.php new file mode 100644 index 0000000000..61efdef9a1 --- /dev/null +++ b/html/includes/output/capture.inc.php @@ -0,0 +1,93 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + +if (!is_admin()) { + echo("Insufficient Privileges"); + exit(); +} + +$hostname = escapeshellcmd($_REQUEST['hostname']); +$type = $_REQUEST['type']; + +switch ($type) { + case 'poller': + $cmd = "php ${config['install_dir']}/poller.php -h $hostname -r -f -d"; + $filename = "poller-$hostname.txt"; + break; + case 'snmpwalk': + $device = device_by_name(mres($hostname)); + + $cmd = gen_snmpwalk_cmd($device, '.', ' -Onet'); + + if ($debug) { + $cmd .= ' 2>&1'; + } + + $filename = $device['os'] . '-' . $device['hostname'] . '.snmpwalk'; + break; + case 'discovery': + $cmd = "php ${config['install_dir']}/discovery.php -h $hostname -d"; + $filename = "discovery-$hostname.txt"; + break; + default: + echo 'You must specify a valid type'; + exit(); +} + +// ---- Output ---- + +if ($_GET['format'] == 'text') { + header("Content-type: text/plain"); + header('X-Accel-Buffering: no'); + + if (($fp = popen($cmd, "r"))) { + while (!feof($fp)) { + $line = stream_get_line($fp, 1024, PHP_EOL); + echo preg_replace('/\033\[[\d;]+m/', '', $line) . PHP_EOL; + ob_flush(); + flush(); // you have to flush buffer + } + fclose($fp); + } +} elseif ($_GET['format'] == 'download') { + ob_start(); + $output = shell_exec($cmd); + ob_end_clean(); + + $output = preg_replace('/\033\[[\d;]+m/', '', $output); + + $length = strlen($output); + + header('Content-Description: File Transfer'); + header('Content-Type: text/plain'); + header("Content-Disposition: attachment; filename=$filename"); + header('Content-Transfer-Encoding: binary'); + header('Content-Length: ' . $length); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Expires: 0'); + header('Pragma: public'); + + echo $output; +} diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index bd584fbd1c..d6ac46e0b2 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -417,6 +417,10 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { Edit '; + + echo '
  • + Capture +
  • '; } echo ' '; diff --git a/html/pages/device/capture.inc.php b/html/pages/device/capture.inc.php new file mode 100644 index 0000000000..80c433a0ac --- /dev/null +++ b/html/pages/device/capture.inc.php @@ -0,0 +1,92 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + +$no_refresh = true; +$pagetitle[] = "Capture"; + + +if (!is_admin()) { + print_error("Insufficient Privileges"); +} else { + ?> +

    Capture Debug Information

    + +
    + 'ajax_output.php?id=capture&format=text&type=discovery&hostname='.$device['hostname'], + 'poller' => 'ajax_output.php?id=capture&format=text&type=poller&hostname='.$device['hostname'], + 'snmp' => 'ajax_output.php?id=capture&format=text&type=snmpwalk&hostname='.$device['hostname'], + ); + + foreach ($tabs as $tab => $url) { + ?> +
    +
    +
    +
    + +
    +
    + + '; +}