本文整理汇总了PHP中getidbyname函数的典型用法代码示例。如果您正苦于以下问题:PHP getidbyname函数的具体用法?PHP getidbyname怎么用?PHP getidbyname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getidbyname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: get_inventory
function get_inventory()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$err_msg = '';
$code = 500;
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$sql = '';
$params = array();
if (isset($_GET['entPhysicalClass']) && !empty($_GET['entPhysicalClass'])) {
$sql .= ' AND entPhysicalClass=?';
$params[] = mres($_GET['entPhysicalClass']);
}
if (isset($_GET['entPhysicalContainedIn']) && !empty($_GET['entPhysicalContainedIn'])) {
$sql .= ' AND entPhysicalContainedIn=?';
$params[] = mres($_GET['entPhysicalContainedIn']);
} else {
$sql .= ' AND entPhysicalContainedIn="0"';
}
if (!is_numeric($device_id)) {
$err_msg = 'Invalid device provided';
$total_inv = 0;
$inventory = array();
} else {
$inventory = dbFetchRows("SELECT * FROM `entPhysical` WHERE 1 {$sql}", $params);
$code = 200;
$status = 'ok';
$total_inv = count($inventory);
}
$output = array('status' => $status, 'err-msg' => $err_msg, 'count' => $total_inv, 'inventory' => $inventory);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例3: print_optionbar_start
$pagetitle[] = 'Syslog';
print_optionbar_start();
?>
<div id="{{ctx.id}}" class="{{css.header}}">
<div class="row">
<div class="col-sm-9 actionBar">
<div class="pull-left">
<form method="post" action="" class="form-inline" role="form" id="result_form">
<div class="form-group">
<select name="device" id="device" class="form-control input-sm">
<option value="">All Devices</option>
<?php
foreach (get_all_devices() as $hostname) {
$device_id = getidbyname($hostname);
if (device_permitted($device_id)) {
echo '"<option value="' . $device_id . '"';
if ($device_id == $vars['device']) {
echo ' selected';
}
echo '>' . $hostname . '</option>';
}
}
?>
</select>
</div>
<div class="form-group">
<select name="program" id="program" class="form-control input-sm">
<option value="">All Programs</option>
<?php
示例4: sprintf
<?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>';
示例5: device_by_name
function device_by_name($name, $refresh = 0)
{
// FIXME - cache name > id too.
return device_by_id_cache(getidbyname($name), $refresh);
}
示例6: update_device
function update_device()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 500;
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$data = json_decode(file_get_contents('php://input'), true);
$bad_fields = array('id', 'hostname');
if (empty($data['field'])) {
$message = 'Device field to patch has not been supplied';
} elseif (in_array($data['field'], $bad_fields)) {
$message = 'Device field is not allowed to be updated';
} else {
if (dbUpdate(array(mres($data['field']) => mres($data['data'])), 'devices', '`device_id`=?', array($device_id)) >= 0) {
$status = 'ok';
$message = 'Device ' . mres($data['field']) . ' field has been updated';
$code = 200;
} else {
$message = 'Device ' . mres($data['field']) . ' field failed to be updated';
}
}
$output = array('status' => $status, 'message' => $message);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例7: list_ipsec
function list_ipsec()
{
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$message = '';
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
if (!is_numeric($device_id)) {
$message = "No valid hostname or device ID provided";
} else {
$ipsec = dbFetchRows("SELECT `D`.`hostname`, `I`.* FROM `ipsec_tunnels` AS `I`, `devices` AS `D` WHERE `I`.`device_id`=? AND `D`.`device_id` = `I`.`device_id`", array($device_id));
$total = count($ipsec);
$status = 'ok';
$code = 200;
}
$output = array('status' => $status, 'err-msg' => $message, 'count' => $total, 'ipsec' => $ipsec);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例8: list_services
function list_services()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'ok';
$code = 200;
$message = '';
$host_par = array();
$sql_param = array();
$services = array();
$where = '';
$devicewhere = '';
// Filter BY STATE
if (isset($_GET['state'])) {
$where = " AND S.service_status= ? AND S.service_disabled='0' AND S.service_ignore='0'";
$host_par[] = $_GET['state'];
if (!is_numeric($_GET['state'])) {
$status = 'error';
$message = "No valid service state provided, valid option is 0=Ok, 1=Warning, 2=Critical";
}
}
// GET BY HOST
if (isset($router['hostname'])) {
$hostname = $router['hostname'];
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$where .= " AND S.device_id = ?";
$host_par[] = $device_id;
if (!is_numeric($device_id)) {
$status = 'error';
$message = "No valid hostname or device id provided";
}
}
// DEVICE
$host_sql = 'SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.device_id ' . $where . ' GROUP BY D.hostname ORDER BY D.hostname';
// SERVICE
foreach (dbFetchRows($host_sql, $host_par) as $device) {
$device_id = $device['device_id'];
$sql_param[0] = $device_id;
// FILTER BY TYPE
if (isset($_GET['type'])) {
$devicewhere = " AND `service_type` LIKE ?";
$sql_param[1] = $_GET['type'];
}
$services = dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ?" . $devicewhere, $sql_param);
}
$count = count($services);
$output = array('status' => $status, 'err-msg' => $message, 'count' => $count, 'services' => $services);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例9: get_port_graphs
function get_port_graphs()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$hostname = $router['hostname'];
if (isset($_GET['columns'])) {
$columns = $_GET['columns'];
} else {
$columns = 'ifName';
}
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$ports = dbFetchRows("SELECT {$columns} FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device_id));
$total_ports = count($ports);
$output = array("status" => "ok", "err-msg" => '', "count" => $total_ports, "ports" => $ports);
$app->response->setStatus('200');
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例10: chdir
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @author Adam Armstrong <adama@memetic.org>
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
$scriptname = basename($argv[0]);
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1]) {
$host = strtolower($argv[1]);
$id = getidbyname($host);
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) == 'rrd' ? TRUE : FALSE;
// Test if a valid id was fetched from getidbyname.
if (isset($id) && is_numeric($id)) {
print_warning(delete_device($id, $delete_rrd));
print_success("Device {$host} removed.");
} else {
print_error("Device {$host} doesn't exist!");
}
} else {
print_message("%n\nUSAGE:\n{$scriptname} <hostname> [rrd]\n\nEXAMPLE:\n%WKeep RRDs%n: {$scriptname} <hostname>\n%WRemove RRDs%n: {$scriptname} <hostname> rrd\n\n%rInvalid arguments!%n", 'color', FALSE);
}
// EOF
示例11: foreach
templates: {
header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">"+
"<div class=\"col-sm-8 actionBar\"><span class=\"pull-left\">"+
"<form method=\"post\" action=\"\" class=\"form-inline\" role=\"form\" id=\"result_form\">"+
"<div class=\"form-group\">"+
"<label>"+
"<strong>Device </strong>"+
"</label>"+
"<select name=\"device_id\" id=\"device_id\" class=\"form-control input-sm\">"+
"<option value=\"\">All Devices</option>"+
<?php
foreach (get_all_devices() as $hostname) {
$device_id = getidbyname($hostname);
if (device_permitted($device_id)) {
echo '"<option value=\\"' . $device_id . '\\""+';
if (getidbyname($hostname) == $_POST['device_id']) {
echo '" selected "+';
}
echo '">' . $hostname . '</option>"+';
}
}
?>
"</select>"+
"</div>"+
"<div class=\"form-group\">"+
"<label>"+
"<strong> State </strong>"+
"</label>"+
"<select name=\"state\" id=\"state\" class=\"form-control input-sm\">"+
"<option value=\"-1\"></option>"+
"<option value=\"0\">Ok</option>"+
示例12: chdir
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
$scriptname = basename($argv[0]);
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRename Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1] && $argv[2]) {
$host = strtolower($argv[1]);
$id = getidbyname($host);
if ($id) {
$tohost = strtolower($argv[2]);
$toid = getidbyname($tohost);
if ($toid) {
print_error("NOT renamed. New hostname {$tohost} already exists.");
} else {
if (renamehost($id, $tohost, 'console')) {
print_message("Host {$host} renamed to {$tohost}.");
}
}
} else {
print_error("Host {$host} doesn't exist.");
}
} else {
print_message("%n\nUSAGE:\n{$scriptname} <old hostname> <new hostname>\n\n%rInvalid arguments!%n", 'color', FALSE);
}
// EOF
示例13: get_device_groups
function get_device_groups()
{
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
if (is_numeric($device_id)) {
$groups = GetGroupsFromDevice($device_id, 1);
} else {
$groups = GetDeviceGroups();
}
if (empty($groups)) {
$message = 'No device groups found';
} else {
$status = 'ok';
$code = 200;
$message = 'Found ' . count($groups) . ' device groups';
}
$output = array('status' => $status, 'message' => $message, 'count' => count($groups), 'groups' => $groups);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例14: foreach
templates: {
header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">"+
"<div class=\"col-sm-8 actionBar\"><span class=\"pull-left\">"+
"<form method=\"post\" action=\"\" class=\"form-inline\" role=\"form\" id=\"result_form\">"+
"<div class=\"form-group\">"+
"<label>"+
"<strong>Device </strong>"+
"</label>"+
"<select name=\"device_id\" id=\"device_id\" class=\"form-control input-sm\">"+
"<option value=\"\">All Devices</option>"+
<?php
foreach (get_all_devices() as $hostname) {
$device_id = getidbyname($hostname);
if (device_permitted($device_id)) {
echo '"<option value=\\"' . $device_id . '\\""+';
if (getidbyname($hostname) == $vars['device_id']) {
echo '" selected "+';
}
echo '">' . $hostname . '</option>"+';
}
}
?>
"</select>"+
"</div>"+
"<button type=\"submit\" class=\"btn btn-default input-sm\">Filter</button>"+
"</form></span></div>"+
"<div class=\"col-sm-4 actionBar\"><p class=\"{{css.search}}\"></p><p class=\"{{css.actions}}\"></p></div></div></div>"
},
post: function ()
{
return {
示例15: list_arp
function list_arp()
{
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$message = '';
$ip = $router['ip'];
if (empty($ip)) {
$message = "No valid IP provided";
} else {
$code = 200;
$status = 'ok';
if ($ip === "all") {
$hostname = mres($_GET['device']);
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$arp = dbFetchRows("SELECT `ipv4_mac`.* FROM `ipv4_mac` LEFT JOIN `ports` ON `ipv4_mac`.`port_id` = `ports`.`port_id` WHERE `ports`.`device_id` = ?", array($device_id));
} else {
$arp = dbFetchRows("SELECT * FROM `ipv4_mac` WHERE `ipv4_address`=?", array($ip));
}
$total = count($arp);
}
$output = array('status' => $status, 'err-msg' => $message, 'count' => $total, 'arp' => $arp);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}