Get rid of some more execs

git-svn-id: http://www.observium.org/svn/observer/trunk@1814 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-10 15:51:56 +00:00
parent a199070100
commit 3c10ede092
10 changed files with 27 additions and 26 deletions

View File

@@ -28,11 +28,11 @@ if(is_array($hrDevices))
$update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'"; $update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'";
} }
$update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"; $update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'";
@mysql_query($update_query); $mysql++; echo("."); @mysql_query($update_query); echo(".");
} else { } else {
$insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) "; $insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) ";
$insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')"; $insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')";
@mysql_query($insert_query); $mysql++; echo("+"); @mysql_query($insert_query); echo("+");
if($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); } if($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); }
} }
$valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1; $valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1;

View File

@@ -58,9 +58,9 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) {
if($debug) {echo("\n" . $acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out ");} if($debug) {echo("\n" . $acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out ");}
$rrdfile = $host_rrd . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"); $rrdfile = $host_rrd . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
if(!is_file($rrdfile)) { if(!is_file($rrdfile))
$woo = shell_exec($config['rrdtool'] ." create $rrdfile \ {
DS:IN:COUNTER:600:0:12500000000 \ rrdtool_create($rrdfile,"DS:IN:COUNTER:600:0:12500000000 \
DS:OUT:COUNTER:600:0:12500000000 \ DS:OUT:COUNTER:600:0:12500000000 \
DS:PIN:COUNTER:600:0:12500000000 \ DS:PIN:COUNTER:600:0:12500000000 \
DS:POUT:COUNTER:600:0:12500000000 \ DS:POUT:COUNTER:600:0:12500000000 \
@@ -76,9 +76,10 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) {
$woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0); $woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0);
$ret = rrdtool_update("$rrdfile", $woo); $ret = rrdtool_update("$rrdfile", $woo);
if ($update) { /// Do Updates if ($update)
{ /// Do Updates
$update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'"; $update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'";
@mysql_query($update_query); $mysql++; @mysql_query($update_query);
if($debug) {echo("\nMYSQL : [ $update_query ]");} if($debug) {echo("\nMYSQL : [ $update_query ]");}
} /// End Updates } /// End Updates
unset($update_query); unset($update); unset($update_query); unset($update);

View File

@@ -12,8 +12,7 @@ if(is_numeric($hrSystem[0]['hrSystemProcesses']))
{ {
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd"; $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd";
if (!is_file($rrd_file)) { if (!is_file($rrd_file)) {
shell_exec($config['rrdtool'] . " create $rrd_file \ rrdtool_create($rrd_file,"--step 300 \
--step 300 \
DS:procs:GAUGE:600:0:U \ DS:procs:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:800 \ RRA:AVERAGE:0.5:1:800 \
RRA:AVERAGE:0.5:6:800 \ RRA:AVERAGE:0.5:6:800 \
@@ -33,8 +32,7 @@ if(is_numeric($hrSystem[0]['hrSystemNumUsers']))
{ {
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd"; $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd";
if (!is_file($rrd_file)) { if (!is_file($rrd_file)) {
shell_exec($config['rrdtool'] . " create $rrd_file \ rrdtool_create($rrd_file, "--step 300 \
--step 300 \
DS:users:GAUGE:600:0:U \ DS:users:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:800 \ RRA:AVERAGE:0.5:1:800 \
RRA:AVERAGE:0.5:6:800 \ RRA:AVERAGE:0.5:6:800 \

View File

@@ -66,8 +66,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
$rrdfile = $host_rrd . "/" . safename($interface['ifIndex'] . ".rrd"); $rrdfile = $host_rrd . "/" . safename($interface['ifIndex'] . ".rrd");
if(!is_file($rrdfile)) { if(!is_file($rrdfile)) {
$woo = shell_exec($config['rrdtool'] . " create $rrdfile \ rrdtool_create($rrdfile,"DS:INOCTETS:COUNTER:600:0:12500000000 \
DS:INOCTETS:COUNTER:600:0:12500000000 \
DS:OUTOCTETS:COUNTER:600:0:12500000000 \ DS:OUTOCTETS:COUNTER:600:0:12500000000 \
DS:INERRORS:COUNTER:600:0:12500000000 \ DS:INERRORS:COUNTER:600:0:12500000000 \
DS:OUTERRORS:COUNTER:600:0:12500000000 \ DS:OUTERRORS:COUNTER:600:0:12500000000 \

View File

@@ -72,8 +72,7 @@
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ipSystemStats-".$af.".rrd"); $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ipSystemStats-".$af.".rrd");
$rrd_create = $config['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 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
$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 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
$rrdupdate = "N"; $rrdupdate = "N";
@@ -84,7 +83,7 @@
if(strstr($stats[$oid], "No") || strstr($stats[$oid], "d") || strstr($stats[$oid], "s")) { $stats[$oid] = "0"; } if(strstr($stats[$oid], "No") || strstr($stats[$oid], "d") || strstr($stats[$oid], "s")) { $stats[$oid] = "0"; }
$rrdupdate .= ":".$stats[$oid]; $rrdupdate .= ":".$stats[$oid];
} }
if(!file_exists($rrdfile)) { shell_exec($rrd_create); } if(!file_exists($rrdfile)) { rrdtool_create($rrdfile,$rrd_create); }
rrdtool_update($rrdfile, $rrdupdate); rrdtool_update($rrdfile, $rrdupdate);
unset($rrdupdate, $rrd_create); unset($rrdupdate, $rrd_create);

View File

@@ -1,9 +1,11 @@
<?php <?php
echo("Doing Juniper JunOS "); echo("Doing Juniper JunOS ");
## FIX ME below
$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -M ".$config['mibdir'] . " -m HOST-RESOURCES-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.25.6.3.1.2.2"))); $jun_ver = snmp_get($device, ".1.3.6.1.2.1.25.6.3.1.2.2", "-Oqv", "HOST-RESOURCES-MIB");
if(strpos($sysDescr, "olive")) {
if(strpos($sysDescr, "olive"))
{
$hardware = "Olive"; $hardware = "Olive";
$serial = ""; $serial = "";
} else { } else {
@@ -27,7 +29,7 @@ if (is_numeric($cpu_usage))
{ {
if (!is_file($cpurrd)) if (!is_file($cpurrd))
{ {
$rrdcreate = shell_exec($config['rrdtool'] ." create $cpurrd --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200 RRA:AVERAGE:0.5:1:2000 \ rrd_create($cpurrd," --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200 RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \ RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \ RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \ RRA:AVERAGE:0.5:288:2000 \

View File

@@ -261,7 +261,7 @@
// Update MySQL // Update MySQL
if ($update) { if ($update) {
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'"; $update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
@mysql_query($update_query); $mysql++; @mysql_query($update_query);
if($debug) {echo("\nMYSQL : [ $update_query ]");} if($debug) {echo("\nMYSQL : [ $update_query ]");}
} }
// End Update MySQL // End Update MySQL

View File

@@ -16,8 +16,7 @@ while($processor = mysql_fetch_array($proc_data)) {
$procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd"); $procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd");
if (!is_file($procrrd)) { if (!is_file($procrrd)) {
shell_exec("rrdtool create $procrrd \ rrdtool_create($procrrd, "--step 300 \
--step 300 \
DS:usage:GAUGE:600:-273:1000 \ DS:usage:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \ RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \ RRA:MIN:0.5:12:2400 \

View File

@@ -9,6 +9,7 @@ if ($config['enable_printers'])
{ {
echo("Checking toner " . $toner['toner_descr'] . "... "); echo("Checking toner " . $toner['toner_descr'] . "... ");
# FIXME needs snmp_get
$toner_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $toner['toner_oid'] . "|grep -v \"No Such Instance\""; $toner_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $toner['toner_oid'] . "|grep -v \"No Such Instance\"";
$tonerperc = trim(str_replace("\"", "", shell_exec($toner_cmd))); $tonerperc = trim(str_replace("\"", "", shell_exec($toner_cmd)));
$tonerperc = $tonerperc / $toner['toner_capacity'] * 100; $tonerperc = $tonerperc / $toner['toner_capacity'] * 100;

View File

@@ -22,9 +22,11 @@ if($dataHandle)
list($cur, $tag) = explode("-", $config['version']); list($cur, $tag) = explode("-", $config['version']);
list($cur_major, $cur_minor, $cur_release) = explode(".", $cur); list($cur_major, $cur_minor, $cur_release) = explode(".", $cur);
if($argv[1] == "--cron") { if($argv[1] == "--cron")
{
shell_exec("echo $major.$minor.$release > rrd/version.txt "); $fd = fopen('vrrd/version.txt','w');
fputs($fd, "$major.$minor.$release");
fclose($fd);
} else { } else {