mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Tidying up
This commit is contained in:
@ -24,10 +24,10 @@ Usage
|
||||
function dbQuery($sql, $parameters = array()) {
|
||||
global $fullSql, $debug;
|
||||
$fullSql = dbMakeQuery($sql, $parameters);
|
||||
//if($debug) {
|
||||
//print Console_Color::convert("\nSQL[%y".$fullSql."%n] ");
|
||||
//echo("\nSQL[".$fullSql."] ");
|
||||
//}
|
||||
if($debug) {
|
||||
print Console_Color::convert("\nSQL[%y".$fullSql."%n] ");
|
||||
#echo("\nSQL[".$fullSql."] ");
|
||||
}
|
||||
|
||||
/*
|
||||
if($this->logFile)
|
||||
@ -35,13 +35,6 @@ function dbQuery($sql, $parameters = array()) {
|
||||
*/
|
||||
|
||||
$result = mysql_query($fullSql); // sets $this->result
|
||||
if (mysql_error()) {
|
||||
echo("\nSQL[".$fullSql."] ");
|
||||
print mysql_error();
|
||||
}
|
||||
if(mysql_error()) {
|
||||
file_put_contents('/tmp/mysql_strict.log',date("Y-m-d H:i:s").','.$fullSql.','.mysql_error()."\n",FILE_APPEND);
|
||||
}
|
||||
/*
|
||||
if($this->logFile) {
|
||||
$time_end = microtime(true);
|
||||
@ -121,13 +114,9 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
|
||||
|
||||
// need field name and placeholder value
|
||||
// but how merge these field placeholders with actual $parameters array for the WHERE clause
|
||||
$sql = 'UPDATE `' . $table . '` SET ';
|
||||
$sql = 'UPDATE `' . $table . '` set ';
|
||||
foreach($data as $key => $value) {
|
||||
if ($value == "NOW()") {
|
||||
$sql .= "`".$key."` = " . $value . ",";
|
||||
} else {
|
||||
$sql .= "`".$key."` = '" . $value . "',";
|
||||
}
|
||||
$sql .= "`".$key."` ". '=:' . $key . ',';
|
||||
}
|
||||
$sql = substr($sql, 0, -1); // strip off last comma
|
||||
|
||||
|
@ -132,7 +132,7 @@ function discover_device($device, $options = NULL)
|
||||
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = NULL, $low_warn_limit = NULL, $warn_limit = NULL, $high_limit = NULL, $current = NULL, $poller_type = 'snmp', $entPhysicalIndex = NULL, $entPhysicalIndex_measured = NULL)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
|
||||
if ($debug) { echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $precision, $entPhysicalIndex\n"); }
|
||||
|
||||
if (is_null($low_warn_limit) || !is_null($warn_limit))
|
||||
@ -355,7 +355,7 @@ function sensor_limit($class, $current)
|
||||
function check_valid_sensors($device, $class, $valid, $poller_type = 'snmp')
|
||||
{
|
||||
$entries = dbFetchRows("SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class=? AND S.device_id = D.device_id AND D.device_id = ? AND S.poller_type = ?", array($class, $device['device_id'], $poller_type));
|
||||
|
||||
|
||||
if (count($entries))
|
||||
{
|
||||
foreach ($entries as $entry)
|
||||
@ -475,8 +475,7 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec
|
||||
global $config, $debug;
|
||||
|
||||
if ($debug) {
|
||||
echo("\n");
|
||||
var_dump($device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex);
|
||||
echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n");
|
||||
}
|
||||
|
||||
if ($descr)
|
||||
@ -523,8 +522,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
|
||||
global $config, $debug;
|
||||
|
||||
if ($debug) {
|
||||
echo("\n");
|
||||
var_dump($device, $index, $type, $descr, $precision, $entPhysicalIndex, $hrDeviceIndex);
|
||||
echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n");
|
||||
}
|
||||
|
||||
#FIXME implement the mempool_perc, mempool_used, etc.
|
||||
|
@ -39,7 +39,6 @@ if ($device['os_group'] == "cisco" || $device['os'] == "acsw")
|
||||
|
||||
if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "")
|
||||
{
|
||||
//discover_processor($valid['processor'], $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
|
||||
discover_processor($valid['processor'], $device, $usage_oid, $index, "cpm", $descr, "1", $usage, $entPhysicalIndex, NULL);
|
||||
}
|
||||
}
|
||||
@ -48,7 +47,6 @@ if ($device['os_group'] == "cisco" || $device['os'] == "acsw")
|
||||
if (!is_array($valid['processor']['cpm']))
|
||||
{
|
||||
$avgBusy5 = snmp_get($device, ".1.3.6.1.4.1.9.2.1.58.0", "-Oqv");
|
||||
|
||||
if (is_numeric($avgBusy5))
|
||||
{
|
||||
discover_processor($valid['processor'], $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", "1", $avgBusy5, NULL, NULL);
|
||||
|
@ -64,7 +64,7 @@ foreach ($device['vlans'] as $domain_id => $vlans)
|
||||
|
||||
if ($from_db['port_vlan_id'])
|
||||
{
|
||||
dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ". $from_db['port_vlan_id']);
|
||||
dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", array($from_db['port_vlan_id']));
|
||||
echo("Updated");
|
||||
} else {
|
||||
dbInsert(array_merge($db_w, $db_a), 'ports_vlans');
|
||||
|
Reference in New Issue
Block a user