mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixed the scrut coding style issues
This commit is contained in:
@@ -139,6 +139,7 @@ function deluser($username)
|
||||
function get_userlist()
|
||||
{
|
||||
global $config, $ds;
|
||||
$userlist = array();
|
||||
|
||||
$filter = '(' . $config['auth_ldap_prefix'] . '*)';
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ function generate_overlib_content($graph_array, $text)
|
||||
|
||||
function get_percentage_colours($percentage)
|
||||
{
|
||||
|
||||
$background = array();
|
||||
if ($percentage > '90') { $background['left']='c4323f'; $background['right']='C96A73'; }
|
||||
elseif ($percentage > '75') { $background['left']='bf5d5b'; $background['right']='d39392'; }
|
||||
elseif ($percentage > '50') { $background['left']='bf875b'; $background['right']='d3ae92'; }
|
||||
@@ -330,7 +330,7 @@ function print_graph_tag($args)
|
||||
|
||||
function generate_graph_tag($args)
|
||||
{
|
||||
|
||||
$urlargs = array();
|
||||
foreach ($args as $key => $arg)
|
||||
{
|
||||
$urlargs[] = $key."=".$arg;
|
||||
@@ -410,6 +410,7 @@ function generate_port_link($port, $text = NULL, $type = NULL)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$graph_array = array();
|
||||
$port = ifNameDescr($port);
|
||||
if (!$text) { $text = fixIfName($port['label']); }
|
||||
if ($type) { $port['graph_type'] = $type; }
|
||||
@@ -535,6 +536,8 @@ function devclass($device)
|
||||
|
||||
function getlocations()
|
||||
{
|
||||
$ignore_dev_location = array();
|
||||
$locations = array();
|
||||
# Fetch override locations, not through get_dev_attrib, this would be a huge number of queries
|
||||
$rows = dbFetchRows("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type");
|
||||
foreach ($rows as $row)
|
||||
@@ -610,6 +613,7 @@ function generate_ap_link($args, $text = NULL, $type = NULL)
|
||||
$content = "<div class=list-large>".$args['text']." - " . fixifName($args['label']) . "</div>";
|
||||
if ($args['ifAlias']) { $content .= $args['ifAlias']."<br />"; }
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array = array();
|
||||
$graph_array['type'] = $args['graph_type'];
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
|
||||
// Device Information
|
||||
function listBillPorts($bill_id) {
|
||||
$device = array();
|
||||
$res = "";
|
||||
$res .= "<table>";
|
||||
$res .= " <tr>";
|
||||
@@ -146,6 +147,7 @@
|
||||
// Bitrate Graph overview
|
||||
function graphOverviewBitrate($bill_id, $history) {
|
||||
global $pdf;
|
||||
$img = array();
|
||||
|
||||
$img['bitrate'] = genGraphs($bill_id, "bitrate", $history['timestampfrom'], $history['timestampto'], $history['type']);
|
||||
$bitrate = $pdf->serializeTCPDFtagParameters(array($img['bitrate'], 10, 44, 280, '', 'PNG', '', 'T'));
|
||||
@@ -157,6 +159,7 @@
|
||||
// Transfer Graph overview
|
||||
function graphOverviewTransfer($bill_id, $history) {
|
||||
global $pdf;
|
||||
$img = array();
|
||||
|
||||
$img['bw_day'] = genGraphs($bill_id, "day", $history['timestampfrom'], $history['timestampto']);
|
||||
$img['bw_hour'] = genGraphs($bill_id, "hour", $history['timestampfrom'], $history['timestampto']);
|
||||
|
||||
@@ -49,6 +49,7 @@ function getDates($dayofmonth, $months=0)
|
||||
$last_from = date_format($date_start, 'Ymd') . "000000";
|
||||
$last_to = date_format($date_end, 'Ymd') . "235959";
|
||||
|
||||
$return = array();
|
||||
$return['0'] = $date_from;
|
||||
$return['1'] = $date_to;
|
||||
$return['2'] = $last_from;
|
||||
@@ -76,6 +77,7 @@ function getValue($host, $port, $id, $inout)
|
||||
|
||||
function getLastPortCounter($port_id,$inout)
|
||||
{
|
||||
$return = array();
|
||||
$rows = dbFetchCell("SELECT count(counter) from `port_" . mres($inout) . "_measurements` WHERE `port_id`='" . mres($port_id)."'");
|
||||
|
||||
if ($rows > 0)
|
||||
@@ -92,6 +94,7 @@ function getLastPortCounter($port_id,$inout)
|
||||
|
||||
function getLastMeasurement($bill_id)
|
||||
{
|
||||
$return = array();
|
||||
$rows = dbFetchCell("SELECT count(delta) from bill_data WHERE bill_id='".mres($bill_id)."'");
|
||||
|
||||
if ($rows > 0)
|
||||
@@ -142,6 +145,7 @@ function get95thout($bill_id,$datefrom,$dateto)
|
||||
|
||||
function getRates($bill_id,$datefrom,$dateto)
|
||||
{
|
||||
$data = array();
|
||||
$mq_text = "SELECT count(delta) FROM bill_data ";
|
||||
$mq_text .= " WHERE bill_id = '".mres($bill_id)."'";
|
||||
$mq_text .= " AND timestamp > '".mres($datefrom)."' AND timestamp <= '".mres($dateto)."'";
|
||||
|
||||
@@ -147,6 +147,7 @@ function get_port_by_ifIndex($device_id, $ifIndex)
|
||||
function get_all_devices($device, $type = "")
|
||||
{
|
||||
global $cache;
|
||||
$devices = array();
|
||||
|
||||
// FIXME needs access control checks!
|
||||
// FIXME respect $type (server, network, etc) -- needs an array fill in topnav.
|
||||
|
||||
@@ -132,6 +132,7 @@ function percent_colour($perc)
|
||||
function interface_errors($rrd_file, $period = '-1d') // Returns the last in/out errors value in RRD
|
||||
{
|
||||
global $config;
|
||||
$errors = array();
|
||||
|
||||
$cmd = $config['rrdtool']." fetch -s $period -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||
$data = trim(shell_exec($cmd));
|
||||
@@ -584,6 +585,7 @@ function match_network($nets, $ip, $first=false)
|
||||
function snmp2ipv6($ipv6_snmp)
|
||||
{
|
||||
$ipv6 = explode('.',$ipv6_snmp);
|
||||
$ipv6_2 = array();
|
||||
|
||||
# Workaround stupid Microsoft bug in Windows 2008 -- this is fixed length!
|
||||
# < fenestro> "because whoever implemented this mib for Microsoft was ignorant of RFC 2578 section 7.7 (2)"
|
||||
@@ -600,6 +602,7 @@ function snmp2ipv6($ipv6_snmp)
|
||||
|
||||
function ipv62snmp($ipv6)
|
||||
{
|
||||
$ipv6_split = array();
|
||||
$ipv6_ex = explode(':',Net_IPv6::uncompress($ipv6));
|
||||
for ($i = 0;$i < 8;$i++) { $ipv6_ex[$i] = zeropad($ipv6_ex[$i],4); }
|
||||
$ipv6_ip = implode('',$ipv6_ex);
|
||||
|
||||
@@ -222,6 +222,7 @@ function poll_device($device, $options)
|
||||
rrdtool_update($ping_rrd, "N:$ping_time");
|
||||
}
|
||||
|
||||
$update_array = array();
|
||||
$update_array['last_polled'] = array('NOW()');
|
||||
$update_array['last_polled_timetaken'] = $device_time;
|
||||
$update_array['last_ping'] = array('NOW()');
|
||||
|
||||
@@ -205,6 +205,7 @@ function rrdtool_create($filename, $options)
|
||||
|
||||
function rrdtool_update($filename, $options)
|
||||
{
|
||||
$values = array();
|
||||
// Do some sanitisation on the data if passed as an array.
|
||||
if (is_array($options))
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@ function snmp_get_multi($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir
|
||||
if (!$debug) { $cmd .= " 2>/dev/null"; }
|
||||
$data = trim(external_exec($cmd));
|
||||
$runtime_stats['snmpget']++;
|
||||
$array = array();
|
||||
foreach (explode("\n", $data) as $entry)
|
||||
{
|
||||
list($oid,$value) = explode("=", $entry);
|
||||
@@ -189,7 +190,7 @@ function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
return $data;
|
||||
}
|
||||
|
||||
function snmpwalk_cache_cip($device, $oid, $array, $mib = 0)
|
||||
function snmpwalk_cache_cip($device, $oid, $array = array(), $mib = 0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$var = array();
|
||||
$var['mess_recv'] = (isset($stats['mess_recv']) ? $stats['mess_recv'] : "U");
|
||||
$var['mess_rejected'] = (isset($stats['mess_rejected']) ? $stats['mess_rejected'] : "U");
|
||||
$var['mess_relay'] = (isset($stats['mess_relay']) ? $stats['mess_relay'] : "U");
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$var = array();
|
||||
$var['offset'] = (isset($ntp['offset']) ? $ntp['offset'] : "U");
|
||||
$var['frequency'] = (isset($ntp['frequency']) ? $ntp['frequency'] : "U");
|
||||
if ($newstats_style) {
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$var = array();
|
||||
$var['stratum'] = (isset($ntpd['stratum']) ? $ntpd['stratum'] : "U");
|
||||
$var['offset'] = (isset($ntpd['offset']) ? $ntpd['offset'] : "U");
|
||||
$var['frequency'] = (isset($ntpd['frequency']) ? $ntpd['frequency'] : "U");
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$var = array();
|
||||
$var['corrupt-packets'] = (isset($pdns['corrupt-packets']) ? $pdns['corrupt-packets'] : "U");
|
||||
$var['deferred-cache-inserts'] = (isset($pdns['deferred-cache-inserts']) ? $pdns['deferred-cache-inserts'] : "U");
|
||||
$var['deferred-cache-lookup'] = (isset($pdns['deferred-cache-lookup']) ? $pdns['deferred-cache-lookup'] : "U");
|
||||
|
||||
@@ -656,6 +656,7 @@ function outputStatistics($rra) {
|
||||
|
||||
function updateXML(&$output, &$rra) {
|
||||
global $numspike, $percent, $avgnan, $method, $total_kills;
|
||||
$new_array = array();
|
||||
|
||||
/* variance subroutine */
|
||||
$rra_num = 0;
|
||||
@@ -797,6 +798,7 @@ function debug($string) {
|
||||
|
||||
function standard_deviation($samples) {
|
||||
$sample_count = count($samples);
|
||||
$sample_square = array();
|
||||
|
||||
for ($current_sample = 0; $sample_count > $current_sample; ++$current_sample) {
|
||||
$sample_square[$current_sample] = pow($samples[$current_sample], 2);
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
function doSNMPv2($vars) {
|
||||
$res = array();
|
||||
foreach ($vars as $items=>$server) {
|
||||
$var = array();
|
||||
$var['bitrate'] = (isset($server['5']) ? (($server['5'] / 8) * 1000) : "0");
|
||||
//$var['bitrate'] = (isset($server['5']) ? ($server['5'] * 1024) : "0");
|
||||
$var['traf_in'] = (isset($server['1']) ? ($var['bitrate'] * $server['1']) : "0");
|
||||
|
||||
Reference in New Issue
Block a user