Remove legacy function calls (#12651)

* massive inlines

* fix style and wtf

* remove rrdtool.inc.php include

* fix CommonFunctions namespace issues

* looking for missing class space, fix undefined class issues

* style fixes
This commit is contained in:
Tony Murray 2021-03-28 17:25:30 -05:00 committed by GitHub
parent 1695f86af8
commit 1c379dcd05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
832 changed files with 2023 additions and 2596 deletions

View File

@ -70,7 +70,7 @@ class AlertDB
if (strstr($opt, '%') && strstr($opt, '.')) {
$tmpp = explode('.', $opt, 2);
$tmpp[0] = str_replace('%', '', $tmpp[0]);
$tables[] = mres(str_replace('(', '', $tmpp[0]));
$tables[] = str_replace('(', '', $tmpp[0]);
$rule = str_replace($opt, $tmpp[0] . '.' . $tmpp[1], $rule);
}
}

View File

@ -29,6 +29,7 @@ use LibreNMS\Config;
use LibreNMS\Data\Measure\Measurement;
use LibreNMS\Exceptions\FileExistsException;
use LibreNMS\Proc;
use LibreNMS\Util\Rewrite;
use Log;
class Rrd extends BaseDatastore
@ -528,6 +529,36 @@ class Rrd extends BaseDatastore
return (string) preg_replace('/[^a-zA-Z0-9,._\-\/\ ]/', ' ', $descr);
}
/**
* Escapes strings and sets them to a fixed length for use with RRDtool
*
* @param string $descr the string to escape
* @param int $length if passed, string will be padded and trimmed to exactly this length (after rrdtool unescapes it)
* @return string
*/
public static function fixedSafeDescr($descr, $length)
{
$result = Rewrite::shortenIfType($descr);
$result = str_replace("'", '', $result); // remove quotes
if (is_numeric($length)) {
// preserve original $length for str_pad()
// determine correct strlen() for substr_count()
$substr_count_length = $length <= 0 ? null : min(strlen($descr), $length);
$extra = substr_count($descr, ':', 0, $substr_count_length);
$result = substr(str_pad($result, $length), 0, ($length + $extra));
if ($extra > 0) {
$result = substr($result, 0, (-1 * $extra));
}
}
$result = str_replace(':', '\:', $result); // escape colons
return $result . ' ';
}
/**
* Only track update and create primarily, just put all others in an "other" bin
*

View File

@ -69,7 +69,7 @@ class Availability
* @param object $found_outages filtered database object with all recorded outages
* @param int $duration time period to calculate for
* @param int $now timestamp for 'now'
* @return sum of all matching outages in seconds
* @return int sum of all matching outages in seconds
*/
protected static function outageSummary($found_outages, $duration, $now = null)
{

View File

@ -23,6 +23,9 @@ namespace LibreNMS;
use LibreNMS\Authentication\LegacyAuth;
use LibreNMS\DB\Eloquent;
use LibreNMS\Enum\AlertState;
use LibreNMS\Util\Number;
use LibreNMS\Util\Time;
use Permissions;
class IRCBot
{
@ -631,7 +634,7 @@ class IRCBot
$this->log("HostAuth on irc matching $host to " . $this->getUserHost($this->data));
}
if (preg_match("/$host/", $this->getUserHost($this->data))) {
$user_id = LegacyAuth::get()->getUserid(mres($nms_user));
$user_id = LegacyAuth::get()->getUserid($nms_user);
$user = LegacyAuth::get()->getUser($user_id);
$this->user['name'] = $user['username'];
$this->user['id'] = $user_id;
@ -682,7 +685,7 @@ class IRCBot
return $this->respond('Nope.');
}
} else {
$user_id = LegacyAuth::get()->getUserid(mres($params[0]));
$user_id = LegacyAuth::get()->getUserid($params[0]);
$user = LegacyAuth::get()->getUser($user_id);
if ($user['email'] && $user['username'] == $params[0]) {
$token = hash('gost', openssl_random_pseudo_bytes(1024));
@ -871,7 +874,7 @@ class IRCBot
return $this->respond('Error: Permission denied.');
}
$status = $device['status'] ? 'Up ' . formatUptime($device['uptime']) : 'Down';
$status = $device['status'] ? 'Up ' . Time::formatInterval($device['uptime']) : 'Down';
$status .= $device['ignore'] ? '*Ignored*' : '';
$status .= $device['disabled'] ? '*Disabled*' : '';
@ -895,12 +898,12 @@ class IRCBot
return $this->respond('Error: Permission denied.');
}
$bps_in = formatRates($port['ifInOctets_rate'] * 8);
$bps_out = formatRates($port['ifOutOctets_rate'] * 8);
$pps_in = format_bi($port['ifInUcastPkts_rate']);
$pps_out = format_bi($port['ifOutUcastPkts_rate']);
$bps_in = Number::formatSi($port['ifInOctets_rate'] * 8, 2, 3, 'bps');
$bps_out = Number::formatSi($port['ifOutOctets_rate'] * 8, 2, 3, 'bps');
$pps_in = Number::formatBi($port['ifInUcastPkts_rate'], 2, 3, 'pps');
$pps_out = Number::formatBi($port['ifOutUcastPkts_rate'], 2, 3, 'pps');
return $this->respond($port['ifAdminStatus'] . '/' . $port['ifOperStatus'] . ' ' . $bps_in . ' > bps > ' . $bps_out . ' | ' . $pps_in . 'pps > PPS > ' . $pps_out . 'pps');
return $this->respond($port['ifAdminStatus'] . '/' . $port['ifOperStatus'] . ' ' . $bps_in . ' > bps > ' . $bps_out . ' | ' . $pps_in . ' > PPS > ' . $pps_out);
}
//end _port()

View File

@ -34,6 +34,7 @@ use LibreNMS\Interfaces\Module;
use LibreNMS\Interfaces\Polling\MempoolsPolling;
use LibreNMS\OS;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\Number;
use Log;
class Mempools implements Module
@ -169,10 +170,10 @@ class Mempools implements Module
}
if ($system !== null) {
$old = format_bi($system->mempool_free);
$old = Number::formatBi($system->mempool_free, 2, 3, 'iB');
$system->fillUsage(($system->mempool_used - $buffers - $cached) / $system->mempool_precision, $system->mempool_total / $system->mempool_precision);
$new = format_bi($system->mempool_free);
Log::debug("Free memory adjusted by availability calculation: {$old}iB -> {$new}iB\n");
$new = Number::formatBi($system->mempool_free, 2, 3, 'iB');
Log::debug("Free memory adjusted by availability calculation: {$old} -> {$new}\n");
}
}
@ -183,9 +184,9 @@ class Mempools implements Module
{
echo "$mempool->mempool_type [$mempool->mempool_class]: $mempool->mempool_descr: $mempool->mempool_perc%";
if ($mempool->mempool_total != 100) {
$used = format_bi($mempool->mempool_used);
$total = format_bi($mempool->mempool_total);
echo " {$used}iB / {$total}iB";
$used = Number::formatBi($mempool->mempool_used, 2, 3, 'iB');
$total = Number::formatBi($mempool->mempool_total, 2, 3, 'iB');
echo " {$used} / {$total}";
}
echo PHP_EOL;
}

View File

@ -625,6 +625,6 @@ class Ironware extends Foundry
'snICX725048HPOERouter' => 'FastIron ICX 7250 48-port PoE+ Router',
];
$this->getDevice()->hardware = array_str_replace($rewrite_ironware_hardware, $this->getDevice()->hardware);
$this->getDevice()->hardware = str_replace(array_keys($rewrite_ironware_hardware), array_values($rewrite_ironware_hardware), $this->getDevice()->hardware);
}
}

View File

@ -668,7 +668,7 @@ class Timos extends OS implements MplsDiscovery, MplsPolling, WirelessPowerDisco
'sapLastStatusChange' => round($value['sapLastStatusChange'] / 100),
]));
//create SAP graphs
$rrd_name = safename('sap-' . $traffic_id);
$rrd_name = \LibreNMS\Data\Store\Rrd::safeName('sap-' . $traffic_id);
$rrd_def = RrdDefinition::make()
->addDataset('sapIngressBits', 'COUNTER', 0)
->addDataset('sapEgressBits', 'COUNTER', 0)

View File

@ -29,6 +29,7 @@ use Closure;
use Exception;
use Illuminate\Support\Str;
use LibreNMS\Device\Processor;
use Rrd;
trait HostResources
{
@ -116,7 +117,7 @@ trait HostResources
$old_name = ['hrProcessor', $index];
$new_name = ['processor', 'hr', $index];
rrd_file_rename($this->getDeviceArray(), $old_name, $new_name);
Rrd::renameFile($this->getDeviceArray(), $old_name, $new_name);
$processor = Processor::discover(
'hr',

View File

@ -26,6 +26,8 @@
namespace LibreNMS\Snmptrap\Handlers;
use LibreNMS\Snmptrap\Trap;
class CyberPowerUtil
{
/**

View File

@ -31,6 +31,8 @@
namespace LibreNMS\Snmptrap\Handlers;
use LibreNMS\Snmptrap\Trap;
class VmwTrapUtil
{
/**

View File

@ -123,7 +123,7 @@ class Html
unset($link_array['height'], $link_array['width']);
$link = Url::generate($link_array);
$full_link = Url::overlibLink($link, Url::lazyGraphTag($graph_array), Url::graphTag($graph_array_zoom), null);
$full_link = Url::overlibLink($link, Url::lazyGraphTag($graph_array), Url::graphTag($graph_array_zoom));
$graph_data[] = $full_link;
if ($print) {

View File

@ -57,6 +57,29 @@ class Rewrite
return $type;
}
public static function shortenIfType($type)
{
return str_ireplace(
[
'FastEthernet',
'TenGigabitEthernet',
'GigabitEthernet',
'Port-Channel',
'Ethernet',
'Bundle-Ether',
],
[
'Fa',
'Te',
'Gi',
'Po',
'Eth',
'BE',
],
$type
);
}
public static function normalizeIfName($name)
{
$rewrite_ifname = [

View File

@ -172,7 +172,7 @@ class Url
}
/**
* @param Sensor $sensor
* @param \App\Models\Sensor $sensor
* @param string $text
* @param string $type
* @param bool $overlib

View File

@ -86,8 +86,8 @@ if (! empty($argv[1])) {
$snmpver = 'v2c';
$additional = [
'snmp_disable' => 1,
'os' => $argv[2] ? mres($argv[2]) : 'ping',
'hardware' => $argv[3] ? mres($argv[3]) : '',
'os' => $argv[2] ? $argv[2] : 'ping',
'hardware' => $argv[3] ? $argv[3] : '',
];
} elseif ($snmpver === 'v3') {
$seclevel = $community;

View File

@ -27,6 +27,7 @@ namespace App\Observers;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Log;
use Rrd;
class MempoolObserver extends ModuleModelObserver
{
@ -36,11 +37,7 @@ class MempoolObserver extends ModuleModelObserver
if ($model->isDirty('mempool_class')) {
Log::debug("Mempool class changed $model->mempool_descr ($model->mempool_id)");
rrd_file_rename(
$model->device->toArray(),
['mempool', $model->mempool_type, $model->getOriginal('mempool_class'), $model->mempool_index],
['mempool', $model->mempool_type, $model->mempool_class, $model->mempool_index]
);
Rrd::renameFile($model->device->toArray(), ['mempool', $model->mempool_type, $model->getOriginal('mempool_class'), $model->mempool_index], ['mempool', $model->mempool_type, $model->mempool_class, $model->mempool_index]);
}
}
}

View File

@ -8,6 +8,9 @@
*
* @copyright (C) 2006 - 2012 Adam Armstrong
*/
use LibreNMS\Util\Number;
$init_modules = [];
require __DIR__ . '/includes/init.php';
@ -50,8 +53,8 @@ foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) {
$type = 'CDR';
$allowed = $bill['bill_cdr'];
$used = $rate_data['rate_95th'];
$allowed_text = format_si($allowed) . 'bps';
$used_text = format_si($used) . 'bps';
$allowed_text = Number::formatSi($allowed, 2, 3, 'bps');
$used_text = Number::formatSi($used, 2, 3, 'bps');
$overuse = ($used - $allowed);
$overuse = (($overuse <= 0) ? '0' : $overuse);
$percent = round((($rate_data['rate_95th'] / $bill['bill_cdr']) * 100), 2);

View File

@ -31,14 +31,18 @@ echo "Starting service polling run:\n\n";
$polled_services = 0;
$where = '';
$params = [];
if ($options['h']) {
if (is_numeric($options['h'])) {
$where = 'AND `S`.`device_id` = ' . $options['h'];
$where = 'AND `S`.`device_id` = ?';
$params[] = (int) $options['h'];
} else {
if (preg_match('/\*/', $options['h'])) {
$where = "AND `hostname` LIKE '" . str_replace('*', '%', mres($options['h'])) . "'";
$where = "AND `hostname` LIKE '?'";
$params[] = str_replace('*', '%', $options['h']);
} else {
$where = "AND `hostname` = '" . mres($options['h']) . "'";
$where = "AND `hostname` = '?'";
$params[] = $options['h'];
}
}
}
@ -48,7 +52,7 @@ $sql = 'SELECT D.*,S.*,attrib_value FROM `devices` AS D'
. ' LEFT JOIN `devices_attribs` as A ON D.device_id = A.device_id AND A.attrib_type = "override_icmp_disable"'
. ' ORDER by D.device_id DESC;';
foreach (dbFetchRows($sql) as $service) {
foreach (dbFetchRows($sql, $params) as $service) {
// Run the polling function if service is enabled and the associated device is up, "Disable ICMP Test" option is not enabled,
// or service hostname/ip is different from associated device
if (! $service['service_disabled'] && ($service['status'] == 1 || ($service['status'] == 0 && $service['status_reason'] === 'snmp') ||
@ -61,7 +65,7 @@ foreach (dbFetchRows($sql) as $service) {
d_echo("\nService check - " . $service['service_id'] . "\nSkipping service check because device "
. $service['hostname'] . " is down due to icmp.\n");
Log::event(
"Service check - {$service['service_desc']} ({$service['service_id']}) -
"Service check - {$service['service_desc']} ({$service['service_id']}) -
Skipping service check because device {$service['hostname']} is down due to icmp",
$service['device_id'],
'service',

View File

@ -28,7 +28,6 @@ return [
'CPS-MIB::lowBattery' => LibreNMS\Snmptrap\Handlers\CpLowBattery::class,
'CPS-MIB::powerRestored' => \LibreNMS\Snmptrap\Handlers\CpPowerRestored::class,
'CPS-MIB::returnFromChargerFailure' => \LibreNMS\Snmptrap\Handlers\CpUpsRtnChargerFailure::class,
'CPS-MIB::returnFromDischarged' => \LibreNMS\Snmptrap\Handlers\CpRtnFromDischarge::class,
'CPS-MIB::returnFromLowBattery' => \LibreNMS\Snmptrap\Handlers\CpRtnLowBattery::class,
'CPS-MIB::upsDiagnosticsFailed' => \LibreNMS\Snmptrap\Handlers\CpUpsDiagFailed::class,
'CPS-MIB::returnFromDischarged' => \LibreNMS\Snmptrap\Handlers\CpRtnDischarge::class,
@ -50,14 +49,12 @@ return [
'EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSAlarm' => \LibreNMS\Snmptrap\Handlers\Mgnt2TrapNmsAlarm::class,
'ENTITY-MIB::entConfigChange' => \LibreNMS\Snmptrap\Handlers\EntityDatabaseConfigChanged::class,
'EQUIPMENT-MIB::equipStatusTrap' => \LibreNMS\Snmptrap\Handlers\EquipStatusTrap::class,
'FORTINET-CORE-MIB::fnTrapMemThreshold' => \LibreNMS\Snmptrap\Handlers\FnTrapMemThreshold::class,
'FORTINET-FORTIGATE-MIB::fgTrapAvOversize' => \LibreNMS\Snmptrap\Handlers\FgTrapAvOversize::class,
'FORTINET-FORTIGATE-MIB::fgTrapIpsAnomaly' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsAnomaly::class,
'FORTINET-FORTIGATE-MIB::fgTrapIpsPkgUpdate' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsPkgUpdate::class,
'FORTINET-FORTIGATE-MIB::fgTrapIpsSignature' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsSignature::class,
'FORTINET-FORTIGATE-MIB::fgTrapVpnTunDown' => \LibreNMS\Snmptrap\Handlers\FgTrapVpnTunDown::class,
'FORTINET-FORTIGATE-MIB::fgTrapVpnTunUp' => \LibreNMS\Snmptrap\Handlers\FgTrapVpnTunUp::class,
'FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmTrapLogAlert' => \LibreNMS\Snmptrap\Handlers\FmTrapLogAlert::class,
'FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmTrapLogRateThreshold' => \LibreNMS\Snmptrap\Handlers\FmTrapLogRateThreshold::class,
'IF-MIB::linkDown' => \LibreNMS\Snmptrap\Handlers\LinkDown::class,
'IF-MIB::linkUp' => \LibreNMS\Snmptrap\Handlers\LinkUp::class,

View File

@ -38,7 +38,7 @@ if (isset($options['h'])) {
$where = "AND `device_id` = '" . $options['h'] . "'";
$doing = $options['h'];
} else {
$where = "AND `hostname` LIKE '" . str_replace('*', '%', mres($options['h'])) . "'";
$where = "AND `hostname` LIKE '" . str_replace('*', '%', $options['h']) . "'";
$doing = $options['h'];
}
}//end if

View File

@ -56,7 +56,7 @@ function levsortos($base, $obj, $keys)
header('Content-type: application/json');
if (isset($_GET['term'])) {
\LibreNMS\Util\OS::loadAllDefinitions(false, true);
$_GET['term'] = clean($_GET['term']);
$_GET['term'] = strip_tags($_GET['term']);
$sortos = levsortos($_GET['term'], \LibreNMS\Config::get('os'), ['text', 'os']);
$sortos = array_slice($sortos, 0, 20);
foreach ($sortos as $lev => $os) {

View File

@ -15,7 +15,7 @@ $bgp = [];
$limit = (int) \LibreNMS\Config::get('webui.global_search_result_limit');
if (isset($_REQUEST['search'])) {
$search = mres($_REQUEST['search']);
$search = $_REQUEST['search'];
header('Content-type: application/json');
if (strlen($search) > 0) {
$found = 0;
@ -124,7 +124,7 @@ if (isset($_REQUEST['search'])) {
$device[] = [
'name' => $name,
'device_id' => $result['device_id'],
'url' => generate_device_url($result),
'url' => \LibreNMS\Util\Url::deviceUrl((int) $result['device_id']),
'colours' => $highlight_colour,
'device_ports' => $num_ports,
'device_image' => getIcon($result),
@ -157,7 +157,7 @@ if (isset($_REQUEST['search'])) {
foreach ($results as $result) {
$name = $result['ifDescr'] == $result['ifAlias'] ? $result['ifName'] : $result['ifDescr'];
$description = display($result['ifAlias']);
$description = \LibreNMS\Util\Clean::html($result['ifAlias'], []);
if ($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) {
// Errored ports
@ -225,7 +225,7 @@ if (isset($_REQUEST['search'])) {
$bgp[] = [
'count' => count($results),
'url' => generate_peer_url($result),
'url' => \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $result['device_id'], 'tab' => 'routing', 'proto' => 'bgp'], []),
'name' => $name,
'description' => $description,
'localas' => $localas,

View File

@ -31,7 +31,7 @@ $ifname = $port['label']; //Interface name that will be showed on top right of g
$hostname = shorthost($device['hostname']);
if ($_GET['title']) {
$ifname = display($_GET['title']);
$ifname = \LibreNMS\Util\Clean::html($_GET['title'], []);
}
/********* Other conf *******/

View File

@ -1,15 +1,16 @@
<?php
use LibreNMS\Config;
use LibreNMS\Util\Number;
function format_bytes_billing($value)
{
return format_number($value, Config::get('billing.base')) . 'B';
return Number::formatBase($value, Config::get('billing.base'));
}//end format_bytes_billing()
function format_bytes_billing_short($value)
{
return format_number($value, Config::get('billing.base'), 2, 3);
return Number::formatBase($value, Config::get('billing.base'), 2, 3, '');
}//end format_bytes_billing_short()
function getDates($dayofmonth, $months = 0)

View File

@ -24,25 +24,6 @@ use LibreNMS\Util\IP;
use LibreNMS\Util\Laravel;
use Symfony\Component\Process\Process;
function generate_priority_label($priority)
{
$map = [
'emerg' => 'label-danger',
'alert' => 'label-danger',
'crit' => 'label-danger',
'err' => 'label-danger',
'warning' => 'label-warning',
'notice' => 'label-info',
'info' => 'label-info',
'debug' => 'label-default',
'' => 'label-info',
];
$barColor = isset($map[$priority]) ? $map[$priority] : 'label-info';
return '<span class="alert-status ' . $barColor . '">&nbsp;</span>';
}
function generate_priority_status($priority)
{
$map = [
@ -194,7 +175,7 @@ function print_message($text)
function get_sensor_rrd($device, $sensor)
{
return rrd_name($device['hostname'], get_sensor_rrd_name($device, $sensor));
return Rrd::name($device['hostname'], get_sensor_rrd_name($device, $sensor));
}
function get_sensor_rrd_name($device, $sensor)
@ -207,14 +188,9 @@ function get_sensor_rrd_name($device, $sensor)
}
}
function getPortRrdName($port_id, $suffix = '')
{
return Rrd::portName($port_id, $suffix);
}
function get_port_rrdfile_path($hostname, $port_id, $suffix = '')
{
return rrd_name($hostname, getPortRrdName($port_id, $suffix));
return Rrd::name($hostname, Rrd::portName($port_id, $suffix));
}
function get_port_by_index_cache($device_id, $ifIndex)
@ -369,20 +345,6 @@ function truncate($substring, $max = 50, $rep = '...')
}
}
function mres($string)
{
return $string; // FIXME bleh
// short function wrapper because the real one is stupidly long and ugly. aesthetics.
global $database_link;
return mysqli_real_escape_string($database_link, $string);
}
function getifhost($id)
{
return dbFetchCell('SELECT `device_id` from `ports` WHERE `port_id` = ?', [$id]);
}
function gethostbyid($device_id)
{
return DeviceCache::get((int) $device_id)->hostname;
@ -429,21 +391,6 @@ function getidbyname($hostname)
return DeviceCache::getByHostname($hostname)->device_id;
}
function safename($name)
{
return \LibreNMS\Data\Store\Rrd::safeName($name);
}
/**
* Function format the rrdtool description text correctly.
* @param $descr
* @return mixed
*/
function safedescr($descr)
{
return \LibreNMS\Data\Store\Rrd::safeDescr($descr);
}
function zeropad($num, $length = 2)
{
return str_pad($num, $length, '0', STR_PAD_LEFT);
@ -480,38 +427,6 @@ function del_dev_attrib($device, $attrib_type)
return DeviceCache::get((int) $device['device_id'])->forgetAttrib($attrib_type);
}
function formatRates($value, $round = '2', $sf = '3')
{
$value = format_si($value, $round, $sf) . 'bps';
return $value;
}
function formatStorage($value, $round = '2', $sf = '3')
{
return \LibreNMS\Util\Number::formatBi($value, $round, $sf);
}
function format_si($value, $round = 2, $sf = 3)
{
return \LibreNMS\Util\Number::formatSi($value, $round, $sf, '');
}
function format_bi($value, $round = 2, $sf = 3)
{
return \LibreNMS\Util\Number::formatBi($value, $round, $sf, '');
}
function format_number($value, $base = 1000, $round = 2, $sf = 3)
{
return \LibreNMS\Util\Number::formatBase($value, $base, $round, $sf, '');
}
function is_valid_hostname($hostname)
{
return \LibreNMS\Util\Validate::hostname($hostname);
}
/*
* convenience function - please use this instead of 'if ($debug) { echo ...; }'
*/
@ -700,21 +615,6 @@ function can_ping_device($attribs)
}
} // end can_ping_device
/*
* @return true if every string in $arr begins with $str
*/
function begins_with($str, $arr)
{
foreach ($arr as $s) {
$pos = strpos($s, $str);
if ($pos === false || $pos > 0) {
return false;
}
}
return true;
} // begins_with
function search_phrase_column($c)
{
global $searchPhrase;
@ -738,7 +638,7 @@ function ceph_rrd($gtype)
$var = $vars['pool'];
}
return rrd_name($device['hostname'], ['app', 'ceph', $vars['id'], $gtype, $var]);
return Rrd::name($device['hostname'], ['app', 'ceph', $vars['id'], $gtype, $var]);
} // ceph_rrd
/**
@ -844,7 +744,7 @@ function format_hostname($device, $hostname = null)
}
if (Config::get('force_hostname_to_sysname') && ! empty($device['sysName'])) {
if (is_valid_hostname($hostname) && ! IP::isValid($hostname)) {
if (\LibreNMS\Util\Validate::hostname($hostname) && ! IP::isValid($hostname)) {
return $device['sysName'];
}
}
@ -1096,30 +996,6 @@ function get_sql_filter_min_severity($min_severity, $alert_rules_name)
return '';
}
/**
* @param $value
* @param bool $strip_tags
* @return string
*/
function clean($value, $strip_tags = true)
{
if ($strip_tags === true) {
return strip_tags(mres($value));
} else {
return mres($value);
}
}
/**
* @param $value
* @param array $purifier_config (key, value pair)
* @return string
*/
function display($value, $purifier_config = [])
{
return \LibreNMS\Util\Clean::html($value, $purifier_config);
}
/**
* Load the os definition for the device and set type and os_group
* $device['os'] must be set
@ -1279,23 +1155,6 @@ function str_to_class($name, $namespace = null)
return $namespace . $class;
}
/**
* Checks file permissions against a minimum permissions mask.
* This only check that bits are enabled, not disabled.
* The mask is in the same format as posix permissions. For example, 600 means user read and write.
*
* @param string $file the name of the file to check
* @param $mask
* @return bool
*/
function check_file_permissions($file, $mask)
{
$perms = fileperms($file);
$mask = octdec($mask);
return ($perms & $mask) === $mask;
}
/**
* Index an array by a column
*

View File

@ -258,12 +258,12 @@ function dbDeleteOrphans($target_table, $parents)
return false;
}
$target_table = mres($target_table);
$target_table = $target_table;
$sql = "DELETE T FROM `$target_table` T";
$where = [];
foreach ((array) $parents as $parent) {
$parent_parts = explode('.', mres($parent));
$parent_parts = explode('.', $parent);
if (count($parent_parts) == 2) {
[$parent_table, $parent_column] = $parent_parts;
$target_column = $parent_column;

View File

@ -72,7 +72,7 @@ foreach ($vrfs_lite_cisco as $vrf) {
$old_mac = $existing_data[$index]['mac_address'];
if ($mac != $old_mac && $mac != '') {
d_echo("Changed mac address for $ip from $old_mac to $mac\n");
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac) . ' -> ' . mac_clean_to_readable($mac), $device, 'interface', 4, $port_id);
log_event("MAC change: $ip : " . \LibreNMS\Util\Rewrite::readableMac($old_mac) . ' -> ' . \LibreNMS\Util\Rewrite::readableMac($mac), $device, 'interface', 4, $port_id);
dbUpdate(['mac_address' => $mac], 'ipv4_mac', 'port_id=? AND ipv4_address=? AND context_name=?', [$port_id, $ip, $context]);
}
d_echo("$raw_mac => $ip\n", '.');

View File

@ -100,7 +100,7 @@ if (($device['os'] == 'routeros')) {
$remote_device_id = find_device_id($lldp['lldpRemSysName'], $lldp['lldpRemManAddr'], $remote_port_mac);
if (! $remote_device_id &&
is_valid_hostname($lldp['lldpRemSysName']) &&
\LibreNMS\Util\Validate::hostname($lldp['lldpRemSysName']) &&
! can_skip_discovery($lldp['lldpRemSysName'], $lldp['lldpRemSysDesc']) &&
Config::get('autodiscovery.xdp') === true) {
$remote_device_id = discover_new_device($lldp['lldpRemSysName'], $device, 'LLDP', $interface);
@ -133,7 +133,7 @@ if (($device['os'] == 'routeros')) {
$remote_device_id = find_device_id($lldp['lldpRemSysName']);
if (! $remote_device_id &&
is_valid_hostname($lldp['lldpRemSysName']) &&
\LibreNMS\Util\Validate::hostname($lldp['lldpRemSysName']) &&
! can_skip_discovery($lldp['lldpRemSysName'], $lldp['lldpRemSysDesc'] &&
Config::get('autodiscovery.xdp') === true)
) {
@ -167,7 +167,7 @@ if (($device['os'] == 'routeros')) {
$remote_device_id = find_device_id($lldp['tmnxLldpRemSysName'][$ifIndex][$MacIndex][$RemIndex]);
if (! $remote_device_id &&
is_valid_hostname($lldp['tmnxLldpRemSysName'][$ifIndex][$MacIndex][$RemIndex]) &&
\LibreNMS\Util\Validate::hostname($lldp['tmnxLldpRemSysName'][$ifIndex][$MacIndex][$RemIndex]) &&
! can_skip_discovery($lldp['tmnxLldpRemSysName'][$ifIndex][$MacIndex][$RemIndex], $lldp['tmnxLldpRemSysDesc'][$ifIndex][$MacIndex][$RemIndex]) &&
Config::get('autodiscovery.xdp') === true
) {

View File

@ -20,7 +20,7 @@ use LibreNMS\Exceptions\InvalidIpException;
use LibreNMS\Util\IP;
use LibreNMS\Util\IPv6;
function discover_new_device($hostname, $device = '', $method = '', $interface = '')
function discover_new_device($hostname, $device = [], $method = '', $interface = '')
{
d_echo("discovering $hostname\n");
@ -32,7 +32,7 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
return false;
}
} elseif (is_valid_hostname($hostname)) {
} elseif (\LibreNMS\Util\Validate::hostname($hostname)) {
if ($mydomain = Config::get('mydomain')) {
$full_host = rtrim($hostname, '.') . '.' . $mydomain;
if (isDomainResolves($full_host)) {
@ -1268,7 +1268,7 @@ function find_device_id($name = '', $ip = '', $mac_address = '')
$where = [];
$params = [];
if ($name && is_valid_hostname($name)) {
if ($name && \LibreNMS\Util\Validate::hostname($name)) {
$where[] = '`hostname`=?';
$params[] = $name;

View File

@ -18,19 +18,19 @@ if (is_array($hrDevices)) {
if (is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) {
if (dbFetchCell('SELECT COUNT(*) FROM `hrDevice` WHERE device_id = ? AND hrDeviceIndex = ?', [$device['device_id'], $hrDevice['hrDeviceIndex']])) {
$update_array = [
'hrDeviceType' => mres($hrDevice['hrDeviceType']),
'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']),
'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']),
'hrDeviceErrors' => mres($hrDevice['hrDeviceErrors']),
'hrDeviceType' => $hrDevice['hrDeviceType'],
'hrDeviceDescr' => $hrDevice['hrDeviceDescr'],
'hrDeviceStatus' => $hrDevice['hrDeviceStatus'],
'hrDeviceErrors' => $hrDevice['hrDeviceErrors'],
];
if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor') {
$update_array['hrProcessorLoad'] = mres($hrDevice['hrProcessorLoad']);
$update_array['hrProcessorLoad'] = $hrDevice['hrProcessorLoad'];
}
dbUpdate($update_array, 'hrDevice', 'device_id=? AND hrDeviceIndex=?', [$device['device_id'], $hrDevice['hrDeviceIndex']]);
echo '.';
} else {
$inserted_rows = dbInsert(['hrDeviceIndex' => mres($hrDevice['hrDeviceIndex']), 'device_id' => mres($device['device_id']), 'hrDeviceType' => mres($hrDevice['hrDeviceType']), 'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']), 'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), 'hrDeviceErrors' => (int) mres($hrDevice['hrDeviceErrors'])], 'hrDevice');
$inserted_rows = dbInsert(['hrDeviceIndex' => $hrDevice['hrDeviceIndex'], 'device_id' => $device['device_id'], 'hrDeviceType' => $hrDevice['hrDeviceType'], 'hrDeviceDescr' => $hrDevice['hrDeviceDescr'], 'hrDeviceStatus' => $hrDevice['hrDeviceStatus'], 'hrDeviceErrors' => (int) $hrDevice['hrDeviceErrors']], 'hrDevice');
echo '+';
d_echo($hrDevice);
d_echo("$inserted_rows row inserted");

View File

@ -120,7 +120,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
// Check whether the Virtual Machine is already known for this host.
$result = dbFetchRow("SELECT * FROM `vminfo` WHERE `device_id` = ? AND `vmwVmVMID` = ? AND `vm_type` = 'libvirt'", [$device['device_id'], $dom_id]);
if (count($result['device_id']) == 0) {
$inserted_id = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'libvirt', 'vmwVmVMID' => $dom_id, 'vmwVmDisplayName' => mres($vmwVmDisplayName), 'vmwVmGuestOS' => mres($vmwVmGuestOS), 'vmwVmMemSize' => mres($vmwVmMemSize), 'vmwVmCpus' => mres($vmwVmCpus), 'vmwVmState' => mres($vmwVmState)], 'vminfo');
$inserted_id = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'libvirt', 'vmwVmVMID' => $dom_id, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus, 'vmwVmState' => $vmwVmState], 'vminfo');
echo '+';
log_event("Virtual Machine added: $vmwVmDisplayName ($vmwVmMemSize MB)", $device, 'vm', 3, $inserted_id);
} else {
@ -130,7 +130,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
|| $result['vmwVmGuestOS'] != $vmwVmGuestOS
|| $result['vmwVmMemSize'] != $vmwVmMemSize
) {
dbUpdate(['vmwVmState' => mres($vmwVmState), 'vmwVmGuestOS' => mres($vmwVmGuestOS), 'vmwVmDisplayName' => mres($vmwVmDisplayName), 'vmwVmMemSize' => mres($vmwVmMemSize), 'vmwVmCpus' => mres($vmwVmCpus)], 'vminfo', "device_id=? AND vm_type='libvirt' AND vmwVmVMID=?", [$device['device_id'], $dom_id]);
dbUpdate(['vmwVmState' => $vmwVmState, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus], 'vminfo', "device_id=? AND vm_type='libvirt' AND vmwVmVMID=?", [$device['device_id'], $dom_id]);
echo 'U';
// FIXME eventlog
} else {

View File

@ -36,8 +36,8 @@ foreach ($oids as $index => $entry) {
* Check if the MEF is already known for this host
*/
if (dbFetchCell('SELECT COUNT(id) FROM `mefinfo` WHERE `device_id` = ? AND `mefID` = ?', [$device['device_id'], $index]) == 0) {
$mefid = dbInsert(['device_id' => $device['device_id'], 'mefID' => $index, 'mefType' => mres($mefType), 'mefIdent' => mres($mefIdent), 'mefMTU' => mres($mefMtu), 'mefAdmState' => mres($mefAdmState), 'mefRowState' => mres($mefRowState)], 'mefinfo');
log_event('MEF link: ' . mres($mefIdent) . ' (' . $index . ') Discovered', $device, 'system', 2);
$mefid = dbInsert(['device_id' => $device['device_id'], 'mefID' => $index, 'mefType' => $mefType, 'mefIdent' => $mefIdent, 'mefMTU' => $mefMtu, 'mefAdmState' => $mefAdmState, 'mefRowState' => $mefRowState], 'mefinfo');
log_event('MEF link: ' . $mefIdent . ' (' . $index . ') Discovered', $device, 'system', 2);
echo '+';
} else {
echo '.';
@ -59,7 +59,7 @@ foreach (dbFetchRows($sql) as $db_mef) {
*/
if (! in_array($db_mef['mefID'], $mef_list)) {
dbDelete('mefinfo', '`id` = ?', [$db_mef['id']]);
log_event('MEF link: ' . mres($db_mef['mefIdent']) . ' Removed', $device, 'system', 3);
log_event('MEF link: ' . $db_mef['mefIdent'] . ' Removed', $device, 'system', 3);
echo '-';
}
}

View File

@ -38,9 +38,9 @@ $ports_db = $ports_mapped['ports'];
foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) {
foreach (['', '-adsl', '-dot3'] as $suffix) {
$old_rrd_name = "port-$ifIndex$suffix.rrd";
$new_rrd_name = getPortRrdName($port_id, ltrim($suffix, '-'));
$new_rrd_name = \Rrd::portName($port_id, ltrim($suffix, '-'));
rrd_file_rename($device, $old_rrd_name, $new_rrd_name);
\Rrd::renameFile($device, $old_rrd_name, $new_rrd_name);
}
}

View File

@ -115,7 +115,7 @@ foreach ($tables as $tablevalue) {
} elseif ($state_name == 'dell.arrayDiskState') {
$descr = str_replace('"', '', snmp_get($device, 'arrayDiskEnclosureConnectionEnclosureName.' . $index . '', '-Ovqn', $tablevalue[4])) . ' - ' . $temp[$index][$tablevalue[3]];
} else {
$descr = clean($temp[$index][$tablevalue[3]]); // Use clean as virtualDiskDeviceName is user defined
$descr = strip_tags($temp[$index][$tablevalue[3]]); // Use clean as virtualDiskDeviceName is user defined
}
//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index);

View File

@ -173,7 +173,7 @@ foreach ($pre_cache['mem_sensors_status'] as $index => $data) {
if (is_numeric($value)) {
$user_func = null;
if ($pre_cache['memSensorsStatusSysTempUnits'] === 'fahrenheit') {
$user_func = 'convert_to_celsius';
$user_func = 'fahrenheit_to_celsius';
}
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid, 'memSensorsTemperature.' . $index, 'apc', $descr, $divisor, $multiplier, null, null, null, null, $value, 'snmp', null, null, $user_func);
}

View File

@ -28,9 +28,11 @@ $temperature_unit = trim(snmp_get($device, '.1.3.6.1.4.1.7428.1.2.2.1.1.12.1', '
$temperature = trim(snmp_get($device, '.1.3.6.1.4.1.7428.1.2.2.1.1.11.1', '-Oqv'), '" ');
if (! empty($temperature_unit) && ! empty($temperature)) {
// If fahrenheit convert to celcius
// If fahrenheit convert to celsius
$function = null;
if ($temperature_unit == '2') {
$temperature = ($temperature - 32) / 1.8;
$function = 'fahrenheit_to_celsius';
$temperature = fahrenheit_to_celsius($temperature);
}
$divisor = 1;
@ -40,5 +42,5 @@ if (! empty($temperature_unit) && ! empty($temperature)) {
$oid = '.1.3.6.1.4.1.7428.1.2.2.1.1.11.1';
$current_value = $temperature / $divisor;
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current_value);
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current_value, 'snmp', null, null, $function);
}

View File

@ -40,7 +40,7 @@ if (is_array($hrstorage_array)) {
if (Str::startsWith($device['os'], 'vmware') && $descr == 'Real Memory') {
$old_rrdfile = ['storage', 'hrstorage', $descr];
$new_rrdfile = ['mempool', 'hrstorage', $storage['hrStorageIndex']];
rrd_file_rename($device, $old_rrdfile, $new_rrdfile);
\Rrd::renameFile($device, $old_rrdfile, $new_rrdfile);
continue;
}

View File

@ -43,8 +43,8 @@ if (($device['os'] == 'vmware-esxi') || ($device['os'] == 'linux')) {
* Check whether the Virtual Machine is already known for this host.
*/
if (dbFetchCell("SELECT COUNT(id) FROM `vminfo` WHERE `device_id` = ? AND `vmwVmVMID` = ? AND vm_type='vmware'", [$device['device_id'], $index]) == 0) {
$vmid = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => mres($vmwVmDisplayName), 'vmwVmGuestOS' => mres($vmwVmGuestOS), 'vmwVmMemSize' => mres($vmwVmMemSize), 'vmwVmCpus' => mres($vmwVmCpus), 'vmwVmState' => mres($vmwVmState)], 'vminfo');
log_event(mres($vmwVmDisplayName) . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', 3, $vmid);
$vmid = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus, 'vmwVmState' => $vmwVmState], 'vminfo');
log_event($vmwVmDisplayName . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', 3, $vmid);
echo '+';
// FIXME eventlog
} else {
@ -71,7 +71,7 @@ if (($device['os'] == 'vmware-esxi') || ($device['os'] == 'linux')) {
if (! in_array($db_vm['vmwVmVMID'], $vmw_vmlist)) {
dbDelete('vminfo', '`id` = ?', [$db_vm['id']]);
log_event(mres($db_vm['vmwVmDisplayName']) . ' Removed', $device, 'system', 4, $db_vm['vmwVmVMID']);
log_event($db_vm['vmwVmDisplayName'] . ' Removed', $device, 'system', 4, $db_vm['vmwVmVMID']);
echo '-';
// FIXME eventlog
}

View File

@ -98,11 +98,6 @@ function array_sort_by_column($array, $on, $order = SORT_ASC)
return $new_array;
}
function mac_clean_to_readable($mac)
{
return \LibreNMS\Util\Rewrite::readableMac($mac);
}
function only_alphanumeric($string)
{
return preg_replace('/[^a-zA-Z0-9]/', '', $string);
@ -308,7 +303,7 @@ function renamehost($id, $new, $source = 'console')
{
$host = gethostbyid($id);
if (! is_dir(get_rrd_dir($new)) && rename(get_rrd_dir($host), get_rrd_dir($new)) === true) {
if (! is_dir(Rrd::dirFromHost($new)) && rename(Rrd::dirFromHost($host), Rrd::dirFromHost($new)) === true) {
dbUpdate(['hostname' => $new, 'ip' => null], 'devices', 'device_id=?', [$id]);
log_event("Hostname changed -> $new ($source)", $id, 'system', 3);
@ -322,8 +317,6 @@ function renamehost($id, $new, $source = 'console')
function device_discovery_trigger($id)
{
global $debug;
if (isCli() === false) {
ignore_user_abort(true);
set_time_limit(0);
@ -391,7 +384,7 @@ function delete_device($id)
}
}
$ex = shell_exec("bash -c '( [ ! -d " . trim(get_rrd_dir($host)) . ' ] || rm -vrf ' . trim(get_rrd_dir($host)) . " 2>&1 ) && echo -n OK'");
$ex = shell_exec("bash -c '( [ ! -d " . trim(Rrd::dirFromHost($host)) . ' ] || rm -vrf ' . trim(Rrd::dirFromHost($host)) . " 2>&1 ) && echo -n OK'");
$tmp = explode("\n", $ex);
if ($tmp[sizeof($tmp) - 1] != 'OK') {
$ret .= "Could not remove files:\n$ex\n";
@ -542,11 +535,6 @@ function deviceArray($host, $community, $snmpver, $port = 161, $transport = 'udp
return $device;
}//end deviceArray()
function formatUptime($diff, $format = 'long')
{
return Time::formatInterval($diff, $format);
}
function isSNMPable($device)
{
$pos = snmp_check($device);
@ -712,11 +700,6 @@ function isDomainResolves($domain)
return ! empty($records);
}
function hoststatus($id)
{
return dbFetchCell('SELECT `status` FROM `devices` WHERE `device_id` = ?', [$id]);
}
function match_network($nets, $ip, $first = false)
{
$return = false;
@ -1176,9 +1159,8 @@ function get_guzzle_proxy()
$tmp = rtrim($proxy, '/');
$proxy = str_replace(['http://', 'https://'], '', $tmp);
if (! empty($proxy)) {
return 'tcp://' . $proxy;
}
return empty($proxy) ? '' : ('tcp://' . $proxy);
}
/**
@ -1212,27 +1194,6 @@ function target_to_id($target)
return $target;
}
function id_to_target($id)
{
if ($id[0] == 'g') {
$id = 'g:' . dbFetchCell('SELECT name FROM device_groups WHERE id = ?', [substr($id, 1)]);
} else {
$id = dbFetchCell('SELECT hostname FROM devices WHERE device_id = ?', [$id]);
}
return $id;
}
function first_oid_match($device, $list)
{
foreach ($list as $item) {
$tmp = trim(snmp_get($device, $item, '-Ovq'), '" ');
if (! empty($tmp)) {
return $tmp;
}
}
}
function fix_integer_value($value)
{
if ($value < 0) {
@ -2145,22 +2106,6 @@ function lock_and_purge_query($table, $sql, $msg)
return -1;
}
/**
* Convert space separated hex OID content to character
*
* @param string $hex_string
* @return string $chr_string
*/
function hexbin($hex_string)
{
$chr_string = '';
foreach (explode(' ', $hex_string) as $a) {
$chr_string .= chr(hexdec($a));
}
return $chr_string;
}
/**
* Check if disk is valid to poll.
* Settings: bad_disk_regexp

View File

@ -184,12 +184,12 @@ function get_port_stats_by_port_hostname(Illuminate\Http\Request $request)
return check_port_permission($port['port_id'], $device_id, function () use ($request, $port) {
$in_rate = $port['ifInOctets_rate'] * 8;
$out_rate = $port['ifOutOctets_rate'] * 8;
$port['in_rate'] = formatRates($in_rate);
$port['out_rate'] = formatRates($out_rate);
$port['in_rate'] = \LibreNMS\Util\Number::formatSi($in_rate, 2, 3, 'bps');
$port['out_rate'] = \LibreNMS\Util\Number::formatSi($out_rate, 2, 3, 'bps');
$port['in_perc'] = number_format($in_rate / $port['ifSpeed'] * 100, 2, '.', '');
$port['out_perc'] = number_format($out_rate / $port['ifSpeed'] * 100, 2, '.', '');
$port['in_pps'] = format_bi($port['ifInUcastPkts_rate']);
$port['out_pps'] = format_bi($port['ifOutUcastPkts_rate']);
$port['in_pps'] = \LibreNMS\Util\Number::formatBi($port['ifInUcastPkts_rate'], 2, 3, '');
$port['out_pps'] = \LibreNMS\Util\Number::formatBi($port['ifOutUcastPkts_rate'], 2, 3, '');
//only return requested columns
if ($request->has('columns')) {
@ -1458,15 +1458,15 @@ function list_bills(Illuminate\Http\Request $request)
$overuse = '';
if (strtolower($bill['bill_type']) == 'cdr') {
$allowed = format_si($bill['bill_cdr']) . 'bps';
$used = format_si($rate_data['rate_95th']) . 'bps';
$allowed = \LibreNMS\Util\Number::formatSi($bill['bill_cdr'], 2, 3, '') . 'bps';
$used = \LibreNMS\Util\Number::formatSi($rate_data['rate_95th'], 2, 3, '') . 'bps';
if ($bill['bill_cdr'] > 0) {
$percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100, 2);
} else {
$percent = '-';
}
$overuse = $rate_data['rate_95th'] - $bill['bill_cdr'];
$overuse = (($overuse <= 0) ? '-' : format_si($overuse));
$overuse = (($overuse <= 0) ? '-' : \LibreNMS\Util\Number::formatSi($overuse, 2, 3, ''));
} elseif (strtolower($bill['bill_type']) == 'quota') {
$allowed = format_bytes_billing($bill['bill_quota']);
$used = format_bytes_billing($rate_data['total_data']);

View File

@ -217,13 +217,13 @@ if (defined('SHOW_SETTINGS')) {
$deviceLabelOld = 'availability-map-oldview-box-up';
$host_up_count++;
}
$updowntime = ($device['uptime'] ? ' - ' : '') . formatUptime($device['uptime']);
$updowntime = ($device['uptime'] ? ' - ' : '') . \LibreNMS\Util\Time::formatInterval($device['uptime']);
} else {
$deviceState = 'down';
$deviceLabel = 'label-danger';
$deviceLabelOld = 'availability-map-oldview-box-down';
$host_down_count++;
$updowntime = ($device['last_polled'] ? ' - ' . formatUptime(time() - strtotime($device['last_polled'])) : '');
$updowntime = ($device['last_polled'] ? ' - ' . \LibreNMS\Util\Time::formatInterval(time() - strtotime($device['last_polled'])) : '');
}
if (AlertUtil::isMaintenance($device['device_id'])) {
@ -237,7 +237,7 @@ if (defined('SHOW_SETTINGS')) {
if ($directpage == 'yes') {
$deviceIcon = getIconTag($device);
$temp_output[] = '
<a href="' . generate_device_url($device) . '" title="' . $device_system_name . $updowntime . '">
<a href="' . \LibreNMS\Util\Url::deviceUrl((int) $device['device_id']) . '" title="' . $device_system_name . $updowntime . '">
<div class="device-availability ' . $deviceState . '" style="width:' . Config::get('webui.availability_map_box_size') . 'px;">
<span class="availability-label label ' . $deviceLabel . ' label-font-border">' . $deviceState . '</span>
<span class="device-icon">' . $deviceIcon . '</span><br>
@ -250,12 +250,12 @@ if (defined('SHOW_SETTINGS')) {
$deviceLabel .= ' widget-availability-fixed';
}
$temp_output[] = '
<a href="' . generate_device_url($device) . '" title="' . $device_system_name . $updowntime . '">
<a href="' . \LibreNMS\Util\Url::deviceUrl((int) $device['device_id']) . '" title="' . $device_system_name . $updowntime . '">
<span class="label ' . $deviceLabel . ' widget-availability label-font-border">' . $deviceState . '</span>
</a>';
}
} else {
$temp_output[] = "<a href='" . generate_device_url($device) . "' title='" . $device_system_name . $updowntime . "'><div class='" . $deviceLabelOld . "' style='width:${compact_tile}px;height:${compact_tile}px;'></div></a>";
$temp_output[] = "<a href='" . \LibreNMS\Util\Url::deviceUrl((int) $device['device_id']) . "' title='" . $device_system_name . $updowntime . "'><div class='" . $deviceLabelOld . "' style='width:${compact_tile}px;height:${compact_tile}px;'></div></a>";
}
}
}
@ -293,7 +293,7 @@ if (defined('SHOW_SETTINGS')) {
if ($directpage == 'yes') {
$deviceIcon = getIconTag($service);
$temp_output[] = '
<a href="' . generate_url(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . '" title="' . $service_system_name . ' - ' . $service['service_type'] . ' - ' . $service['service_desc'] . '">
<a href="' . \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . '" title="' . $service_system_name . ' - ' . $service['service_type'] . ' - ' . $service['service_desc'] . '">
<div class="service-availability ' . $serviceState . '" style="width:' . Config::get('webui.availability_map_box_size') . 'px;">
<span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service['service_type'] . '</span>
<span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
@ -308,12 +308,12 @@ if (defined('SHOW_SETTINGS')) {
$serviceLabel .= ' widget-availability-fixed';
}
$temp_output[] = '
<a href="' . generate_url(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . '" title="' . shorthost($service_system_name) . ' - ' . $service['service_type'] . ' - ' . $service['service_desc'] . '">
<a href="' . \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . '" title="' . shorthost($service_system_name) . ' - ' . $service['service_type'] . ' - ' . $service['service_desc'] . '">
<span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $serviceText . '</span>
</a>';
}
} else {
$temp_output[] = "<a href='" . generate_url(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . "' title='${service_system_name} - ${service['service_type']} - ${service['service_desc']}'><div class='" . $serviceLabelOld . "' style='width:${compact_tile}px;height:${compact_tile}px;'></div></a>";
$temp_output[] = "<a href='" . \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $service['device_id'], 'tab' => 'services']) . "' title='${service_system_name} - ${service['service_type']} - ${service['service_desc']}'><div class='" . $serviceLabelOld . "' style='width:${compact_tile}px;height:${compact_tile}px;'></div></a>";
}
}
} else {

View File

@ -49,7 +49,7 @@ searchbar = "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">
$tmp_output .= '"<div class=\"form-group\"><select name=\"stream\" id=\"stream\" class=\"form-control\" data-placeholder=\"All Messages\">"+';
if ($vars['stream']) {
$tmp_output .= '"<option value=\"' . display($vars['stream']) . '\">' . display($vars['stream']) . '</option>" +';
$tmp_output .= '"<option value=\"' . \LibreNMS\Util\Clean::html($vars['stream'], []) . '\">' . \LibreNMS\Util\Clean::html($vars['stream'], []) . '</option>" +';
$filter_device = $device->device_id;
}
$tmp_output .= '"</select>&nbsp;</div>"+';
@ -61,7 +61,7 @@ if (! empty($filter_device)) {
} else {
$tmp_output .= '
"<div class=\"form-group\"><select name=\"device\" id=\"device\" class=\"form-control\" data-placeholder=\"All Devices\">"+
';
if ($vars['device'] && $device = Device::find($vars['device'])) {
$tmp_output .= '"<option value=\"' . $device->device_id . '\">' . $device->displayName() . '</option>" +';
@ -133,16 +133,16 @@ $tmp_output .= '
post: function ()
{
return {
stream: "' . (isset($_POST['stream']) ? mres($_POST['stream']) : '') . '",
stream: "' . (isset($_POST['stream']) ? $_POST['stream'] : '') . '",
device: "' . (isset($filter_device) ? $filter_device : '') . '",
range: "' . (isset($_POST['range']) ? mres($_POST['range']) : '') . '",
loglevel: "' . (isset($_POST['loglevel']) ? mres($_POST['loglevel']) : '') . '",
range: "' . (isset($_POST['range']) ? $_POST['range'] : '') . '",
loglevel: "' . (isset($_POST['loglevel']) ? $_POST['loglevel'] : '') . '",
};
},
url: "' . url('/ajax/table/graylog') . '",
});
init_select2("#stream", "graylog-streams", {}, "' . (isset($_POST['stream']) ? mres($_POST['stream']) : '') . '");
init_select2("#stream", "graylog-streams", {}, "' . (isset($_POST['stream']) ? $_POST['stream'] : '') . '");
init_select2("#device", "device", {limit: 100}, "' . (isset($filter_device) ? $filter_device : '') . '");
</script>

View File

@ -122,7 +122,7 @@ var greenMarker = L.AwesomeMarkers.icon({
$z_offset = 10000; // move marker to foreground
}
}
$temp_output .= "var title = '<a href=\"" . generate_device_url($map_devices) . '"><img src="' . getIcon($map_devices) . '" width="32" height="32" alt=""> ' . format_hostname($map_devices) . "</a>';
$temp_output .= "var title = '<a href=\"" . \LibreNMS\Util\Url::deviceUrl((int) $map_devices['device_id']) . '"><img src="' . getIcon($map_devices) . '" width="32" height="32" alt=""> ' . format_hostname($map_devices) . "</a>';
var tooltip = '" . format_hostname($map_devices) . "';
var marker = L.marker(new L.LatLng(" . $map_devices['lat'] . ', ' . $map_devices['lng'] . "), {title: tooltip, icon: $icon, zIndexOffset: $z_offset});
marker.bindPopup(title);
@ -132,7 +132,7 @@ marker.bindPopup(title);
if (Config::get('network_map_show_on_worldmap')) {
if (Auth::user()->hasGlobalRead()) {
$sql = "
SELECT
SELECT
ll.id AS left_id,
ll.lat AS left_lat,
ll.lng AS left_lng,
@ -151,9 +151,9 @@ marker.bindPopup(title);
ports as lp
WHERE
l.local_device_id = ld.device_id
AND l.remote_device_id = rd.device_id
AND l.remote_device_id = rd.device_id
AND ld.location_id != rd.location_id
AND ld.location_id = ll.id
AND ld.location_id = ll.id
AND rd.location_id = rl.id
AND lp.device_id = ld.device_id
AND lp.port_id = l.local_port_id
@ -178,7 +178,7 @@ marker.bindPopup(title);
} else {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$sql = "
SELECT
SELECT
ll.id AS left_id,
ll.lat AS left_lat,
ll.lng AS left_lng,
@ -197,9 +197,9 @@ marker.bindPopup(title);
ports as lp
WHERE
l.local_device_id = ld.device_id
AND l.remote_device_id = rd.device_id
AND l.remote_device_id = rd.device_id
AND ld.location_id != rd.location_id
AND ld.location_id = ll.id
AND ld.location_id = ll.id
AND rd.location_id = rl.id
AND lp.device_id = ld.device_id
AND lp.port_id = l.local_port_id

View File

@ -14,7 +14,7 @@ echo "<div class='row'>
if (Config::get('overview_show_sysDescr')) {
echo '<i class="fa fa-id-card fa-lg icon-theme" aria-hidden="true"></i> <strong>';
echo Config::get('overview_show_sysDescr', true) ? display($device['sysDescr']) : 'System';
echo Config::get('overview_show_sysDescr', true) ? Clean::html($device['sysDescr'], []) : 'System';
echo '</strong>';
}
@ -35,7 +35,7 @@ $device['os_text'] = Config::getOsSetting($device['os'], 'text');
echo '<div class="row">
<div class="col-sm-4">System Name</div>
<div class="col-sm-8">' . display($device['sysName']) . ' </div>
<div class="col-sm-8">' . Clean::html($device['sysName'], []) . ' </div>
</div>';
if (! empty($device['overwrite_ip'])) {
@ -54,33 +54,33 @@ if (! empty($device['overwrite_ip'])) {
if ($device['purpose']) {
echo '<div class="row">
<div class="col-sm-4">Description</div>
<div class="col-sm-8">' . display($device['purpose']) . '</div>
<div class="col-sm-8">' . Clean::html($device['purpose'], []) . '</div>
</div>';
}
if ($device['hardware']) {
echo '<div class="row">
<div class="col-sm-4">Hardware</div>
<div class="col-sm-8">' . display($device['hardware']) . '</div>
<div class="col-sm-8">' . Clean::html($device['hardware'], []) . '</div>
</div>';
}
echo '<div class="row">
<div class="col-sm-4 text-nowrap">Operating System</div>
<div class="col-sm-8">' . display($device['os_text'] . ' ' . $device['version'] . ' ' . $device['features']) . ' </div>
<div class="col-sm-8">' . Clean::html($device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'], []) . ' </div>
</div>';
if ($device['serial']) {
echo '<div class="row">
<div class="col-sm-4">Serial</div>
<div class="col-sm-8">' . display($device['serial']) . '</div>
<div class="col-sm-8">' . Clean::html($device['serial'], []) . '</div>
</div>';
}
if ($device['sysObjectID']) {
echo '<div class="row">
<div class="col-sm-4">Object ID</div>
<div class="col-sm-8">' . display($device['sysObjectID']) . '</div>
<div class="col-sm-8">' . Clean::html($device['sysObjectID'], []) . '</div>
</div>';
}
@ -130,7 +130,7 @@ if ($device['location_id']) {
echo '
<div class="row">
<div class="col-sm-4">Location</div>
<div class="col-sm-8">' . display($location->display()) . '</div>
<div class="col-sm-8">' . Clean::html($location->display(), []) . '</div>
</div>
<div class="row" id="coordinates-row" data-toggle="collapse" data-target="#toggle-map">
<div class="col-sm-4">Lat / Lng</div>

View File

@ -50,16 +50,16 @@ if ($override_query === 'on') {
$query = QueryBuilderParser::fromJson($builder_json)->toSql();
}
$rule_id = $_POST['rule_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$interval = mres($_POST['interval']);
$mute = mres(isset($_POST['mute']) ? $_POST['mute'] : null);
$invert = mres(isset($_POST['invert']) ? $_POST['invert'] : null);
$name = mres($_POST['name']);
$proc = mres($_POST['proc']);
$count = $_POST['count'];
$delay = $_POST['delay'];
$interval = $_POST['interval'];
$mute = isset($_POST['mute']) ? $_POST['mute'] : null;
$invert = isset($_POST['invert']) ? $_POST['invert'] : null;
$name = $_POST['name'];
$proc = $_POST['proc'];
$recovery = ($vars['recovery']);
$invert_map = mres(isset($_POST['invert_map']) ? $_POST['invert_map'] : null);
$severity = mres($_POST['severity']);
$invert_map = isset($_POST['invert_map']) ? $_POST['invert_map'] : null;
$severity = $_POST['severity'];
if (! is_numeric($count)) {
$count = '-1';

View File

@ -31,7 +31,7 @@ $template_id = 0;
$template_newid = 0;
$create = true;
$name = mres($vars['name']);
$name = $vars['name'];
if (isset($vars['template']) && empty(view(['template' => $vars['template']], [])->__toString())) {
$message = 'Template failed to be parsed, please check the syntax';
} elseif (! empty($name)) {

View File

@ -22,12 +22,12 @@ $rule = implode(' ', $_POST['rules']);
$rule = rtrim($rule, '&|');
$query = AlertDB::genSQL($rule);
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$interval = mres($_POST['interval']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
$count = $_POST['count'];
$delay = $_POST['delay'];
$interval = $_POST['interval'];
$mute = $_POST['mute'];
$invert = $_POST['invert'];
$name = $_POST['name'];
if ($_POST['proc'] != '') {
$proc = $_POST['proc'];
} else {
@ -65,7 +65,7 @@ if (empty($rule)) {
];
$extra_json = json_encode($extra);
if (is_numeric($alert_id) && $alert_id > 0) {
if (dbUpdate(['rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name, 'proc' => $proc, 'query' => $query], 'alert_rules', 'id=?', [$alert_id]) >= 0) {
if (dbUpdate(['rule' => $rule, 'severity' => $_POST['severity'], 'extra' => $extra_json, 'name' => $name, 'proc' => $proc, 'query' => $query], 'alert_rules', 'id=?', [$alert_id]) >= 0) {
$update_message = "Edited Rule: <i>$name: $rule</i>";
} else {
$update_message = 'ERROR: Failed to edit Rule: <i>' . $rule . '</i>';
@ -74,7 +74,7 @@ if (empty($rule)) {
if (is_array($_POST['maps'])) {
$device_id = ':' . $device_id;
}
if (dbInsert(['device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'disabled' => 0, 'name' => $name, 'proc' => $proc, 'query' => $query], 'alert_rules')) {
if (dbInsert(['device_id' => $device_id, 'rule' => $rule, 'severity' => $_POST['severity'], 'extra' => $extra_json, 'disabled' => 0, 'name' => $name, 'proc' => $proc, 'query' => $query], 'alert_rules')) {
$update_message = "Added Rule: <i>$name: $rule</i>";
if (is_array($_POST['maps'])) {
foreach ($_POST['maps'] as $target) {

View File

@ -16,57 +16,57 @@ $message = '';
$device_id = $_POST['device_id'];
$id = $_POST['ccustomoid_id'];
$action = mres($_POST['action']);
$name = mres($_POST['name']);
$oid = mres($_POST['oid']);
$datatype = mres($_POST['datatype']);
if (empty(mres($_POST['unit']))) {
$action = $_POST['action'];
$name = $_POST['name'];
$oid = $_POST['oid'];
$datatype = $_POST['datatype'];
if (empty(($_POST['unit']))) {
$unit = ['NULL'];
} else {
$unit = mres($_POST['unit']);
$unit = $_POST['unit'];
}
if (! empty(mres($_POST['limit'])) && is_numeric(mres($_POST['limit']))) {
$limit = mres($_POST['limit']);
if (! empty(($_POST['limit'])) && is_numeric($_POST['limit'])) {
$limit = $_POST['limit'];
} else {
$limit = ['NULL'];
}
if (! empty(mres($_POST['limit_warn'])) && is_numeric(mres($_POST['limit_warn']))) {
$limit_warn = mres($_POST['limit_warn']);
if (! empty(($_POST['limit_warn'])) && is_numeric($_POST['limit_warn'])) {
$limit_warn = $_POST['limit_warn'];
} else {
$limit_warn = ['NULL'];
}
if (! empty(mres($_POST['limit_low'])) && is_numeric(mres($_POST['limit_low']))) {
$limit_low = mres($_POST['limit_low']);
if (! empty(($_POST['limit_low'])) && is_numeric($_POST['limit_low'])) {
$limit_low = $_POST['limit_low'];
} else {
$limit_low = ['NULL'];
}
if (! empty(mres($_POST['limit_low_warn'])) && is_numeric(mres($_POST['limit_low_warn']))) {
$limit_low_warn = mres($_POST['limit_low_warn']);
if (! empty(($_POST['limit_low_warn'])) && is_numeric($_POST['limit_low_warn'])) {
$limit_low_warn = $_POST['limit_low_warn'];
} else {
$limit_low_warn = ['NULL'];
}
if (mres($_POST['alerts']) == 'on') {
if ($_POST['alerts'] == 'on') {
$alerts = 1;
} else {
$alerts = 0;
}
if (mres($_POST['passed']) == 'on') {
if ($_POST['passed'] == 'on') {
$passed = 1;
} else {
$passed = 0;
}
if (! empty(mres($_POST['divisor'])) && is_numeric(mres($_POST['divisor']))) {
$divisor = mres($_POST['divisor']);
if (! empty(($_POST['divisor'])) && is_numeric($_POST['divisor'])) {
$divisor = $_POST['divisor'];
} else {
$divisor = 1;
}
if (! empty(mres($_POST['multiplier'])) && is_numeric(mres($_POST['multiplier']))) {
$multiplier = mres($_POST['multiplier']);
if (! empty(($_POST['multiplier'])) && is_numeric($_POST['multiplier'])) {
$multiplier = $_POST['multiplier'];
} else {
$multiplier = 1;
}
if (! empty(mres($_POST['user_func']))) {
$user_func = mres($_POST['user_func']);
if (! empty(($_POST['user_func']))) {
$user_func = $_POST['user_func'];
} else {
$user_func = ['NULL'];
}

View File

@ -25,7 +25,7 @@ $status = 'error';
$message = 'unknown error';
$dashboard_id = (int) $_REQUEST['dashboard_id'];
$dashboard_name = display($_REQUEST['dashboard_name']);
$dashboard_name = \LibreNMS\Util\Clean::html($_REQUEST['dashboard_name'], []);
$access = $_REQUEST['access'];
if (isset($dashboard_id) && isset($dashboard_name) && isset($access)) {

View File

@ -51,7 +51,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
if (isset($_POST['format']) && ! empty($_POST['searchPhrase'])) {
$searchphrase = '%' . mres($_POST['searchPhrase']) . '%';
$searchphrase = '%' . $_POST['searchPhrase'] . '%';
$search_arr = [$searchphrase, $searchphrase, $searchphrase];
$device_deps = dbFetchRows($deps_query, $search_arr);
$rec_count = dbFetchCell($count_query, $search_arr);

View File

@ -26,9 +26,9 @@ if (! Auth::user()->hasGlobalAdmin()) {
$status = 'error';
$message = 'Error updating mempool information';
$device_id = mres($_POST['device_id']);
$mempool_id = mres($_POST['mempool_id']);
$data = mres($_POST['data']);
$device_id = $_POST['device_id'];
$mempool_id = $_POST['mempool_id'];
$data = $_POST['data'];
if (! is_numeric($device_id)) {
$message = 'Missing device id';

View File

@ -23,9 +23,9 @@ if (! Auth::user()->hasGlobalAdmin()) {
exit;
}
$device['device_id'] = mres($_POST['device_id']);
$attrib = mres($_POST['attrib']);
$state = mres($_POST['state']);
$device['device_id'] = $_POST['device_id'];
$attrib = $_POST['attrib'];
$state = $_POST['state'];
$status = 'error';
$message = 'Error with config';

View File

@ -21,8 +21,8 @@ if (! Auth::user()->hasGlobalAdmin()) {
$ok = '';
$error = '';
$group_id = $_POST['group_id'];
$group_name = mres($_POST['group_name']);
$descr = mres($_POST['descr']);
$group_name = $_POST['group_name'];
$descr = $_POST['descr'];
if (! empty($group_name)) {
if (is_numeric($group_id)) {
if (dbUpdate(['group_name' => $group_name, 'descr' => $descr], 'poller_groups', 'id = ?', [$group_id]) >= 0) {

View File

@ -26,9 +26,9 @@ if (! Auth::user()->hasGlobalAdmin()) {
$status = 'error';
$message = 'Error updating processor information';
$device_id = mres($_POST['device_id']);
$processor_id = mres($_POST['processor_id']);
$data = mres($_POST['data']);
$device_id = $_POST['device_id'];
$processor_id = $_POST['processor_id'];
$data = $_POST['data'];
if (! is_numeric($device_id)) {
$message = 'Missing device id';

View File

@ -12,7 +12,7 @@
header('Content-type: application/json');
$device_hostname = clean($_POST['device_hostname']);
$device_hostname = strip_tags($_POST['device_hostname']);
if (Auth::user()->hasGlobalAdmin() && isset($device_hostname)) {
if (oxidized_node_update($device_hostname, 'LibreNMS GUI refresh', Auth::user()->username)) {
$status = 'ok';

View File

@ -28,23 +28,23 @@ if ($sub_type == 'new-maintenance') {
$update = 0;
$message = '';
$schedule_id = mres($_POST['schedule_id']);
$schedule_id = $_POST['schedule_id'];
if ($schedule_id > 0) {
$update = 1;
}
$title = mres($_POST['title']);
$notes = mres($_POST['notes']);
$title = $_POST['title'];
$notes = $_POST['notes'];
$recurring = $_POST['recurring'] ? 1 : 0;
$start_recurring_dt = mres($_POST['start_recurring_dt']);
$end_recurring_dt = mres($_POST['end_recurring_dt']);
$start_recurring_hr = mres($_POST['start_recurring_hr']);
$end_recurring_hr = mres($_POST['end_recurring_hr']);
$recurring_day = mres($_POST['recurring_day']);
$start = mres($_POST['start']);
[$duration_hour, $duration_min] = explode(':', mres($_POST['duration']));
$end = mres($_POST['end']);
$maps = mres($_POST['maps']);
$start_recurring_dt = $_POST['start_recurring_dt'];
$end_recurring_dt = $_POST['end_recurring_dt'];
$start_recurring_hr = $_POST['start_recurring_hr'];
$end_recurring_hr = $_POST['end_recurring_hr'];
$recurring_day = $_POST['recurring_day'];
$start = $_POST['start'];
[$duration_hour, $duration_min] = explode(':', $_POST['duration']);
$end = $_POST['end'];
$maps = $_POST['maps'];
if (isset($duration_hour) && isset($duration_min)) {
$end = date('Y-m-d H:i:00', strtotime('+' . intval($duration_hour) . ' hour ' . intval($duration_min) . ' minute', strtotime($start)));
@ -208,7 +208,7 @@ if ($sub_type == 'new-maintenance') {
$response['recurring_day'] = $alert_schedule->getOriginal('recurring_day');
$response['targets'] = $items;
} elseif ($sub_type == 'del-maintenance') {
$schedule_id = mres($_POST['del_schedule_id']);
$schedule_id = $_POST['del_schedule_id'];
dbDelete('alert_schedule', '`schedule_id`=?', [$schedule_id]);
dbDelete('alert_schedulables', '`schedule_id`=?', [$schedule_id]);
$status = 'ok';

View File

@ -13,7 +13,7 @@ header('Content-type: application/json');
$status = 'error';
$message = 'unknown error';
$parameters = clean($_POST['search_in_conf_textbox']);
$parameters = strip_tags($_POST['search_in_conf_textbox']);
if (isset($parameters)) {
$message = 'Queried';
if ($output = search_oxidized_config($parameters)) {
@ -22,9 +22,9 @@ if (isset($parameters)) {
} else {
$message = 'ERROR: Could not query';
}
echo display(json_encode([
echo \LibreNMS\Util\Clean::html(json_encode([
'status' => $status,
'message' => $message,
'search_in_conf_textbox' => $parameters,
'output' => $output,
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), []);

View File

@ -26,9 +26,9 @@ if (! Auth::user()->hasGlobalAdmin()) {
$status = 'error';
$message = 'Error updating storage information';
$device_id = mres($_POST['device_id']);
$storage_id = mres($_POST['storage_id']);
$data = mres($_POST['data']);
$device_id = $_POST['device_id'];
$storage_id = $_POST['storage_id'];
$data = $_POST['data'];
if (! is_numeric($device_id)) {
$message = 'Missing device id';

View File

@ -15,10 +15,10 @@ header('Content-type: application/json');
$status = 'error';
$descr = mres($_POST['descr']);
$device_id = mres($_POST['device_id']);
$ifName = mres($_POST['ifName']);
$port_id = mres($_POST['port_id']);
$descr = $_POST['descr'];
$device_id = $_POST['device_id'];
$ifName = $_POST['ifName'];
$port_id = $_POST['port_id'];
if (! empty($ifName) && is_numeric($port_id)) {
// We have ifName and port id so update ifAlias

View File

@ -14,10 +14,10 @@ header('Content-type: application/json');
$status = 'error';
$speed = mres($_POST['speed']);
$device_id = mres($_POST['device_id']);
$ifName = mres($_POST['ifName']);
$port_id = mres($_POST['port_id']);
$speed = $_POST['speed'];
$device_id = $_POST['device_id'];
$ifName = $_POST['ifName'];
$port_id = $_POST['port_id'];
if (! empty($ifName) && is_numeric($port_id) && is_numeric($port_id)) {
// We have ifName and port id so update ifAlias

View File

@ -14,8 +14,8 @@ header('Content-type: application/json');
$status = 'error';
$message = 'unknown error';
$device_id = mres($_POST['device_id']);
$port_id_notes = mres($_POST['port_id_notes']);
$device_id = $_POST['device_id'];
$port_id_notes = $_POST['port_id_notes'];
$attrib_value = $_POST['notes'];
if (isset($attrib_value) && set_dev_attrib(['device_id' => $device_id], $port_id_notes, $attrib_value)) {

View File

@ -11,6 +11,8 @@
*/
use LibreNMS\Config;
use LibreNMS\Util\Number;
use LibreNMS\Util\Rewrite;
/**
* Compare $t with the value of $vars[$v], if that exists
@ -52,20 +54,9 @@ function data_uri($file, $mime)
return 'data:' . $mime . ';base64,' . $base64;
}//end data_uri()
/**
* Convert string to nice case, mostly used for applications
*
* @param $item
* @return mixed|string
*/
function nicecase($item)
{
return \LibreNMS\Util\StringHelpers::niceCase($item);
}
function toner2colour($descr, $percent)
{
$colour = get_percentage_colours(100 - $percent);
$colour = \LibreNMS\Util\Colors::percentage(100 - $percent, null);
if (substr($descr, -1) == 'C' || stripos($descr, 'cyan') !== false) {
$colour['left'] = '55D6D3';
@ -110,14 +101,9 @@ function linkify($text)
function generate_link($text, $vars, $new_vars = [])
{
return '<a href="' . generate_url($vars, $new_vars) . '">' . $text . '</a>';
return '<a href="' . \LibreNMS\Util\Url::generate($vars, $new_vars) . '">' . $text . '</a>';
}//end generate_link()
function generate_url($vars, $new_vars = [])
{
return \LibreNMS\Util\Url::generate($vars, $new_vars);
}
function escape_quotes($text)
{
return str_replace('"', "\'", str_replace("'", "\'", $text));
@ -128,7 +114,7 @@ function generate_overlib_content($graph_array, $text)
$overlib_content = '<div class=overlib><span class=overlib-text>' . $text . '</span><br />';
foreach (['day', 'week', 'month', 'year'] as $period) {
$graph_array['from'] = Config::get("time.$period");
$overlib_content .= escape_quotes(generate_graph_tag($graph_array));
$overlib_content .= escape_quotes(\LibreNMS\Util\Url::graphTag($graph_array));
}
$overlib_content .= '</div>';
@ -136,98 +122,11 @@ function generate_overlib_content($graph_array, $text)
return $overlib_content;
}//end generate_overlib_content()
function get_percentage_colours($percentage, $component_perc_warn = null)
{
return \LibreNMS\Util\Colors::percentage($percentage, $component_perc_warn);
}//end get_percentage_colours()
function generate_minigraph_image($device, $start, $end, $type, $legend = 'no', $width = 275, $height = 100, $sep = '&amp;', $class = 'minigraph-image', $absolute_size = 0)
{
return '<img class="' . $class . '" width="' . $width . '" height="' . $height . '" src="graph.php?' . implode($sep, ['device=' . $device['device_id'], "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend", "absolute=$absolute_size"]) . '">';
}//end generate_minigraph_image()
function generate_device_url($device, $vars = [])
{
return \LibreNMS\Util\Url::deviceUrl((int) $device['device_id'], $vars);
}
function generate_device_link($device, $text = null, $vars = [], $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
{
if (! $start) {
$start = Config::get('time.day');
}
$deviceModel = DeviceCache::get((int) $device['device_id']);
if (! $end) {
$end = Config::get('time.now');
}
$class = devclass($device);
$text = format_hostname($device, $text);
$graphs = \LibreNMS\Util\Graph::getOverviewGraphsForDevice(DeviceCache::get($device['device_id']));
$url = generate_device_url($device, $vars);
// beginning of overlib box contains large hostname followed by hardware & OS details
$contents = '<div><span class="list-large">' . $device['hostname'] . '</span>';
if ($device['hardware']) {
$contents .= ' - ' . $device['hardware'];
}
if ($device['os']) {
$contents .= ' - ' . Config::getOsSetting($device['os'], 'text');
}
if ($device['version']) {
$contents .= ' ' . mres($device['version']);
}
if ($device['features']) {
$contents .= ' (' . mres($device['features']) . ')';
}
if (isset($device['location'])) {
$contents .= ' - ' . htmlentities($device['location']);
}
$contents .= '</div>';
foreach ($graphs as $entry) {
$graph = $entry['graph'];
$graphhead = $entry['text'];
$contents .= '<div class="overlib-box">';
$contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
$contents .= generate_minigraph_image($device, $start, $end, $graph);
$contents .= generate_minigraph_image($device, Config::get('time.week'), $end, $graph);
$contents .= '</div>';
}
if ($escape_text) {
$text = htmlentities($text);
}
if ($overlib == 0) {
$link = $contents;
} else {
$link = overlib_link($url, $text, escape_quotes($contents), $class);
}
if (device_permitted($device['device_id'])) {
return $link;
} else {
return $device['hostname'];
}
}//end generate_device_link()
function overlib_link($url, $text, $contents, $class = null)
{
return \LibreNMS\Util\Url::overlibLink($url, $text, $contents, $class);
}
function print_graph_popup($graph_array)
{
echo \LibreNMS\Util\Url::graphPopup($graph_array);
return \LibreNMS\Util\Url::deviceLink($deviceModel, $text, $vars, $start, $end, $escape_text, $overlib);
}
function bill_permitted($bill_id)
@ -274,11 +173,6 @@ function device_permitted($device_id)
return \Permissions::canAccessDevice($device_id, Auth::id());
}
function print_graph_tag($args)
{
echo generate_graph_tag($args);
}//end print_graph_tag()
function alert_layout($severity)
{
switch ($severity) {
@ -308,16 +202,6 @@ function alert_layout($severity)
'background_color' => $background, ];
}
function generate_graph_tag($args)
{
return \LibreNMS\Util\Url::graphTag($args);
}
function generate_lazy_graph_tag($args)
{
return \LibreNMS\Util\Url::lazyGraphTag($args);
}
function generate_dynamic_graph_tag($args)
{
$urlargs = [];
@ -452,7 +336,7 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
$graph_array = [];
if (! $text) {
$text = fixifName($port['label']);
$text = Rewrite::normalizeIfName($port['label']);
}
if ($type) {
@ -469,9 +353,9 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
$port = array_merge($port, device_by_id_cache($port['device_id']));
}
$content = '<div class=list-large>' . $port['hostname'] . ' - ' . fixifName(addslashes(display($port['label']))) . '</div>';
$content = '<div class=list-large>' . $port['hostname'] . ' - ' . Rewrite::normalizeIfName(addslashes(\LibreNMS\Util\Clean::html($port['label'], []))) . '</div>';
if ($port['ifAlias']) {
$content .= addslashes(display($port['ifAlias'])) . '<br />';
$content .= addslashes(\LibreNMS\Util\Clean::html($port['ifAlias'], [])) . '<br />';
}
$content .= "<div style=\'width: 850px\'>";
@ -482,14 +366,14 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
$graph_array['to'] = Config::get('time.now');
$graph_array['from'] = Config::get('time.day');
$graph_array['id'] = $port['port_id'];
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
if ($single_graph == 0) {
$graph_array['from'] = Config::get('time.week');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.month');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.year');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
}
$content .= '</div>';
@ -499,9 +383,9 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
if ($overlib == 0) {
return $content;
} elseif (port_permitted($port['port_id'], $port['device_id'])) {
return overlib_link($url, $text, $content, $class);
return \LibreNMS\Util\Url::overlibLink($url, $text, $content, $class);
} else {
return fixifName($text);
return Rewrite::normalizeIfName($text);
}
}//end generate_port_link()
@ -533,44 +417,29 @@ function generate_sensor_link($args, $text = null, $type = null)
'from' => Config::get('time.day'),
'id' => $args['sensor_id'],
];
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.week');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.month');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.year');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$content .= '</div>';
$url = generate_sensor_url($args);
$url = \LibreNMS\Util\Url::generate(['page' => 'graphs', 'id' => $args['sensor_id'], 'type' => $args['graph_type'], 'from' => \LibreNMS\Config::get('time.day')], []);
return overlib_link($url, $text, $content, null);
return \LibreNMS\Util\Url::overlibLink($url, $text, $content);
}//end generate_sensor_link()
function generate_sensor_url($sensor, $vars = [])
{
return generate_url(['page' => 'graphs', 'id' => $sensor['sensor_id'], 'type' => $sensor['graph_type'], 'from' => Config::get('time.day')], $vars);
}//end generate_sensor_url()
function generate_port_url($port, $vars = [])
{
return generate_url(['page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']], $vars);
return \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']], $vars);
}//end generate_port_url()
function generate_peer_url($peer, $vars = [])
{
return generate_url(['page' => 'device', 'device' => $peer['device_id'], 'tab' => 'routing', 'proto' => 'bgp'], $vars);
}//end generate_peer_url()
function generate_bill_url($bill, $vars = [])
{
return generate_url(['page' => 'bill', 'bill_id' => $bill['bill_id']], $vars);
}//end generate_bill_url()
function generate_sap_url($sap, $vars = [])
{
return \LibreNMS\Util\Url::graphPopup(['device' => $sap['device_id'], 'page' => 'graphs', 'type' => 'device_sap', 'tab' => 'routing', 'proto' => 'mpls', 'view' => 'saps', 'traffic_id' => $sap['svc_oid'] . '.' . $sap['sapPortId'] . '.' . $sap['sapEncapValue']], $vars);
@ -585,17 +454,6 @@ function generate_port_image($args)
return "<img src='graph.php?type=" . $args['graph_type'] . '&amp;id=' . $args['port_id'] . '&amp;from=' . $args['from'] . '&amp;to=' . $args['to'] . '&amp;width=' . $args['width'] . '&amp;height=' . $args['height'] . '&amp;bg=' . $args['bg'] . "'>";
}//end generate_port_image()
function generate_port_thumbnail($port)
{
$port['graph_type'] = 'port_bits';
$port['from'] = Config::get('time.day');
$port['to'] = Config::get('time.now');
$port['width'] = 150;
$port['height'] = 21;
return generate_port_image($port);
}//end generate_port_thumbnail()
/**
* Create image to output text instead of a graph.
*
@ -673,29 +531,6 @@ function print_optionbar_end()
';
}//end print_optionbar_end()
function overlibprint($text)
{
return "onmouseover=\"return overlib('" . $text . "');\" onmouseout=\"return nd();\"";
}//end overlibprint()
function humanmedia($media)
{
global $rewrite_iftype;
array_preg_replace($rewrite_iftype, $media);
return $media;
}//end humanmedia()
function humanspeed($speed)
{
$speed = formatRates($speed);
if ($speed == '') {
$speed = '-';
}
return $speed;
}//end humanspeed()
function devclass($device)
{
if (isset($device['status']) && $device['status'] == '0') {
@ -756,7 +591,7 @@ function generate_ap_link($args, $text = null, $type = null)
{
$args = cleanPort($args);
if (! $text) {
$text = fixIfName($args['label']);
$text = Rewrite::normalizeIfName($args['label']);
}
if ($type) {
@ -771,9 +606,9 @@ function generate_ap_link($args, $text = null, $type = null)
$args = array_merge($args, device_by_id_cache($args['device_id']));
}
$content = '<div class=list-large>' . $args['text'] . ' - ' . fixifName($args['label']) . '</div>';
$content = '<div class=list-large>' . $args['text'] . ' - ' . Rewrite::normalizeIfName($args['label']) . '</div>';
if ($args['ifAlias']) {
$content .= display($args['ifAlias']) . '<br />';
$content .= \LibreNMS\Util\Clean::html($args['ifAlias'], []) . '<br />';
}
$content .= "<div style=\'width: 850px\'>";
@ -785,26 +620,26 @@ function generate_ap_link($args, $text = null, $type = null)
$graph_array['to'] = Config::get('time.now');
$graph_array['from'] = Config::get('time.day');
$graph_array['id'] = $args['accesspoint_id'];
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.week');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.month');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$graph_array['from'] = Config::get('time.year');
$content .= generate_graph_tag($graph_array);
$content .= \LibreNMS\Util\Url::graphTag($graph_array);
$content .= '</div>';
$url = generate_ap_url($args);
if (port_permitted($args['interface_id'], $args['device_id'])) {
return overlib_link($url, $text, $content, null);
return \LibreNMS\Util\Url::overlibLink($url, $text, $content);
} else {
return fixifName($text);
return Rewrite::normalizeIfName($text);
}
}//end generate_ap_link()
function generate_ap_url($ap, $vars = [])
{
return generate_url(['page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoints', 'ap' => $ap['accesspoint_id']], $vars);
return \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoints', 'ap' => $ap['accesspoint_id']], $vars);
}//end generate_ap_url()
// Find all the files in the given directory that match the pattern
@ -883,39 +718,6 @@ function get_client_ip()
return $client_ip;
}//end get_client_ip()
/**
* @param $string
* @param int $max
* @return string
*/
function shorten_text($string, $max = 30)
{
return \LibreNMS\Util\StringHelpers::shortenText($string, $max);
}
function shorten_interface_type($string)
{
return str_ireplace(
[
'FastEthernet',
'TenGigabitEthernet',
'GigabitEthernet',
'Port-Channel',
'Ethernet',
'Bundle-Ether',
],
[
'Fa',
'Te',
'Gi',
'Po',
'Eth',
'BE',
],
$string
);
}//end shorten_interface_type()
function clean_bootgrid($string)
{
$output = str_replace(["\r", "\n"], '', $string);
@ -947,7 +749,7 @@ function alert_details($details)
$fallback = true;
$fault_detail .= '#' . ($o + 1) . ':&nbsp;';
if ($tmp_alerts['bill_id']) {
$fault_detail .= '<a href="' . generate_bill_url($tmp_alerts) . '">' . $tmp_alerts['bill_name'] . '</a>;&nbsp;';
$fault_detail .= '<a href="' . \LibreNMS\Util\Url::generate(['page' => 'bill', 'bill_id' => $tmp_alerts['bill_id']], []) . '">' . $tmp_alerts['bill_name'] . '</a>;&nbsp;';
$fallback = false;
}
@ -993,10 +795,12 @@ function alert_details($details)
if ($tmp_alerts['bgpPeer_id']) {
// If we have a bgpPeer_id, we format the data accordingly
$fault_detail .= "BGP peer <a href='" .
generate_url(['page' => 'device',
\LibreNMS\Util\Url::generate([
'page' => 'device',
'device' => $tmp_alerts['device_id'],
'tab' => 'routing',
'proto' => 'bgp', ]) .
'proto' => 'bgp',
]) .
"'>" . $tmp_alerts['bgpPeerIdentifier'] . '</a>';
$fault_detail .= ', AS' . $tmp_alerts['bgpPeerRemoteAs'];
$fault_detail .= ', State ' . $tmp_alerts['bgpPeerState'];
@ -1013,10 +817,13 @@ function alert_details($details)
}
if (in_array('app_id', array_keys($tmp_alerts))) {
$fault_detail .= "<a href='" . generate_url(['page' => 'device',
'device' => $tmp_alerts['device_id'],
'tab' => 'apps',
'app' => $tmp_alerts['app_type'], ]) . "'>";
$fault_detail .= "<a href='" .
\LibreNMS\Util\Url::generate([
'page' => 'device',
'device' => $tmp_alerts['device_id'],
'tab' => 'apps',
'app' => $tmp_alerts['app_type'],
]) . "'>";
$fault_detail .= $tmp_alerts['metric'];
$fault_detail .= '</a>';
@ -1214,7 +1021,7 @@ function eventlog_severity($eventlog_severity)
function set_image_type()
{
return header('Content-type: ' . get_image_type());
header('Content-type: ' . get_image_type());
}
function get_image_type()
@ -1256,12 +1063,6 @@ function get_oxidized_nodes_list()
}
}
// fetches disks for a system
function get_disks($device)
{
return dbFetchRows('SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr', [$device]);
}
/**
* Get the fail2ban jails for a device... just requires the device ID
* an empty return means either no jails or fail2ban is not in use
@ -1329,9 +1130,9 @@ function get_arrays_with_application($device, $app_id, $app_name, $category = nu
$separator = '-';
if ($category) {
$pattern = sprintf('%s/%s-%s-%s-%s-*.rrd', get_rrd_dir($device['hostname']), 'app', $app_name, $app_id, $category);
$pattern = sprintf('%s/%s-%s-%s-%s-*.rrd', Rrd::dirFromHost($device['hostname']), 'app', $app_name, $app_id, $category);
} else {
$pattern = sprintf('%s/%s-%s-%s-*.rrd', get_rrd_dir($device['hostname']), 'app', $app_name, $app_id);
$pattern = sprintf('%s/%s-%s-%s-*.rrd', Rrd::dirFromHost($device['hostname']), 'app', $app_name, $app_id);
}
// app_name contains a separator character? consider it
@ -1521,7 +1322,7 @@ function get_sensor_label_color($sensor, $type = 'sensors')
}
$unit = __("$type.{$sensor['sensor_class']}.unit");
if ($sensor['sensor_class'] == 'runtime') {
$sensor['sensor_current'] = formatUptime($sensor['sensor_current'] * 60, 'short');
$sensor['sensor_current'] = \LibreNMS\Util\Time::formatInterval($sensor['sensor_current'] * 60);
return "<span class='label $label_style'>" . trim($sensor['sensor_current']) . '</span>';
}
@ -1529,7 +1330,7 @@ function get_sensor_label_color($sensor, $type = 'sensors')
return "<span class='label $label_style'>" . trim($sensor['sensor_current']) . ' ' . $unit . '</span>';
}
return "<span class='label $label_style'>" . trim(format_si($sensor['sensor_current']) . $unit) . '</span>';
return "<span class='label $label_style'>" . trim(Number::formatSi($sensor['sensor_current'], 2, 3, $unit)) . '</span>';
}
/**

View File

@ -4,7 +4,7 @@ require 'includes/html/graphs/common.inc.php';
$device = device_by_id_cache($id);
$rrd_filename = rrd_name($device['hostname'], 'mem');
$rrd_filename = Rrd::name($device['hostname'], 'mem');
$rrd_options .= ' -b 1024';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Channel';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Interference';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Num Clients';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'MonBSSIDs';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Mon Clients';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'radioutil';

View File

@ -1,6 +1,6 @@
<?php
$rrd_filename = rrd_name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_filename = Rrd::name($device['hostname'], ['arubaap', $ap['name'] . $ap['radio_number']]);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'txpow';

View File

@ -6,7 +6,7 @@ require 'includes/html/graphs/common.inc.php';
$device = device_by_id_cache($id);
$rrd_filename = rrd_name($device['hostname'], 'altiga-ssl');
$rrd_filename = Rrd::name($device['hostname'], 'altiga-ssl');
$rrd_options .= " DEF:TotalSessions=$rrd_filename:TotalSessions:AVERAGE";
$rrd_options .= " DEF:ActiveSessions=$rrd_filename:ActiveSessions:AVERAGE";

View File

@ -4,9 +4,9 @@ $scale_min = 0;
require 'includes/html/graphs/common.inc.php';
$apache_rrd = rrd_name($device['hostname'], ['app', 'apache', $app['app_id']]);
$apache_rrd = Rrd::name($device['hostname'], ['app', 'apache', $app['app_id']]);
if (rrdtool_check_rrd_exists($apache_rrd)) {
if (Rrd::checkRrdExists($apache_rrd)) {
$rrd_filename = $apache_rrd;
}

View File

@ -4,9 +4,9 @@ $scale_min = 0;
require 'includes/html/graphs/common.inc.php';
$apache_rrd = rrd_name($device['hostname'], ['app', 'apache', $app['app_id']]);
$apache_rrd = Rrd::name($device['hostname'], ['app', 'apache', $app['app_id']]);
if (rrdtool_check_rrd_exists($apache_rrd)) {
if (Rrd::checkRrdExists($apache_rrd)) {
$rrd_filename = $apache_rrd;
}

View File

@ -4,9 +4,9 @@ $scale_min = 0;
require 'includes/html/graphs/common.inc.php';
$apache_rrd = rrd_name($device['hostname'], ['app', 'apache', $app['app_id']]);
$apache_rrd = Rrd::name($device['hostname'], ['app', 'apache', $app['app_id']]);
if (rrdtool_check_rrd_exists($apache_rrd)) {
if (Rrd::checkRrdExists($apache_rrd)) {
$rrd_filename = $apache_rrd;
}

View File

@ -4,7 +4,7 @@ $scale_min = 0;
require 'includes/html/graphs/common.inc.php';
$rrd_filename = rrd_name($device['hostname'], ['app', 'apache', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'apache', $app['app_id']]);
$array = [
'sb_reading' => [
@ -50,7 +50,7 @@ $array = [
];
$i = 0;
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds => $var) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $var['descr'];

View File

@ -9,6 +9,6 @@ $colour_line = '2EAC6D';
$colour_area_max = 'FFEE99';
$graph_max = 10000;
$unit_text = 'Calls';
$rrd_filename = rrd_name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
require 'includes/html/graphs/generic_simplex.inc.php';

View File

@ -9,6 +9,6 @@ $colour_line = '2EAC6D';
$colour_area_max = 'FFEE99';
$graph_max = 20000;
$unit_text = 'Channels';
$rrd_filename = rrd_name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
require 'includes/html/graphs/generic_simplex.inc.php';

View File

@ -5,7 +5,7 @@ $i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = 'IAX2 Peers';
$rrd_filename = rrd_name($device['hostname'], ['app', 'asterisk', 'iax2', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'asterisk', 'iax2', $app['app_id']]);
$astiax2_access_array = [
'iax2peers' => 'Total Peers',
@ -17,7 +17,7 @@ $astiax2_access_array = [
$colours = 'mixed';
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($astiax2_access_array as $ds => $descr) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;

View File

@ -6,7 +6,7 @@ $scale_min = 0;
$nototal = 1;
$descr_len = 21;
$unit_text = 'SIP Peers';
$rrd_filename = rrd_name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'asterisk', 'stats', $app['app_id']]);
$astsip_access_array = [
'sippeers' => 'Total Peers',
@ -19,7 +19,7 @@ $astsip_access_array = [
$colours = 'mixed';
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($astsip_access_array as $ds => $descr) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;

View File

@ -2,7 +2,7 @@
require 'includes/html/graphs/common.inc.php';
$rrd_filename = rrd_name($device['hostname'], ['app', 'backupninja', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'backupninja', $app['app_id']]);
$array = [
'last_actions' => [
@ -24,7 +24,7 @@ $array = [
];
$i = 0;
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds => $var) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $var['descr'];

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'adb']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'adb']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Addresses',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'adb']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'adb']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Address',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Mem Exhaustion',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Total',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Hits',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'cache']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Total',

View File

@ -33,7 +33,7 @@ $unit_text = 'query/sec';
$colours = 'psychedelic';
$rrd_list = [];
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id']]);
$array = [
'any',
'a',
@ -46,7 +46,7 @@ $array = [
'srv',
'spf',
];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[] = [
'filename' => $rrd_filename,
@ -58,7 +58,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
echo "file missing: $file";
}
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'incoming']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'incoming']);
$array = [
'afsdb',
'apl',
@ -93,7 +93,7 @@ $array = [
'ixfr',
'opt',
];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[] = [
'filename' => $rrd_filename,

View File

@ -9,7 +9,7 @@ $unit_text = 'query/sec';
$colours = 'psychedelic';
$rrd_list = [];
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'outgoing']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'outgoing']);
$array = [
'any',
'a',
@ -54,7 +54,7 @@ $array = [
'ixfr',
'opt',
];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[] = [
'filename' => $rrd_filename,

View File

@ -32,7 +32,7 @@ $i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = 'Query/sec';
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id']]);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id']]);
$array = [
'any',
'a',
@ -50,7 +50,7 @@ $rrd_list = [];
Config::set('graph_colours.merged', array_merge(Config::get('graph_colours.greens'), Config::get('graph_colours.blues')));
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'NXDOMAIN',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'IPv4 NS Ftchd',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'IPv4 Sent',

View File

@ -9,7 +9,7 @@ $unit_text = 'RR sets';
$colours = 'psychedelic';
$rrd_list = [];
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'rrnegative']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'rrnegative']);
$array = [
'any',
'a',
@ -55,7 +55,7 @@ $array = [
'ixfr',
'opt',
];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[] = [
'filename' => $rrd_filename,

View File

@ -9,7 +9,7 @@ $unit_text = 'RR sets';
$colours = 'psychedelic';
$rrd_list = [];
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'rrpositive']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'rrpositive']);
$array = [
'any',
'a',
@ -55,7 +55,7 @@ $array = [
'ixfr',
'opt',
];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
foreach ($array as $ds) {
$rrd_list[] = [
'filename' => $rrd_filename,

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'resolver']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => '<10',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Auth Qry Rej',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'IPv4 Req',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'server']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'Successful',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'TCP/IPv4',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'UDP/IPv4',

View File

@ -9,10 +9,10 @@ $printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_filename = Rrd::name($device['hostname'], ['app', 'bind', $app['app_id'], 'sockets']);
$rrd_list = [];
if (rrdtool_check_rrd_exists($rrd_filename)) {
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list[] = [
'filename' => $rrd_filename,
'descr' => 'UDP/IPv4',

Some files were not shown because too many files have changed in this diff Show More