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


PHP dbFetchCell函数代码示例

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


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

示例1: get_authlog_array

function get_authlog_array($vars)
{
    $array = array();
    // Short authlog? (no pagination, small out)
    $array['short'] = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $array['pagination'] = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $array['pageno'] = $vars['pageno'];
    $array['pagesize'] = $vars['pagesize'];
    $start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
    $pagesize = $array['pagesize'];
    $query = " FROM `authlog`";
    $query_count = 'SELECT COUNT(`id`) ' . $query;
    $query_updated = 'SELECT MAX(`datetime`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `datetime` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query authlog
    $array['entries'] = dbFetchRows($query, $param);
    // Query authlog count
    if ($array['pagination'] && !$array['short']) {
        $array['count'] = dbFetchCell($query_count, $param);
        $array['pagination_html'] = pagination($vars, $array['count']);
    } else {
        $array['count'] = count($array['entries']);
    }
    // Query for last timestamp
    $array['updated'] = dbFetchCell($query_updated, $param);
    return $array;
}
开发者ID:skive,项目名称:observium,代码行数:32,代码来源:authlog.inc.php

示例2: get_cache

function get_cache($host, $value)
{
    global $dev_cache;
    if (!isset($dev_cache[$host][$value])) {
        switch ($value) {
            case 'device_id':
                // Try by hostname
                $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host));
                // If failed, try by IP
                if (!is_numeric($dev_cache[$host]['device_id'])) {
                    $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($host));
                }
                break;
            case 'os':
                $dev_cache[$host]['os'] = dbFetchCell('SELECT `os` FROM devices WHERE `device_id` = ?', array(get_cache($host, 'device_id')));
                break;
            case 'version':
                $dev_cache[$host]['version'] = dbFetchCell('SELECT `version` FROM devices WHERE `device_id`= ?', array(get_cache($host, 'device_id')));
                break;
            default:
                return null;
        }
        //end switch
    }
    //end if
    return $dev_cache[$host][$value];
}
开发者ID:sfromm,项目名称:librenms,代码行数:27,代码来源:syslog.php

示例3: IssueAlert

/**
 * Issue Alert-Object
 * @param array $alert
 * @return boolean
 */
function IssueAlert($alert)
{
    global $config;
    if (dbFetchCell('SELECT attrib_value FROM devices_attribs WHERE attrib_type = "disable_notify" && device_id = ?', array($alert['device_id'])) == '1') {
        return true;
    }
    $default_tpl = "%title\r\nSeverity: %severity\r\n{if %state == 0}Time elapsed: %elapsed\r\n{/if}Timestamp: %timestamp\r\nUnique-ID: %uid\r\nRule: {if %name}%name{else}%rule{/if}\r\n{if %faults}Faults:\r\n{foreach %faults}  #%key: %value.string\r\n{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}";
    // FIXME: Put somewhere else?
    if ($config['alert']['fixed-contacts'] == false) {
        $alert['details']['contacts'] = GetContacts($alert['details']['rule']);
    }
    $obj = DescribeAlert($alert);
    if (is_array($obj)) {
        $tpl = dbFetchRow('SELECT `template` FROM `alert_templates` JOIN `alert_template_map` ON `alert_template_map`.`alert_templates_id`=`alert_templates`.`id` WHERE `alert_template_map`.`alert_rule_id`=?', array($alert['rule_id']));
        if (isset($tpl['template'])) {
            $tpl = $tpl['template'];
        } else {
            $tpl = $default_tpl;
        }
        echo 'Issuing Alert-UID #' . $alert['id'] . '/' . $alert['state'] . ': ';
        $msg = FormatAlertTpl($tpl, $obj);
        $obj['msg'] = $msg;
        if (!empty($config['alert']['transports'])) {
            ExtTransports($obj);
        }
        echo "\r\n";
    }
    return true;
}
开发者ID:Operasoft,项目名称:librenms,代码行数:34,代码来源:alerts.php

示例4: get_instance_stats

function get_instance_stats()
{
    // Overall Ports/Devices statistics
    $stats['ports'] = dbFetchCell("SELECT COUNT(*) FROM ports");
    $stats['devices'] = dbFetchCell("SELECT COUNT(*) FROM devices");
    $stats['edition'] = OBSERVIUM_EDITION;
    // Per-feature statistics
    $stats['sensors'] = dbFetchCell("SELECT COUNT(*) FROM `sensors`");
    $stats['services'] = dbFetchCell("SELECT COUNT(*) FROM `services`");
    $stats['applications'] = dbFetchCell("SELECT COUNT(*) FROM `applications`");
    $stats['bgp'] = dbFetchCell("SELECT COUNT(*) FROM `bgpPeers`");
    $stats['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports`");
    $stats['eigrp'] = dbFetchCell("SELECT COUNT(*) FROM `eigrp_ports`");
    $stats['ipsec_tunnels'] = dbFetchCell("SELECT COUNT(*) FROM `ipsec_tunnels`");
    $stats['munin_plugins'] = dbFetchCell("SELECT COUNT(*) FROM `munin_plugins`");
    $stats['pseudowires'] = dbFetchCell("SELECT COUNT(*) FROM `pseudowires`");
    $stats['vrfs'] = dbFetchCell("SELECT COUNT(*) FROM `vrfs`");
    $stats['vminfo'] = dbFetchCell("SELECT COUNT(*) FROM `vminfo`");
    $stats['users'] = dbFetchCell("SELECT COUNT(*) FROM `users`");
    $stats['bills'] = dbFetchCell("SELECT COUNT(*) FROM `bills`");
    $stats['alerts'] = dbFetchCell("SELECT COUNT(*) FROM `alert_table`");
    $stats['alert_tests'] = dbFetchCell("SELECT COUNT(*) FROM `alert_tests`");
    $stats['slas'] = dbFetchCell("SELECT COUNT(*) FROM `slas`");
    $stats['statuses'] = dbFetchCell("SELECT COUNT(*) FROM `status`");
    $stats['groups'] = dbFetchCell("SELECT COUNT(*) FROM `groups`");
    $stats['group_members'] = dbFetchCell("SELECT COUNT(*) FROM `group_table`");
    $stats['poller_time'] = dbFetchCell("SELECT SUM(`last_polled_timetaken`) FROM devices");
    $stats['discovery_time'] = dbFetchCell("SELECT SUM(`last_discovered_timetaken`) FROM devices");
    $stats['php_version'] = phpversion();
    $os_text = external_exec("DISTROFORMAT=export " . $GLOBALS['config']['install_dir'] . "/scripts/distro");
    foreach (explode("\n", $os_text) as $part) {
        list($a, $b) = explode("=", $part);
        $stats['os'][$a] = $b;
    }
    // sysObjectID for Generic devices
    foreach (dbFetchRows("SELECT `sysObjectID`, COUNT(*) AS `count` FROM `devices` WHERE `os` = 'generic' GROUP BY `sysObjectID`") as $data) {
        $stats['generics'][$data['sysObjectID']] = $data['count'];
    }
    // Per-OS counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `os` FROM `devices` GROUP BY `os`") as $data) {
        $stats['devicetypes'][$data['os']] = $data['count'];
    }
    // Per-type counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `type` FROM `devices` GROUP BY `type`") as $data) {
        $stats['types'][$data['type']] = $data['count'];
    }
    // Per-apptype counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `app_type` FROM `applications` GROUP BY `app_type`") as $data) {
        $stats['app_types'][$data['app_type']] = $data['count'];
    }
    $stats['misc']['max_len']['port_label'] = dbFetchCell("SELECT MAX(LENGTH(`port_label`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_short'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_short`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_base'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_base`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_num'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_num`)) FROM `ports`");
    $stats['version'] = OBSERVIUM_VERSION;
    $stats['uuid'] = get_unique_id();
    return $stats;
}
开发者ID:Natolumin,项目名称:observium,代码行数:58,代码来源:versioncheck.inc.php

示例5: discover_service

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
function discover_service($device, $service)
{
    if (!dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?", array($service, $device['device_id']))) {
        add_service($device, $service, "(自动发现) {$service}");
        log_event("自动发现服务: 类型 {$service}", $device, 'service');
        echo "+";
    }
    echo "{$service} ";
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:19,代码来源:services.inc.php

示例6: discover_service

function discover_service($device, $service)
{
    if (!dbFetchCell('SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?', array($service, $device['device_id']))) {
        add_service($device, $service, "(Auto discovered) {$service}");
        log_event('Autodiscovered service: type ' . mres($service), $device, 'service');
        echo '+';
    }
    echo "{$service} ";
}
开发者ID:job,项目名称:librenms,代码行数:9,代码来源:services.inc.php

示例7: get_cache

function get_cache($host, $value)
{
    global $dev_cache;
    $host = strtolower(trim($host));
    // Check cache expiration
    $now = time();
    $expired = TRUE;
    if (isset($dev_cache[$host]['lastchecked'])) {
        if ($now - $dev_cache[$host]['lastchecked'] < 3600) {
            $expired = FALSE;
        }
        // will expire after 1 hour
    }
    if ($expired) {
        $dev_cache[$host]['lastchecked'] = $now;
    }
    if (!isset($dev_cache[$host][$value]) || $expired) {
        switch ($value) {
            case 'device_id':
                // Try by hostname
                $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `hostname` = ? OR `sysName` = ?', array($host, $host));
                // If failed, try by IP
                if (!is_numeric($dev_cache[$host]['device_id'])) {
                    $ip = $host;
                    $ip_version = get_ip_version($ip);
                    if ($ip_version !== FALSE) {
                        if ($ip_version == 6) {
                            $ip = Net_IPv6::uncompress($ip, TRUE);
                        }
                        $address_count = dbFetchCell('SELECT COUNT(*) FROM `ipv' . $ip_version . '_addresses` WHERE `ipv' . $ip_version . '_address` = ?;', array($ip));
                        if ($address_count) {
                            $query = 'SELECT `device_id` FROM `ipv' . $ip_version . '_addresses` AS A, `ports` AS I WHERE A.`ipv' . $ip_version . '_address` = ? AND I.`port_id` = A.`port_id`';
                            // If more than one IP address, also check the status of the port.
                            if ($address_count > 1) {
                                $query .= " AND I.`ifOperStatus` = 'up'";
                            }
                            $dev_cache[$host]['device_id'] = dbFetchCell($query, array($ip));
                        }
                    }
                }
                break;
            case 'os':
            case 'version':
                $dev_cache[$host][$value] = dbFetchCell('SELECT `' . $value . '` FROM `devices` WHERE `device_id` = ?', array(get_cache($host, 'device_id')));
                break;
            case 'os_group':
                $os = get_cache($host, 'os');
                $dev_cache[$host]['os_group'] = isset($GLOBALS['config']['os'][$os]['group']) ? $GLOBALS['config']['os'][$os]['group'] : '';
                break;
            default:
                return NULL;
        }
    }
    return $dev_cache[$host][$value];
}
开发者ID:skive,项目名称:observium,代码行数:55,代码来源:syslog.inc.php

示例8: post_notifications

/**
 * Post notifications to users
 * @return null
 */
function post_notifications()
{
    $notifs = get_notifications();
    echo '[ ' . date('r') . ' ] Updating DB ';
    foreach ($notifs as $notif) {
        if (dbFetchCell('select 1 from notifications where checksum = ?', array($notif['checksum'])) != 1 && dbInsert('notifications', $notif) > 0) {
            echo '.';
        }
    }
    echo ' Done';
    echo PHP_EOL;
}
开发者ID:samyscoub,项目名称:librenms,代码行数:16,代码来源:notifications.php

示例9: offsetGet

 /**
  * Get Data-Object
  * @param string $obj Name of Data-Object
  * @return mixed
  */
 public function offsetGet($obj)
 {
     if (isset($this->data[$obj])) {
         if (isset($this->data[$obj]['value'])) {
             return $this->data[$obj]['value'];
         } elseif (isset($GLOBALS['_ObjCache'][$this->obj][$obj]['value'])) {
             return $GLOBALS['_ObjCache'][$this->obj][$obj]['value'];
         } else {
             $GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = dbFetchCell($this->data[$obj]['query'], $this->data[$obj]['params']);
             return $GLOBALS['_ObjCache'][$this->obj][$obj]['value'];
         }
     }
 }
开发者ID:REAP720801,项目名称:librenms,代码行数:18,代码来源:object-cache.inc.php

示例10: IssueAlert

/**
 * Issue Alert-Object
 * @param array $alert
 * @return boolean
 */
function IssueAlert($alert)
{
    global $config;
    if (dbFetchCell('SELECT attrib_value FROM devices_attribs WHERE attrib_type = "disable_notify" && device_id = ?', array($alert['device_id'])) == '1') {
        return true;
    }
    if ($config['alert']['fixed-contacts'] == false) {
        $alert['details']['contacts'] = GetContacts($alert['details']['rule']);
    }
    $obj = DescribeAlert($alert);
    if (is_array($obj)) {
        echo 'Issuing Alert-UID #' . $alert['id'] . '/' . $alert['state'] . ': ';
        $msg = FormatAlertTpl($obj);
        $obj['msg'] = $msg;
        if (!empty($config['alert']['transports'])) {
            ExtTransports($obj);
        }
        echo "\r\n";
    }
    return true;
}
开发者ID:n-st,项目名称:librenms,代码行数:26,代码来源:alerts.php

示例11: process_port_adsl

function process_port_adsl(&$this_port, $device, $port)
{
    // Check to make sure Port data is cached.
    if (!isset($this_port['adslLineCoding'])) {
        return;
    }
    // Used below for StatsD only
    $adsl_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAtucChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate', 'adslAturChanCurrTxRate', 'adslAtucPerfLofs', 'adslAtucPerfLoss', 'adslAtucPerfLprs', 'adslAtucPerfESs', 'adslAtucPerfInits', 'adslAturPerfLofs', 'adslAturPerfLoss', 'adslAturPerfLprs', 'adslAturPerfESs', 'adslAtucChanCorrectedBlks', 'adslAtucChanUncorrectBlks', 'adslAturChanCorrectedBlks', 'adslAturChanUncorrectBlks');
    $adsl_db_oids = array('adslLineCoding', 'adslLineType', 'adslAtucInvVendorID', 'adslAtucInvVersionNumber', 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAturInvSerialNumber', 'adslAturInvVendorID', 'adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate');
    $adsl_tenth_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr');
    foreach ($adsl_tenth_oids as $oid) {
        if (isset($this_port[$oid])) {
            $this_port[$oid] = $this_port[$oid] / 10;
        }
    }
    if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])) == "0") {
        dbInsert(array('port_id' => $port['port_id']), 'ports_adsl');
    }
    $adsl_update = array('port_adsl_updated' => array('NOW()'));
    foreach ($adsl_db_oids as $oid) {
        $adsl_update[$oid] = $this_port[$oid];
    }
    dbUpdate($adsl_update, 'ports_adsl', '`port_id` = ?', array($port['port_id']));
    if ($this_port['adslAtucCurrSnrMgn'] > "1280") {
        $this_port['adslAtucCurrSnrMgn'] = "U";
    }
    if ($this_port['adslAturCurrSnrMgn'] > "1280") {
        $this_port['adslAturCurrSnrMgn'] = "U";
    }
    rrdtool_update_ng($device, 'port-adsl', array('AtucCurrSnrMgn' => $this_port['adslAtucCurrSnrMgn'], 'AtucCurrAtn' => $this_port['adslAtucCurrAtn'], 'AtucCurrOutputPwr' => $this_port['adslAtucCurrOutputPwr'], 'AtucCurrAttainableR' => $this_port['adslAtucCurrAttainableR'], 'AtucChanCurrTxRate' => $this_port['adslAtucChanCurrTxRate'], 'AturCurrSnrMgn' => $this_port['adslAturCurrSnrMgn'], 'AturCurrAtn' => $this_port['adslAturCurrAtn'], 'AturCurrOutputPwr' => $this_port['adslAturCurrOutputPwr'], 'AturCurrAttainableR' => $this_port['adslAturCurrAttainableR'], 'AturChanCurrTxRate' => $this_port['adslAturChanCurrTxRate'], 'AtucPerfLofs' => $this_port['adslAtucPerfLofs'], 'AtucPerfLoss' => $this_port['adslAtucPerfLoss'], 'AtucPerfLprs' => $this_port['adslAtucPerfLprs'], 'AtucPerfESs' => $this_port['adslAtucPerfESs'], 'AtucPerfInits' => $this_port['adslAtucPerfInits'], 'AturPerfLofs' => $this_port['adslAturPerfLofs'], 'AturPerfLoss' => $this_port['adslAturPerfLoss'], 'AturPerfLprs' => $this_port['adslAturPerfLprs'], 'AturPerfESs' => $this_port['adslAturPerfESs'], 'AtucChanCorrectedBl' => $this_port['adslAtucChanCorrectedBl'], 'AtucChanUncorrectBl' => $this_port['adslAtucChanUncorrectBl'], 'AturChanCorrectedBl' => $this_port['adslAturChanCorrectedBl'], 'AturChanUncorrectBl' => $this_port['adslAturChanUncorrectBl']), get_port_rrdindex($port));
    if ($GLOBALS['config']['statsd']['enable']) {
        foreach ($adsl_oids as $oid) {
            // Update StatsD/Carbon
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
        }
    }
    //echo("ADSL (".$this_port['adslLineCoding']."/".formatRates($this_port['adslAtucChanCurrTxRate'])."/".formatRates($this_port['adslAturChanCurrTxRate']).")");
}
开发者ID:Natolumin,项目名称:observium,代码行数:38,代码来源:adsl-line-mib.lib.php

示例12: dbFetchCell

            echo 'S';
        }
        $ipv4_network_id = dbFetchCell('SELECT `ipv4_network_id` FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($network));
        if (dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `ipv4_prefixlen` = ? AND `port_id` = ?', array($oid, $cidr, $port_id)) == '0') {
            dbInsert(array('ipv4_address' => $oid, 'ipv4_prefixlen' => $cidr, 'ipv4_network_id' => $ipv4_network_id, 'port_id' => $port_id), 'ipv4_addresses');
            // echo("Added $oid/$cidr to $port_id ( $hostname $ifIndex )\n $i_query\n");
            echo '+';
        } else {
            echo '.';
        }
        $full_address = "{$oid}/{$cidr}|{$ifIndex}";
        $valid_v4[$full_address] = 1;
    } else {
        echo '!';
    }
    //end if
}
//end foreach
$sql = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE I.device_id = '" . $device['device_id'] . "' AND  A.port_id = I.port_id";
foreach (dbFetchRows($sql) as $row) {
    $full_address = $row['ipv4_address'] . '/' . $row['ipv4_prefixlen'] . '|' . $row['ifIndex'];
    if (!$valid_v4[$full_address]) {
        echo '-';
        $query = dbDelete('ipv4_addresses', '`ipv4_address_id` = ?', array($row['ipv4_address_id']));
        if (!dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_network_id` = ?', array($row['ipv4_network_id']))) {
            $query = dbDelete('ipv4_networks', '`ipv4_network_id` = ?', array($row['ipv4_network_id']));
        }
    }
}
echo "\n";
unset($valid_v4);
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:ipv4-addresses.inc.php

示例13: BGP

    }
    // Do Alerts at the bottom
    if ($bgp_alerts) {
        echo '
            <li role="presentation" class="divider"></li>
            <li><a href="routing/protocol=bgp/adminstatus=start/state=down/"><img src="images/16/link_error.png" border="0" align="absmiddle" /> Alerted BGP (' . $bgp_alerts . ')</a></li>
   ';
    }
    echo '          </ul>';
    ?>

        </li><!-- End 4 columns container -->

<?php 
}
$packages = dbFetchCell("SELECT COUNT(pkg_id) from `packages`");
if ($packages) {
    ?>

        <li class="dropdown">
          <a href="<?php 
    echo generate_url(array('page' => 'packages'));
    ?>
" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><img src="images/16/box.png" border="0" align="absmiddle" /> Packages<b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="<?php 
    echo generate_url(array('page' => 'packages'));
    ?>
"><img src="images/16/box.png" border="0" align="absmiddle" /> All Packages</a></li>
          </ul>
        </li>
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:print-menubar.php

示例14: substr

                if ($stp_raw[$port]['dot1dStpPortDesignatedPort']) {
                    $dp = $stp_raw[$port]['dot1dStpPortDesignatedPort'] - $dp_value;
                    $stp_port['designatedPort'] = $dp;
                }
            } else {
                // Port saved in format priority+port (ieee 802.1d-1998: clause 8.5.5.1)
                $dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2);
                //discard the first octet (priority part)
                $stp_port['designatedPort'] = hexdec($dp);
            }
            d_echo($stp_port);
            // Write to db
            if (!dbFetchCell('SELECT 1 FROM `ports_stp` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $stp_port['port_id']))) {
                dbInsert($stp_port, 'ports_stp');
                echo '+';
            }
        }
    }
    // Delete STP ports from db if absent in SNMP query
    $stp_port_db = dbFetchRows('SELECT * FROM `ports_stp` WHERE `device_id` = ?', array($device['device_id']));
    //d_echo($stp_port_db);
    foreach ($stp_port_db as $port => $value) {
        $if_index = dbFetchCell('SELECT `ifIndex` FROM `ports` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id']));
        if ($if_index != $stp_raw[$if_index]['dot1dStpPort']) {
            dbDelete('ports_stp', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id']));
            echo '-';
        }
    }
}
unset($stp_raw, $stp, $stp_db, $stp_port, $stp_port_db);
echo "\n";
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:stp.inc.php

示例15:

<?php

if ($device['os'] == 'screenos' && dbFetchCell("SELECT COUNT(*) FROM `processors` WHERE `device_id` = ? AND `processor_type` != 'screenos'", array($device['device_id'])) == '0') {
    // .1.3.6.1.4.1.3224.16.1.3.0 Cpu Last 5 Minutes
    // discover_processor(&$valid, $device, $oid, $index, $type, $descr, $precision = "1", $current = NULL, $entPhysicalIndex = NULL, $hrDeviceIndex = NULL)
    echo 'ScreenOS ';
    $percent = snmp_get($device, '.1.3.6.1.4.1.3224.16.1.3.0', '-OvQ');
    if (is_numeric($percent)) {
        discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.3224.16.1.3.0', '1', 'screenos', 'Processor', '1', $percent, null, null);
    }
}
开发者ID:samyscoub,项目名称:librenms,代码行数:11,代码来源:screenos.inc.php


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