本文整理汇总了PHP中wm_debug函数的典型用法代码示例。如果您正苦于以下问题:PHP wm_debug函数的具体用法?PHP wm_debug怎么用?PHP wm_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wm_debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReadData
/**
* @param string $targetString The string from the config file
* @param the $map A reference to the map object (redundant)
* @param the $mapItem A reference to the object this target is attached to
* @return array invalue, outvalue, unix timestamp that the data was valid
*/
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetString, $matches)) {
$timezone = $matches[1];
$offset = "now";
if (preg_match("/^([^:]+):(.*)\$/", $timezone, $matches2)) {
$timezone = $matches2[1];
$offset = $matches2[2];
// test that the offset is valid
$timestamp = strtotime($offset);
if ($timestamp === false || $timestamp === -1) {
warn("Time ReadData: Offset String ({$offset}) is bogus - ignoring [WMTIME03]\n");
$offset = "now";
}
}
$timezone_l = strtolower($timezone);
if (array_key_exists($timezone_l, $this->timezones)) {
$tz = $this->timezones[$timezone_l];
wm_debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime($offset, new DateTimeZone($tz));
$mapItem->add_note("time_time12", $dateTime->format("h:i"));
$mapItem->add_note("time_time12ap", $dateTime->format("h:i A"));
$mapItem->add_note("time_time24", $dateTime->format("H:i"));
$mapItem->add_note("time_timet", $dateTime->format("U"));
$mapItem->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data[OUT] = $dateTime->format("i");
$data_time = time();
$matches++;
}
if ($matches == 0) {
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetString} \n");
}
wm_debug("Time ReadData: Returning (" . WMUtility::valueOrNull($data[IN]) . "," . WMUtility::valueOrNull($data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例2: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
$itemname = $item->name;
$matches = 0;
$fd = fopen($targetstring, "r");
if ($fd) {
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
# strip out any Windows line-endings that have gotten in here
$buffer = str_replace("\r", "", $buffer);
if (preg_match("/^{$itemname}\t(\\d+\\.?\\d*[KMGT]*)\t(\\d+\\.?\\d*[KMGT]*)/", $buffer, $matches)) {
$data[IN] = unformat_number($matches[1]);
$data[OUT] = unformat_number($matches[2]);
}
}
$stats = stat($targetstring);
$data_time = $stats['mtime'];
} else {
// some error code to go in here
wm_debug("TabText ReadData: Couldn't open ({$targetstring}). \n");
}
wm_debug("TabText ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例3: run
function run(&$map)
{
$enable = $map->get_hint('post_zabbix_graphs');
if ($enable) {
$this->zabbixApi = new SimpleZabbixApi($map->get_hint('zabbix_url'), $map->get_hint('zabbix_user'), $map->get_hint('zabbix_password'));
if ($this->zabbixApi->isConnected()) {
$baseUrl = $map->get_hint('post_zabbix_graph_base_url');
$addGraphLink = $map->get_hint('post_zabbix_graph_link');
$graphWidth = $map->get_hint('post_zabbix_graph_width');
$graphHeight = $map->get_hint('post_zabbix_graph_height');
$graphPeriod = $map->get_hint('post_zabbix_graph_period');
foreach (array_merge($map->links, $map->nodes) as $item) {
foreach (range(0, 1) as $k) {
// IN and OUT, if necessary
$graph = $item->overliburl[$k];
foreach ($graph as $index => $graphItem) {
if (preg_match('/^zabbix:([-a-zA-Z0-9_\\.\\/\\[\\]]+):([-a-zA-Z0-9_\\.\\/\\[\\]]+):([-a-zA-Z0-9_\\.\\/\\[\\]]+)$/', $graphItem, $matches)) {
$keyname = $matches[1];
$host = $matches[2];
$key = $matches[3];
wm_debug("Zabbix ReadData: Found (" . $host . "," . $key . ")\n");
$graphId = $this->zabbixApi->getGraphId($host, $keyname, $key);
if (isset($graphId)) {
if ($addGraphLink) {
$item->infourl[$k] = $baseUrl . '/charts.php?form_refresh=1&fullscreen=0&graphid=' . $graphId;
}
$item->overliburl[$k][$index] = $baseUrl . '/chart2.php?width=' . $graphWidth . '&height=' . $graphHeight . '&period=' . $graphPeriod . '&stime=now&graphid=' . $graphId;
}
}
}
}
}
}
}
}
示例4: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match("/^dbplug:([^:]+)\$/", $targetString, $matches)) {
$database_user = $map->get_hint('dbplug_dbuser');
$database_pass = $map->get_hint('dbplug_dbpass');
$database_name = $map->get_hint('dbplug_dbname');
$database_host = $map->get_hint('dbplug_dbhost');
$key = mysql_real_escape_string($matches[1]);
// This is the one line you will certainly need to change
$SQL = "select in,out from table where host={$key} LIMIT 1";
if (mysql_connect($database_host, $database_user, $database_pass)) {
if (mysql_select_db($database_name)) {
$result = mysql_query($SQL);
if (!$result) {
wm_warn("dbplug ReadData: Invalid query: " . mysql_error() . "\n");
} else {
$row = mysql_fetch_assoc($result);
$data[IN] = $row['in'];
$data[OUT] = $row['out'];
}
} else {
wm_warn("dbplug ReadData: failed to select database: " . mysql_error() . "\n");
}
} else {
wm_warn("dbplug ReadData: failed to connect to database server: " . mysql_error() . "\n");
}
$data_time = now();
}
wm_debug("RRD ReadData dbplug: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[IN]) . ", {$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例5: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$matches = 0;
if (preg_match($this->regexpsHandled[0], $targetString, $matches)) {
$dataFileName = $matches[1];
$dataItemName = $matches[2];
}
if (!file_exists($dataFileName)) {
wm_warn("WMData ReadData: {$dataFileName} doesn't exist [WMWMDATA01]");
return array(null, null, 0);
}
$fileHandle = fopen($targetString, "r");
if (!$fileHandle) {
wm_warn("WMData ReadData: Couldn't open ({$dataFileName}). [WMWMDATA02]\n");
return array(null, null, 0);
}
list($found, $data) = $this->findDataItem($fileHandle, $dataItemName, $data);
if ($found === true) {
$stats = stat($dataFileName);
$data_time = $stats['mtime'];
} else {
wm_warn("WMData ReadData: Data name '{$dataItemName}' didn't exist in '{$dataFileName}'. [WMWMDATA03]\n");
}
wm_debug(sprintf("WMData ReadData: Returning (%s, %s, %s)\n", string_or_null($data[IN]), string_or_null($data[OUT]), $data_time));
return array($data[IN], $data[OUT], $data_time);
}
示例6: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match("/^zabbix:([-a-zA-Z0-9_\\.\\/\\[\\]]+):([-a-zA-Z0-9_\\.\\/\\[\\]]+):([-a-zA-Z0-9_\\.\\/\\[\\]]+):([-a-zA-Z0-9_\\.\\/\\[\\]]+)\$/", $targetstring, $matches)) {
$zabbix_uri = $map->get_hint('zabbix_uri');
$zabbix_key = $matches[1];
$host = $matches[2];
$in = $matches[3];
$out = $matches[4];
wm_debug("Zabbix ReadData: Found (" . $host . "," . $in . "," . $out . ")\n");
$raw_out_value = $this->zabbixApi->getItemLastValue($host, $zabbix_key, $out);
$raw_in_value = $this->zabbixApi->getItemLastValue($host, $zabbix_key, $in);
$in_value = $raw_in_value["lastvalue"];
$out_value = $raw_out_value["lastvalue"];
$data_time = $raw_out_value["lastclock"];
if (isset($in_value)) {
$data[IN] = $in_value;
}
if (isset($out_value)) {
$data[OUT] = $out_value;
}
}
wm_debug("Zabbix ReadData: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[IN]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例7: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
$itemname = $item->name;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetstring, $matches)) {
$timezone = $matches[1];
$timezone_l = strtolower($timezone);
$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach ($timezone_identifiers as $tz) {
if (strtolower($tz) == $timezone_l) {
wm_debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime("now", new DateTimeZone($tz));
$item->add_note("time_time12", $dateTime->format("h:i"));
$item->add_note("time_time12ap", $dateTime->format("h:i A"));
$item->add_note("time_time24", $dateTime->format("H:i"));
$item->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data_time = time();
$data[OUT] = $dateTime->format("i");
$matches++;
}
}
if ($matches == 0) {
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetstring} \n");
}
wm_debug("Time ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例8: getSlope
public function getSlope()
{
if ($this->dx == 0) {
// special case - if slope is infinite, fudge it to be REALLY BIG instead. Close enough for TV.
wm_debug("Slope is infinite.\n");
return 10000000000.0;
}
return $this->dy / $this->dx;
}
示例9: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match("/^cactihost:(\\d+)\$/", $targetString, $matches)) {
$cacti_id = intval($matches[1]);
$SQL = "select * from host where id={$cacti_id}";
// 0=disabled
// 1=down
// 2=recovering
// 3=up
// (4 is tholdbreached in cactimonitor, so skipped here for compatibility)
// 5=unknown
$state = -1;
$result = db_fetch_row($SQL);
if (isset($result)) {
// create a note, which can be used in icon filenames or labels more nicely
if ($result['status'] == 5) {
$state = 5;
$statename = 'unknown';
}
if ($result['status'] == 1) {
$state = 1;
$statename = 'down';
}
if ($result['status'] == 2) {
$state = 2;
$statename = 'recovering';
}
if ($result['status'] == 3) {
$state = 3;
$statename = 'up';
}
if ($result['disabled']) {
$state = 0;
$statename = 'disabled';
}
$data[IN] = $state;
$data[OUT] = $state;
$mapItem->add_note("state", $statename);
$mapItem->add_note("cacti_description", $result['description']);
$mapItem->add_note("cacti_hostname", $result['hostname']);
$mapItem->add_note("cacti_curtime", $result['cur_time']);
$mapItem->add_note("cacti_avgtime", $result['avg_time']);
$mapItem->add_note("cacti_mintime", $result['min_time']);
$mapItem->add_note("cacti_maxtime", $result['max_time']);
$mapItem->add_note("cacti_availability", $result['availability']);
$mapItem->add_note("cacti_faildate", $result['status_fail_date']);
$mapItem->add_note("cacti_recdate", $result['status_rec_date']);
}
}
wm_debug("CactiHost ReadData: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例10: run
public function run()
{
$enable = $this->owner->get_hint("post_test_enable");
if ($enable) {
wm_debug(__CLASS__ . " is here\n");
// do your work in here...
$orig = $this->owner->get_note("test");
$this->owner->add_note("test", $orig . " TESTYTEST");
} else {
wm_debug(__CLASS__ . " Not Enabled\n");
}
}
示例11: getTimeForTimeZone
/**
* @param $timezone
* @param $offset
* @return array
* @internal param $mapItem
* @internal param $data
* @internal param $matches
* @internal param $timezone_l
*/
private function getTimeForTimeZone($timezone, $offset)
{
$timezone_l = strtolower($timezone);
if (array_key_exists($timezone_l, $this->timezones)) {
$timezone_name = $this->timezones[$timezone_l];
wm_debug("Time ReadData: Timezone exists: {$timezone_name}\n");
$dateTime = new DateTime($offset, new DateTimeZone($timezone_name));
return array($dateTime, $timezone_name);
}
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
return null;
}
示例12: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match('/^cactihost:(\\d+)$/', $targetString, $matches)) {
$cacti_id = intval($matches[1]);
$data = $this->readDataFromCacti($mapItem, $cacti_id, $data);
}
wm_debug("CactiHost ReadData: Returning (" . ($data[IN] === null ? 'null' : $data[IN]) . "," . ($data[OUT] === null ? 'null' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例13: run
function run(&$map)
{
$enable = $map->get_hint("post_test_enable");
if ($enable) {
wm_debug(__CLASS__ . " is here\n");
// do your work in here...
$orig = $map->get_note("test");
$map->add_note("test", $orig . " TESTYTEST");
// -------------------------
} else {
wm_debug(__CLASS__ . " Not Enabled\n");
}
}
示例14: ReadData
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (1 === preg_match('/^cacti:(\\d+)$/', $targetString, $matches)) {
$local_data_id = intval($matches[1]);
$SQL = 'select * from weathermap_data where local_data_id=' . $local_data_id;
$result = db_fetch_row($SQL);
}
wm_debug(sprintf("cacti ReadData: Returning (%s, %s, %s)\n", string_or_null($data[IN]), string_or_null($data[OUT]), $data_time));
return array($data[IN], $data[OUT], $data_time);
}
示例15: UpdateCactiData
function UpdateCactiData(&$item, $local_data_id)
{
$map = $item->owner;
wm_debug("fetching for {$local_data_id}\n");
if (isset($map->dsinfocache[$local_data_id])) {
$to_set = $map->dsinfocache[$local_data_id];
} else {
$to_set = array();
$set_speed = intval($item->get_hint("cacti_use_ifspeed"));
$r3 = db_fetch_assoc(sprintf("select data_local.host_id, field_name,field_value from data_local,host_snmp_cache USE INDEX (host_id) where data_local.id=%d and data_local.host_id=host_snmp_cache.host_id and data_local.snmp_index=host_snmp_cache.snmp_index and data_local.snmp_query_id=host_snmp_cache.snmp_query_id", $local_data_id));
foreach ($r3 as $vv) {
$vname = "cacti_" . $vv['field_name'];
$to_set[$vname] = $vv['field_value'];
}
if ($set_speed != 0) {
$ifSpeed = intval($to_set['cacti_ifSpeed']);
$ifHighSpeed = intval($to_set['cacti_ifHighSpeed']);
$speed = 0;
if ($ifSpeed > 0) {
$speed = $ifSpeed;
}
# see https://lists.oetiker.ch/pipermail/mrtg/2004-November/029312.html
if ($ifHighSpeed > 20) {
$speed = $ifHighSpeed . "M";
}
if ($speed > 0) {
// might need to dust these off for php4...
if ($item->my_type() == 'NODE') {
$map->nodes[$item->name]->max_bandwidth_in = $speed;
$map->nodes[$item->name]->max_bandwidth_out = $speed;
}
if ($item->my_type() == 'LINK') {
$map->links[$item->name]->max_bandwidth_in = $speed;
$map->links[$item->name]->max_bandwidth_out = $speed;
}
}
}
if (isset($vv['host_id'])) {
$to_set['cacti_host_id'] = intval($vv['host_id']);
}
$r4 = db_fetch_row(sprintf("SELECT DISTINCT graph_templates_item.local_graph_id,title_cache FROM graph_templates_item,graph_templates_graph,data_template_rrd WHERE data_template_rrd.id=task_item_id and graph_templates_graph.local_graph_id = graph_templates_item.local_graph_id and local_data_id=%d LIMIT 1", $local_data_id));
if (isset($r4['local_graph_id'])) {
$to_set["cacti_graph_id"] = intval($r4['local_graph_id']);
}
$map->dsinfocache[$local_data_id] = $to_set;
}
# By now, we have the values, one way or another.
foreach ($to_set as $k => $v) {
$item->add_note($k, $v);
}
}