本文整理汇总了PHP中device_by_name函数的典型用法代码示例。如果您正苦于以下问题:PHP device_by_name函数的具体用法?PHP device_by_name怎么用?PHP device_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_by_name函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_vm_row
function print_vm_row($vm, $device = NULL)
{
echo '<tr>';
echo '<td>';
if (getidbyname($vm['vmwVmDisplayName'])) {
echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
} else {
echo $vm['vmwVmDisplayName'];
}
echo "</td>";
echo '<td>' . $vm['vmwVmState'] . "</td>";
if ($vm['vmwVmGuestOS'] == "E: tools not installed") {
echo '<td class="small">Unknown (VMware Tools not installed)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "E: tools not running") {
echo '<td class="small">Unknown (VMware Tools not running)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "") {
echo '<td class="small"><i>(Unknown)</i></td>';
} elseif (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
echo '<td>' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . "</td>";
} else {
echo '<td>' . $vm['vmwVmGuestOS'] . "</td>";
}
}
}
if ($vm['vmwVmMemSize'] >= 1024) {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize'] / 1024) . " GB</td>";
} else {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize']) . " MB</td>";
}
echo '<td>' . $vm['vmwVmCpus'] . " CPU</td>";
}
示例2: generate_device_link
<?php
echo '<tr class="list">';
echo '<td class="list">';
if (getidbyname($vm['vmwVmDisplayName'])) {
echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
} else {
echo $vm['vmwVmDisplayName'];
}
echo '</td>';
echo '<td class="list">' . $vm['vmwVmState'] . '</td>';
if ($vm['vmwVmGuestOS'] == 'E: tools not installed') {
echo '<td class="box-desc">Unknown (VMware Tools not installed)</td>';
} else {
if ($vm['vmwVmGuestOS'] == '') {
echo '<td class="box-desc"><i>(Unknown)</i></td>';
} else {
if (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
echo '<td class="list">' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . '</td>';
} else {
echo '<td class="list">' . $vm['vmwVmGuestOS'] . '</td>';
}
}
}
if ($vm['vmwVmMemSize'] >= 1024) {
echo '<td class=list>' . sprintf('%.2f', $vm['vmwVmMemSize'] / 1024) . ' GB</td>';
} else {
echo '<td class=list>' . sprintf('%.2f', $vm['vmwVmMemSize']) . ' MB</td>';
}
echo '<td class="list">' . $vm['vmwVmCpus'] . ' CPU</td>';
示例3: print_graph_row
echo '<tr><td>';
echo '<h3>Aggregate</h3>';
print_graph_row($graph_array);
echo '</td></tr>';
unset($graph_array['legend']);
asort($smokeping_files['outgoing'][$device['hostname']]);
foreach ($smokeping_files['outgoing'][$device['hostname']] as $host) {
$hostname = basename($host, ".rrd");
list($hostname) = explode("~", $hostname);
if ($config['smokeping']['suffix']) {
$hostname = $hostname . $config['smokeping']['suffix'];
}
if ($config['smokeping']['split_char']) {
$hostname = str_replace($config['smokeping']['split_char'], ".", $hostname);
}
$host = device_by_name($hostname);
if (is_numeric($host['device_id'])) {
echo '<tr><td>';
echo '<h3>' . generate_device_link($host) . '</h3>';
$graph_array['type'] = "smokeping_out";
$graph_array['device'] = $device['device_id'];
$graph_array['dest'] = $host['device_id'];
print_graph_row($graph_array);
echo '</td></tr>';
}
}
}
}
echo '</table>';
$pagetitle[] = "Latency";
// EOF
示例4: escapeshellcmd
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
if (!is_admin()) {
echo "Insufficient Privileges";
exit;
}
$hostname = escapeshellcmd($_REQUEST['hostname']);
$type = $_REQUEST['type'];
switch ($type) {
case 'poller':
$cmd = "php {$config['install_dir']}/poller.php -h {$hostname} -r -f -d";
$filename = "poller-{$hostname}.txt";
break;
case 'snmpwalk':
$device = device_by_name(mres($hostname));
$cmd = gen_snmpwalk_cmd($device, '.', ' -Onet');
if ($debug) {
$cmd .= ' 2>&1';
}
$filename = $device['os'] . '-' . $device['hostname'] . '.snmpwalk';
break;
case 'discovery':
$cmd = "php {$config['install_dir']}/discovery.php -h {$hostname} -d";
$filename = "discovery-{$hostname}.txt";
break;
default:
echo 'You must specify a valid type';
exit;
}
// ---- Output ----
示例5: foreach
<?php
// Push $_GET into $vars to be compatible with web interface naming
foreach ($_GET as $name => $value) {
$vars[$name] = $value;
}
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
if (is_numeric($vars['device'])) {
$device = device_by_id_cache($vars['device']);
} else {
if (!empty($vars['device'])) {
$device = device_by_name($vars['device']);
}
}
// FIXME -- remove these
$width = $vars['width'];
$height = $vars['height'];
$title = $vars['title'];
$vertical = $vars['vertical'];
$legend = $vars['legend'];
$from = isset($vars['from']) ? $vars['from'] : time() - 60 * 60 * 24;
$to = isset($vars['to']) ? $vars['to'] : time();
if ($from < 0) {
$from = $to + $from;
}
$period = $to - $from;
$prev_from = $from - $period;
$graphfile = $config['temp_dir'] . '/' . strgen() . '.png';
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
if ($auth !== true && $auth != 1) {
示例6: gethostbyname
} else {
$query = '*';
}
if (isset($current)) {
$offset = $current * $rowCount - $rowCount;
$limit = $rowCount;
}
if ($rowCount != -1) {
$extra_query = "&limit={$limit}&offset={$offset}";
}
if (!empty($filter_hostname)) {
if (!empty($query)) {
$query .= ' && ';
}
$ip = gethostbyname($filter_hostname);
$device = device_by_name($filter_hostname);
$query .= 'source:"' . $filter_hostname . '" || source:"' . $ip . '"';
if (isset($device['ip']) && $ip != $device['ip']) {
$query .= ' || source:"' . $device['ip'] . '"';
}
}
if (isset($config['graylog']['base_uri'])) {
$graylog_base = $config['graylog']['base_uri'];
} elseif (version_compare($config['graylog']['version'], '2.1', '>=')) {
$graylog_base = '/api/search/universal/relative';
} else {
$graylog_base = '/search/universal/relative';
}
$graylog_url = $config['graylog']['server'] . ':' . $config['graylog']['port'] . $graylog_base . '?query=' . urlencode($query) . '&range=' . $filter_range . $extra_query;
$context = stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode($config['graylog']['username'] . ':' . $config['graylog']['password']) . "\r\n" . "Accept: application/json")));
$messages = json_decode(file_get_contents($graylog_url, false, $context), true);
示例7: generate_entity_link
function generate_entity_link($entity_type, $entity, $text = NULL, $graph_type = NULL, $escape = TRUE, $short = FALSE)
{
if (is_numeric($entity)) {
$entity = get_entity_by_id_cache($entity_type, $entity);
}
entity_rewrite($entity_type, $entity);
switch ($entity_type) {
case "device":
$link = generate_device_link($entity);
break;
case "mempool":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'mempool'));
break;
case "processor":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'processor'));
break;
case "status":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'status', 'id' => $entity['status_id']));
break;
case "sensor":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => $entity['sensor_class'], 'id' => $entity['sensor_id']));
break;
case "printersupply":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'printing', 'supply' => $entity['supply_type']));
break;
case "port":
$link = generate_port_link($entity, NULL, $graph_type, $escape, $short);
break;
case "storage":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
break;
case "bgp_peer":
$url = generate_url(array('page' => 'device', 'device' => $entity['peer_device_id'] ? $entity['peer_device_id'] : $entity['device_id'], 'tab' => 'routing', 'proto' => 'bgp'));
break;
case "netscalervsvr":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_vsvr', 'vsvr' => $entity['vsvr_id']));
break;
case "netscalersvc":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_services', 'svc' => $entity['svc_id']));
break;
case "netscalersvcgrpmem":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_servicegroupmembers', 'svc' => $entity['svc_id']));
break;
case "sla":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'slas', 'id' => $entity['sla_id']));
break;
case "pseudowire":
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'pseudowires', 'id' => $entity['pseudowire_id']));
break;
case "maintenance":
$url = generate_url(array('page' => 'alert_maintenance', 'maintenance' => $entity['maint_id']));
break;
case "group":
$url = generate_url(array('page' => 'group', 'group_id' => $entity['group_id']));
break;
case "virtualmachine":
// If we know this device by its vm name in our system, create a link to it, else just print the name.
if (get_device_id_by_hostname($entity['vm_name'])) {
$link = generate_device_link(device_by_name($entity['vm_name']));
} else {
// Hardcode $link to just show the name, no actual link
$link = $entity['vm_name'];
}
break;
default:
$url = NULL;
}
if (!isset($link)) {
if (!isset($text)) {
if ($short && $entity['entity_shortname']) {
$text = $entity['entity_shortname'];
} else {
$text = $entity['entity_name'];
}
}
if ($escape) {
$text = escape_html($text);
}
$link = '<a href="' . $url . '" class="entity-popup ' . $entity['html_class'] . '" data-eid="' . $entity['entity_id'] . '" data-etype="' . $entity_type . '">' . $text . '</a>';
}
return $link;
}
示例8: print_vm_row
function print_vm_row($vm, $device = NULL)
{
echo '<tr>';
echo '<td>';
if (get_device_id_by_hostname($vm['vmwVmDisplayName'])) {
echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
} else {
echo $vm['vmwVmDisplayName'];
}
echo "</td>";
echo '<td>' . $vm['vmwVmState'] . "</td>";
if ($vm['vmwVmGuestOS'] == "E: 工具未安装") {
echo '<td class="small">未知 (VMware Tools 未安装)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "E: 工具未运行") {
echo '<td class="small">未知 (VMware Tools 未运行)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "") {
echo '<td class="small"><i>(未知)</i></td>';
} elseif (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
echo '<td>' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . "</td>";
} else {
echo '<td>' . $vm['vmwVmGuestOS'] . "</td>";
}
}
}
if ($vm['vmwVmMemSize'] >= 1024) {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize'] / 1024) . " GB</td>";
} else {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize']) . " MB</td>";
}
echo '<td>' . $vm['vmwVmCpus'] . " CPU</td>";
}