本文整理汇总了PHP中get_dev_attrib函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dev_attrib函数的具体用法?PHP get_dev_attrib怎么用?PHP get_dev_attrib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dev_attrib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: d_echo
}
// Set VLAN and Trunk from Q-BRIDGE-MIB
if (!isset($this_port['ifVlan']) && isset($this_port['dot1qPvid'])) {
$this_port['ifVlan'] = $this_port['dot1qPvid'];
}
// FIXME use $q_bridge_mib[$this_port['ifIndex']] to see if it is a trunk (>1 array count)
echo 'VLAN == ' . $this_port['ifVlan'];
// When devices do not provide ifAlias data, populate with ifDescr data if configured
if ($this_port['ifAlias'] == '' || $this_port['ifAlias'] == NULL || $config['os'][$device['os']]['descr_to_alias'] == 1) {
$this_port['ifAlias'] = $this_port['ifDescr'];
d_echo('Using ifDescr as ifAlias');
}
// Update IF-MIB data
foreach ($data_oids as $oid) {
if ($oid == 'ifAlias') {
if (get_dev_attrib($device, 'ifName:' . $port['ifName'], 1)) {
$this_port['ifAlias'] = $port['ifAlias'];
}
}
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) {
$port['update'][$oid] = array('NULL');
log_event($oid . ': ' . $port[$oid] . ' -> NULL', $device, 'interface', $port['port_id']);
if ($debug) {
d_echo($oid . ': ' . $port[$oid] . ' -> NULL ');
} else {
echo $oid . ' ';
}
} else {
if ($port[$oid] != $this_port[$oid]) {
$port['update'][$oid] = $this_port[$oid];
log_event($oid . ': ' . $port[$oid] . ' -> ' . $this_port[$oid], $device, 'interface', $port['port_id']);
示例2: dbFetchRow
$updated = 0;
}
}
//end if
}
//end if
$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id']));
$descr = $device['purpose'];
if ($updated && $update_message) {
print_message($update_message);
} else {
if ($update_message) {
print_error($update_message);
}
}
$max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters');
echo "\n <form id='edit' name='edit' method='post' action='' role='form' class='form-horizontal'>\n <input type=hidden name='editing' value='yes'>\n <div class='form-group'>\n <label for='snmpver' class='col-sm-2 control-label'>SNMP Details</label>\n <div class='col-sm-1'>\n <select id='snmpver' name='snmpver' class='form-control input-sm' onChange='changeForm();'>\n <option value='v1'>v1</option>\n <option value='v2c' " . ($device['snmpver'] == 'v2c' ? 'selected' : '') . ">v2c</option>\n <option value='v3' " . ($device['snmpver'] == 'v3' ? 'selected' : '') . ">v3</option>\n </select>\n </div>\n <div class='col-sm-2'>\n <input type='text' name='port' placeholder='port' class='form-control input-sm' value='" . ($device['port'] == $config['snmp']['port'] ? "" : $device['port']) . "'>\n </div>\n <div class='col-sm-1'>\n <select name='transport' id='transport' class='form-control input-sm'>";
foreach ($config['snmp']['transports'] as $transport) {
echo "<option value='" . $transport . "'";
if ($transport == $device['transport']) {
echo " selected='selected'";
}
echo '>' . $transport . '</option>';
}
echo " </select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-2'>\n </div>\n <div class='col-sm-1'>\n <input id='timeout' name='timeout' class='form-control input-sm' value='" . ($device['timeout'] ? $device['timeout'] : '') . "' placeholder='seconds' />\n </div>\n <div class='col-sm-1'>\n <input id='retries' name='retries' class='form-control input-sm' value='" . ($device['timeout'] ? $device['retries'] : '') . "' placeholder='retries' />\n </div>\n </div>\n <div class='form-group'>\n <label for='port_assoc_mode' class='col-sm-2 control-label'>Port Association Mode</label>\n <div class='col-sm-1'>\n <select name='port_assoc_mode' id='port_assoc_mode' class='form-control input-sm'>\n";
foreach (get_port_assoc_modes() as $pam) {
$pam_id = get_port_assoc_mode_id($pam);
echo " <option value='{$pam_id}'";
if ($pam_id == $device['port_association_mode']) {
echo " selected='selected'";
}
示例3: dynamic_override_config
function dynamic_override_config($type, $name, $device)
{
$attrib_val = get_dev_attrib($device, $name);
if ($attrib_val == 'true') {
$checked = 'checked';
} else {
$checked = '';
}
if ($type == 'checkbox') {
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="' . $name . '" data-device_id="' . $device['device_id'] . '" data-size="small" ' . $checked . '>';
}
}
示例4: is_mib_poller_enabled
function is_mib_poller_enabled($device)
{
$val = get_dev_attrib($device, 'poll_mib');
if ($val == null) {
return is_module_enabled('poller', 'mib');
}
return $val;
}
示例5: get_dev_attrib
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$pagetitle[] = 'Notes';
$port_id_notes = 'port_id_notes:' . $port['port_id'];
$device_id = $device['device_id'];
$data = get_dev_attrib($device, $port_id_notes);
?>
<form class="form-horizontal" action="" method="post">
<h3>Port Notes</h3>
<hr>
<div class="form-group">
<div class="col-sm-10">
<textarea class="form-control" rows="6" name="notes" id="port-notes"><?php
echo htmlentities($data);
?>
</textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
示例6: notify
function notify($device, $title, $message)
{
global $config;
if ($config['alerts']['email']['enable']) {
if (!get_dev_attrib($device, 'disable_notify')) {
if ($config['alerts']['email']['default_only']) {
$email = $config['alerts']['email']['default'];
} else {
if (get_dev_attrib($device, 'override_sysContact_bool')) {
$email = get_dev_attrib($device, 'override_sysContact_string');
} elseif ($device['sysContact']) {
$email = $device['sysContact'];
} else {
$email = $config['alerts']['email']['default'];
}
}
$emails = parse_email($email);
if ($emails) {
$message_header = $config['page_title_prefix'] . "\n\n";
// FIXME: use different config element
$message_footer = "\n\nE-mail sent to: ";
$i = 0;
$count = count($emails);
foreach ($emails as $email => $email_name) {
$i++;
$message_footer .= $email;
if ($i < $count) {
$message_footer .= ", ";
} else {
$message_footer .= "\n";
}
}
$message_footer .= "E-mail sent at: " . date($config['timestamp_format']) . "\n";
if (($err = send_mail($emails, $title, $message_header . $message . $message_footer)) !== true) {
echo "Mailer Error: " . $err . "\n";
}
}
}
}
}
示例7: str_replace
$poll_device['sysContact'] = str_replace("\"", "", $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysContact'] = trim($poll_device['sysContact'], "\\");
if ($poll_device['sysLocation'] == "not set") {
$poll_device['sysLocation'] = "";
}
if ($poll_device['sysContact'] == "not set") {
$poll_device['sysContact'] = "";
}
if ($poll_device['sysContact'] && $poll_device['sysContact'] != $device['sysContact']) {
$update_array['sysContact'] = $poll_device['sysContact'];
log_event("Contact -> " . $poll_device['sysContact'], $device, 'system');
}
if ($poll_device['sysObjectID'] && $poll_device['sysObjectID'] != $device['sysObjectID']) {
$update_array['sysObjectID'] = $poll_device['sysObjectID'];
log_event("ObjectID -> " . $poll_device['sysObjectID'], $device, 'system');
}
if ($poll_device['sysName'] && $poll_device['sysName'] != $device['sysName']) {
$update_array['sysName'] = $poll_device['sysName'];
log_event("sysName -> " . $poll_device['sysName'], $device, 'system');
}
if ($poll_device['sysDescr'] && $poll_device['sysDescr'] != $device['sysDescr']) {
$update_array['sysDescr'] = $poll_device['sysDescr'];
log_event("sysDescr -> " . $poll_device['sysDescr'], $device, 'system');
}
if ($poll_device['sysLocation'] && $device['location'] != $poll_device['sysLocation']) {
if (!get_dev_attrib($device, 'override_sysLocation_bool')) {
$update_array['location'] = $poll_device['sysLocation'];
log_event("Location -> " . $poll_device['sysLocation'], $device, 'system');
}
}
示例8: unserialize
*
* This file is part of Observium.
*
* @package observium
* @subpackage graphs
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
include_once $config['html_dir'] . "/includes/graphs/common.inc.php";
$scale_min = 0;
$colours = "mixed";
$unit_text = "Errors";
$nototal = 1;
$i = 0;
$colourset = "mixed";
$rownames = unserialize(get_dev_attrib($device, 'edac_rownames'));
foreach ($rownames as $mc => $data) {
$data['rowname']['unknown']['unknown'] = 'unknown';
// Add 'unknown' line to every memory controller; we don't have unknown-unknown but unknown-all is added below
foreach ($data['rowname'] as $row => $channels) {
array_unshift($channels, 'all');
// Add 'all' to front of array
foreach ($channels as $channel) {
foreach (array('ue', 'ce') as $errortype) {
switch ((string) $row) {
case 'unknown':
case 'all':
$row_id = $row;
break;
default:
$row_id = "csrow{$row}";
示例9: foreach
}
echo ">" . $descr['text'] . "</option>";
}
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="ipmi_interface">IPMI Interface</label>
<div class="controls">
<select class="selectpicker" name="ipmi_interface">
<?php
foreach ($config['ipmi']['interfaces'] as $type => $descr) {
echo "<option value='" . $type . "'";
if ($type == get_dev_attrib($device, 'ipmi_interface')) {
echo " selected='selected'";
}
echo ">" . $descr['text'] . "</option>";
}
?>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
<span class="help-inline">To disable IPMI polling, please clear the setting fields and click <strong>Save Changes</strong>.</span>
</div>
</fieldset>
示例10: print_message
if ($updated && $update_message) {
print_message($update_message);
} else {
if ($update_message) {
print_error($update_message);
}
}
}
if (!file_exists($config['ipmitool'])) {
print_warning("The ipmitool binary was not found at the configured path (" . $config['ipmitool'] . "). IPMI polling will not work.");
}
$ipmi_userlevels = array();
foreach ($config['ipmi']['userlevels'] as $type => $descr) {
$ipmi_userlevels[$type] = array('name' => $descr['text']);
}
$ipmi_interfaces = array();
foreach ($config['ipmi']['interfaces'] as $type => $descr) {
$ipmi_interfaces[$type] = array('name' => $descr['text']);
}
$form = array('type' => 'horizontal', 'id' => 'edit', 'title' => 'IPMI Settings', 'fieldset' => array('edit' => ''));
$form['row'][0]['editing'] = array('type' => 'hidden', 'value' => 'yes');
$form['row'][1]['ipmi_hostname'] = array('type' => 'text', 'name' => 'IPMI Hostname', 'width' => '250px', 'readonly' => $readonly, 'value' => escape_html(get_dev_attrib($device, 'ipmi_hostname')));
$form['row'][2]['ipmi_port'] = array('type' => 'text', 'name' => 'IPMI Port', 'width' => '250px', 'readonly' => $readonly, 'value' => escape_html(get_dev_attrib($device, 'ipmi_port')));
$form['row'][3]['ipmi_username'] = array('type' => 'text', 'name' => 'IPMI Username', 'width' => '250px', 'readonly' => $readonly, 'value' => escape_html(get_dev_attrib($device, 'ipmi_username')));
$form['row'][4]['ipmi_password'] = array('type' => 'password', 'name' => 'IPMI Password', 'width' => '250px', 'readonly' => $readonly, 'show_password' => !$readonly, 'value' => escape_html(get_dev_attrib($device, 'ipmi_password')));
$form['row'][5]['ipmi_userlevel'] = array('type' => 'select', 'name' => 'IPMI Userlevel', 'width' => '250px', 'readonly' => $readonly, 'values' => $ipmi_userlevels, 'value' => escape_html(get_dev_attrib($device, 'ipmi_userlevel')));
$form['row'][6]['ipmi_interface'] = array('type' => 'select', 'name' => 'IPMI Interface', 'width' => '250px', 'readonly' => $readonly, 'values' => $ipmi_interfaces, 'value' => escape_html(get_dev_attrib($device, 'ipmi_interface')));
$form['row'][7]['submit'] = array('type' => 'submit', 'name' => 'Save Changes', 'icon' => 'icon-ok icon-white', 'class' => 'btn-primary', 'readonly' => $readonly, 'value' => 'save');
print_form($form);
unset($form);
// EOF
示例11: get_dev_attrib
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
// Note, device attrib 'eqlgrpmemid' sets in equallogic 'os' module.
$eqlgrpmemid = get_dev_attrib($device, 'eqlgrpmemid');
if (is_numeric($eqlgrpmemid)) {
$oids = snmpwalk_cache_oid($device, 'eqlMemberHealthDetailsFanTable', array(), 'EQLMEMBER-MIB');
// copy of eqlMemberHealthDetailsFanIndex
$sensorname = array('emm0fan0', 'emm0fan1', 'emm1fan0', 'emm1fan1', 'emm2fan0', 'emm2fan1', 'emm3fan0', 'emm3fan1');
$sensorid = array(1, 2, 3, 4, 5, 6, 7, 8);
foreach ($oids as $index => $entry) {
# EQLMEMBER-MIB returns sensors for all members. only process sensors that match our member id
if (strstr($index, $eqlgrpmemid)) {
$numindex = str_replace($sensorname, $sensorid, $index);
$entry['oid'] = ".1.3.6.1.4.1.12740.2.1.7.1.3.{$numindex}";
$limits = array('limit_high' => $entry['eqlMemberHealthDetailsFanHighCriticalThreshold'], 'limit_low' => $entry['eqlMemberHealthDetailsFanLowCriticalThreshold'], 'limit_high_warn' => $entry['eqlMemberHealthDetailsFanHighWarningThreshold'], 'limit_low_warn' => $entry['eqlMemberHealthDetailsFanLowWarningThreshold']);
if ($entry['eqlMemberHealthDetailsFanValue'] != 0) {
discover_sensor($valid['sensor'], 'fanspeed', $device, $entry['oid'], $numindex, 'equallogic', $entry['eqlMemberHealthDetailsFanName'], 1, $entry['eqlMemberHealthDetailsFanValue'], $limits);
}
}
}
$oids = snmpwalk_cache_oid($device, 'eqlMemberHealthDetailsTemperatureTable', array(), 'EQLMEMBER-MIB');
示例12: escape_html
<div class="control-group">
<label class="control-label" for="wmi_username">WMI Username</label>
<div class="controls">
<input name="wmi_username" type="text" size="32" value="<?php
echo escape_html(get_dev_attrib($device, 'wmi_username'));
?>
" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="wmi_password">WMI Password</label>
<div class="controls">
<input name="wmi_password" type="password" size="32" value="<?php
echo escape_html(get_dev_attrib($device, 'wmi_password'));
// FIXME. For passwords we should use filter instead escape!
?>
" />
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<div class="col-md-6">
示例13: foreach
}
} else {
echo '<div class="panel panel-default panel-condensed">
<div class="table-responsive">
<table class="table table-condensed">';
if ($subformat == "detail" || $subformat == "basic") {
echo '<tr>
<th></th>
<th></th>
<th>Device</th>
<th></th>
<th>Platform</th>
<th>Operating System</th>
<th>Uptime/Location</th>
</tr>';
}
foreach (dbFetchRows($query, $sql_param) as $device) {
if (device_permitted($device['device_id'])) {
if (!$location_filter || (get_dev_attrib($device, 'override_sysLocation_bool') && get_dev_attrib($device, 'override_sysLocation_string') == $location_filter || $device['location'] == $location_filter)) {
if ($subformat == "detail") {
include "includes/hostbox.inc.php";
} else {
include "includes/hostbox-basic.inc.php";
}
}
}
}
echo "</table>";
echo '</div>';
echo '</div>';
}
示例14: get_dev_attrib
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
global $debug, $ipmi_sensors;
include_once "includes/polling/functions.inc.php";
/// FIXME. From this uses only check_valid_sensors(), maybe need move to global functions or copy to polling. --mike
include_once "includes/discovery/functions.inc.php";
echo "IPMI: ";
if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
$ipmi['user'] = get_dev_attrib($device, 'ipmi_username');
$ipmi['password'] = get_dev_attrib($device, 'ipmi_password');
$ipmi['port'] = get_dev_attrib($device, 'ipmi_port');
$ipmi['interface'] = get_dev_attrib($device, 'ipmi_interface');
if (!is_numeric($ipmi['port'])) {
$ipmi['port'] = 623;
}
if (array_search($ipmi['interface'], array_keys($config['ipmi']['interfaces'])) === FALSE) {
$ipmi['interface'] = 'lan';
}
// Also triggers on empty value
if ($config['own_hostname'] != $device['hostname'] || $ipmi['host'] != 'localhost') {
$remote = " -I " . escapeshellarg($ipmi['interface']) . " -p " . $ipmi['port'] . " -H " . escapeshellarg($ipmi['host']) . " -L USER -U " . escapeshellarg($ipmi['user']) . " -P " . escapeshellarg($ipmi['password']);
}
$ipmi_start = utime();
$results = external_exec($config['ipmitool'] . $remote . " sensor 2>/dev/null");
$ipmi_end = utime();
$ipmi_time = round(($ipmi_end - $ipmi_start) * 1000);
echo '(' . $ipmi_time . 'ms) ';
示例15: array
if (!isset($sort) || empty($sort)) {
$sort = '`ifIndex` ASC';
}
$sql .= " ORDER BY {$sort}";
if (isset($current)) {
$limit_low = $current * $rowCount - $rowCount;
$limit_high = $rowCount;
}
if ($rowCount != -1) {
$sql .= " LIMIT {$limit_low},{$limit_high}";
}
$sql = "SELECT * {$sql}";
$response[] = array('ifIndex' => "<button id='save-form' type='submit' value='Save' class='btn btn-success btn-sm' title='Save current port disable/ignore settings'>Save</button><button type='submit' value='Reset' class='btn btn-danger btn-sm' id='form-reset' title='Reset form to previously-saved settings'>Reset</button>", 'label' => '', 'ifAdminStatus' => '', 'ifOperStatus' => "<button type='submit' value='Alerted' class='btn btn-default btn-sm' id='alerted-toggle' title='Toggle alerting on all currently-alerted ports'>Alerted</button><button type='submit' value='Down' class='btn btn-default btn-sm' id='down-select' title='Disable alerting on all currently-down ports'>Down</button>", 'disabled' => "<button type='submit' value='Toggle' class='btn btn-default btn-sm' id='disable-toggle' title='Toggle polling for all ports'>Toggle</button><button type='submit' value='Select' class='btn btn-default btn-sm' id='disable-select' title='Disable polling on all ports'>Select All</button>", 'ignore' => "<button type='submit' value='Toggle' class='btn btn-default btn-sm' id='ignore-toggle' title='Toggle alerting for all ports'>Toggle</button><button type='submit' value='Select' class='btn btn-default btn-sm' id='ignore-select' title='Disable alerting on all ports'>Select All</button>", 'ifAlias' => '');
foreach (dbFetchRows($sql, $param) as $port) {
$port = ifLabel($port);
// Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled
// - as to draw the attention to a possible problem.
$isportbad = $port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down' ? 1 : 0;
$dowecare = $port['ignore'] == 0 && $port['disabled'] == 0 ? $isportbad : !$isportbad;
$outofsync = $dowecare ? " class='red'" : '';
$checked = '';
if (get_dev_attrib($device_id, 'ifName_tune:' . $port['ifName']) == "true") {
$checked = 'checked';
}
$response[] = array('ifIndex' => $port['ifIndex'], 'ifName' => $port['label'], 'ifAdminStatus' => $port['ifAdminStatus'], 'ifOperStatus' => '<span name="operstatus_' . $port['port_id'] . '"' . $outofsync . '>' . $port['ifOperStatus'] . '</span>', 'disabled' => '<input type="checkbox" class="disable-check" name="disabled_' . $port['port_id'] . '"' . ($port['disabled'] ? 'checked' : '') . '>
<input type="hidden" name="olddis_' . $port['port_id'] . '" value="' . ($port['disabled'] ? 1 : 0) . '"">', 'ignore' => '<input type="checkbox" class="ignore-check" name="ignore_' . $port['port_id'] . '"' . ($port['ignore'] ? 'checked' : '') . '>
<input type="hidden" name="oldign_' . $port['port_id'] . '" value="' . ($port['ignore'] ? 1 : 0) . '"">', 'port_tune' => '<input type="checkbox" id="override_config" name="override_config" data-attrib="ifName_tune:' . $port['ifName'] . '" data-device_id="' . $port['device_id'] . '" data-size="small" ' . $checked . '>', 'ifAlias' => '<div class="form-group"><input class="form-control input-sm" id="if-alias" name="if-alias" data-device_id="' . $port['device_id'] . '" data-port_id="' . $port['port_id'] . '" data-ifName="' . $port['ifName'] . '" value="' . $port['ifAlias'] . '"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>');
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);