private function init() { $this->url = $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID']; include_once 'classes/Property.php'; $property = new Property(); if ($this->rrdtool = $property->get_property("path_rrdtool")) { } else { print $property->get_error(); exit; } if ($this->rrd_dir = $property->get_property("path_rrddir")) { } else { print $property->get_error(); exit; } if (!$this->rrdtool || $this->rrdtool == '') { print "Could not find rrdtool"; exit; } if (!$this->rrd_dir || $this->rrd_dir == '') { print "Could not find rrd_dir"; exit; } return; }
<?php include_once 'config/opendb.php'; include_once 'config/graph.conf'; include_once 'classes/RRD.php'; include_once 'classes/Property.php'; $property = new Property(); if ($rrdtool = $property->get_property("path_rrdtool")) { } else { print $property->get_error(); exit; } if ($rrd_dir = $property->get_property("path_rrddir")) { } else { print $property->get_error(); exit; } if (!$rrdtool || $rrdtool == '') { print "Could not find rrdtool"; exit; } if (!$rrd_dir || $rrd_dir == '') { print "Could not find rrd_dir"; exit; } // Do not edit below, unless you know what you are doing // This is a hack, so that sou can access it as a webpage as well // It will just request the same page, but will present it as html with // the graph in img tag if (isset($_GET['ctype'])) { $ctype = $_GET['ctype'];
function displayCheckGraphs($interval = 'day') { global $tool, $form, $status_array, $status_collors; $my_colors = array("FF0000", "0404B4", "04B431", "B45F04", "F7FE2E", "8B008B", "4B0082", "FA8072", "4169E1", "D2B9D3", "B4CFEC", "eF6600", "77CEEB", "eFFF00", "6FFF00", "8E7BFF", "7B008B", "3B0082", "eA8072", "3169E1", "c2B9D3", "a4CFEC", "dF6600", "67CEEB", "dFFF00", "5FFF00", "7E7BFF", "6B008B", "2B0082", "dA8072", "2169E1", "b2B9D3", "94CFEC"); if (is_numeric($_GET[checkid])) { $check = new Check($_GET[checkid]); } else { $form->warning("Invalid check id"); } $property = new Property(); if ($rrd_dir = $property->get_property("path_rrddir")) { } else { $form->warning($property->get_error()); return false; } if ($rrdtool = $property->get_property("path_rrdtool")) { } else { return; } $filename = "checks/checkid_" . $check->get_check_id() . ".rrd"; $filepath = $rrd_dir . "/" . $filename; // Now check if there's are graphs for this check // Not all checks have these if (!file_exists($filepath)) { //$form->warning( "file $filename not there"); return false; } if ($interval == 'week') { $from = "-7d"; } elseif ($interval == 'month') { $from = "-1m"; } elseif ($interval == 'year') { $from = "-365d"; } else { $from = "-24h"; } $rrd = new RRD("{$filepath}", $rrdtool); $datasources = $rrd->get_data_sources(); ksort($datasources, SORT_STRING); $exclude_ds = array(); $color_codes = ""; $exclude = ""; $i = 0; foreach ($datasources as $ds => $value) { $color_code .= "&ds_colors[{$ds}]={$my_colors[$i]}"; $i++; if (isset($_GET[$ds]) && $_GET[$ds] == 'no') { array_push($exclude_ds, $ds); $exclude .= "&exclude_ds[{$ds}]=yes"; } } $rrd_url = "rrdgraph.php?file=" . urlencode($filename) . "&type=check&title=" . urlencode($check->get_name()) . "&width=400&height=122&from={$from}" . "{$exclude}" . $color_code; return "<img src='{$rrd_url}'>"; }
function displayPaths() { global $tool, $propertyForm; $my_paths = array("path_snmpwalk" => "snmpwalk", "path_snmpget" => "snmpget", "path_rrdupdate" => "rrdupdate", "path_rrdtool" => "rrdtool", "path_rrddir" => "RRD Directory"); $content = ""; $content .= "<h1>System Paths</h1>"; $content .= "<div style='padding-left: 600px;'>\n\t\t\t<a class='tooltip' title='This will try to detect the tools below in the current \$path'><img src='icons/Info.png' height='19'></a>\n\t\t\t<a href='javascript:LoadPage(\"configurations.php?action=paths&mode=autodetect\",\"settingsInfo\")'>\n\t\t\tclick here to Auto Discover paths</a></div>"; $form = new Form("auto", 2); $keyHandlers = array(); $keyData = array(); $keyTitle = array(); $postKeys = array(); foreach ($my_paths as $id => $path) { $property = new Property(); $value = $property->get_property($id); if ($value === false) { $value = "WARNING: Property '{$id}' Not Found in Property table, Contact your admininistrator" . $property->get_error(); } $desc = $property->get_desc($id); if (is_readable($value)) { $check = "<font size='' color='green'>Found!</font>"; if ($id == 'path_rrdtool') { $cmd = "{$value} -v| awk '{print \$2}'|head -1"; exec($cmd, $output, $return_var); if ($output[0] < "1.4") { $check = "<font size='' color='Orange'>Found version {$output['0']}! You need at least RRDtool version 1.4.0 otherwise some graphs won't display correctlty</font>"; } } } else { $check = "<font size='' color='orange'>Not Found!</font>"; } array_push($postKeys, "{$id}"); array_push($keyData, "{$value}"); array_push($keyTitle, "<font size='2'>{$path}</font><br><i>{$desc}</i><br>{$check}"); #$content .= "<tr><td><input type=checkbox name=devices[] value='$id' $checked ></td>"; #$content .= "<td>$name</td><td>". $deviceInfo->get_type_name() ."</td>"; #$content .= "<td>". $deviceInfo->get_location_name() ."</td></tr>"; } #$content .= "</table> <br>"; //get all the device and display them all in the 3 sections "Device Name", "Device Type", "Location". $heading = array("Program", "Path"); $form->setSortable(true); // or false for not sortable $form->setHeadings($heading); $form->setEventHandler($handler); $form->setData($keyData); $form->setTitles($keyTitle); $form->setTableWidth("800px"); $form->setDatabase($postKeys); $form->setUpdateValue("savePaths"); $form->setUpdateText("Save Program Paths"); $content .= $form->editForm(); print $content; }