mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-03-05 05:13:28 +00:00
finish script checks
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
<q-item clickable v-close-popup @click="showAddWinSvcCheck = true">
|
||||
<q-item-section>Windows Service Check</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="showAddScriptCheck = true">
|
||||
<q-item-section>Script Check</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
@@ -38,9 +41,8 @@
|
||||
<th width="33%" class="text-left">More Info</th>
|
||||
<th width="34%" class="text-left">Date / Time</th>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
|
||||
<q-tr
|
||||
v-for="check in allChecks"
|
||||
:key="check.id + check.check_type"
|
||||
@@ -49,11 +51,15 @@
|
||||
<q-menu context-menu>
|
||||
<q-list dense style="min-width: 200px">
|
||||
<q-item clickable v-close-popup @click="editCheck(check.check_type)">
|
||||
<q-item-section side><q-icon name="edit" /></q-item-section>
|
||||
<q-item-section side>
|
||||
<q-icon name="edit" />
|
||||
</q-item-section>
|
||||
<q-item-section>Edit</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="deleteCheck(check.id, check.check_type)">
|
||||
<q-item-section side><q-icon name="delete" /></q-item-section>
|
||||
<q-item-section side>
|
||||
<q-icon name="delete" />
|
||||
</q-item-section>
|
||||
<q-item-section>Delete</q-item-section>
|
||||
</q-item>
|
||||
<q-separator></q-separator>
|
||||
@@ -87,11 +93,14 @@
|
||||
v-if="check.check_type === 'diskspace'"
|
||||
>Disk Space Drive {{ check.disk }} > {{check.threshold }}%</td>
|
||||
<td v-else-if="check.check_type === 'cpuload'">Avg CPU Load > {{ check.cpuload }}%</td>
|
||||
<td v-else-if="check.check_type === 'script'">Script check: {{ check.script.name }}</td>
|
||||
<td v-else-if="check.check_type === 'ping'">Ping {{ check.name }} ({{ check.ip }})</td>
|
||||
<td
|
||||
v-else-if="check.check_type === 'memory'"
|
||||
>Avg memory usage > {{ check.threshold }}%</td>
|
||||
<td v-else-if="check.check_type === 'winsvc'">Service Check - {{ check.svc_display_name }}</td>
|
||||
<td
|
||||
v-else-if="check.check_type === 'winsvc'"
|
||||
>Service Check - {{ check.svc_display_name }}</td>
|
||||
<td v-if="check.status === 'pending'">Awaiting First Synchronization</td>
|
||||
<td v-else-if="check.status === 'passing'">
|
||||
<q-badge color="positive">Passing</q-badge>
|
||||
@@ -100,19 +109,21 @@
|
||||
<q-badge color="negative">Failing</q-badge>
|
||||
</td>
|
||||
<td v-if="check.check_type === 'ping'">
|
||||
<span
|
||||
<span
|
||||
style="cursor:pointer;color:blue;text-decoration:underline"
|
||||
@click="pingMoreInfo(check.more_info)"
|
||||
>
|
||||
output
|
||||
</span>
|
||||
@click="moreInfo('Ping', check.more_info)"
|
||||
>output</span>
|
||||
</td>
|
||||
<td v-else-if="check.check_type === 'script'">
|
||||
<span
|
||||
style="cursor:pointer;color:blue;text-decoration:underline"
|
||||
@click="moreInfo('Script Check', check.more_info)"
|
||||
>output</span>
|
||||
</td>
|
||||
<td v-else>{{ check.more_info }}</td>
|
||||
<td>{{ check.last_run }}</td>
|
||||
</q-tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</q-markup-table>
|
||||
</template>
|
||||
</div>
|
||||
@@ -169,6 +180,17 @@
|
||||
:agentpk="checks.pk"
|
||||
/>
|
||||
</q-dialog>
|
||||
<!-- script check -->
|
||||
<q-dialog v-model="showAddScriptCheck">
|
||||
<AddScriptCheck @close="showAddScriptCheck = false" :agentpk="checks.pk" />
|
||||
</q-dialog>
|
||||
<q-dialog v-model="showEditScriptCheck">
|
||||
<EditScriptCheck
|
||||
@close="showEditScriptCheck = false"
|
||||
:editCheckPK="editCheckPK"
|
||||
:agentpk="checks.pk"
|
||||
/>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -186,6 +208,8 @@ import AddMemCheck from "@/components/modals/checks/AddMemCheck";
|
||||
import EditMemCheck from "@/components/modals/checks/EditMemCheck";
|
||||
import AddWinSvcCheck from "@/components/modals/checks/AddWinSvcCheck";
|
||||
import EditWinSvcCheck from "@/components/modals/checks/EditWinSvcCheck";
|
||||
import AddScriptCheck from "@/components/modals/checks/AddScriptCheck";
|
||||
import EditScriptCheck from "@/components/modals/checks/EditScriptCheck";
|
||||
|
||||
export default {
|
||||
name: "ChecksTab",
|
||||
@@ -199,7 +223,9 @@ export default {
|
||||
AddMemCheck,
|
||||
EditMemCheck,
|
||||
AddWinSvcCheck,
|
||||
EditWinSvcCheck
|
||||
EditWinSvcCheck,
|
||||
AddScriptCheck,
|
||||
EditScriptCheck
|
||||
},
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
@@ -214,6 +240,8 @@ export default {
|
||||
showEditMemCheck: false,
|
||||
showAddWinSvcCheck: false,
|
||||
showEditWinSvcCheck: false,
|
||||
showAddScriptCheck: false,
|
||||
showEditScriptCheck: false,
|
||||
editCheckPK: null
|
||||
};
|
||||
},
|
||||
@@ -238,10 +266,10 @@ export default {
|
||||
onRefresh(id) {
|
||||
this.$store.dispatch("loadChecks", id);
|
||||
},
|
||||
pingMoreInfo(output) {
|
||||
moreInfo(name, output) {
|
||||
this.$q.dialog({
|
||||
title: "Ping output",
|
||||
style: "width: 600px; max-width: 90vw",
|
||||
title: `${name} output`,
|
||||
style: "width: 80vw; max-width: 90vw",
|
||||
message: `<pre>${output}</pre>`,
|
||||
html: true,
|
||||
dark: true
|
||||
@@ -264,6 +292,9 @@ export default {
|
||||
case "winsvc":
|
||||
this.showEditWinSvcCheck = true;
|
||||
break;
|
||||
case "script":
|
||||
this.showEditScriptCheck = true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -294,11 +325,12 @@ export default {
|
||||
}),
|
||||
allChecks() {
|
||||
return [
|
||||
...this.checks.pingchecks,
|
||||
...this.checks.diskchecks,
|
||||
...this.checks.cpuloadchecks,
|
||||
...this.checks.memchecks,
|
||||
...this.checks.winservicechecks
|
||||
...this.checks.scriptchecks,
|
||||
...this.checks.winservicechecks,
|
||||
...this.checks.pingchecks
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="pingInterval"
|
||||
label="Interval for ping checks (seconds)"
|
||||
v-model.number="checkInterval"
|
||||
label="Interval for checks (seconds)"
|
||||
:rules="[
|
||||
val => !!val || '*Required',
|
||||
val => val >= 60 || 'Minimum is 60 seconds',
|
||||
@@ -246,7 +246,7 @@ export default {
|
||||
monTypes: ["server", "workstation"],
|
||||
desc: "",
|
||||
overdueTime: null,
|
||||
pingInterval: null,
|
||||
checkInterval: null,
|
||||
emailAlert: null,
|
||||
textAlert: null,
|
||||
tree: {},
|
||||
@@ -282,7 +282,7 @@ export default {
|
||||
this.monType = r.data.monitoring_type;
|
||||
this.desc = r.data.description;
|
||||
this.overdueTime = r.data.overdue_time;
|
||||
this.pingInterval = r.data.ping_check_interval;
|
||||
this.checkInterval = r.data.check_interval;
|
||||
this.emailAlert = r.data.overdue_email_alert;
|
||||
this.textAlert = r.data.overdue_text_alert;
|
||||
this.updatePolicy = r.data.winupdatepolicy;
|
||||
@@ -312,7 +312,7 @@ export default {
|
||||
montype: this.monType,
|
||||
desc: this.desc,
|
||||
overduetime: this.overdueTime,
|
||||
pinginterval: this.pingInterval,
|
||||
checkinterval: this.checkInterval,
|
||||
emailalert: this.emailAlert,
|
||||
textalert: this.textAlert,
|
||||
critical: this.critical,
|
||||
|
||||
113
src/components/modals/checks/AddScriptCheck.vue
Normal file
113
src/components/modals/checks/AddScriptCheck.vue
Normal file
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<q-card v-if="scripts.length === 0" style="min-width: 400px">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Add Script Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<p>You need to upload a script first</p>
|
||||
<p>Settings -> Script Manager</p>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
<q-card v-else style="min-width: 400px">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Add Script Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="addScriptCheck">
|
||||
<q-card-section>
|
||||
<q-select
|
||||
:rules="[val => !!val || '*Required']"
|
||||
dense
|
||||
outlined
|
||||
v-model="scriptName"
|
||||
:options="scriptOptions"
|
||||
label="Select script"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model.number="timeout"
|
||||
label="Timeout (seconds)"
|
||||
:rules="[
|
||||
val => !!val || '*Required',
|
||||
val => val >= 10 || 'Minimum is 10 seconds',
|
||||
val => val <= 86400 || 'Maximum is 86400 seconds'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="failure"
|
||||
:options="failures"
|
||||
label="Number of consecutive failures before alert"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn label="Add" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import { mapState } from "vuex";
|
||||
import { mapGetters } from "vuex";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "AddScriptCheck",
|
||||
props: ["agentpk"],
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
scriptName: null,
|
||||
failure: 1,
|
||||
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
timeout: 120
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getScripts() {
|
||||
this.$store.dispatch("getScripts");
|
||||
},
|
||||
addScriptCheck() {
|
||||
const data = {
|
||||
pk: this.agentpk,
|
||||
check_type: "script",
|
||||
scriptPk: this.scriptPk,
|
||||
timeout: this.timeout,
|
||||
failures: this.failure
|
||||
};
|
||||
axios
|
||||
.post("/checks/addstandardcheck/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
this.notifySuccess(r.data);
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data));
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["scripts"]),
|
||||
scriptOptions() {
|
||||
return this.scripts.map(k => k.name).sort();
|
||||
},
|
||||
scriptPk(name) {
|
||||
return this.scripts.filter(k => k.name === this.scriptName)[0].id;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getScripts();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
89
src/components/modals/checks/EditScriptCheck.vue
Normal file
89
src/components/modals/checks/EditScriptCheck.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<q-card style="min-width: 400px">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Edit Script Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="editScriptCheck">
|
||||
<q-card-section>
|
||||
<q-select dense outlined v-model="scriptName" disable label="Select script" />
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model.number="timeout"
|
||||
label="Timeout (seconds)"
|
||||
:rules="[
|
||||
val => !!val || '*Required',
|
||||
val => val >= 10 || 'Minimum is 10 seconds',
|
||||
val => val <= 86400 || 'Maximum is 86400 seconds'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="failure"
|
||||
:options="failures"
|
||||
label="Number of consecutive failures before alert"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn label="Edit" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "EditScriptCheck",
|
||||
props: ["agentpk", "editCheckPK"],
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
scriptName: null,
|
||||
failure: null,
|
||||
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
timeout: null
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getScriptCheck() {
|
||||
axios
|
||||
.get(`/checks/getstandardcheck/script/${this.editCheckPK}/`)
|
||||
.then(r => {
|
||||
this.failure = r.data.failures;
|
||||
this.timeout = r.data.timeout;
|
||||
this.scriptName = r.data.script.name;
|
||||
});
|
||||
},
|
||||
editScriptCheck() {
|
||||
const data = {
|
||||
pk: this.editCheckPK,
|
||||
check_type: "script",
|
||||
failures: this.failure,
|
||||
timeout: this.timeout
|
||||
};
|
||||
axios
|
||||
.patch("/checks/editstandardcheck/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
this.notifySuccess(r.data);
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.error));
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getScriptCheck();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -23,7 +23,8 @@ export const store = new Vuex.Store({
|
||||
agentChecks: {},
|
||||
agentTableLoading: false,
|
||||
treeLoading: false,
|
||||
installedSoftware: []
|
||||
installedSoftware: [],
|
||||
scripts: [],
|
||||
},
|
||||
getters: {
|
||||
loggedIn(state) {
|
||||
@@ -50,6 +51,9 @@ export const store = new Vuex.Store({
|
||||
},
|
||||
agentHostname(state) {
|
||||
return state.agentSummary.hostname;
|
||||
},
|
||||
scripts(state) {
|
||||
return state.scripts;
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
@@ -92,9 +96,17 @@ export const store = new Vuex.Store({
|
||||
(state.winUpdates = {});
|
||||
(state.installedSoftware = []);
|
||||
state.selectedRow = "";
|
||||
},
|
||||
SET_SCRIPTS(state, scripts) {
|
||||
state.scripts = scripts;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getScripts(context) {
|
||||
axios.get("/checks/getscripts/").then(r => {
|
||||
context.commit("SET_SCRIPTS", r.data);
|
||||
})
|
||||
},
|
||||
loadInstalledSoftware(context, pk) {
|
||||
axios.get(`/software/installed/${pk}`).then(r => {
|
||||
context.commit("SET_INSTALLED_SOFTWARE", r.data.software);
|
||||
|
||||
Reference in New Issue
Block a user