mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
remove the last usage of config variables outside of the $config array ($rrd_file) + fixed adduser script
git-svn-id: http://www.observium.org/svn/observer/trunk@354 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -216,8 +216,8 @@ function truncate($substring, $max = 50, $rep = '...')
|
||||
|
||||
function interface_rates ($interface)
|
||||
{
|
||||
global $config, $rrd_dir;
|
||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||
global $config;
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
|
||||
$data = trim(`$cmd`);
|
||||
foreach( explode("\n", $data) as $entry) {
|
||||
@@ -231,8 +231,8 @@ function interface_rates ($interface)
|
||||
|
||||
function interface_errors ($interface)
|
||||
{
|
||||
global $config, $rrd_dir;
|
||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||
global $config;
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||
$data = trim(`$cmd`);
|
||||
foreach( explode("\n", $data) as $entry) {
|
||||
@@ -356,9 +356,8 @@ function delHost($id)
|
||||
mysql_query("DELETE FROM `interfaces` WHERE `device_id` = '$id'");
|
||||
mysql_query("DELETE FROM `services` WHERE `service_host` = '$id'");
|
||||
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
||||
$rrd_dir = $config['rrd_dir'];
|
||||
`rm -f $rrd_dir/$host-*.rrd`;
|
||||
`rm -rf $rrd_dir/$host`;
|
||||
shell_exec("rm -f ".$config['rrd_dir'] . "/$host-*.rrd");
|
||||
shell_exec("rm -rf ".$config['rrd_dir']."/$host");
|
||||
echo("Removed device $host<br />");
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ while($peer = mysql_fetch_array($peers)) {
|
||||
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
|
||||
$peerrrd = $rrd_dir . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
||||
|
||||
if(!is_file($peerrrd)) {
|
||||
$woo = `rrdtool create $peerrrd \
|
||||
|
@@ -8,9 +8,9 @@ $serial = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c
|
||||
$version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion);
|
||||
list($hardware,$version,$features) = explode("||", $version);
|
||||
|
||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-cpu.rrd";
|
||||
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-memory.rrd";
|
||||
$sessrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-sessions.rrd";
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-cpu.rrd";
|
||||
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-memory.rrd";
|
||||
$sessrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-sessions.rrd";
|
||||
|
||||
$cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||
$cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0";
|
||||
|
@@ -5,17 +5,9 @@
|
||||
$hostname = $device['hostname'];
|
||||
$port = $device['port'];
|
||||
|
||||
$Otemprrd = "rrd/" . $hostname . "-temp.rrd";
|
||||
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
||||
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
|
||||
|
||||
$temprrd = $rrd_dir . "/" . $hostname . "/temp.rrd";
|
||||
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
|
||||
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
|
||||
|
||||
if(is_file($Otemprrd) && !is_file($temprrd)) { rename($Otemprrd, $temprrd); echo("Moving $Otemprrd to $temprrd"); }
|
||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
||||
$temprrd = $config['rrd_dir'] . "/" . $hostname . "/temp.rrd";
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
|
||||
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
|
||||
|
||||
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
|
||||
$version = str_replace("IOS (tm) ", "", $version);
|
||||
|
@@ -11,7 +11,7 @@ $features = preg_replace("/.+\ \((.+)\)$/", "\\1", $jun_ver);
|
||||
|
||||
echo("$hardware - $version - $features - $serial\n");
|
||||
|
||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/junos-cpu.rrd";
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/junos-cpu.rrd";
|
||||
|
||||
$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||
$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0";
|
||||
|
@@ -12,10 +12,7 @@ if($device[os] != "Snom") {
|
||||
'tcpEstabResets','tcpInSegs','tcpOutSegs','tcpRetransSegs','udpInDatagrams','udpOutDatagrams','udpInErrors',
|
||||
'udpNoPorts');
|
||||
|
||||
$rrdfile = $rrd_dir . "/" . $device['hostname'] . "/netinfo.rrd";
|
||||
|
||||
$Orrdfile = "rrd/" . $device['hostname'] . "-netinfo.rrd";
|
||||
if(is_file($Orrdfile) && !is_file($rrdfile)) { rename($Orrdfile, $rrdfile); echo("Moving $Orrdfile to $rrdfile"); }
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/netinfo.rrd";
|
||||
|
||||
$rrd_create = "rrdtool create $rrdfile ";
|
||||
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
|
@@ -1,14 +1,7 @@
|
||||
<?
|
||||
|
||||
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
||||
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
|
||||
|
||||
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
|
||||
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
|
||||
|
||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
||||
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
|
||||
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
|
||||
|
||||
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
|
||||
$cpu = `$cpu_cmd`;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
$rxbytes = 0 - $rxbytes * 8;
|
||||
echo("$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations");
|
||||
|
||||
$rrdfile = $rrd_dir . "/" . $device['hostname'] . "/data.rrd";
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/data.rrd";
|
||||
if(!is_file($rrdfile)) {
|
||||
$woo = `rrdtool create $rrdfile \
|
||||
DS:INOCTETS:COUNTER:600:U:100000000000 \
|
||||
|
@@ -1,21 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
$Oloadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
|
||||
$Ocpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
|
||||
$Omemrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
|
||||
$Osysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
|
||||
|
||||
$loadrrd = $rrd_dir . "/" . $device['hostname'] . "/load.rrd";
|
||||
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/cpu.rrd";
|
||||
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/mem.rrd";
|
||||
$sysrrd = $rrd_dir . "/" . $device['hostname'] . "/sys.rrd";
|
||||
|
||||
if(is_file($Oloadrrd) && !is_file($loadrrd)) { rename($Oloadrrd, $loadrrd); echo("Moving $Oloadrrd to $loadrrd"); }
|
||||
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
|
||||
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
|
||||
if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Moving $Osysrrd to $sysrrd"); }
|
||||
$loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd";
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd";
|
||||
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
|
||||
$sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
|
||||
|
||||
if ($device['os'] == "FreeBSD") {
|
||||
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
||||
@@ -67,11 +55,7 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
|
||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||
|
||||
$storage_rrd = $rrd_dir . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
||||
$ostorage_rrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
|
||||
|
||||
if(is_file($ostorage_rrd) && !is_file($storage_rrd)) { rename($ostorage_rrd, $storage_rrd); echo("Moving $ostorage_rrd to $storage_rrd"); }
|
||||
|
||||
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
||||
|
||||
if (!is_file($storage_rrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $storage_rrd \
|
||||
|
@@ -13,12 +13,6 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
||||
$temprrd = str_replace(")", "_", $temprrd);
|
||||
$temprrd = str_replace("(", "_", $temprrd);
|
||||
|
||||
$otemprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
|
||||
$otemprrd = str_replace(")", "_", $otemprrd);
|
||||
$otemprrd = str_replace("(", "_", $otemprrd);
|
||||
|
||||
if(is_file($otemprrd) && !is_file($temprrd)) { rename($otemprrd, $temprrd); echo("Moving $otemprrd to $temprrd"); }
|
||||
|
||||
if (!is_file($temprrd)) {
|
||||
`rrdtool create $temprrd \
|
||||
--step 300 \
|
||||
|
Reference in New Issue
Block a user