mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add configuration support for IPMIv2 Kg key (#13845)
* Add support for IPMIv2 Kg Key in device settings Some devices require that the Kg key be specified. An example would be a server of mine, a Cisco C220 M3. Otherwise, it would error out with `Error: Unable to establish IPMI v2 / RMCP+ session`. With verbose output enabled, the connection attempt would stop at `RAKP 4 message has invalid integrity check value`. * Add Kg key support in Poller * Sanitize Kg key from debug output * Added Kg key support for discovery process And it seems to work like a charm. New fields, such as fan tachometers, were added in automatically. * Applying StyleCI changes
This commit is contained in:
@@ -47,6 +47,7 @@ function external_exec($command)
|
||||
'/-X\' \'[\S]+\'/',
|
||||
'/-P\' \'[\S]+\'/',
|
||||
'/-H\' \'[\S]+\'/',
|
||||
'/-y\' \'[\S]+\'/',
|
||||
'/(udp|udp6|tcp|tcp6):([^:]+):([\d]+)/',
|
||||
];
|
||||
$replacements = [
|
||||
@@ -57,6 +58,7 @@ function external_exec($command)
|
||||
'-X\' \'PASSWORD\'',
|
||||
'-P\' \'PASSWORD\'',
|
||||
'-H\' \'HOSTNAME\'',
|
||||
'-y\' \'KG_KEY\'',
|
||||
'\1:HOSTNAME:\3',
|
||||
];
|
||||
|
||||
|
@@ -9,10 +9,15 @@ 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['kg_key'] = get_dev_attrib($device, 'ipmi_kg_key');
|
||||
|
||||
$cmd = [Config::get('ipmitool', 'ipmitool')];
|
||||
if (Config::get('own_hostname') != $device['hostname'] || $ipmi['host'] != 'localhost') {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER');
|
||||
if (empty($ipmi['kg_key']) || is_null($ipmi['kg_key'])) {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER');
|
||||
} else {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-y', $ipmi['kg_key'], '-L', 'USER');
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Config::get('ipmi.type', []) as $ipmi_type) {
|
||||
|
@@ -6,6 +6,7 @@ if ($_POST['editing']) {
|
||||
$ipmi_port = (int) $_POST['ipmi_port'];
|
||||
$ipmi_username = $_POST['ipmi_username'];
|
||||
$ipmi_password = $_POST['ipmi_password'];
|
||||
$ipmi_kg_key = $_POST['ipmi_kg_key'];
|
||||
|
||||
if ($ipmi_hostname != '') {
|
||||
set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname);
|
||||
@@ -31,6 +32,12 @@ if ($_POST['editing']) {
|
||||
del_dev_attrib($device, 'ipmi_password');
|
||||
}
|
||||
|
||||
if ($ipmi_kg_key != '') {
|
||||
set_dev_attrib($device, 'ipmi_kg_key', $ipmi_kg_key);
|
||||
} else {
|
||||
del_dev_attrib($device, 'ipmi_kg_key');
|
||||
}
|
||||
|
||||
$update_message = 'Device IPMI data updated.';
|
||||
$updated = 1;
|
||||
} else {
|
||||
@@ -73,6 +80,12 @@ if ($updated && $update_message) {
|
||||
<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="form-group">
|
||||
<label for="ipmi_kg_key" class="col-sm-2 control-label">IPMIv2 Kg key</label>
|
||||
<div class="col-sm-6">
|
||||
<input id="ipmi_kg_key" name="ipmi_kg_key" type="password" class="form-control" value="<?php echo get_dev_attrib($device, 'ipmi_kg_key'); ?>" placeholder="A0FE1A760B304... (Leave blank if none)" />
|
||||
</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>
|
||||
|
@@ -13,13 +13,18 @@ if (is_array($ipmi_rows)) {
|
||||
$ipmi['port'] = filter_var($device['attribs']['ipmi_port'], FILTER_VALIDATE_INT) ? $device['attribs']['ipmi_port'] : '623';
|
||||
$ipmi['user'] = $device['attribs']['ipmi_username'];
|
||||
$ipmi['password'] = $device['attribs']['ipmi_password'];
|
||||
$ipmi['kg_key'] = $device['attribs']['ipmi_kg_key'];
|
||||
$ipmi['type'] = $device['attribs']['ipmi_type'];
|
||||
|
||||
echo 'Fetching IPMI sensor data...';
|
||||
|
||||
$cmd = [Config::get('ipmitool', 'ipmitool')];
|
||||
if (Config::get('own_hostname') != $device['hostname'] || $ipmi['host'] != 'localhost') {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER', '-p', $ipmi['port']);
|
||||
if (empty($ipmi['kg_key']) || is_null($ipmi['kg_key'])) {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER', '-p', $ipmi['port']);
|
||||
} else {
|
||||
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER', '-p', $ipmi['port'], '-y', $ipmi['kg_key']);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if we know which IPMI interface to use
|
||||
|
Reference in New Issue
Block a user