rename ipmi repo
|
@ -1,7 +1,7 @@
|
|||
<?xml version='1.0' standalone='yes'?>
|
||||
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "ipmitool">
|
||||
<!ENTITY name "ipmitool-plugin">
|
||||
<!ENTITY author "dmacias72">
|
||||
<!ENTITY version "2015.12.11">
|
||||
<!ENTITY launch "Tools/IPMItool">
|
||||
|
@ -115,9 +115,7 @@ The 'remove' script.
|
|||
removepkg &plgpath;/&plgname;.txz \
|
||||
&plgpath;/&pkg;
|
||||
rm -rf &emhttp; \
|
||||
-f &plgpath;/&plgname;.txz \
|
||||
-f &plgpath;/&plgname;.md5
|
||||
|
||||
-rf &plgpath;/&plgname;
|
||||
|
||||
echo "Unloading ipmi drivers..."
|
||||
modprobe -r ipmi_si
|
|
@ -6,14 +6,14 @@
|
|||
# customary to leave one space after the ':' except on otherwise blank lines.
|
||||
|
||||
|-----handy-ruler------------------------------------------------------|
|
||||
speedtest: Speedtest (Command Line Tool)
|
||||
speedtest:
|
||||
speedtest: This is a plugin for unRAID 6.1+. It is an interface for testing
|
||||
speedtest: internet bandwidth using speedtest.net and speedtest-cli.
|
||||
speedtest:
|
||||
speedtest: sivel/speedtest-cli
|
||||
speedtest: https://github.com/sivel/speedtest-cli
|
||||
speedtest:
|
||||
speedtest: dmacias72/unRAID
|
||||
speedtest: https://github.com/dmacias72/unRAID
|
||||
speedtest:
|
||||
ipmitool-plugin: Ipmitool unRAID Plugin
|
||||
ipmitool-plugin:
|
||||
ipmitool-plugin: The ipmitool plugin allows you to view your system sensors and
|
||||
ipmitool-plugin: events using your ipmi hardware. Allows for local or remote
|
||||
ipmitool-plugin: access and event notification.
|
||||
ipmitool-plugin:
|
||||
ipmitool-plugin: https://github.com/dmacias72/unRAID
|
||||
ipmitool-plugin:
|
||||
ipmitool-plugin:
|
||||
ipmitool-plugin:
|
||||
ipmitool-plugin:
|
|
@ -38,7 +38,7 @@ if($ipmitool_cfg['REMOTE'] == "enable") {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/plugins/ipmitool/javascript/jquery.ipmitool.js"></script>
|
||||
<script type="text/javascript" src="/plugins/ipmitool-plugin/javascript/jquery.ipmitool.js"></script>
|
||||
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
|
@ -14,10 +14,10 @@ $ipmitool_password = isset($ipmitool_cfg['PASSWORD']) ? $ipmitool_cfg['PASSWORD'
|
|||
$ipmitool_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmievd.pid0 2> /dev/null`/exe ] && echo 'yes' || echo 'no' 2> /dev/null" ));
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="/plugins/ipmitool/javascript/jquery.mask.js"></script>
|
||||
<script type="text/javascript" src="/plugins/ipmitool-plugin/javascript/jquery.mask.js"></script>
|
||||
|
||||
<form markdown="1" name="ipmitool_settings" method="POST" action="/update.php" target="progressFrame">
|
||||
<input type="hidden" name="#file" value="ipmitool/ipmitool.cfg" />
|
||||
<input type="hidden" name="#file" value="ipmitool-plugin/ipmitool.cfg" />
|
||||
<input type="hidden" id="command" name="#command" value="" />
|
||||
|
||||
Enable Event Notifications:
|
||||
|
@ -73,9 +73,9 @@ function checkRUNNING(form) {
|
|||
$("#btnApply").prop("disabled", false);
|
||||
}
|
||||
if (form.SERVICE.value == "enable")
|
||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool/scripts/start";
|
||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start";
|
||||
else {
|
||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool/scripts/stop";
|
||||
form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
source /boot/config/plugins/ipmitool-plugin/ipmitool.cfg
|
||||
if [ $SERVICE = enable ]; then
|
||||
/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start
|
||||
fi
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 891 B After Width: | Height: | Size: 891 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 417 B |
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 532 B |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
|
@ -42,7 +42,7 @@ function clearEvents() {
|
|||
$('#allEvents').attr('checked', false);
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/plugins/ipmitool/include/delete_event.php",
|
||||
url : "/plugins/ipmitool-plugin/include/delete_event.php",
|
||||
data : {options: "clear" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$("#tblEvent tbody").empty();
|
||||
|
@ -56,7 +56,7 @@ function clearEvents() {
|
|||
var par = $(this).parent().parent(); //get table row
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/plugins/ipmitool/include/delete_event.php",
|
||||
url : "/plugins/ipmitool-plugin/include/delete_event.php",
|
||||
data : {options: "delete " + EventId + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
par.remove(); //remove table row
|
||||
|
@ -84,7 +84,7 @@ function sensorArray(Refresh){
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/plugins/ipmitool/include/ipmitool_array.php",
|
||||
url: "/plugins/ipmitool-plugin/include/ipmitool_array.php",
|
||||
data : {options: "-vc sdr" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$.each(data, function (i, val) {
|
||||
|
@ -119,7 +119,7 @@ function sensorArray(Refresh){
|
|||
} else {
|
||||
$("#tblSensor tbody").append(
|
||||
"<tr id='"+Name+"'>"+
|
||||
"<td title='"+data[i][3]+"'><img src='/plugins/ipmitool/images/green-on.png'/></td>"+ //status
|
||||
"<td title='"+data[i][3]+"'><img src='/plugins/ipmitool-plugin/images/green-on.png'/></td>"+ //status
|
||||
"<td>"+data[i][0]+"</td>"+ //sensor name
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + LowerNonRec + "</td>"+
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + LowerCritical + "</td>"+
|
||||
|
@ -147,7 +147,7 @@ function eventArray(){
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/plugins/ipmitool/include/ipmitool_array.php",
|
||||
url: "/plugins/ipmitool-plugin/include/ipmitool_array.php",
|
||||
data : {options: "-c sel elist" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$.each(data, function (i, val) {
|
||||
|
@ -156,7 +156,7 @@ function eventArray(){
|
|||
$("#tblEvent tbody").append(
|
||||
"<tr>"+
|
||||
"<td> <input class='checkEvent' type='checkbox' value=" + data[i][0] + "></td>"+ //checkbox
|
||||
"<td title='"+data[i][5]+"'><img src='/plugins/ipmitool/images/" + Status + "-on.png'/></td>"+ //status
|
||||
"<td title='"+data[i][5]+"'><img src='/plugins/ipmitool-plugin/images/" + Status + "-on.png'/></td>"+ //status
|
||||
"<td>" + data[i][0] + "</td>"+ //event id
|
||||
"<td>" + data[i][1] + " "+data[i][2]+"</td>"+ //time stamp
|
||||
"<td>" + Sensor[1] + "</td>"+ //sensor name
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/sh
|
||||
# read our configuration
|
||||
source /boot/config/plugins/ipmitool/ipmitool.cfg
|
||||
source /boot/config/plugins/ipmitool-plugin/ipmitool.cfg
|
||||
|
||||
prog="ipmievd"
|
||||
prog2="ipmitail"
|
||||
IPMIEVD="/usr/sbin/$prog"
|
||||
IPMITAIL="/usr/local/emhttp/plugins/ipmitool/scripts/$prog2"
|
||||
IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/$prog2"
|
||||
LOCKFILE="/var/lock/$prog"
|
||||
PIDFILE="/var/run/$prog.pid0"
|
||||
CONFIG="/boot/config/plugins/ipmitool"
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# read our configuration
|
||||
source /boot/config/plugins/ipmitool/ipmitool.cfg
|
||||
source /boot/config/plugins/ipmitool-plugin/ipmitool.cfg
|
||||
|
||||
prog="ipmievd"
|
||||
prog2="ipmitail"
|
|
@ -1,275 +0,0 @@
|
|||
Menu="IPMItool:2"
|
||||
Title="Fan Control"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2014, Lime Technology
|
||||
* Copyright 2014, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
|
||||
<?
|
||||
if ($name == "") {
|
||||
/* default values when adding new share */
|
||||
$share = array("nameOrig" => "",
|
||||
"name" => "",
|
||||
"comment" => "",
|
||||
"allocator" => "highwater",
|
||||
"floor" => "",
|
||||
"splitLevel" => "",
|
||||
"include" => "",
|
||||
"exclude" => "",
|
||||
"useCache" => "no");
|
||||
} else if (array_key_exists($name, $shares)) {
|
||||
/* edit existing share */
|
||||
$share = $shares[$name];
|
||||
} else {
|
||||
/* handle share deleted case */
|
||||
echo "<p class='notice'>Share $name has been deleted.</p><input type='button' value='OK' onclick='done()'>";
|
||||
return;
|
||||
}
|
||||
|
||||
/* check for empty share */
|
||||
function shareEmpty($name) {
|
||||
return (($files = @scandir('/mnt/user/'.$name)) && (count($files) <= 2));
|
||||
}
|
||||
|
||||
if ($var['shareUserInclude']) {
|
||||
$myDisks = explode(',',$var['shareUserInclude']);
|
||||
} else {
|
||||
$myDisks = array();
|
||||
foreach ($disks as $disk) $myDisks[] = $disk['name'];
|
||||
}
|
||||
|
||||
if ($var['shareUserExclude']) {
|
||||
$exclude = explode(',',$var['shareUserExclude']);
|
||||
foreach ($exclude as $disk) {
|
||||
$index = array_search($disk,$myDisks);
|
||||
if ($index !== false) array_splice($myDisks,$index,1);
|
||||
}
|
||||
}
|
||||
?>
|
||||
> A *Share*, also called a *User Share*, is simply the name of a top-level directory that exists on one or more of your
|
||||
> storage devices (array and cache). Each share can be exported for network access. When browsing a share, we return the
|
||||
> composite view of all files and subdirectories for which that top-level directory exists on each storage device.
|
||||
<script>
|
||||
$(function() {
|
||||
$("#s1").dropdownchecklist({emptyText:'All', width:300, explicitClose:'...close'});
|
||||
$("#s2").dropdownchecklist({emptyText:'None', width:300, explicitClose:'...close'});
|
||||
setDiskList(document.share_edit.shareUseCache);
|
||||
presetSpace(document.share_edit.shareFloor);
|
||||
});
|
||||
|
||||
function prepareShareEdit() {
|
||||
$("#s1").dropdownchecklist('destroy');
|
||||
$("#s1").dropdownchecklist({emptyText:'All', width:300, explicitClose:'...close'});
|
||||
$("#s2").dropdownchecklist('destroy');
|
||||
$("#s2").dropdownchecklist({emptyText:'None', width:300, explicitClose:'...close'});
|
||||
setDiskList(document.share_edit.shareUseCache);
|
||||
presetSpace(document.share_edit.shareFloor);
|
||||
}
|
||||
|
||||
function setDiskList(cache) {
|
||||
var onOff = cache=='only' ? 'disable' : 'enable';
|
||||
$("#s1").dropdownchecklist(onOff);
|
||||
$("#s2").dropdownchecklist(onOff);
|
||||
}
|
||||
|
||||
function presetSpace(shareFloor) {
|
||||
var unit = ['KB','MB','GB','TB','PB'];
|
||||
var scale = shareFloor.value;
|
||||
if (scale.replace(/[0-9.,\s]/g,'').length>0) return;
|
||||
var base = scale>0 ? Math.floor(Math.log(scale)/Math.log(1000)) : 0;
|
||||
if (base>=unit.length) base = unit.length-1;
|
||||
shareFloor.value = (scale/Math.pow(1000, base))+unit[base];
|
||||
}
|
||||
|
||||
// Compose input fields
|
||||
function prepareEdit(form) {
|
||||
// Test share name validity
|
||||
var share = form.shareName.value;
|
||||
if (!share) {
|
||||
alert('Please enter a share name');
|
||||
return false;
|
||||
}
|
||||
if (share.match('^disk[0-9]+$')) {
|
||||
alert('Invalid share name specified\nDo not use reserved names.');
|
||||
return false;
|
||||
}
|
||||
// Adjust minimum free space value to selected unit
|
||||
var unit = 'KB,MB,GB,TB,PB';
|
||||
var scale = form.shareFloor.value;
|
||||
var index = unit.indexOf(scale.replace(/[0-9.,\s]/g,'').toUpperCase());
|
||||
form.shareFloor.value = scale.replace(/[A-Z\s]/gi,'') * Math.pow(1000, (index>0 ? index/3 : 0))
|
||||
// Return include as single line input
|
||||
var include = '';
|
||||
for (var i=0,item; item=form.shareInclude.options[i]; i++) {
|
||||
if (item.selected) {
|
||||
if (include.length) include += ',';
|
||||
include += item.value;
|
||||
item.selected = false;
|
||||
}
|
||||
}
|
||||
item = form.shareInclude.options[0];
|
||||
item.value = include;
|
||||
item.selected = true;
|
||||
// Return exclude as single line input
|
||||
var exclude = '';
|
||||
for (var i=0,item; item=form.shareExclude.options[i]; i++) {
|
||||
if (item.selected) {
|
||||
if (exclude.length) exclude += ',';
|
||||
exclude += item.value;
|
||||
item.selected = false;
|
||||
}
|
||||
}
|
||||
item = form.shareExclude.options[0];
|
||||
item.value = exclude;
|
||||
item.selected = true;
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<form markdown="1" name="share_edit" method="POST" action="/update.htm" target="progressFrame" onsubmit="return prepareEdit(this)">
|
||||
<input type="hidden" name="shareNameOrig" value="<?=$share['nameOrig']?>">
|
||||
Name:
|
||||
: <input type="text" name="shareName" maxlength="40" value="<?=$share['name']?>">
|
||||
|
||||
> The share name can be up to 40 characters, and is case-sensitive. While almost all characters can be used,
|
||||
> make your life easier and avoid special characters such as apostrophes and quotes.
|
||||
|
||||
Comments:
|
||||
: <input type="text" name="shareComment" maxlength="256" value="<?=$share['comment']?>">
|
||||
|
||||
> Anything you like, up to 256 characters.
|
||||
|
||||
Allocation method:
|
||||
: <select name="shareAllocator" size="1">
|
||||
<?=mk_option($share['allocator'], "highwater", "High-water")?>
|
||||
<?=mk_option($share['allocator'], "fillup", "Fill-up")?>
|
||||
<?=mk_option($share['allocator'], "mostfree", "Most-free")?>
|
||||
</select>
|
||||
|
||||
> This setting determines how unRAID OS will choose which disk to use when creating a new file or directory:
|
||||
>
|
||||
> **High-water**
|
||||
> Choose the lowest numbered disk with free space still above the current *high water mark*. The
|
||||
> *high water mark* is initialized with the size of the largest data disk divided by 2. If no disk
|
||||
> has free space above the current *high water mark*, divide the *high water mark* by 2 and choose again.
|
||||
>
|
||||
> The goal of **High-water** is to write as much data as possible to each disk (in order to minimize
|
||||
> how often disks need to be spun up), while at the same time, try to keep the same amount of free space on
|
||||
> each disk (in order to distribute data evenly across the array).
|
||||
>
|
||||
> **Fill-up**
|
||||
> Choose the lowest numbered disk that still has free space above the current **Minimum free space**
|
||||
> setting.
|
||||
>
|
||||
> **Most-free**
|
||||
> Choose the disk that currently has the most free space.
|
||||
|
||||
Minimum free space:
|
||||
: <input type="text" name="shareFloor" maxlength="16" value="<?=$share['floor']?>">
|
||||
|
||||
> The *minimum free space* available to allow writing to any disk belonging to the share.<br>
|
||||
>
|
||||
> Choose a value which is equal or greater than the biggest single file size you intend to copy to the share.
|
||||
> Include units KB, MB, GB and TB as appropriate, e.g. 10MB.
|
||||
|
||||
Split level:
|
||||
: <select name="shareSplitLevel" size="1" style="width:320px">
|
||||
<?=mk_option($share['splitLevel'], "", "Automatically split any directory as required")?>
|
||||
<?=mk_option($share['splitLevel'], "1", "Automatically split only the top level directory as required")?>
|
||||
<?=mk_option($share['splitLevel'], "2", "Automatically split only the top two directory levels as required")?>
|
||||
<?=mk_option($share['splitLevel'], "3", "Automatically split only the top three directory levels as required")?>
|
||||
<?=mk_option($share['splitLevel'], "4", "Automatically split only the top four directory levels as required")?>
|
||||
<?=mk_option($share['splitLevel'], "5", "Automatically split only the top five directory levels as required")?>
|
||||
<?=mk_option($share['splitLevel'], "0", "Manual: do not automatically split directories")?>
|
||||
</select>
|
||||
|
||||
> Determines whether a directory is allowed to expand onto multiple disks.
|
||||
|
||||
> **Automatically split any directory as required**
|
||||
> When a new file or subdirectory needs to be created in a share, unRAID OS first chooses which disk
|
||||
> it should be created on, according to the configured *Allocation method*. If the parent directory containing
|
||||
> the new file or or subdiretory does not exist on this disk, then unRAID OS will first create all necessary
|
||||
> parent directories, and then create the new file or subdirectory.
|
||||
>
|
||||
> **Automatically split only the top level directory as required**
|
||||
> When a new file or subdirectory is being created in the first level subdirectory of a share, if that first
|
||||
> level subdirectory does not exist on the disk being written, then the subdirectory will be created first.
|
||||
> If a new file or subdirectory is being created in the second or lower level subdirectory of a share, the new
|
||||
> file or subdirectory is created on the same disk as the new file or subdirectorys parent directory.
|
||||
>
|
||||
> **Automatically split only the top "N" level directories as required**
|
||||
> Similar to previous: when a new file or subdirectory is being created, if the parent directory is at level "N",
|
||||
> and does not exist on the chosen disk, unRAID OS will first create all necessary parent directories. If the
|
||||
> parent directory of the new file or subdirectory is beyond level "N", then the new file or subdirectory is
|
||||
> created on the same disk where the parent directory exists.
|
||||
>
|
||||
> **Manual: do not automatically split directories**
|
||||
> When a new file or subdirectory needs to be created in a share, unRAID OS will only condider disks where the
|
||||
> parent directory already exists.
|
||||
|
||||
Included disk(s):
|
||||
: <select id="s12" name="shareInclude" size="1" multiple="multiple" >
|
||||
<?foreach ($myDisks as $disk):?>
|
||||
<?=mk_option_check($disk, $share['include'])?>
|
||||
<?endforeach;?>
|
||||
</select>
|
||||
|
||||
> Specify the disks which can be used by the share. By default all disks are included; that is, if specific
|
||||
> disks are not selected here, then the share may expand into *all* array disks.
|
||||
|
||||
Excluded disk(s):
|
||||
: <select id="s22" name="shareExclude" size="1" multiple="multiple" >
|
||||
<?foreach ($myDisks as $disk):?>
|
||||
<?=mk_option_check($disk, $share['exclude'])?>
|
||||
<?endforeach;?>
|
||||
</select>
|
||||
|
||||
> Specify the disks which can *not* be used by the share. By default no disks are excluded.
|
||||
|
||||
<?if ($var['cacheActive']=="yes"):?>
|
||||
Use cache disk:
|
||||
: <select name="shareUseCache" size="1" onchange="setDiskList(this.value)">
|
||||
<?=mk_option($share['useCache'], "no", "No")?>
|
||||
<?=mk_option($share['useCache'], "yes", "Yes")?>
|
||||
<?=mk_option($share['useCache'], "only", "Only")?>
|
||||
</select>
|
||||
<?endif;?>
|
||||
|
||||
> Specify whether new files and subdirectories written on the share can be written onto the Cache disk/pool.
|
||||
>
|
||||
> **No** prohibits new files and subdirectories from being written onto the Cache disk/pool.
|
||||
>
|
||||
> **Yes** indicates that all new files and subdirectories should be written to the Cache disk/pool, provided
|
||||
> enough free space exists on the Cache disk/pool. If there is insufficant space on the Cache disk/pool, then
|
||||
> new files and directories are created on the array. When the *mover* is invoked, files and subdirectories are
|
||||
> transfered off the Cache disk/pool and onto the array.
|
||||
>
|
||||
> **Only** indicates that all new files and subdirectories must be writen to the Cache disk/pool. If there
|
||||
> is insufficient free space on the Cache disk/pool, *create* operations will fail with *out of space* status.
|
||||
|
||||
<?if ($share['name'] == ""):?>
|
||||
<input type="reset" value="Reset" onclick="setTimeout(prepareShareEdit,0)">
|
||||
: <input type="submit" name="cmdEditShare" value="Add Share"><input type="button" value="Cancel" onclick="done()">
|
||||
<?elseif (shareEmpty($share['name'])):?>
|
||||
Share empty?
|
||||
: Yes
|
||||
|
||||
Delete<input type="checkbox" name="confirmDelete" onchange="chkDelete(this.form, this.form.cmdEditShare);">
|
||||
: <input type="submit" name="cmdEditShare" value="Apply"><input type="button" value="Done" onclick="done()">
|
||||
<?else:?>
|
||||
Share empty?
|
||||
: No
|
||||
|
||||
<input type="reset" value="Reset" onclick="setTimeout(prepareShareEdit,0)">
|
||||
: <input type="submit" name="cmdEditShare" value="Apply"><input type="button" value="Done" onclick="done()">
|
||||
<?endif;?>
|
||||
</form>
|
|
@ -1,392 +0,0 @@
|
|||
#!/bin/bash
|
||||
# check_ipmi_sensor: Nagios/Icinga plugin to check IPMI sensors
|
||||
#
|
||||
# Copyright (C) 2009-2011 Thomas-Krenn.AG (written by Werner Fischer),
|
||||
# additional contributors see changelog.txt
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
# The following guides provide helpful information if you want to extend this
|
||||
# script:
|
||||
# http://tldp.org/LDP/abs/html/ (Advanced Bash-Scripting Guide)
|
||||
# http://www.gnu.org/software/gawk/manual/ (Gawk: Effective AWK Programming)
|
||||
# http://de.wikibooks.org/wiki/Awk (awk Wikibook, in German)
|
||||
# http://nagios.sourceforge.net/docs/3_0/customobjectvars.html (hints on
|
||||
# custom object variables)
|
||||
# http://nagiosplug.sourceforge.net/developer-guidelines.html (plug-in
|
||||
# development guidelines)
|
||||
# http://nagios.sourceforge.net/docs/3_0/pluginapi.html (plugin API)
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
# set text variables
|
||||
version="check_ipmi_sensor version 2.4-dev"
|
||||
version_text="$version
|
||||
Copyright (C) 2009-2012 Thomas-Krenn.AG (written by Werner Fischer)
|
||||
Current updates available at http://git.thomas-krenn.com/check_ipmi_sensor_v2.git"
|
||||
usage_text="Usage:
|
||||
check_ipmi_sensor -H <hostname>
|
||||
[-f <FreeIPMI config file> | -U <username> -P <password> -L <privilege level>]
|
||||
[-O <FreeIPMI options>] [-b] [-T <sensor type>] [-x <sensor id>] [-v 1|2|3]
|
||||
[-o zenoss] [-h] [-V]"
|
||||
help_text="Options:
|
||||
-H <hostname>
|
||||
hostname or IP of the IPMI interface.
|
||||
For \"-H localhost\" the Nagios/Icinga user must be allowed to execute
|
||||
ipmimonitoring with root privileges via sudo (ipmimonitoring must be
|
||||
able to access the IPMI devices via the IPMI system interface).
|
||||
[-f <FreeIPMI config file>]
|
||||
path to the FreeIPMI configuration file.
|
||||
Only neccessary for communication via network.
|
||||
Not neccessary for access via IPMI system interface (\"-H localhost\").
|
||||
It should contain IPMI username, IPMI password, and IPMI privilege-level,
|
||||
for example:
|
||||
username monitoring
|
||||
password yourpassword
|
||||
privilege-level user
|
||||
As alternative you can use -U/-P/-L instead (see below).
|
||||
[-U <username> -P <password> -L <privilege level>]
|
||||
IPMI username, IPMI password and IPMI privilege level, provided as
|
||||
parameters and not by a FreeIPMI configuration file. Useful for RHEL/
|
||||
Centos 5.* with FreeIPMI 0.5.1 (this elder FreeIPMI version does not
|
||||
support config files).
|
||||
Warning: with this method the password is visible in the process list.
|
||||
So whenever possible use a FreeIPMI confiugration file instead.
|
||||
[-O <FreeIPMI options>]
|
||||
additional options for FreeIPMI. Useful for RHEL/CentOS 5.* with
|
||||
FreeIPMI 0.5.1 (this elder FreeIPMI version does not support config
|
||||
files).
|
||||
[-b]
|
||||
backward compatibility mode for FreeIPMI 0.5.* (this omits the FreeIPMI
|
||||
caching options --quiet-cache and --sdr-cache-recreate)
|
||||
[-T <sensor type>]
|
||||
limit sensors to query based on IPMI sensor type.
|
||||
Examples for IPMI sensor type are 'Fan', 'Temperature', 'Voltage', ...
|
||||
See chapter '42.2 Sensor Type Codes and Data' of the IPMI 2.0 spec for a
|
||||
full list of possible sensor types. The available types depend on your
|
||||
particular server and the available sensors there.
|
||||
[-x <sensor id>]
|
||||
exclude sensor matching <sensor id>. Useful for cases when unused
|
||||
sensors cannot be deleted from SDR and are reported in a non-OK state.
|
||||
Option can be specified multiple times. The <sensor id> is a numeric
|
||||
value (sensor names are not used as some servers have multiple sensors
|
||||
with the same name). Use -v 3 option to query the <sensor ids>.
|
||||
[-v 1|2|3]
|
||||
be verbose
|
||||
(no -v) .. single line output
|
||||
-v 1 ..... single line output with additional details for warnings
|
||||
-v 2 ..... multi line output, also with additional details for warnings
|
||||
-v 3 ..... debugging output, followed by normal multi line output
|
||||
[-o]
|
||||
change output format. Useful for using the plugin with other monitoring
|
||||
software than Nagios or Icinga.
|
||||
-o zenoss .. create ZENOSS compatible formatted output (output with
|
||||
underscores instead of whitespaces and no single quotes)
|
||||
[-h]
|
||||
show this help
|
||||
[-V]
|
||||
show version information
|
||||
|
||||
When you use the plugin with newer FreeIPMI versions (version 0.8.* and newer)
|
||||
you need to set the --legacy-ouput option to get a parsable output. Further you
|
||||
can use --interpret-oem-data to interpret OEM data (available since FreeIPMI
|
||||
version 0.8.*)
|
||||
You can set these options in your FreeIPMI configuration file:
|
||||
ipmimonitoring-legacy-output on
|
||||
ipmi-sensors-interpret-oem-data on
|
||||
or you provide
|
||||
-O '--legacy-output --interpret-oem-data'
|
||||
to the plugin.
|
||||
|
||||
Further information about this plugin can be found in the Thomas Krenn Wiki
|
||||
(currently only in German):
|
||||
http://www.thomas-krenn.com/de/wiki/IPMI_Sensor_Monitoring_Plugin
|
||||
|
||||
Send email to the IPMI-plugin-user mailing list if you have questions regarding
|
||||
use of this software, to submit patches, or suggest improvements.
|
||||
The mailing list is available at http://lists.thomas-krenn.com/
|
||||
"
|
||||
abort_text=""
|
||||
missing_command_text=""
|
||||
|
||||
################################################################################
|
||||
# set ipmimonitoring path
|
||||
if [ -x "/usr/sbin/ipmimonitoring" ]; then IPMICOMMAND="/usr/sbin/ipmimonitoring"
|
||||
elif [ -x "/usr/bin/ipmimonitoring" ]; then IPMICOMMAND="/usr/bin/ipmimonitoring"
|
||||
elif [ -x "/usr/local/sbin/ipmimonitoring" ]; then IPMICOMMAND="/usr/local/sbin/ipmimonitoring"
|
||||
elif [ -x "/usr/local/bin/ipmimonitoring" ]; then IPMICOMMAND="/usr/local/bin/ipmimonitoring"
|
||||
else missing_command_text=" ipmimonitoring command not found."
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# read parameters
|
||||
# * uses getopts, see http://tldp.org/LDP/abs/html/internal.html#GETOPTSX
|
||||
while getopts "H:f:U:P:L:O:bT:v:x:o:hV?" option
|
||||
do
|
||||
case $option in
|
||||
H) IPMI_HOST=$OPTARG;;
|
||||
f) IPMI_CONFIG_FILE=$OPTARG;;
|
||||
U) IPMI_USER=$OPTARG;;
|
||||
P) IPMI_PASSWORD=$OPTARG;;
|
||||
L) IPMI_PRIVILEGE_LEVEL=$OPTARG;;
|
||||
O) FREEIPMI_OPTIONS=$OPTARG;;
|
||||
b) FREEIPMI_BACKWARD_COMPATIBILITY=1;;
|
||||
T) IPMI_SENSOR_TYPE=$OPTARG;;
|
||||
v) VERBOSITY=$OPTARG;;
|
||||
x) if [ -z "$IPMI_XLIST" ]; then
|
||||
IPMI_XLIST="$OPTARG"
|
||||
else
|
||||
IPMI_XLIST="${IPMI_XLIST};$OPTARG"
|
||||
fi
|
||||
;;
|
||||
o) IPMI_OUTFORMAT=$OPTARG;;
|
||||
h) echo "$version_text"
|
||||
echo
|
||||
echo "$usage_text"
|
||||
echo
|
||||
echo "$help_text"
|
||||
exit 0;;
|
||||
V) echo "$version_text"
|
||||
exit 0;;
|
||||
\?) echo "$usage_text"
|
||||
exit 3;;
|
||||
esac
|
||||
done
|
||||
|
||||
################################################################################
|
||||
# verify if all mandatory parameters are set and initialize various variables
|
||||
if [ -z "$IPMI_HOST" ]; then abort_text="$abort_text -H <hostname>"
|
||||
else
|
||||
if [ "$IPMI_HOST" == "localhost" ]; then
|
||||
BASECOMMAND="sudo $IPMICOMMAND"
|
||||
else
|
||||
if [ -n "$IPMI_CONFIG_FILE" ]; then
|
||||
BASECOMMAND="$IPMICOMMAND -h $IPMI_HOST --config-file $IPMI_CONFIG_FILE"
|
||||
elif [ -n "$IPMI_USER" -a -n "$IPMI_PASSWORD" -a -n "$IPMI_PRIVILEGE_LEVEL" ]; then
|
||||
BASECOMMAND="$IPMICOMMAND -h $IPMI_HOST -u $IPMI_USER -p $IPMI_PASSWORD -l $IPMI_PRIVILEGE_LEVEL"
|
||||
else
|
||||
abort_text="$abort_text -f <FreeIPMI config file> or -U <username> -P <password> -L <privilege level>"; fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$missing_command_text" ]; then
|
||||
echo "Error:$missing_command_text"
|
||||
exit 3
|
||||
fi
|
||||
if [ -n "$abort_text" ]; then
|
||||
echo "Error:$abort_text missing."
|
||||
echo "$usage_text"
|
||||
exit 3
|
||||
fi
|
||||
if [ -n "$IPMI_SENSOR_TYPE" ]; then BASECOMMAND="$BASECOMMAND -g $IPMI_SENSOR_TYPE"; fi
|
||||
if [ -n "$FREEIPMI_OPTIONS" ]; then BASECOMMAND="$BASECOMMAND $FREEIPMI_OPTIONS"; fi
|
||||
if [ -n "$FREEIPMI_BACKWARD_COMPATIBILITY" ]; then
|
||||
GET_STATUS="$BASECOMMAND"
|
||||
else
|
||||
GET_STATUS="$BASECOMMAND --quiet-cache --sdr-cache-recreate"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# execute $GET_STATUS
|
||||
# * uses old-style backquote so the backslash retains its literal meaning except
|
||||
# when followed by ‘$’, ‘`’, or ‘\’
|
||||
# see http://www.gnu.org/software/bash/manual/bashref.html#Command-Substitution
|
||||
ipmioutput=`eval $GET_STATUS 2>&1`
|
||||
returncode=$?
|
||||
|
||||
################################################################################
|
||||
# print debug output when verbosity is set to 3 (-v 3)
|
||||
if [ "$VERBOSITY" = "3" ]
|
||||
then
|
||||
ipmicommandversion=`eval $IPMICOMMAND -V 2>&1 | head -n 1`
|
||||
echo "------------- begin of debug output (-v 3 is set): ------------"
|
||||
echo " script was executed with the following parameters:"
|
||||
echo " $0 $@"
|
||||
echo " check_ipmi_sensor version:"
|
||||
echo " $version"
|
||||
echo " ipmimonitoring version:"
|
||||
echo " $ipmicommandversion"
|
||||
echo " ipmimonitoring was executed with the following parameters:"
|
||||
echo " $GET_STATUS"
|
||||
echo " ipmimonitoring return code: $returncode"
|
||||
echo " output of ipmimonitoring:"
|
||||
echo "$ipmioutput"
|
||||
echo "--------------------- end of debug output ---------------------"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# generate main output
|
||||
if [ $returncode != 0 ]
|
||||
then
|
||||
echo "$ipmioutput"
|
||||
echo "-> Execution of ipmimonitoring failed with return code $returncode."
|
||||
echo "-> ipmimonitoring was executed with the following parameters:"
|
||||
echo " $GET_STATUS"
|
||||
exit 3
|
||||
else
|
||||
if [ -n "$IPMI_SENSOR_TYPE" ]; then
|
||||
echo -n "Sensor Type '$IPMI_SENSOR_TYPE' Status: ";
|
||||
else
|
||||
echo -n "IPMI Status: ";
|
||||
fi
|
||||
echo "$ipmioutput" | gawk -v verbosity=$VERBOSITY -v xlist="$IPMI_XLIST" -v outformat="$IPMI_OUTFORMAT" -F '|' '
|
||||
################################################################################
|
||||
# * BEGIN rule is executed once only, before the first input record is read
|
||||
# see http://www.gnu.org/software/gawk/manual/html_node/Using-BEGIN_002fEND.html
|
||||
# * we initialize variables here
|
||||
BEGIN {
|
||||
EXIT=0
|
||||
number_of_numerical_records=0
|
||||
w_sensors=""
|
||||
split(xlist,xl_array,";")
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# * the "$4 !~ /Monitoring Status/" pattern below is used to omit the header
|
||||
# output of ipmimonitoring
|
||||
# see http://www.gnu.org/software/gawk/manual/html_node/Regexp-Usage.html
|
||||
# * we fill the following arrays with data here:
|
||||
# - arrays containing all sensors:
|
||||
# - sensor_id[] .......... contains the id of the sensor, e.g. "1"
|
||||
# - sensor_name[] ........ contains the name of the sensor, e.g. "Fan 1"
|
||||
# - sensor_status[] ...... contains the status of the sensor, e.g. "Nominal"
|
||||
# - sensor_units[] ....... contains the units of the sensor, e.g. "RPM"
|
||||
# - sensor_reading[] ..... contains the sensor reading , e.g. "5719.000"
|
||||
# - arrays containing only numerical sensors (for performance data)
|
||||
# - n_record_name[] ...... contains the name of the sensor, e.g. "Fan 1"
|
||||
# - n_record_value[] ..... contains the numerical reading, e.g. "5719.000"
|
||||
$4 !~ /Monitoring Status/ {
|
||||
########################################################################
|
||||
# Remove extra spaces
|
||||
gsub(/ +$/,"",$1)
|
||||
gsub(/^ +/,"",$2)
|
||||
gsub(/ +$/,"",$2)
|
||||
gsub(/^ +/,"",$4)
|
||||
gsub(/ +$/,"",$4)
|
||||
gsub(/^ +/,"",$5)
|
||||
gsub(/ +$/,"",$5)
|
||||
gsub(/^ +/,"",$6)
|
||||
gsub(/ +$/,"",$6)
|
||||
# Substitute whitespaces with underscores in sensor_name for ZENOSS
|
||||
if (outformat == "zenoss") gsub(/[[:space:]]/,"_",$2)
|
||||
|
||||
sensor_id[NR]=$1
|
||||
sensor_name[NR]=$2
|
||||
# sensor_type[NR]=$3 (currently not used)
|
||||
sensor_status[NR]=$4
|
||||
sensor_units[NR]=$5
|
||||
sensor_reading[NR]=$6
|
||||
|
||||
########################################################################
|
||||
# Omit this sensor if the sensor is included in the list of sensors to
|
||||
# exclude
|
||||
for (ind in xl_array)
|
||||
{
|
||||
if (sensor_id[NR] == xl_array[ind]) next
|
||||
}
|
||||
########################################################################
|
||||
# * set EXIT variable to 1 if a sensor is not "ok" or "ns"
|
||||
# * also build contents of w_sensors variable (sensors with status not
|
||||
# ok) in this case
|
||||
if (sensor_status[NR] != "Nominal")
|
||||
{
|
||||
if (EXIT < 1) EXIT=1
|
||||
if (EXIT < 2 && sensor_status[NR] != "Warning" ) EXIT=2
|
||||
if (verbosity>0)
|
||||
{
|
||||
if (w_sensors == "")
|
||||
w_sensors=sensor_name[NR]" = "sensor_status[NR]" ("sensor_reading[NR]")"
|
||||
else
|
||||
w_sensors=w_sensors", "sensor_name[NR]" = "sensor_status[NR]" ("sensor_reading[NR]")"
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w_sensors == "")
|
||||
w_sensors=sensor_name[NR]" = "sensor_status[NR]
|
||||
else
|
||||
w_sensors=w_sensors", "sensor_name[NR]" = "sensor_status[NR]
|
||||
}
|
||||
}
|
||||
|
||||
if (sensor_units[NR] != "N/A")
|
||||
{
|
||||
number_of_numerical_records++
|
||||
n_record_name[number_of_numerical_records]=sensor_name[NR]
|
||||
n_record_value[number_of_numerical_records]=sensor_reading[NR]
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# * END rule is executed once only, after all the input is read
|
||||
# see http://www.gnu.org/software/gawk/manual/html_node/Using-BEGIN_002fEND.html
|
||||
# * we print the data which has been collected above in this part below
|
||||
END {
|
||||
########################################################################
|
||||
# * build perfdata string (variable pstring) using quotes
|
||||
# see http://www.gnu.org/software/gawk/manual/html_node/Quoting.html
|
||||
while(j<number_of_numerical_records) {
|
||||
j++
|
||||
if (outformat == "zenoss")
|
||||
pstring=pstring""n_record_name[j]"="n_record_value[j]" "
|
||||
else
|
||||
pstring=pstring"\47"n_record_name[j]"\47="n_record_value[j]" "
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# * print status message (first text output line)
|
||||
if (EXIT==0)
|
||||
{
|
||||
if (number_of_numerical_records>0)
|
||||
print "OK | "pstring
|
||||
else
|
||||
print "OK"
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EXIT==1)
|
||||
{
|
||||
if (number_of_numerical_records>0)
|
||||
print "Warning ["w_sensors"] | "pstring
|
||||
else
|
||||
print "Warning ["w_sensors"]"
|
||||
}
|
||||
else
|
||||
{
|
||||
if (number_of_numerical_records>0)
|
||||
print "Critical ["w_sensors"] | "pstring
|
||||
else
|
||||
print "Critical ["w_sensors"]"
|
||||
}
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# * print additional text lines (multi-line output) for verbosity > 1
|
||||
if (verbosity>1)
|
||||
{
|
||||
while(i<FNR)
|
||||
{
|
||||
i++
|
||||
exclude="false"
|
||||
for (counter in xl_array)
|
||||
if (sensor_id[i] == xl_array[counter]) exclude="true"
|
||||
########################################################
|
||||
# "i > 1" is necessary to omit the header output line
|
||||
if (i > 1 && exclude == "false")
|
||||
print sensor_name[i],"=",sensor_reading[i],"(Status:",sensor_status[i]")"
|
||||
}
|
||||
}
|
||||
exit EXIT
|
||||
}
|
||||
'
|
||||
fi
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
source /boot/config/plugins/ipmitool/ipmitool.cfg
|
||||
if [ $SERVICE = enable ]; then
|
||||
/usr/local/emhttp/plugins/ipmitool/scripts/start
|
||||
fi
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
/usr/local/emhttp/plugins/ipmitool/scripts/stop
|
|
@ -1,248 +0,0 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
##############################
|
||||
###### DEAMON SECTION ######
|
||||
##############################
|
||||
$cron = FALSE;
|
||||
$DEBUG = FALSE;
|
||||
|
||||
# DO NOT TOUCH
|
||||
set_time_limit(0);
|
||||
$program_name = pathinfo(__FILE__, PATHINFO_FILENAME);
|
||||
$lockfile = "/var/run/${program_name}.pid";
|
||||
$service_file = __FILE__;
|
||||
openlog($program_name, LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||
|
||||
$usage = <<<EOT
|
||||
Usage: $program_name = start the daemon
|
||||
$program_name -q = quit the program if it is running
|
||||
|
||||
EOT;
|
||||
|
||||
function debug($m){
|
||||
global $program_name, $DEBUG;
|
||||
if($DEBUG){
|
||||
$STDERR = fopen('php://stderr', 'w+');
|
||||
fwrite($STDERR, $m."\n");
|
||||
fclose($STDERR);
|
||||
}
|
||||
}
|
||||
|
||||
$background_args = "";
|
||||
if(isset($argv)){
|
||||
for ($i=0; $i <= count($argv); $i++) {
|
||||
switch ($argv[$i]) {
|
||||
case '-q':
|
||||
$quit = TRUE;
|
||||
break;
|
||||
case '--background':
|
||||
$background = TRUE;
|
||||
break;
|
||||
case '-c':
|
||||
$cron = $argv[$i+1];
|
||||
$background_args .= " ${argv[$i]} ${argv[$i+1]}";
|
||||
break;
|
||||
case '-d':
|
||||
$DEBUG = TRUE;
|
||||
$background_args .= " ${argv[$i]}";
|
||||
break;
|
||||
case '-h':
|
||||
case '--help':
|
||||
echo $usage;
|
||||
exit(0);
|
||||
# Especific switches:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Deal with cron
|
||||
if (isset($cron) && is_numeric($cron) && ! isset($quit)){
|
||||
exec("crontab -l 2>/dev/null", $crontab);
|
||||
$crontab = array_unique($crontab);
|
||||
if (! isset($quit)){
|
||||
$entry = sprintf("*/%s * * * * ${service_file}${background_args} 1> /dev/null 2>&1", $cron);
|
||||
if (! preg_grep("#${service_file}#", $crontab)){
|
||||
$crontab[] = $entry;
|
||||
debug("\nCRONTAB\n".implode("\n", $crontab)."\n");
|
||||
file_put_contents("/tmp/${program_name}.cron", implode(PHP_EOL, $crontab));
|
||||
shell_exec("crontab /tmp/${program_name}.cron");
|
||||
unlink("/tmp/$program_name.cron");
|
||||
}
|
||||
}
|
||||
unset($crontab);
|
||||
} else if (isset($quit)){
|
||||
exec("crontab -l 2>/dev/null", $crontab);
|
||||
$crontab = array_unique($crontab);
|
||||
if (preg_grep("#${service_file}#", $crontab)){
|
||||
$crontab = preg_grep("#${service_file}#", $crontab, PREG_GREP_INVERT);
|
||||
debug("\nCRONTAB\n".implode("\n", $crontab)."\n");
|
||||
file_put_contents("/tmp/${program_name}.cron", implode(PHP_EOL, $crontab));
|
||||
shell_exec("crontab /tmp/${program_name}.cron");
|
||||
unlink("/tmp/$program_name.cron");
|
||||
};
|
||||
unset($crontab);
|
||||
}
|
||||
|
||||
if (is_file($lockfile)){
|
||||
$lock_pid = file($lockfile, FILE_IGNORE_NEW_LINES)[0];
|
||||
$pid_running=preg_replace("/\s+/", "", shell_exec("ps -p ${lock_pid}| grep ${lock_pid}"));
|
||||
if (! $pid_running){
|
||||
if (! isset($quit)){
|
||||
file_put_contents($lockfile, getmypid());
|
||||
} else {
|
||||
echo "${lock_pid} is not currently running";
|
||||
unlink($lockfile);
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
if (isset($quit)){
|
||||
syslog(LOG_INFO, "killing daemon with PID [${lock_pid}]");
|
||||
exec("kill $lock_pid");
|
||||
unlink($lockfile);
|
||||
if (function_exists('at_exit')) at_exit();
|
||||
exit(0);
|
||||
} else {
|
||||
echo "$program_name is already running [${lock_pid}]".PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(isset($quit)){
|
||||
echo "$program_name not currently running".PHP_EOL;
|
||||
exit(0);
|
||||
} else {
|
||||
file_put_contents($lockfile, getmypid());
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($background)){
|
||||
exec("php $service_file --background $background_args 1>/dev/null ".($DEBUG ? "":"2>&1 ")."&");
|
||||
exit(0);
|
||||
} else {
|
||||
syslog(LOG_INFO, "process started. To terminate it, type: $program_name -q");
|
||||
}
|
||||
|
||||
##############################
|
||||
##### PROGRAM SECTION ######
|
||||
##############################
|
||||
$plugin = "dynamix.system.autofan";
|
||||
$config_file = "/boot/config/plugins/${plugin}/fan.conf";
|
||||
|
||||
function scan_dir($dir, $type = ""){
|
||||
$out = array();
|
||||
foreach (array_slice(scandir($dir), 2) as $entry){
|
||||
$sep = (preg_match("/\/$/", $dir)) ? "" : "/";
|
||||
$out[] = $dir.$sep.$entry ;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function get_highest_temp($hdds){
|
||||
$highest_temp="0";
|
||||
foreach ($hdds as $hdd) {
|
||||
if (shell_exec("hdparm -C ${hdd} 2>/dev/null| grep -c standby") == 0){
|
||||
$temp = preg_replace("/\s+/", "", shell_exec("smartctl -A ${hdd} 2>/dev/null| grep -m 1 -i Temperature_Celsius | awk '{print $10}'"));
|
||||
$highest_temp = ($temp > $highest_temp) ? $temp : $highest_temp;
|
||||
}
|
||||
}
|
||||
debug("Highest temp is ${highest_temp}ºC");
|
||||
return $highest_temp;
|
||||
}
|
||||
|
||||
function get_all_hdds(){
|
||||
$hdds = array();
|
||||
$flash = preg_replace("/\d$/", "", realpath("/dev/disk/by-label/UNRAID"));
|
||||
foreach (scan_dir("/dev/") as $dev) {
|
||||
if(preg_match("/[sh]d[a-z]+$/", $dev) && $dev != $flash) {
|
||||
$hdds[] = $dev;
|
||||
}
|
||||
}
|
||||
return $hdds;
|
||||
}
|
||||
|
||||
$hdds = get_all_hdds();
|
||||
while(TRUE){ while(TRUE){
|
||||
#### DO YOUR STUFF HERE ####
|
||||
|
||||
# Load config file or die
|
||||
if(is_file($config_file)){
|
||||
$params = (is_file($config_file)) ? parse_ini_file($config_file) : array();
|
||||
extract($params, EXTR_OVERWRITE);
|
||||
} else {
|
||||
unlink($lockfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# Wait probes to become ready
|
||||
if (! is_file($PWM_CONTROLLER) || ! is_file($PWM_FAN)){
|
||||
sleep(15);
|
||||
continue;
|
||||
}
|
||||
|
||||
# Set PWM_HIGH and PWM_OFF
|
||||
$PWM_HIGH = 255;
|
||||
$PWM_OFF = $PWM_LOW-5;
|
||||
|
||||
# Disable fan mininum RPM
|
||||
$FAN_RPM_MIN = file(split("_", $PWM_FAN)[0]."_min", FILE_IGNORE_NEW_LINES)[0];
|
||||
$D_FAN_RPM_MIN = ($FAN_RPM_MIN > 0) ? $FAN_RPM_MIN : FALSE;
|
||||
|
||||
# Enable speed change on fan
|
||||
$PWM_MODE=file("${PWM_CONTROLLER}_enable", FILE_IGNORE_NEW_LINES)[0];
|
||||
if($PWM_MODE != 1){
|
||||
$DEFAULT_PWM_MODE = $PWM_MODE;
|
||||
file_put_contents("${PWM_CONTROLLER}_enable", 1);
|
||||
}
|
||||
|
||||
# Calculate size of increments.
|
||||
$TEMP_INCREMENTS = $TEMP_HIGH-$TEMP_LOW;
|
||||
$PWM_INCREMENTS = round(($PWM_HIGH-$PWM_LOW)/$TEMP_INCREMENTS);
|
||||
# Get current fan rpm and pwm
|
||||
$CURRENT_PWM = preg_replace("/\s*/", "", file_get_contents($PWM_CONTROLLER));
|
||||
$CURRENT_RPM = preg_replace("/\s*/", "", file_get_contents($PWM_FAN));
|
||||
# Get current fan PWM percentage
|
||||
$CURRENT_PERCENT_PWM = round(($CURRENT_PWM*100)/$PWM_HIGH);
|
||||
$CURRENT_OUTPUT = "${CURRENT_PWM} (${CURRENT_PERCENT_PWM}% @ ${CURRENT_RPM}rpm)";
|
||||
|
||||
# Calculate a new scenario
|
||||
# Get highest drive temperature
|
||||
$HIGHEST_TEMP = get_highest_temp($hdds);
|
||||
if ($HIGHEST_TEMP <= $TEMP_LOW){
|
||||
$NEW_PWM = $PWM_OFF;
|
||||
$NEW_PERCENT_PWM = 0;
|
||||
} else if ($HIGHEST_TEMP >= $TEMP_HIGH){
|
||||
$NEW_PWM = $PWM_HIGH;
|
||||
$NEW_PERCENT_PWM = 100;
|
||||
} else {
|
||||
$NEW_PWM = (($HIGHEST_TEMP-$TEMP_LOW)*$PWM_INCREMENTS)+$PWM_LOW;
|
||||
$NEW_PERCENT_PWM = round(($NEW_PWM*100)/$PWM_HIGH);
|
||||
}
|
||||
|
||||
# Change the fan speed as needed
|
||||
if ($CURRENT_PWM != $NEW_PWM){
|
||||
file_put_contents($PWM_CONTROLLER, $NEW_PWM);
|
||||
sleep(5);
|
||||
$NEW_RPM = preg_replace("/\s*/", "", file_get_contents($PWM_FAN));
|
||||
$NEW_PERCENT_PWM = round(($NEW_PWM*100)/$PWM_HIGH);
|
||||
$NEW_OUTPUT = "${NEW_PWM} (${NEW_PERCENT_PWM}% @ ${NEW_RPM}rpm)";
|
||||
syslog(LOG_INFO, "highest disk temp is ${HIGHEST_TEMP}ºC, adjusting fan PWM from: $CURRENT_OUTPUT to: $NEW_OUTPUT");
|
||||
}
|
||||
|
||||
# PRINT VARIABLES DEBUG
|
||||
$defined_vars = get_defined_vars();
|
||||
foreach (array("_GET","_POST","_COOKIE","_FILES","argv","argc","_SERVER") as $i) {unset($defined_vars[$i]);}
|
||||
debug("\nDECLARED VARIABLES:\n".print_r($defined_vars, true));
|
||||
unset($defined_vars);
|
||||
|
||||
$time1 = time();
|
||||
$MD5 = shell_exec("md5sum $config_file|awk '{print $1}'");
|
||||
$MD5 = md5_file($config_file);
|
||||
for ($i=0; $i < $INTERVAL*6 ; $i++) {
|
||||
sleep(10);
|
||||
if (md5_file($config_file) != $MD5){syslog(LOG_INFO, "config file updated, reloading."); $i=10000;}
|
||||
}
|
||||
debug("Sleeped ".(time()-$time1)." seconds.");
|
||||
|
||||
###### END OF SECTION ######
|
||||
};};?>
|
||||
|
|
@ -1,285 +0,0 @@
|
|||
#!/bin/bash
|
||||
#=======================================================================================
|
||||
# Name: autofan
|
||||
#=======================================================================================
|
||||
# Description:
|
||||
#
|
||||
# A simple script to check for the highest hard disk temperature and then set the
|
||||
# fan to an apropriate speed. Fan needs to be connected to a motherboard with pwm
|
||||
# support.
|
||||
#
|
||||
# How to invoke in your "go" script (copy to /boot/scripts):
|
||||
# chmod +x /boot/scripts/fan_speed.sh -- superseeded by Dynamix plugin
|
||||
# /boot/fan_speed.sh -- superseeded by Dynamix plugin
|
||||
#=======================================================================================
|
||||
# Version 1.0 Authored by Aiden
|
||||
# Version 1.1 Modified by Dan Stroot to run in a loop. Does not require the user
|
||||
# to add this to cron - just start it in your go file.
|
||||
# Version 1.2 Modified by Guzzi - removed -d ata to work on sas controllers
|
||||
# Version 1.3 Modified by gfjardim - added to dynamix.system.autofan
|
||||
# Version 1.4 Modified by Bergware - added additional line parameters
|
||||
# start/stop control by Dynamix plugin
|
||||
#=======================================================================================
|
||||
# Dependencies: grep,awk,smartctl,hdparm
|
||||
#=======================================================================================
|
||||
version=1.4
|
||||
program_name="autofan"
|
||||
usage() {
|
||||
echo "Usage: $program_name [-t min_temp] [-T max_temp] [-m loop in minutes] [-c controller] [-f fan] [-l low]"
|
||||
echo " $program_name -V = print program version "
|
||||
echo " $program_name -q = quit the program if it is running"
|
||||
echo
|
||||
echo " Argument descriptions:"
|
||||
echo " -t NN = set the low disk temp, below this temp the fan is off (default=35)"
|
||||
echo " -T NN = set the high disk temp, above this temp the fan is 100% (default=45)"
|
||||
echo " -c name = specify name of the controller (default=/sys/class/hwmon/hwmon2/pwm1)"
|
||||
echo " -f name = specify name of the fan (default=/sys/class/hwmon/hwmon2/fan1_input)"
|
||||
echo " -l NN = set value to slow down the fan speed (default=35)"
|
||||
echo " -m NN = number of minutes to wait between fan speed changes (default=5)"
|
||||
}
|
||||
#=======================================================================================
|
||||
# USER DEFINED VARIABLES: *MUST* BE SET TO *YOUR* VALUES
|
||||
#=======================================================================================
|
||||
# Fan device. Depends on *your* system. pwmconfig can help with finding this out.
|
||||
# pwm1 is usually the cpu fan. You can "cat /sys/class/hwmon/hwmon1/device/fan4_input"
|
||||
# to see the current rpm of the fan. If 0 then fan is off or there is no fan connected
|
||||
# or motherboard can't read rpm of fan.
|
||||
PWM_CONTROLLER=/sys/class/hwmon/hwmon2/pwm1 # Power (speed) setting
|
||||
PWM_FAN=/sys/class/hwmon/hwmon2/fan1_input # Used to track actual rpm values
|
||||
|
||||
# Temperature boundaries
|
||||
TEMP_LOW=35 # Anything this number and below - fan is *off*
|
||||
TEMP_HIGH=45 # Anything this number and above - fan is *full*
|
||||
|
||||
# Fan speed settings. Run pwmconfig (part of the lm_sensors package) to determine
|
||||
# what numbers you want to use for your fan pwm settings. Should not need to
|
||||
# change the OFF variable, only the LOW and maybe also HIGH to what you desire.
|
||||
# Any real number between 0 and 255.
|
||||
PWM_OFF=30 # Off Value (note: many PWM fans will not turn off)
|
||||
PWM_LOW=35 # Value to make your fan go slow
|
||||
PWM_HIGH=255 # Value to make your fan go fast
|
||||
|
||||
INTERVAL=5 # The default number of minutes to loop
|
||||
#=======================================================================================
|
||||
# PROGRAM LOGIC - CHANGE AT YOUR PERIL ;)
|
||||
#=======================================================================================
|
||||
# Get User Input
|
||||
while getopts "t:T:m:c:f:l:qhV" opt; do
|
||||
case $opt in
|
||||
t) TEMP_LOW=$OPTARG ;;
|
||||
T) TEMP_HIGH=$OPTARG ;;
|
||||
m) INTERVAL=$OPTARG ;;
|
||||
c) PWM_CONTROLLER=$OPTARG ;;
|
||||
f) PWM_FAN=$OPTARG ;;
|
||||
l) PWM_LOW=$OPTARG ;;
|
||||
V) echo $program_name version: $version ; exit 0 ;;
|
||||
h) usage >&2 ; exit 0 ;;
|
||||
q) quit_flag="yes" ;;
|
||||
\?) usage >&2 ; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
show_values() {
|
||||
echo TEMP_LOW=$TEMP_LOW
|
||||
echo TEMP_HIGH=$TEMP_HIGH
|
||||
echo PWM_OFF=$PWM_OFF
|
||||
echo PWM_LOW=$PWM_LOW
|
||||
echo PWM_HIGH=$PWM_HIGH
|
||||
echo INTERVAL=$INTERVAL
|
||||
}
|
||||
#show_values # uncomment for debugging
|
||||
|
||||
# validate the fan off temp
|
||||
cc="$(echo $TEMP_LOW | sed 's/[0-9]//g')"
|
||||
if [[ ! -z $cc ]]; then
|
||||
echo "Error: min fan temp must be numeric (whole number, not negative)." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# validate the fan high temp
|
||||
cc="$(echo $TEMP_HIGH | sed 's/[0-9]//g')"
|
||||
if [[ ! -z $cc ]]; then
|
||||
echo "Error: max fan temp must be numeric (whole number, not negative)." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# validate the minutes
|
||||
cc="$(echo $INTERVAL | sed 's/[0-9]//g')"
|
||||
if [[ ! -z $cc ]]; then
|
||||
echo "Error: minutes must be numeric (whole number, not negative)." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Lockfile processing
|
||||
lockfile="/var/run/${program_name}.pid"
|
||||
if [[ -f $lockfile ]]; then
|
||||
# The file exists so read the PID
|
||||
# to see if it is still running
|
||||
lock_pid=`head -n 1 "${lockfile}"`
|
||||
pid_running=`ps -p "${lock_pid}" | grep ${lock_pid}`
|
||||
|
||||
if [[ -z $pid_running ]]; then
|
||||
if [[ $quit_flag == no ]]; then
|
||||
# The process is not running
|
||||
# Echo current PID into lock file
|
||||
echo $$ > "${lockfile}"
|
||||
else
|
||||
echo "$program_name ${lock_pid} is not currently running "
|
||||
rm "${lockfile}"
|
||||
fi
|
||||
else
|
||||
if [[ $quit_flag == yes ]]; then
|
||||
echo killing $program_name process "$lock_pid"
|
||||
echo killing $program_name process "$lock_pid" | logger -t$program_name
|
||||
kill "$lock_pid"
|
||||
rm "${lockfile}"
|
||||
exit 0
|
||||
else
|
||||
echo "$program_name is already running [${lock_pid}]"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ $quit_flag == yes ]]; then
|
||||
echo "$program_name not currently running "
|
||||
exit 0
|
||||
else
|
||||
echo $$ > "${lockfile}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Obtain the ID of your flash drive (your flash drive is named "UnRaid" right?)
|
||||
flash=/dev/`ls -l /dev/disk/by-label| grep UNRAID | cut -d/ -f3 | cut -c 1-3`
|
||||
|
||||
# Count the number of drives in your array (ignoring the flash drive we identified)
|
||||
NUM_OF_DRIVES=$(ls /dev/[hs]d? | grep -v "$flash" | wc -l)
|
||||
|
||||
# Identify the drives in your array so we can test their temperature
|
||||
COUNT=1
|
||||
for d in $(ls /dev/[hs]d? | grep -v "$flash"); do
|
||||
HD[$COUNT]=$d
|
||||
#echo HDD=${HD[$COUNT]} # Uncomment for debugging
|
||||
COUNT=$[$COUNT+1]
|
||||
done
|
||||
|
||||
function_get_highest_hd_temp() {
|
||||
HIGHEST_TEMP=0
|
||||
for DISK in "${HD[@]}"; do
|
||||
SLEEPING=`hdparm -C ${DISK} | grep -c standby`
|
||||
if [[ $SLEEPING -eq 0 ]]; then
|
||||
CURRENT_TEMP=`smartctl -A ${DISK} | grep -m 1 -i Temperature_Celsius | awk '{print $10}'`
|
||||
if [[ $HIGHEST_TEMP -le $CURRENT_TEMP ]]; then
|
||||
HIGHEST_TEMP=$CURRENT_TEMP
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function_get_current_fan_speed() {
|
||||
# Function to get current fan values
|
||||
CURRENT_FAN_SPEED=`cat $PWM_CONTROLLER`
|
||||
CURRENT_FAN_RPM=`cat $PWM_FAN`
|
||||
CURRENT_PERCENT_SPEED=$(($(($CURRENT_FAN_SPEED*100))/$PWM_HIGH))
|
||||
#echo Current Fan Speed = $CURRENT_FAN_SPEED # Uncomment for debugging
|
||||
#echo Current Fan RPM = $CURRENT_FAN_RPM # Uncomment for debugging
|
||||
#echo Current Percent Speed = $CURRENT_PERCENT_SPEED # Uncomment for debugging
|
||||
if [[ $CURRENT_FAN_SPEED -le $PWM_OFF ]]; then
|
||||
CURRENT_OUTPUT="OFF (0% @ 0rpm)"
|
||||
#echo Current output = $CURRENT_OUTPUT # Uncomment for debugging
|
||||
else
|
||||
if [[ $CURRENT_FAN_SPEED -ge $PWM_HIGH ]]; then
|
||||
CURRENT_OUTPUT="FULL (100% @ ${CURRENT_FAN_RPM}rpm)"
|
||||
#echo Current output = $CURRENT_OUTPUT # Uncomment for debugging
|
||||
else
|
||||
CURRENT_OUTPUT="$CURRENT_FAN_SPEED (${CURRENT_PERCENT_SPEED}% @ ${CURRENT_FAN_RPM}rpm)"
|
||||
#echo Current output = $CURRENT_OUTPUT # Uncomment for debugging
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function_calc_new_fan_speed() {
|
||||
# Calculate new fan values based on highest drive temperature
|
||||
if [[ $HIGHEST_TEMP -le $TEMP_LOW ]]; then
|
||||
ADJUSTED_FAN_SPEED=$PWM_OFF
|
||||
ADJUSTED_PERCENT_SPEED=0
|
||||
ADJUSTED_OUTPUT="OFF"
|
||||
else
|
||||
if [[ $HIGHEST_TEMP -ge $TEMP_HIGH ]]; then
|
||||
ADJUSTED_FAN_SPEED=$PWM_HIGH
|
||||
ADJUSTED_PERCENT_SPEED=100
|
||||
ADJUSTED_OUTPUT="FULL"
|
||||
else
|
||||
ADJUSTED_FAN_SPEED=$(($(($(($HIGHEST_TEMP-$TEMP_LOW))*$FAN_PWM_INCREMENTS))+$PWM_LOW))
|
||||
ADJUSTED_PERCENT_SPEED=$(($(($ADJUSTED_FAN_SPEED*100))/$PWM_HIGH))
|
||||
ADJUSTED_OUTPUT=$ADJUSTED_FAN_SPEED
|
||||
fi
|
||||
fi
|
||||
#echo Adjusted output = $ADJUSTED_OUTPUT # Uncomment for debugging
|
||||
}
|
||||
|
||||
function_change_fan_speed() {
|
||||
# Implemenent fan speed change if neeeded
|
||||
if [[ $CURRENT_FAN_SPEED -ne $ADJUSTED_FAN_SPEED ]]; then
|
||||
# Enable speed change on fan
|
||||
if [[ `cat ${PWM_CONTROLLER}_enable` -ne 1 ]]; then
|
||||
echo 1 > "${PWM_CONTROLLER}_enable"
|
||||
fi
|
||||
# set fan to new value
|
||||
echo $ADJUSTED_FAN_SPEED > $PWM_CONTROLLER
|
||||
sleep 5
|
||||
# Get new rpm value
|
||||
ADJUSTED_FAN_RPM=`cat $PWM_FAN`
|
||||
ADJUSTED_OUTPUT="${ADJUSTED_OUTPUT} (${ADJUSTED_PERCENT_SPEED}% @ ${ADJUSTED_FAN_RPM}rpm)"
|
||||
# Output the change
|
||||
echo "$program_name: Highest disk temp is ${HIGHEST_TEMP}°C, adjusting fan speed from: $CURRENT_OUTPUT to: $ADJUSTED_OUTPUT"
|
||||
echo "Highest disk temp is ${HIGHEST_TEMP}°C, adjusting fan speed from: $CURRENT_OUTPUT to: $ADJUSTED_OUTPUT" | logger -t$program_name
|
||||
fi
|
||||
}
|
||||
|
||||
# Main Loop
|
||||
while [[ -f $lockfile ]]; do
|
||||
# Just wait if modules aren't loaded
|
||||
if [[ ! -f $PWM_FAN || ! -f $PWM_CONTROLLER ]]; then
|
||||
sleep $(($INTERVAL*60));
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Set PWM_OFF
|
||||
PWM_OFF=$(($PWM_LOW-5)) # Off Value (note: many PWM fans will not turn off)
|
||||
|
||||
# Disable fan mininum RPM
|
||||
FAN_RPM_MIN=$(echo ${PWM_FAN} | cut -d"_" -f1)"_min"
|
||||
if [[ $(cat $FAN_RPM_MIN) -ne 0 ]]; then
|
||||
echo 0 > $FAN_RPM_MIN
|
||||
fi
|
||||
|
||||
# Calculate size of increments.
|
||||
FAN_TEMP_INCREMENTS=$(($TEMP_HIGH-$TEMP_LOW))
|
||||
FAN_PWM_INCREMENTS=$(($(($PWM_HIGH-$PWM_LOW))/$FAN_TEMP_INCREMENTS))
|
||||
|
||||
# Get highest drive temperature
|
||||
function_get_highest_hd_temp
|
||||
|
||||
# Get current fan speed
|
||||
function_get_current_fan_speed
|
||||
|
||||
# Calculate new fan speed
|
||||
function_calc_new_fan_speed
|
||||
|
||||
# Change fan speed if necessary
|
||||
function_change_fan_speed
|
||||
|
||||
#echo Sleeping for $INTERVAL minutes # uncomment for debugging
|
||||
sleep $(($INTERVAL*60))
|
||||
done &
|
||||
|
||||
# while loop was put into background, now disown it so it will continue to run when you log off.
|
||||
# to get it to stop, type: rm /var/lock/fan_speed.LCK
|
||||
background_pid=$!
|
||||
echo $background_pid > "${lockfile}"
|
||||
echo "$program_name process ID $background_pid started, To terminate it, type: $program_name -q" >&2
|
||||
echo "$program_name process ID $background_pid started, To terminate it, type: $program_name -q" | logger -t$program_name
|
||||
disown %%
|