Exemplo n.º 1
0
 }
 // 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']);
Exemplo n.º 2
0
            $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'";
    }
Exemplo n.º 3
0
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 . '>';
    }
}
Exemplo n.º 4
0
function is_mib_poller_enabled($device)
{
    $val = get_dev_attrib($device, 'poll_mib');
    if ($val == null) {
        return is_module_enabled('poller', 'mib');
    }
    return $val;
}
Exemplo n.º 5
0
<?php

/*
 * LibreNMS
 *
 * Copyright (c) 2015 Søren Friis Rosiak <*****@*****.**>
 * 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">
Exemplo n.º 6
0
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";
                }
            }
        }
    }
}
Exemplo n.º 7
0
$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');
    }
}
Exemplo n.º 8
0
 *
 *   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}";
Exemplo n.º 9
0
    }
    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>
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
<?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');
Exemplo n.º 12
0
          <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">
Exemplo n.º 13
0
    }
} 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>';
}
Exemplo n.º 14
0
 *
 * @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) ';
Exemplo n.º 15
0
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);
Exemplo n.º 16
0
    // severity 5, for logging user info
} elseif ($update_message) {
    print_error($update_message);
}
?>

<form id="edit" name="edit" method="post" class="form-horizontal" action="">
  <input type=hidden name="editing" value="yes">

  <div id="agent">
    <fieldset>
      <legend>代理连接</legend>
      <div class="control-group">
        <label class="control-label" for="agent_port">代理端口</label>
        <div class="controls">
          <input type=text name="agent_port" size="32" value="<?php 
echo escape_html(get_dev_attrib($device, 'agent_port'));
?>
"/>
        </div>
      </div>
    </fieldset>
  </div>

  <div class="form-actions">
    <button type="submit" class="btn btn-primary" name="submit" value="save"><i class="icon-ok icon-white"></i> 保存变化</button>
  </div>

</form>
<?php 
// EOF
Exemplo n.º 17
0
<?php

$ipmi_rows = dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND poller_type='ipmi'", array($device['device_id']));
d_echo($ipmi_rows);
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['type'] = get_dev_attrib($device, 'ipmi_type');
    echo 'Fetching IPMI sensor data...';
    if ($config['own_hostname'] != $device['hostname'] || $ipmi['host'] != 'localhost') {
        $remote = ' -H ' . $ipmi['host'] . ' -U ' . $ipmi['user'] . ' -P ' . $ipmi['password'];
    }
    $results = external_exec($config['ipmitool'] . ' -I ' . $ipmi['type'] . ' -c ' . $remote . ' sdr 2>/dev/null');
    d_echo($results);
    echo " done.\n";
    foreach (explode("\n", $results) as $row) {
        list($desc, $value, $type, $status) = explode(',', $row);
        $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['value'] = $value;
        $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['unit'] = $type;
    }
    foreach ($ipmi_rows as $ipmisensors) {
        echo 'Updating IPMI sensor ' . $ipmisensors['sensor_descr'] . '... ';
        $sensor = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['value'];
        $unit = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['unit'];
        echo $sensor . " {$unit}\n";
        $rrd_name = get_sensor_rrd_name($device, $ipmisensors);
        $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000';
        $fields = array('sensor' => $sensor);
        $tags = array('sensor_class' => $sensor['sensor_class'], 'sensor_type' => $sensor['sensor_type'], 'sensor_descr' => $sensor['sensor_descr'], 'sensor_index' => $sensor['sensor_index'], 'rrd_name' => $rrd_name, 'rrd_def' => $rrd_def);
        data_update($device, 'ipmi', $tags, $fields);
        // FIXME warnings in event & mail not done here yet!
Exemplo n.º 18
0
<?php

if ($device['os_group'] == 'unix') {
    echo $config['project_name'] . ' UNIX Agent: ';
    $agent_port = get_dev_attrib($device, 'override_Unixagent_port');
    if (empty($agent_port)) {
        $agent_port = $config['unix-agent']['port'];
    }
    if (empty($config['unix-agent']['connection-timeout'])) {
        $config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out'];
    }
    if (empty($config['unix-agent']['read-timeout'])) {
        $config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
    }
    $agent_start = microtime(true);
    $agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
    // Set stream timeout (for timeouts during agent  fetch
    stream_set_timeout($agent, $config['unix-agent']['read-timeout']);
    $agentinfo = stream_get_meta_data($agent);
    if (!$agent) {
        echo 'Connection to UNIX agent failed on port ' . $port . '.';
    } else {
        // fetch data while not eof and not timed-out
        while (!feof($agent) && !$agentinfo['timed_out']) {
            $agent_raw .= fgets($agent, 128);
            $agentinfo = stream_get_meta_data($agent);
        }
        if ($agentinfo['timed_out']) {
            echo 'Connection to UNIX agent timed out during fetch on port ' . $port . '.';
        }
    }
Exemplo n.º 19
0
function notify($device, $title, $message)
{
    /// NOTE. Need full rewrite to universal function with message queues and multi-protocol (email,jabber,twitter)
    global $config, $debug;
    if ($config['alerts']['email']['enable'] && !$device['ignore']) {
        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) {
                // Mail backend params
                $params = array('localhost' => php_uname('n'));
                $backend = strtolower(trim($config['email_backend']));
                switch ($backend) {
                    case 'sendmail':
                        $params['sendmail_path'] = $config['email_sendmail_path'];
                        break;
                    case 'smtp':
                        $params['host'] = $config['email_smtp_host'];
                        $params['port'] = $config['email_smtp_port'];
                        if ($config['email_smtp_secure'] == 'ssl') {
                            $params['host'] = 'ssl://' . $config['email_smtp_host'];
                            if ($config['email_smtp_port'] == 25) {
                                $params['port'] = 465;
                                // Default port for SSL
                            }
                        }
                        $params['timeout'] = $config['email_smtp_timeout'];
                        $params['auth'] = $config['email_smtp_auth'];
                        $params['username'] = $config['email_smtp_username'];
                        $params['password'] = $config['email_smtp_password'];
                        if ($debug) {
                            $params['debug'] = TRUE;
                        }
                        break;
                    default:
                        $backend = 'mail';
                        // Default mailer backend
                }
                // Mail headers
                $headers = array();
                if (empty($config['email_from'])) {
                    $headers['From'] = '"Observium" <observium@' . $params['localhost'] . '>';
                    // Default "From:"
                } else {
                    foreach (parse_email($config['email_from']) as $from => $from_name) {
                        $headers['From'] = empty($from_name) ? $from : '"' . $from_name . '" <' . $from . '>';
                        // From:
                    }
                }
                $rcpts_full = '';
                $rcpts = '';
                foreach ($emails as $to => $to_name) {
                    $rcpts_full .= empty($to_name) ? $to . ', ' : '"' . $to_name . '" <' . $to . '>, ';
                    $rcpts .= $to . ', ';
                }
                $rcpts_full = substr($rcpts_full, 0, -2);
                // To:
                $rcpts = substr($rcpts, 0, -2);
                $headers['Subject'] = $title;
                // Subject:
                $headers['X-Priority'] = 3;
                // Mail priority
                $headers['X-Mailer'] = OBSERVIUM_PRODUCT . ' ' . OBSERVIUM_VERSION;
                // X-Mailer:
                #$headers['Content-type'] = 'text/html';
                $headers['Message-ID'] = '<' . md5(uniqid(time())) . '@' . $params['localhost'] . '>';
                $headers['Date'] = date('r', time());
                // Mail body
                $message_header = $config['page_title_prefix'] . "\n\n";
                $message_footer = "\n\nE-mail sent to: " . $rcpts . "\n";
                $message_footer .= "E-mail sent at: " . date($config['timestamp_format']) . "\n";
                $body = $message_header . $message . $message_footer;
                // Create mailer instance
                $mail =& Mail::factory($backend, $params);
                // Sending email
                $status = $mail->send($rcpts_full, $headers, $body);
                if (PEAR::isError($status)) {
                    echo 'Mailer Error: ' . $status->getMessage() . PHP_EOL;
                }
            }
        }
    }
}
}
unset($graph_array);
if (get_dev_attrib($device, "imagingdrum_c_oid")) {
    $graph_title = "成像鼓";
    $graph_type = "device_imagingdrums";
    include "includes/print-device-graph.php";
} elseif (get_dev_attrib($device, "imagingdrum_oid")) {
    $graph_title = "成像鼓";
    $graph_type = "device_imagingdrum";
    include "includes/print-device-graph.php";
}
unset($graph_array);
if (get_dev_attrib($device, "fuser_oid")) {
    $graph_title = "融合器";
    $graph_type = "device_fuser";
    include "includes/print-device-graph.php";
}
unset($graph_array);
if (get_dev_attrib($device, "transferroller_oid")) {
    $graph_title = "传送辊";
    $graph_type = "device_transferroller";
    include "includes/print-device-graph.php";
}
unset($graph_array);
if (get_dev_attrib($device, "wastebox_oid")) {
    $graph_title = "废碳粉盒";
    $graph_type = "device_wastebox";
    include "includes/print-device-graph.php";
}
echo '</table>';
$page_title[] = "打印";
Exemplo n.º 21
0
        echo '
        <td>' . htmlspecialchars(get_dev_attrib($device, 'override_sysContact_string')) . '</td>
      </tr>
      <tr>
        <td class="entity">SNMP Contact</td>';
    }
    echo '
        <td>' . htmlspecialchars($device['sysContact']) . '</td>
      </tr>';
}
if ($device['location']) {
    echo '<tr>
        <td class="entity">Location</td>
        <td>' . htmlspecialchars($device['location']) . '</td>
      </tr>';
    if (get_dev_attrib($device, 'override_sysLocation_bool') && !empty($device['real_location'])) {
        echo '<tr>
        <td class="entity">SNMP Location</td>
        <td>' . htmlspecialchars($device['real_location']) . '</td>
      </tr>';
    }
}
if ($device['uptime']) {
    echo '<tr>
        <td class="entity">Uptime</td>
        <td>' . deviceUptime($device) . '</td>
      </tr>';
}
echo "</table>";
echo "</div></div>";
// EOF
Exemplo n.º 22
0
 }
 // 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'])) {
             $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']);
Exemplo n.º 23
0
    </div>
  </div>
  <div class="form-group">
    <label for="ipmi_username" class="col-sm-2 control-label">IPMI/BMC Username</label>
    <div class="col-sm-6">
      <input id="ipmi_username" name="ipmi_username" class="form-control" value="<?php 
echo get_dev_attrib($device, 'ipmi_username');
?>
" />
    </div>
  </div>
  <div class="form-group">
    <label for="impi_password" class="col-sm-2 control-label">IPMI/BMC Password</label>
    <div class="col-sm-6">
      <input id="ipmi_password" name="ipmi_password" type="password" class="form-control" value="<?php 
echo get_dev_attrib($device, 'ipmi_password');
?>
" />
    </div>
  </div>
  <div class="row">
    <div class="col-md-1 col-md-offset-2">
        <button type="submit" name="Submit"  class="btn btn-default"><i class="fa fa-check"></i> Save</button>
    </div>
  </div>
  <br><br>
  <div class="alert alert-info" role="alert">
    <p>To disable IPMI polling, please clear the setting fields and click <b>Save</b>.</p>
  </div>
</form>
Exemplo n.º 24
0
            $device['ignore_until'] = $vars['ignore_until'];
        } else {
            $update['ignore_until'] = array('NULL');
            $device['ignore_until'] = '';
        }
        dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id']));
        $update_message = "Device alert settings updated.";
        $updated = 1;
    }
    if ($updated && $update_message) {
        print_message($update_message);
    } else {
        if ($update_message) {
            print_error($update_message);
        }
    }
}
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
$disable_notify = get_dev_attrib($device, 'disable_notify');
$form = array('type' => 'horizontal', 'id' => 'edit', 'title' => 'Alert Settings', 'icon' => 'oicon-gear', 'fieldset' => array('edit' => ''));
$form['row'][0]['editing'] = array('type' => 'hidden', 'value' => 'yes');
$form['row'][1]['ignore_until'] = array('type' => 'datetime', 'name' => 'Ignore Until', 'placeholder' => '', 'readonly' => $readonly, 'disabled' => empty($device['ignore_until']), 'min' => 'current', 'value' => $device['ignore_until'] ? $device['ignore_until'] : '');
$form['row'][1]['ignore_until_enable'] = array('type' => 'switch', 'readonly' => $readonly, 'onchange' => "toggleAttrib('disabled', 'ignore_until')", 'value' => !empty($device['ignore_until']));
$form['row'][2]['override_sysContact'] = array('type' => 'checkbox', 'name' => 'Override sysContact', 'placeholder' => 'Use custom contact below', 'readonly' => $readonly, 'onchange' => "toggleAttrib('disabled', 'sysContact')", 'value' => $override_sysContact_bool);
$form['row'][3]['sysContact'] = array('type' => 'text', 'name' => 'Custom contact', 'placeholder' => '', 'width' => '250px', 'readonly' => $readonly, 'disabled' => !$override_sysContact_bool, 'value' => escape_html($override_sysContact_string));
$form['row'][5]['disable_notify'] = array('type' => 'checkbox', 'name' => 'Disable alerts', 'placeholder' => 'Don\'t send alert mails (<i>but write to eventlog</i>)', 'readonly' => $readonly, 'value' => $disable_notify);
$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
Exemplo n.º 25
0
function is_dev_attrib_enabled($device, $attrib, $default = true)
{
    $val = get_dev_attrib($device, $attrib);
    if ($val != NULL) {
        // attribute is set
        return $val != 0;
    } else {
        // attribute not set
        return $default;
    }
}
Exemplo n.º 26
0
         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_tune = get_dev_attrib($device, 'ifName_tune:' . $port['ifName']);
             $device_tune = get_dev_attrib($device, 'override_rrdtool_tune');
             if ($port_tune == "true" || $device_tune == "true" && $port_tune != 'false' || $config['rrdtool_tune'] == "true" && $port_tune != 'false' && $device_tune != 'false') {
                 if ($oid == 'ifSpeed') {
                     $tune_port = true;
                 }
             }
             $port['update'][$oid] = $this_port[$oid];
             log_event($oid . ': ' . $port[$oid] . ' -> ' . $this_port[$oid], $device, 'interface', $port['port_id']);
             if ($debug) {
                 d_echo($oid . ': ' . $port[$oid] . ' -> ' . $this_port[$oid] . ' ');
             } else {
                 echo $oid . ' ';
             }
         }
     }
 }
Exemplo n.º 27
0
            }
            $updated = 1;
            $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
        } elseif ($rows_updated = '-1') {
            $update_message = "装置记录不变. 没有更新的必要.";
            $updated = -1;
        } else {
            $update_message = "装置的记录更新错误.";
        }
    } else {
        include "includes/error-no-perm.inc.php";
    }
}
$descr = $device['purpose'];
$override_sysLocation_bool = get_dev_attrib($device, 'override_sysLocation_bool');
$override_sysLocation_string = get_dev_attrib($device, 'override_sysLocation_string');
if ($updated && $update_message) {
    print_message($update_message);
} elseif ($update_message) {
    print_error($update_message);
}
?>

 <form id="edit" name="edit" method="post" class="form-horizontal" action="<?php 
echo $url;
?>
">

  <fieldset>
  <legend>设备属性</legend>
  <input type=hidden name="editing" value="yes">
Exemplo n.º 28
0
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
global $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";
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');
    $ipmi['userlevel'] = get_dev_attrib($device, 'ipmi_userlevel');
    if (!is_numeric($ipmi['port'])) {
        $ipmi['port'] = 623;
    }
    if ($ipmi['userlevel'] == '') {
        $ipmi['userlevel'] = 'USER';
    }
    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 " . escapeshellarg($ipmi['userlevel']) . " -U " . escapeshellarg($ipmi['user']) . " -P " . escapeshellarg($ipmi['password']);
    }
    $results = external_exec($config['ipmitool'] . $remote . " sensor 2>/dev/null");
    $ipmi_sensors = parse_ipmitool_sensor($device, $results);
Exemplo n.º 29
0
<?php

// IPMI - We can discover this on poll!
if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
    echo 'IPMI : ';
    $ipmi['user'] = get_dev_attrib($device, 'ipmi_username');
    $ipmi['password'] = get_dev_attrib($device, 'ipmi_password');
    if ($config['own_hostname'] != $device['hostname'] || $ipmi['host'] != 'localhost') {
        $remote = " -H " . $ipmi['host'] . " -U '" . $ipmi['user'] . "' -P '" . $ipmi['password'] . "' -L USER";
    }
    foreach ($config['ipmi']['type'] as $ipmi_type) {
        $results = external_exec($config['ipmitool'] . " -I {$ipmi_type}" . $remote . ' sensor 2>/dev/null|sort');
        if ($results != '') {
            set_dev_attrib($device, 'ipmi_type', $ipmi_type);
            break;
        }
    }
    echo $ipmi_type;
    $index = 0;
    foreach (explode("\n", $results) as $sensor) {
        // BB +1.1V IOH     | 1.089      | Volts      | ok    | na        | 1.027     | 1.054     | 1.146     | 1.177     | na
        list($desc, $current, $unit, $state, $low_nonrecoverable, $low_limit, $low_warn, $high_warn, $high_limit, $high_nonrecoverable) = explode('|', $sensor);
        $index++;
        if (trim($current) != 'na' && $config['ipmi_unit'][trim($unit)]) {
            discover_sensor($valid['sensor'], $config['ipmi_unit'][trim($unit)], $device, trim($desc), $index, 'ipmi', trim($desc), '1', '1', trim($low_limit) == 'na' ? null : trim($low_limit), trim($low_warn) == 'na' ? null : trim($low_warn), trim($high_warn) == 'na' ? null : trim($high_warn), trim($high_limit) == 'na' ? null : trim($high_limit), $current, 'ipmi');
        }
    }
    echo "\n";
}
check_valid_sensors($device, 'voltage', $valid['sensor'], 'ipmi');
check_valid_sensors($device, 'temperature', $valid['sensor'], 'ipmi');
Exemplo n.º 30
0
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// FIXME. From this uses only check_valid_sensors(), maybe need move to global functions or copy to polling. --mike
// Also uses check_valid_virtual_machines(). We (should) do a lot more discovery through the agent, IMO we should do away with the distinction. --tom
include_once "includes/discovery/functions.inc.php";
global $valid, $agent_sensors;
if ($device['os_group'] == "unix") {
    echo "Observium UNIX Agent: ";
    // Use port configured in config (or defaults)
    $agent_port = $config['unix-agent']['port'];
    // ... Unless user configured a port for this specific device, and it's valid (numeric and within 16-bit port range)
    $override_port = get_dev_attrib($device, 'agent_port');
    if (is_numeric($override_port) && $override_port < 65536) {
        $agent_port = $override_port;
    }
    $agent_start = utime();
    $agent_socket = "tcp://" . $device['hostname'] . ":" . $agent_port;
    $agent = @stream_socket_client($agent_socket, $errno, $errstr, 10);
    if (!$agent) {
        print_warning("Connection to UNIX agent on " . $agent_socket . " failed. ERROR: " . $errno . " " . $errstr);
        logfile("UNIX-AGENT: Connection on " . $agent_socket . " failed. ERROR: " . $errno . " " . $errstr);
    } else {
        $agent_raw = stream_get_contents($agent);
    }
    $agent_end = utime();
    $agent_time = round(($agent_end - $agent_start) * 1000);
    if (!empty($agent_raw)) {