本文整理汇总了PHP中Property::get_property方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::get_property方法的具体用法?PHP Property::get_property怎么用?PHP Property::get_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::get_property方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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;
}
示例2: Property
function get_content()
{
//use the property class to get content from db
include_once "classes/Property.php";
//name of the property
$name = "Plugin_HelloWorld_greetings";
//create the property to get information
$property = new Property($name);
//if this property gets the information, show the information out
if ($propertyInfo = $property->get_property($name)) {
return "<h1>" . addslashes($propertyInfo) . "</h1>";
} else {
return $this->content;
}
}
示例3: number
function update_performance_data()
{
/*
Expected format of $this->performance_data is multiple label value tuples
seperated by comma whitespace ", " example:
percent_packet_loss=0, rta=0.80
This is the nagios plugin perfomance data format:
'label'=value[UOM];[warn];[crit];[min];[max]
For now we don't implement [warn];[crit];[min];[max] , just the data
UOM (unit of measurement) is one of:
no unit specified - assume a number (int or float) of things (eg, users, processes, load averages)
s - seconds (also us, ms)
% - percentage
B - bytes (also KB, MB, TB)
c - a continous counter (such as bytes transmitted on an interface)
This will be implemented as all GAUGE RRD datatypes
expecpt for c - a continous counter, this should be COUNTER/DERIVE
*/
if (!is_null($this->performance_data) && !empty($this->performance_data)) {
// Now split perf data, and store in $rrd_data
$rrd_data = array();
$perfdata = trim($this->performance_data);
$sections = preg_split("/,/", $perfdata, -1, PREG_SPLIT_NO_EMPTY);
foreach ($sections as $k => $word) {
// Now split the key value part
$tupple = preg_split("/=/", $word, -1, PREG_SPLIT_NO_EMPTY);
$label = trim($tupple[0]);
// label
$value = trim($tupple[1]);
// value
if (!array_key_exists(0, $tupple) || !array_key_exists(1, $tupple) || $label == '' || $value == '') {
print "{$label} {$value}\n";
print "Warning invalid performance data part '{$tupple}' in {$perfdata}\n";
continue;
}
// Store data
// A DS can not be longer than 19 chars, so we need to reformaat that
$tmp_label = substr($label, 0, 18);
$rrd_data[$label]['label'] = $tmp_label;
// Determine type based on UOM (unit of measurement)
// Only if it ends with "c" (counter) do we need a counter
// Use preg_replace to replace c$ (last c) if that's the case
// it's a counter, we then have to correct value
// all others are GAUGE
// For clarity, spell out other cases, we need to strip all of the
// UOM anyways
if (preg_match("/c\$/", $value)) {
$new_val = preg_replace("/c\$/", "", $value);
//print "Detected counter ,$value matched c$ new value is $new_val\n";
// A counter always has to be a 'simple integer', no floats and positive
$new_val = intval($new_val);
$rrd_data[$label]['type'] = "COUNTER";
$rrd_data[$label]['value'] = $new_val;
} elseif (preg_match("/(s)\$|(ms)\$|(us)\$/", $value, $matches)) {
$new_val = preg_replace("/s\$|ms\$|us\$/", "", $value);
//print "Detected s - seconds (also us, ms)\n";
// Rewrite to seconds
if ($matches[0] == "s") {
$new_val = $new_val * 1;
} elseif ($matches[0] == "ms") {
$new_val = $new_val * pow(10, -3);
} elseif ($matches[0] == "us") {
$new_val = $new_val * pow(10, -6);
}
$rrd_data[$label]['type'] = "GAUGE";
$rrd_data[$label]['value'] = $new_val;
} elseif (preg_match("/%\$/", $value)) {
$new_val = preg_replace("/%\$/", "", $value);
//print "Detected % $value matched % new value is $new_val\n";
$rrd_data[$label]['type'] = "GAUGE";
$rrd_data[$label]['value'] = $new_val;
} elseif (preg_match("/(B)\$|(KB)\$|(MB)\$|(GB)\$|(TB)\$|(PB)\$/", $value, $matches)) {
$new_val = preg_replace("/B\$|KB\$|MB\$|GB\$|TB\$|PB\$/", "", $value);
// Rewrite to bytes
if ($matches[0] == "B") {
$new_val = $new_val * 1;
} elseif ($matches[0] == "KB") {
$new_val = $new_val * pow(10, 3);
} elseif ($matches[0] == "MB") {
$new_val = $new_val * pow(10, 6);
} elseif ($matches[0] == "GB") {
$new_val = $new_val * pow(10, 9);
} elseif ($matches[0] == "TB") {
$new_val = $new_val * pow(10, 12);
} elseif ($matches[0] == "PB") {
$new_val = $new_val * pow(10, 15);
}
$rrd_data[$label]['type'] = "GAUGE";
$rrd_data[$label]['value'] = $new_val;
} else {
//print "Detected default\n";
$rrd_data[$label]['type'] = "GAUGE";
$rrd_data[$label]['value'] = $value;
}
}
// Now check if the rrd file already exists, or if we need to create it
$property = new Property();
$rrdtool = $property->get_property("path_rrdtool");
//.........这里部分代码省略.........
示例4: Property
<?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'];
示例5: get_files_for_device
private function get_files_for_device($device_id)
{
if (!is_numeric($device_id)) {
return;
}
$selectedDevice = new Device($device_id);
$output = "<h2>Displaying Counters for: <b>" . $selectedDevice->get_name() . "</b></h2><br>";
//print $selectedDevice->get_name() . "<br>";
$property = new Property();
if ($rrdtool = $property->get_property("path_rrdtool")) {
} else {
return;
}
if ($rrd_dir = $property->get_property("path_rrddir")) {
} else {
return;
}
$pattern = "{$rrd_dir}/fwcounters/fwcounter_deviceid" . $device_id . "_*.rrd";
$files = glob($pattern);
foreach ($files as $v) {
$path_parts = pathinfo($v);
$fullPath = "fwcounters/" . $path_parts['basename'];
$fileName = $path_parts['filename'];
//(\d+)_(.+)$
$searchPattern = '/fwcounter_deviceid(\\d+)_(.+)$/';
$replacement = $selectedDevice->get_name() . ' $2';
$counterName = preg_replace($searchPattern, $replacement, $fileName);
// If this is an interface-specific counter then show more info about the interface
$outputPortInfo = "";
// print strtolower($counterName);
//ge-0-2-5.0
$arrPortTypes = array();
$arrPortTypes[] = "fe";
$arrPortTypes[] = "ge";
$arrPortTypes[] = "xe";
$arrPortTypes[] = "et";
$interfaceName = false;
foreach ($arrPortTypes as $k => $v) {
$interfaceName = strstr($counterName, $v . "-");
if ($interfaceName != false) {
$interfaceName = strtr($interfaceName, array('-' => '/'));
$interfaceName = str_replace($v . "/", $v . "-", $interfaceName);
break;
}
}
if ($interfaceName != false) {
$thisDevice = new Device($device_id);
$interfaceID = $thisDevice->get_interface_id_by_name($interfaceName);
if ($interfaceID) {
$thisPort = new Port($interfaceID);
$outputPortInfo = "<br>Port description: " . $thisPort->get_alias();
}
}
$output .= "<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2'><h3>RRD File: {$fileName} {$outputPortInfo} </h3></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>";
$height = 150;
$width = 550;
$from = "-1d";
if (isset($_GET['From'])) {
$from = $_GET['From'];
}
$graph = "Bits Per Second";
$graph = str_replace(" ", "%20", $graph);
$type = "traffic";
$type = str_replace(" ", "%20", $type);
$link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type;
$output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br><br>";
$output .= "</td><td>";
$graph = "Unicast Packets Per Second";
$graph = str_replace(" ", "%20", $graph);
$type = "unicastpkts";
$type = str_replace(" ", "%20", $type);
$link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type;
$output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br>";
$output .= "</td></tr><br><hr>";
}
return $output;
}
示例6: displayCheckGraphs
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}'>";
}
示例7: displayPaths
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;
}
示例8: get_ldap_groups
private function get_ldap_groups($user_name, $user_pass)
{
$property = new Property();
if (!($ldap_server = $property->get_property("LDAP_server"))) {
$this->error = "No ldap server specified. Please configure an LDAP server address";
return false;
}
if (!($ldap_version = $property->get_property("LDAP_version"))) {
$this->error = "No ldap version specified. Please configure an LDAP protocol version ";
return false;
}
if (!($dn = $property->get_property("LDAP_DN"))) {
$this->error = "No ldap Distinguished Name specified. Please configure a Distinguished Name ";
return false;
}
if (!($group_base_dn = $property->get_property("LDAP_group_base_dn"))) {
$this->error = "No ldap group base DN specified. Please configure a group base DN ";
return false;
}
if (!($group_search = $property->get_property("LDAP_group_search_filter"))) {
$this->error = "No ldap group search filter specified. ";
return false;
}
// These should be retrieved using get_properties
#$ldap_version = 3;
#$ldap_server = 'ldap.bc.net';
#$dn = "cn=<username>,ou=people,dc=bc,dc=net";
#$group_base_dn = "ou=groups,dc=bc,dc=net";
#$group_search = "uniqueMember=cn=<username>,ou=people,dc=bc,dc=net" ;
/* strip bad chars from username - prevent altering filter from username */
$user_name = str_replace("&", "", $user_name);
$user_name = str_replace("|", "", $user_name);
$user_name = str_replace("(", "", $user_name);
$user_name = str_replace(")", "", $user_name);
$user_name = str_replace("*", "", $user_name);
$user_name = str_replace(">", "", $user_name);
$user_name = str_replace("<", "", $user_name);
$user_name = str_replace("!", "", $user_name);
$user_name = str_replace("=", "", $user_name);
$dn = str_replace("<username>", $user_name, $dn);
$group_search = str_replace("<username>", $user_name, $group_search);
// Set result to false;
$result = false;
if (!($connect = ldap_connect($ldap_server))) {
$this->error = "Could not connect to LDAP server: {$ldap_server}";
return false;
}
if (!ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, $ldap_version)) {
$this->error = "Failed to set version to protocol {$ldap_version}";
return false;
}
// verify binding
if ($bind = @ldap_bind($connect, $dn, $user_pass)) {
} else {
// unable to bind
$ldap_error = ldap_errno($connect);
$this->error = ldap_error($connect);
$result = false;
}
// Get all groups
$member_groups = array();
$sr = ldap_search($connect, $group_base_dn, $group_search);
$info = ldap_get_entries($connect, $sr);
for ($i = 0; $i < $info["count"]; $i++) {
array_push($member_groups, $info[$i]["cn"][0]);
}
return $member_groups;
}