• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getHostOS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getHostOS函数的典型用法代码示例。如果您正苦于以下问题:PHP getHostOS函数的具体用法?PHP getHostOS怎么用?PHP getHostOS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getHostOS函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: checkOS

 /**
  * Set up and test an os
  * If $filename is not set, it will use the snmprec file matching $expected_os
  *
  * @param string $expected_os The os we should get back from getHostOS()
  * @param string $filename the name of the snmprec file to use
  */
 private function checkOS($expected_os, $filename = null)
 {
     $community = $filename ?: $expected_os;
     ob_start();
     $os = getHostOS($this->genDevice($community));
     $output = ob_get_contents();
     ob_end_clean();
     $this->assertEquals($expected_os, $os, "Test file: {$community}.snmprec\n{$output}");
 }
开发者ID:vitalisator,项目名称:librenms,代码行数:16,代码来源:OSDiscoveryTest.php


示例2: discover_device

function discover_device($device, $options = null)
{
    global $config, $valid;
    $valid = array();
    // Reset $valid array
    $attribs = get_dev_attribs($device['device_id']);
    $device_start = utime();
    // Start counting device poll time
    echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
    if ($device['os'] == 'generic') {
        // verify if OS has changed from generic
        $device['os'] = getHostOS($device);
        if ($device['os'] != 'generic') {
            echo "\nDevice os was updated to " . $device['os'] . '!';
            dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
        }
    }
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo ' (' . $device['os_group'] . ')';
    }
    echo "\n";
    // If we've specified modules, use them, else walk the modules array
    if ($options['m']) {
        foreach (explode(',', $options['m']) as $module) {
            if (is_file("includes/discovery/{$module}.inc.php")) {
                include "includes/discovery/{$module}.inc.php";
            }
        }
    } else {
        foreach ($config['discovery_modules'] as $module => $module_status) {
            if ($attribs['discover_' . $module] || $module_status && !isset($attribs['discover_' . $module])) {
                include 'includes/discovery/' . $module . '.inc.php';
            } else {
                if (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] == '0') {
                    echo "Module [ {$module} ] disabled on host.\n";
                } else {
                    echo "Module [ {$module} ] disabled globally.\n";
                }
            }
        }
    }
    // Set type to a predefined type for the OS if it's not already set
    if ($device['type'] == 'unknown' || $device['type'] == '') {
        if ($config['os'][$device['os']]['type']) {
            $device['type'] = $config['os'][$device['os']]['type'];
        }
    }
    $device_end = utime();
    $device_run = $device_end - $device_start;
    $device_time = substr($device_run, 0, 5);
    dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
    echo "Discovered in {$device_time} seconds\n";
    global $discovered_devices;
    echo "\n";
    $discovered_devices++;
}
开发者ID:rkojedzinszky,项目名称:librenms,代码行数:57,代码来源:functions.inc.php


示例3: createHost

function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group = '0')
{
    global $config;
    $host = trim(strtolower($host));
    $poller_group = getpollergroup($poller_group);
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver, 'poller_group' => $poller_group);
    $device = array_merge($device, $v3);
    $device['os'] = getHostOS($device);
    if ($device['os']) {
        $device_id = dbInsert($device, 'devices');
        if ($device_id) {
            return $device_id;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
开发者ID:syzdek,项目名称:librenms,代码行数:19,代码来源:functions.php


示例4: discover_device

function discover_device($device, $options = null)
{
    global $config, $valid;
    $valid = array();
    // Reset $valid array
    $attribs = get_dev_attribs($device['device_id']);
    $device['snmp_max_repeaters'] = $attribs['snmp_max_repeaters'];
    $device_start = microtime(true);
    // Start counting device poll time
    echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
    if ($device['os'] == 'generic') {
        // verify if OS has changed from generic
        $device['os'] = getHostOS($device);
        if ($device['os'] != 'generic') {
            echo "\nDevice os was updated to " . $device['os'] . '!';
            dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
        }
    }
    // Set type to a predefined type for the OS if it's not already set
    if ($device['type'] == 'unknown' || $device['type'] == '') {
        if ($config['os'][$device['os']]['type']) {
            $device['type'] = $config['os'][$device['os']]['type'];
        }
    }
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo ' (' . $device['os_group'] . ')';
    }
    echo "\n";
    // If we've specified modules, use them, else walk the modules array
    $force_module = false;
    if ($options['m']) {
        $config['discovery_modules'] = array();
        foreach (explode(',', $options['m']) as $module) {
            if (is_file("includes/discovery/{$module}.inc.php")) {
                $config['discovery_modules'][$module] = 1;
                $force_module = true;
            }
        }
    }
    foreach ($config['discovery_modules'] as $module => $module_status) {
        if ($force_module === true || $attribs['discover_' . $module] || $module_status && !isset($attribs['discover_' . $module])) {
            $module_start = microtime(true);
            echo "#### Load disco module {$module} ####\n";
            include "includes/discovery/{$module}.inc.php";
            $module_time = microtime(true) - $module_start;
            $module_time = substr($module_time, 0, 5);
            echo "\n>> Runtime for discovery module '{$module}': {$module_time} seconds\n";
            echo "#### Unload disco module {$module} ####\n\n";
        } elseif (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] == '0') {
            echo "Module [ {$module} ] disabled on host.\n\n";
        } else {
            echo "Module [ {$module} ] disabled globally.\n\n";
        }
    }
    if (is_mib_poller_enabled($device)) {
        $devicemib = array($device['sysObjectID'] => 'all');
        register_mibs($device, $devicemib, "includes/discovery/functions.inc.php");
    }
    $device_end = microtime(true);
    $device_run = $device_end - $device_start;
    $device_time = substr($device_run, 0, 5);
    dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
    echo "Discovered in {$device_time} seconds\n";
    global $discovered_devices;
    echo "\n";
    $discovered_devices++;
}
开发者ID:arrmo,项目名称:librenms,代码行数:68,代码来源:functions.inc.php


示例5: createHost

function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group = '0', $port_assoc_mode = 'ifIndex')
{
    global $config;
    $host = trim(strtolower($host));
    $poller_group = getpollergroup($poller_group);
    /* Get port_assoc_mode id if neccessary
     * We can work with names of IDs here */
    if (!is_int($port_assoc_mode)) {
        $port_assoc_mode = get_port_assoc_mode_id($port_assoc_mode);
    }
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver, 'poller_group' => $poller_group, 'status_reason' => '', 'port_association_mode' => $port_assoc_mode);
    $device = array_merge($device, $v3);
    $device['os'] = getHostOS($device);
    if ($device['os']) {
        if (host_exists($host) === false) {
            $device_id = dbInsert($device, 'devices');
            if ($device_id) {
                oxidized_reload_nodes();
                return $device_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return FALSE;
    }
}
开发者ID:gottaloveit,项目名称:librenms,代码行数:29,代码来源:functions.php


示例6: getHostOS

<?php

echo 'OS: ';
$os = getHostOS($device);
if ($os != $device['os']) {
    log_event('Device OS changed ' . $device['os'] . " => {$os}", $device, 'system');
    $device['os'] = $os;
    $sql = dbUpdate(array('os' => $os), 'devices', 'device_id=?', array($device['device_id']));
    echo "Changed OS! : {$os}\n";
}
$icon = getImageName($device, false);
if ($icon != $device['icon']) {
    log_event('Device Icon changed ' . $device['icon'] . " => {$icon}", $device, 'system');
    $device['icon'] = $icon;
    $sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
    echo "Changed Icon! : {$icon}\n";
}
开发者ID:greggcz,项目名称:librenms,代码行数:17,代码来源:os.inc.php


示例7: createHost

function createHost($host, $community, $snmpver, $port = 161)
{
    $host = trim(strtolower($host));
    $device = array('hostname' => $host, 'community' => $community, 'snmpver' => $snmpver, 'port' => $port);
    $host_os = getHostOS($device);
    if ($host_os) {
        $sql = mysql_query("INSERT INTO `devices` (`hostname`, `sysName`, `community`, `port`, `os`, `status`,`snmpver`) VALUES ('{$host}', '{$host}', '{$community}', '{$port}', '{$host_os}', '1','{$snmpver}')");
        if (mysql_affected_rows()) {
            $device_id = mysql_result(mysql_query("SELECT device_id FROM devices WHERE hostname = '{$host}'"), 0);
            mysql_query("INSERT INTO devices_attribs (attrib_type, attrib_value, device_id) VALUES ('discover','1','{$device_id}')");
            return "Created host : {$host} (id:{$device_id}) (os:{$host_os})";
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
开发者ID:kyrisu,项目名称:observernms_clean,代码行数:18,代码来源:functions.php


示例8: createHost

function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array())
{
    $host = trim(strtolower($host));
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver);
    $device = array_merge($device, $v3);
    $device['os'] = getHostOS($device);
    $device['sysName'] = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
    $device['location'] = snmp_get($device, "sysLocation.0", "-Oqv", "SNMPv2-MIB");
    $device['sysContact'] = snmp_get($device, "sysContact.0", "-Oqv", "SNMPv2-MIB");
    if ($device['os']) {
        $device_id = dbInsert($device, 'devices');
        if ($device_id) {
            echo "Discovering " . $device['hostname'] . " (" . $device_id . ")";
            $device['device_id'] = $device_id;
            // Discover things we need when linking this to other hosts.
            discover_device($device, $options = array('m' => 'ports'));
            discover_device($device, $options = array('m' => 'ipv4-addresses'));
            discover_device($device, $options = array('m' => 'ipv6-addresses'));
            array_push($GLOBAL['devices'], $device_id);
            return $device_id;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:27,代码来源:functions.php


示例9: discover_device

function discover_device($device, $options = NULL)
{
    global $config, $valid;
    $valid = array();
    // Reset $valid array
    $attribs = get_dev_attribs($device['device_id']);
    $device_start = utime();
    // Start counting device poll time
    echo $device['hostname'] . " " . $device['device_id'] . " " . $device['os'] . " ";
    if ($device['os'] == 'generic') {
        $device['os'] = getHostOS($device);
        if ($device['os'] != 'generic') {
            echo "\nDevice os was updated to " . $device['os'] . "!";
            dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
        }
    }
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo " (" . $device['os_group'] . ")";
    }
    echo "\n";
    // If we've specified a module, use that, else walk the modules array
    if ($options['m']) {
        foreach (explode(",", $options['m']) as $module) {
            if (is_file("includes/discovery/" . $module . ".inc.php")) {
                include "includes/discovery/" . $module . ".inc.php";
            }
        }
    } else {
        foreach ($config['discovery_modules'] as $module => $module_status) {
            if (in_array($device['os_group'], $config['os']['discovery_blacklist'])) {
                // Module is blacklisted for this OS.
                debug("Module {$module} is in the blacklist for " . $device['os_group'] . "\n");
            } elseif (in_array($device['os'], $config['os']['discovery_blacklist'])) {
                // Module is blacklisted for this OS.
                debug("Module {$module} is in the blacklist for " . $device['os'] . "\n");
            } else {
                if ($attribs['discover_' . $module] || $module_status && !isset($attribs['discover_' . $module])) {
                    include 'includes/discovery/' . $module . '.inc.php';
                } elseif (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] == "0") {
                    echo "Module [ {$module} ] disabled on host.\n";
                } else {
                    echo "Module [ {$module} ] disabled globally.\n";
                }
            }
        }
    }
    // Set type to a predefined type for the OS if it's not already set
    if ($device['type'] == "unknown" || $device['type'] == "") {
        if ($config['os'][$device['os']]['type']) {
            $device['type'] = $config['os'][$device['os']]['type'];
        }
    }
    $device_end = utime();
    $device_run = $device_end - $device_start;
    $device_time = substr($device_run, 0, 5);
    dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
    // put performance into devices_perftimes
    dbInsert(array('device_id' => $device['device_id'], 'operation' => 'discover', 'start' => $device_start, 'duration' => $device_run), 'devices_perftimes');
    echo "Discovered in {$device_time} seconds\n";
    // not worth putting discovery data into rrd. it's not done every 5 mins :)
    global $discovered_devices;
    echo "\n";
    $discovered_devices++;
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:65,代码来源:functions.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getHosts函数代码示例发布时间:2022-05-15
下一篇:
PHP getHostName函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap