Skip to content

Commit

Permalink
add save diagnostics function
Browse files Browse the repository at this point in the history
add function so user is easily able to save their UPS details into a dummy-ups compliant .dev file, which the plugin developers can then request from the user to better identify problems with certain devices and the plugin itself.
  • Loading branch information
desertwitch committed Jul 25, 2023
1 parent 54edfd3 commit b3f9ae3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/nut/usr/local/emhttp/plugins/nut/NUTdetails.page
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ table.tablesorter tbody tr:nth-child(even) {
<tbody id="nut_status"><tr><td colspan="4" style="text-align:center"><i class="fa fa-spinner fa-spin icon"></i><em>Please wait, retrieving UPS information...</em></td></tr></tbody>
</table>

<div style="font-size:x-small;font-weight:bold;"><a href="/plugins/nut/include/nut_status.php?diagsave=true&all=true">Save Diagnostics</a></div>

<script>
function getNUTstatus() {
$.get('/plugins/nut/include/nut_status.php',{all:'true'},function(data) {
Expand Down
12 changes: 12 additions & 0 deletions source/nut/usr/local/emhttp/plugins/nut/include/nut_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@

if (file_exists('/var/run/nut/upsmon.pid')) {
exec("/usr/bin/upsc ".escapeshellarg($nut_name)."@$nut_ip 2>/dev/null", $rows);

if ($_GET['diagsave'] == "true") {

$diagstring = implode("\n",$rows);
header('Content-Disposition: attachment; filename="nut-diagnostics.dev"');
header('Content-Type: text/plain');
header('Content-Length: ' . strlen($diagstring));
header('Connection: close');
die($diagstring);

}

for ($i=0; $i<count($rows); $i++) {
$row = array_map('trim', explode(':', $rows[$i], 2));
$key = $row[0];
Expand Down

0 comments on commit b3f9ae3

Please sign in to comment.