Skip to content

Commit

Permalink
show more detail in checks tab closes amidaware/tacticalrmm#2014
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Oct 15, 2024
1 parent 33dbeb5 commit 870d70b
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions src/components/agents/ChecksTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showPingInfo(props.row)"
>Last Output</span
>{{
grep(props.row.check_result.more_info, [
"transmitted",
"received",
"packet loss",
])
}}</span
>
<span
v-else-if="
Expand All @@ -379,7 +385,7 @@
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showScriptOutput(props.row.check_result)"
>Last Output</span
>{{ processOutput(props.row.check_result) }}</span
>
<span
v-else-if="
Expand All @@ -392,7 +398,9 @@
>
<span
v-else-if="
props.row.check_type === 'diskspace' ||
['diskspace', 'cpuload', 'memory'].includes(
props.row.check_type,
) ||
(props.row.check_type === 'winsvc' && props.row.check_result.id)
"
>{{ props.row.check_result.more_info }}</span
Expand Down Expand Up @@ -510,6 +518,40 @@ export default {
descending: false,
});
// TODO this will break when we add translations
function grep(text, stringsToMatch) {
try {
const lines = text.split("\n");
const matched = [];
for (const line of lines) {
if (stringsToMatch.every((str) => line.includes(str))) {
matched.push(line);
}
}
return matched.length > 0 ? matched.join("\n") : "Last Output";
} catch (e) {
console.error(e);
return "Last Output";
}
}
function processOutput(result) {
try {
if (result.stdout && result.stdout.trim() !== "") {
return result.stdout.substring(0, 60);
} else if (result.stderr && result.stderr.trim() !== "") {
return result.stderr.substring(0, 60);
} else {
return "Last Output";
}
} catch (e) {
console.error(e);
return "Last Output";
}
}
function getAlertSeverity(check) {
if (check.check_result.alert_severity) {
return check.check_result.alert_severity;
Expand Down Expand Up @@ -707,6 +749,8 @@ export default {
getAlertSeverity,
runChecks,
resetAllChecks,
grep,
processOutput,
// dialogs
showScriptOutput,
Expand Down

0 comments on commit 870d70b

Please sign in to comment.