diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIEvents.page b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIEvents.page index a702e38f..05dd959b 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIEvents.page +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIEvents.page @@ -6,7 +6,7 @@ Title="Event Log" Status - Event ID + Event ID Time Stamp Sensor Name Description diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page index df8eb157..93d8680e 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page @@ -1,113 +1,248 @@ Menu="IPMI:2" Title="Fan Control" --- - - + + -function temp_val($val) { - global $display; - return $display['unit']=='C' ? $val : round(9/5*$val+32); -} -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 list_pwm() { - $out = array(); - exec("find /sys/devices -type f -iname 'pwm[0-9]' -exec dirname \"{}\" +|uniq", $chips); - foreach ($chips as $chip) { - $name = is_file("$chip/name") ? file_get_contents("$chip/name") : ""; - foreach (preg_grep("/pwm\d+$/", scan_dir($chip)) as $pwm) { - $out[] = array('chip'=>$name, 'name'=>end(split('/',$pwm)), 'sensor'=>$pwm); - } - } - return $out; -} -?> - - -
- - - - - -Fan control function: +IPMI Fan Control: : -PWM controller: -: +  -PWM fan: -: + -Minimun PWM value: -: + temperature sensor: +: -Low temperature threshold (°): -: + Low temperature threshold: +: -High temperature threshold (°): -: + High temperature threshold: +: -Refresh interval (minutes): -: +  - -: + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + +  + + + + + + temperature sensor: +: + + Low temperature threshold: +: + + High temperature threshold: +: + + + +  + + +:
diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page.old b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page.old new file mode 100755 index 00000000..bdfb24e6 --- /dev/null +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMIFans.page.old @@ -0,0 +1,101 @@ +Menu="IPMI:2" +Title="Fan Control" +--- +$name, 'name'=>end(split('/',$pwm)), 'sensor'=>$pwm); + } + } + return $out; +} +?> + +
+ + + + + +Fan control function: +: + +PWM controller: +: + +PWM fan: +: + +Minimun PWM value: +: + +Low temperature threshold (°): +: + +High temperature threshold (°): +: + +Refresh interval (minutes): +: + + +: +
+ + diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISensors.page b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISensors.page index 31d8dd2a..41ea2f66 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISensors.page +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISensors.page @@ -33,5 +33,4 @@ Icon="sensorspage.png" - diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISettings.page b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISettings.page index b216507b..01c2ecb8 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISettings.page +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/IPMISettings.page @@ -3,7 +3,6 @@ Title="Settings" --- @@ -13,19 +12,19 @@ $sName = "ipmievd"; Enable Event Notifications: -: + + Enable Remote Connection: -: -: +: : @@ -35,20 +34,23 @@ Enable Remote Connection: Display CPU temperature: : Display Motherboard temperature: : + + + Display Fan speed: : + + + - + : @@ -57,7 +59,7 @@ $(function(){ $('.tabs') .append("Fan Control: ") .append("Event Notification: "); - checkRUNNING(document.ipmitool_settings); + checkIPMIEVD(document.ipmitool_settings); checkREMOTE(document.ipmitool_settings); decData(document.ipmitool_settings); //ip address input mask @@ -72,16 +74,16 @@ function resetDATA(form) { form.submit(); } -function checkRUNNING(form) { - if ("" == "yes") +function checkIPMIEVD(form) { + if ("" == true) { - $(".ipmitool-run").prop("disabled", true); + $(".ipmievd-run").prop("disabled", true); form.btnApply.disabled = "disabled"; }else{ - $(".ipmitool-run").prop("disabled", false); + $(".ipmievd-run").prop("disabled", false); $("#btnApply").prop("disabled", false); } - if (form.SERVICE.value == "enable") + if (form.IPMIEVD.value == "enable") form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start"; else { form.command.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop"; @@ -97,13 +99,13 @@ function checkREMOTE(form) { $(".ipmitool-lan").hide(); else $(".ipmitool-lan").show(); - $(".ipmitool-lan").prop("disabled", (form.SERVICE.value == "enable")); + $(".ipmitool-lan").prop("disabled", (form.IPMIEVD.value == "enable")); } function verifyDATA(form) { - form.SERVICE.value = form.SERVICE.value.replace(/ /g,"_"); + form.IPMIEVD.value = form.IPMIEVD.value.replace(/ /g,"_"); form.REMOTE.value = form.REMOTE.value.replace(/ /g,"_"); form.USER.value = form.USER.value.replace(/ /g,"_"); form.PASSWORD.value = btoa(form.PASSWORD.value); } - + \ No newline at end of file diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php index b9a491c5..0c9f99b0 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php @@ -2,13 +2,17 @@ /* ipmi tool variables*/ $plugin = 'ipmitool-plugin'; $cfg = parse_ini_file("/boot/config/plugins/$plugin/$plugin.cfg"); -$service = isset($cfg['SERVICE']) ? $cfg['SERVICE'] : "disable"; -$remote = isset($cfg['REMOTE']) ? $cfg['REMOTE'] : "disable"; -$ipmievd_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmievd.pid0 2> /dev/null`/exe ] && echo 'yes' || echo 'no' 2> /dev/null" )); +$ipmievd = isset($cfg['IPMIEVD']) ? $cfg['IPMIEVD'] : "disable"; +$ipmifan = isset($cfg['IPMIFAN']) ? $cfg['IPMIFAN'] : "disable"; +$remote = isset($cfg['REMOTE']) ? $cfg['REMOTE'] : "disable"; + +//check running status +$ipmievd_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmievd.pid0 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" )); +$ipmifan_running = trim(shell_exec( "[ -f /proc/`cat /var/run/ipmifan.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" )); $running = "Running"; $stopped = "Stopped"; -$ipmievd_status = ($ipmievd_running == "yes") ? $running : $stopped; -$ipmifan_status = ($ipmifan_running == "yes") ? $running : $stopped; +$ipmievd_status = ($ipmievd_running) ? $running : $stopped; +$ipmifan_status = ($ipmifan_running) ? $running : $stopped; // use save ip address or use local ipmi address $ipaddr = preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $cfg['IPADDR']) ? @@ -20,24 +24,32 @@ $mb = isset($cfg['MB_TEMP']) ? $cfg['MB_TEMP'] : ""; // mb temp display $fan = isset($cfg['IPMI_FAN']) ? $cfg['IPMI_FAN'] : ""; // fan speed display name $user = isset($cfg['USER']) ? $cfg['USER'] : ""; // user for remote access $password = isset($cfg['PASSWORD']) ? $cfg['PASSWORD'] : ""; // password for remote access -$sensors = [$cpu, $mb, $fan]; // options for remote access or not $options = ($remote == "enable") ? "-I lanplus -H '$ipaddr' -U '$user' -P '". base64_decode($password)."'" : ""; +// Get sensor info and check connection if remote enabled +$sensors = ipmi_sensors($options); +$fans = ipmi_get_fans($sensors); + +if($remote == "enable"){ + $conn = ($sensors) ? true : false; + $conn_check = ($conn) ? "Connection successful" : "Connection failed"; +} + /* get an array of all sensors and their values */ function ipmi_sensors($options) { - $cmd = "/usr/bin/ipmitool -vc sdr $options -N 1 -R 1 2>/dev/null"; + $cmd = "/usr/bin/ipmitool -vc sdr $options -N 1 -R 1 2>/dev/null"; // N seconds R retries exec($cmd, $output, $return); if ($return) - return []; + return []; // return empty array if error // key names for ipmitool sensor output $keys = ['Name','Reading','Units','Status','Entity','Location','Type','Nominal', - 'NormalMin','NormalMax','UpperNonRec','UpperCritical','UpperNonCritical','LowerNonRec', - 'LowerCritical','LowerNonCritical','MinRange','MaxRange']; + 'NormalMin','NormalMax','UpperNonRec','UpperCritical','UpperNonCrit','LowerNonRec', + 'LowerCritical','LowerNonCrit','MinRange','MaxRange']; $sensors = []; @@ -54,11 +66,11 @@ function ipmi_sensors($options) { /* get array of events and their values */ function ipmi_events($options=null){ - $cmd = "/usr/bin/ipmitool -c sel elist $options -N 1 -R 1 2>/dev/null"; + $cmd = "/usr/bin/ipmitool -c sel elist $options -N 1 -R 1 2>/dev/null"; // N seconds R retries exec($cmd, $output, $return); if ($return) - return []; + return []; // return empty array if error // key names for ipmitool event output $keys = array('Event','Datestamp','Timestamp','Sensor','Description','Status'); @@ -76,9 +88,8 @@ function ipmi_events($options=null){ } /* get select options for a given sensor type */ -function ipmi_get_options($selected, $type, $options){ - $sensors = ipmi_sensors($options=null); - $options = "\n"; +function ipmi_get_options($sensors, $type, $selected=null){ + $options = ""; foreach($sensors as $sensor){ if ($sensor["Type"] == $type && $sensor["Status"] != "ns"){ $name = $sensor["Name"]; @@ -88,7 +99,7 @@ function ipmi_get_options($selected, $type, $options){ if ($selected == $name) $options .= " selected"; - $options .= ">$name\n"; + $options .= ">$name"; } } return $options; @@ -97,23 +108,29 @@ function ipmi_get_options($selected, $type, $options){ /* get reading for a given sensor by name */ function ipmi_get_reading($names, $options=null) { $readings = []; - $cmd = "/usr/bin/ipmitool -c sdr $options -N 1 -R 1 2>/dev/null"; + $cmd = "/usr/bin/ipmitool -c sdr $options -N 1 -R 1 2>/dev/null"; // N seconds R retries exec($cmd, $output, $return); if ($return) - return []; + return []; // return empty array if error for ($i = 0; $i < sizeof($names); $i++) { - foreach($output as $sensor){ - $sensors = explode(",", $sensor); + foreach($output as $line){ + $sensor = explode(",", $line); - if ($sensors[0] == $names[$i]) // check name - $readings[$names[$i]] = $sensors[1]; // reading + if ($sensor[0] == $names[$i]) // check name + $readings[$names[$i]] = $sensor[1]; // get reading by name from readings } } return $readings; // reading } -//echo json_encode(ipmi_get_reading($sensors, $options)); -//echo json_encode(ipmi_sensors($options)); -?> \ No newline at end of file + +function ipmi_get_fans($sensors){ + foreach($sensors as $sensor){ + if ($sensor['Type'] == 'Fan' && $sensor['Status'] != 'ns') + $fans[] = str_replace(' ', '_', $sensor['Name']); + } + return $fans; +} +?> diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_temp.php b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_temp.php index 0561adee..bbfbaaf6 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_temp.php +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_temp.php @@ -6,7 +6,7 @@ function ipmi_temp($reading, $unit, $dot) { } if ($cpu || $mb || $fan){ - $readings = ipmi_get_reading($sensors, $options); + $readings = ipmi_get_reading([$cpu, $mb, $fan], $options); $temps = []; if ($readings[$cpu]) @@ -20,4 +20,4 @@ if ($cpu || $mb || $fan){ } if ($temps) echo "".implode(' ', $temps).""; -?> +?> \ No newline at end of file diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js index 4cc6b198..081167f9 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js @@ -58,7 +58,7 @@ $(function(){ //sensor refresh function sensorRefresh() { sensorArray(true); - setTimeout(sensorRefresh, 3000); + setTimeout(sensorRefresh, 5000); }; //load ipmi sensor table @@ -70,42 +70,42 @@ function sensorArray(Refresh){ var Reading = parseFloat(data[i].Reading); var LowerNonRec = parseFloat(data[i].LowerNonRec); var LowerCritical = parseFloat(data[i].LowerCritical); - var LowerNonCritical = parseFloat(data[i].LowerNonCritical); - var UpperNonCritical = parseFloat(data[i].UpperNonCritical); + var LowerNonCrit = parseFloat(data[i].LowerNonCrit); + var UpperNonCrit = parseFloat(data[i].UpperNonCrit); var UpperCritical = parseFloat(data[i].UpperCritical); var UpperNonRec = parseFloat(data[i].UpperNonRec); var Color = "green"; - // replace illegal characters + // replace invalid characters var Name = data[i].Name.replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_'); if (data[i].Type=="Voltage"){ // if voltage is less than lower non-critical - // or voltage is greater than upper non-critical show orange - if (Reading < LowerNonCritical && Reading > UpperNonCritical) + // or voltage is greater than upper non-critical show critical + if (Reading < LowerNonCrit && Reading > UpperNonCrit) Color = "orange"; // if voltage is less than lower critical - // or voltage is greater than upper critical show red + // or voltage is greater than upper critical show non-recoverable if (Reading < LowerCritical || Reading > UpperCritical) Color = "red"; } else if (data[i].Type=="Fan"){ // if Fan RPMs are less than lower non-critical - if (Reading < LowerNonCritical || Reading < LowerCritical || Reading < LowerNonRec) + if (Reading < LowerNonCrit || Reading < LowerCritical || Reading < LowerNonRec) Color = "red"; } else if (data[i].Type=="Temperature"){ // if Temperature is greater than upper non-critical - if (Reading > UpperNonCritical || Reading > UpperCritical || Reading > UpperNonRec) + if (Reading > UpperNonCrit || Reading > UpperCritical || Reading > UpperNonRec) Color = "red"; } if (Refresh) { - $("#" + Name + " td.reading").html("" + Reading + ""); + $("#" + Name + " td.reading").html("" + Reading + ""); } else { $("#tblSensor tbody") .append(""+ @@ -113,10 +113,10 @@ function sensorArray(Refresh){ ""+data[i].Name+""+ //sensor name ""+ data[i].LowerNonRec +""+ ""+ data[i].LowerCritical +""+ - ""+ data[i].LowerNonCritical +""+ - ""+ Reading +""+ //sensor reading + ""+ data[i].LowerNonCrit +""+ + ""+ "" + Reading + ""+ //sensor reading ""+data[i].Units+""+ //sensor units - ""+ data[i].UpperNonCritical +""+ + ""+ data[i].UpperNonCrit +""+ ""+ data[i].UpperCritical +""+ ""+ data[i].UpperNonRec +""+ ""); @@ -165,16 +165,33 @@ function eventArray(){ }; function Delete(Row) { - var Confirm = (Row == "all") ? confirm("Are your sure you want to remove all events!?"): true; - if (Confirm){ - var Method = (Row == "all") ? "clear " : "delete "; - var EventId = (Row == "all") ? "" : Row; - $.getJSON("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: Method + EventId}, function(data) { - if (Row == "all") - $("#tblEvent tbody").empty(); // empty table - else - $('#'+Row).remove(); //remove table row - } + if (Row == "all"){ + swal({ + title: "Are you sure?", + text: "Are your sure you want to remove all events!?", + type: "warning", + showCancelButton: true, + closeOnConfirm: true, + }, function() { + $.get("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: "clear"}, function() { + $("#tblEvent tbody").empty(); // empty table + } + ); + }); + } else { + $.get("/plugins/ipmitool-plugin/include/ipmi_event_delete.php", {options: "delete " + Row}, function() { + slideRow($('#'+Row)); //remove table row + } ); } -}; \ No newline at end of file +}; + +function slideRow(td) { + td + .children('td') + .animate({ padding: 0 }) + .wrapInner('
') + .children() + .slideUp(function() { td.remove(); }); + $("#tblEvents").trigger("update") +}; diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmifan b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmifan index df0c4611..069aac43 100644 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmifan +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmifan @@ -29,9 +29,9 @@ Usage: $prog [options] = start daemon EOF; -$shortopts = "cquv"; +$shortopts = "bc:dqv"; $longopts = [ - "cron", + "cron:", "debug", "help", "quiet", @@ -51,23 +51,23 @@ if (array_key_exists("version", $args)) { exit(1); } -$argcr = (array_key_exists("c", $args) || array_key_exists("cron", $args)); -$argd = (array_key_exists("d", $args) || array_key_exists("debug", $args)); -$argq = (array_key_exists("q", $args) || array_key_exists("quit", $args)); -$argu = (array_key_exists("u", $args) || array_key_exists("uninstall", $args)); +$cron = (array_key_exists("c", $args) || array_key_exists("cron", $args)); +$DEBUG = (array_key_exists("d", $args) || array_key_exists("debug", $args)); +$quit = (array_key_exists("q", $args) || array_key_exists("quit", $args)); +$background = (array_key_exists("b", $args) || array_key_exists("background", $args)); $argv = (array_key_exists("v", $args) || array_key_exists("verbose", $args)); // ipmitool raw 0x3a 0x01 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xGG 0xHH //ipmitool raw 0x3a 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 // 0x00 = smartfan mode // 0x01 - 0x64 = 1% - 100% -$asrock_array = [ -'CPU_FAN1' => 'AA', -'CPU_FAN2' => 'BB', -'REAR_FAN1' => 'CC', -'REAR_FAN2' => 'DD', -'FRNT_FAN1' => 'EE', -'FRNT_FAN2' => 'FF' +$asrock = [ + 'CPU_FAN1' => 'AA', + 'CPU_FAN2' => 'BB', + 'REAR_FAN1' => 'CC', + 'REAR_FAN2' => 'DD', + 'FRNT_FAN1' => 'EE', + 'FRNT_FAN2' => 'FF' ]; function debug($m){ @@ -79,7 +79,7 @@ function debug($m){ } } -$background_args = ""; +/*$background_args = ""; if(isset($argv)){ for ($i=0; $i <= count($argv); $i++) { switch ($argv[$i]) { @@ -94,20 +94,15 @@ if(isset($argv)){ $DEBUG = TRUE; $background_args .= " ${argv[$i]}"; break; - case '-h': - case '--help': - echo $usage; - exit(0); - # Especific switches: } } -} +}*/ # Deal with cron -if ($cron) && is_numeric($cron) && !$argq){ +if ($cron) && is_numeric($cron) && !$quit){ exec("crontab -l 2>/dev/null", $crontab); $crontab = array_unique($crontab); - if (!$argq){ + if (!$quit){ $entry = sprintf("*/%s * * * * ${service}${background_args} 1> /dev/null 2>&1", $cron); if (! preg_grep("#${service}#", $crontab)){ $crontab[] = $entry; @@ -118,7 +113,7 @@ if ($cron) && is_numeric($cron) && !$argq){ } } unset($crontab); -} else if ($argq){ +} else if ($quit){ exec("crontab -l 2>/dev/null", $crontab); $crontab = array_unique($crontab); if (preg_grep("#${service}#", $crontab)){ @@ -133,9 +128,9 @@ if ($cron) && is_numeric($cron) && !$argq){ 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 (!$argq){ + $pid = preg_replace("/\s+/", "", shell_exec("ps -p ${lock_pid}| grep ${lock_pid}")); + if (!$pid){ + if (!$quit){ file_put_contents($lockfile, getmypid()); } else { echo "$lock_pid is not currently running"; @@ -143,19 +138,19 @@ if (is_file($lockfile)){ exit(0); } } else { - if ($argq){ - syslog(LOG_INFO, "killing daemon with PID [${lock_pid}]"); + if ($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 "$prog is already running [${lock_pid}]".PHP_EOL; + echo "$prog is already running [$lock_pid]".PHP_EOL; exit(0); } } } else { - if($argq){ + if($quit){ echo "$prog not currently running".PHP_EOL; exit(0); } else { diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail index 01eb6a7c..8cbda6f1 100755 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail @@ -1,7 +1,7 @@ #!/bin/bash -prog="ipmievd: " - +DAEMON="ipmievd: " +LASTMSG="Waiting for events" exec /usr/bin/tail -n 0 -F /var/log/syslog | \ while read LINE; @@ -14,7 +14,8 @@ do [[ "$LINE" == *"Get SEL Info command failed"* ]] && continue # only notify when ipmievd: is in the system log -[[ "$LINE" != *$prog* ]] && continue +[[ "$LINE" != *$DAEMON* ]] && continue +MESSAGE=$(echo "$LINE" | sed -e 's/.*$DAEMON//') sleep 1 | -exec /usr/local/emhttp/webGui/scripts/notify -s "Notice [$HOSTNAME]" -d "$(echo "$LINE" | sed -e 's/.*$prog//')" -i "warning" && continue 2 -done +exec /usr/local/emhttp/webGui/scripts/notify -s "Notice [$HOSTNAME]" -d "$MESSAGE" -i "warning" && continue 2 +done \ No newline at end of file diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start index 3de85710..f0ac9f22 100755 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start @@ -1,17 +1,15 @@ #!/bin/sh # read our configuration -prog="ipmievd" -prog2="ipmitail" -IPMIEVD="/usr/sbin/$prog" -IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/$prog2" -LOCKFILE="/var/lock/$prog" -PIDFILE="/var/run/$prog.pid0" +DAEMON="/usr/sbin/ipmievd" +IPMITAIL="/usr/local/emhttp/plugins/ipmitool-plugin/scripts/ipmitail" +LOCKFILE="/var/lock/ipmievd" +PIDFILE="/var/run/ipmievd.pid0" CONFIG="/boot/config/plugins/ipmitool-plugin/ipmitool-plugin.cfg" OPTIONS="" if [ -e $CONFIG ]; then source $CONFIG - if [ $SERVICE == "enable" ]; then + if [ $IPMIEVD == "enable" ]; then # no-op if already running if [ ! -r $PIDFILE ]; then if [ $REMOTE == "enable" ]; then @@ -19,7 +17,7 @@ if [ -e $CONFIG ]; then fi sleep 1 - nohup $IPMIEVD sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool & + nohup $DAEMON sel $OPTIONS > /dev/null 2>&1 | logger -tipmitool & touch $LOCKFILE TIMER=0 while [ ! -e $PIDFILE ]; do diff --git a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop index 118d79e8..aa09ab90 100755 --- a/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop +++ b/source/ipmitool-plugin/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop @@ -1,27 +1,27 @@ #!/bin/sh -prog="ipmievd" -prog2="ipmitail" -LOCKFILE="/var/lock/$prog" -PIDFILE="/var/run/$prog.pid0" +DAEMON="ipmievd" +TAIL="ipmitail" +LOCKFILE="/var/lock/$DAEMON" +PIDFILE="/var/run/$DAEMON.pid0" # no-op if not running if [ -r $PIDFILE ]; then TIMER=0 -while `killall $prog 2>/dev/null`; do +while `killall $DAEMON 2>/dev/null`; do sleep 1 TIMER=$((TIMER+1)) if [ $TIMER -ge 30 ]; then - killall -9 $prog + killall -9 $DAEMON sleep 1 break fi done TIMER=0 -while `killall $prog2 2>/dev/null`; do +while `killall $TAIL 2>/dev/null`; do sleep 1 TIMER=$((TIMER+1)) if [ $TIMER -ge 30 ]; then - killall -9 $prog2 + killall -9 $TAIL sleep 1 break fi