当前位置: 首页>>代码示例>>PHP>>正文


PHP getidbyname函数代码示例

本文整理汇总了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>";
}
开发者ID:skive,项目名称:observium,代码行数:33,代码来源:rows.inc.php

示例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);
}
开发者ID:RobsanInc,项目名称:librenms,代码行数:38,代码来源:api_functions.inc.php

示例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 
开发者ID:ekoyle,项目名称:librenms,代码行数:31,代码来源:syslog.inc.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>';
开发者ID:samyscoub,项目名称:librenms,代码行数:30,代码来源:print-vm.inc.php

示例5: device_by_name

function device_by_name($name, $refresh = 0)
{
    // FIXME - cache name > id too.
    return device_by_id_cache(getidbyname($name), $refresh);
}
开发者ID:BillTheBest,项目名称:librenms,代码行数:5,代码来源:common.php

示例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);
}
开发者ID:DINKIN,项目名称:librenms,代码行数:30,代码来源:api_functions.inc.php

示例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);
}
开发者ID:wiad,项目名称:librenms,代码行数:23,代码来源:api_functions.inc.php

示例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);
}
开发者ID:arrmo,项目名称:librenms,代码行数:52,代码来源:api_functions.inc.php

示例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);
}
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:20,代码来源:api_functions.inc.php

示例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
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:delete_device.php

示例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&nbsp;</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>&nbsp;State&nbsp;</strong>"+
               "</label>"+
               "<select name=\"state\" id=\"state\" class=\"form-control input-sm\">"+
               "<option value=\"-1\"></option>"+
               "<option value=\"0\">Ok</option>"+
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:alert-log.inc.php

示例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
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:rename_device.php

示例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);
}
开发者ID:gottaloveit,项目名称:librenms,代码行数:26,代码来源:api_functions.inc.php

示例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&nbsp;</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 {
开发者ID:jmacul2,项目名称:librenms,代码行数:31,代码来源:alert-log.inc.php

示例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);
}
开发者ID:Tatermen,项目名称:librenms,代码行数:27,代码来源:api_functions.inc.php


注:本文中的getidbyname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。