Added most framework for Policies in Checks and Tasks. Added MongoDB to docker setup and configured for MeshCentral

This commit is contained in:
Josh Krawczyk
2020-04-19 17:54:27 -04:00
parent fefb74815b
commit 4ca723a3f1
16 changed files with 338 additions and 27 deletions

View File

@@ -56,7 +56,7 @@ export default {
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
const data = {
pk,
...pk,
check_type: "cpuload",
threshold: this.threshold,
failure: this.failure

View File

@@ -45,7 +45,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddDiskSpaceCheck",
props: ["agentpk"],
props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -58,14 +58,16 @@ export default {
},
methods: {
getDisks() {
axios.get(`/checks/getdisks/${this.agentpk}/`).then(r => {
axios.get(`/checks/getdisks/policies/`).then(r => {
this.disks = Object.keys(r.data);
this.firstdisk = Object.keys(r.data)[0];
});
},
addCheck() {
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
const data = {
pk: this.agentpk,
...pk,
check_type: "diskspace",
disk: this.firstdisk,
threshold: this.threshold,
@@ -75,7 +77,13 @@ export default {
.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess(`Disk check for drive ${data.disk} was added!`);
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -42,7 +42,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddMemCheck",
props: ["agentpk"],
props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -53,8 +53,10 @@ export default {
},
methods: {
addCheck() {
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
const data = {
pk: this.agentpk,
...pk,
check_type: "mem",
threshold: this.threshold,
failure: this.failure
@@ -63,7 +65,13 @@ export default {
.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("Memory check was added!");
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -66,7 +66,7 @@ export default {
name: this.pingname,
ip: this.pingip,
};
console.log(data)
axios.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");

View File

@@ -65,7 +65,7 @@ import { mapGetters } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddScriptCheck",
props: ["agentpk"],
props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -80,8 +80,10 @@ export default {
this.$store.dispatch("getScripts");
},
addScriptCheck() {
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
const data = {
pk: this.agentpk,
...pk,
check_type: "script",
scriptPk: this.scriptPk,
timeout: this.timeout,
@@ -91,7 +93,13 @@ export default {
.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess(r.data);
})
.catch(e => this.notifyError(e.response.data));

View File

@@ -48,7 +48,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddWinSvcCheck",
props: ["agentpk"],
props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -69,7 +69,7 @@ export default {
methods: {
async getServices() {
try {
let r = await axios.get(`/services/${this.agentpk}/services/`);
let r = await axios.get(`/services/policies/`);
this.servicesData = Object.freeze([r.data][0].services);
} catch (e) {
console.log(`ERROR!: ${e}`);
@@ -82,8 +82,11 @@ export default {
this.rawName = [svc].map(j => j.name);
},
addCheck() {
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
const data = {
pk: this.agentpk,
...pk,
check_type: "winsvc",
displayname: this.displayName,
rawname: this.rawName[0],
@@ -95,7 +98,13 @@ export default {
.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess(`${data.displayname} service check added!`);
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -42,7 +42,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "EditCpuLoadCheck",
props: ["agentpk", "editCheckPK"],
props: ["agentpk", "policypk", "editCheckPK"],
mixins: [mixins],
data() {
return {
@@ -71,7 +71,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("CPU load check was edited!");
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -58,7 +58,7 @@ export default {
methods: {
getCheck() {
axios
.get(`/checks/getstandardcheck/diskspace/${this.editCheckPK}/`)
.get(`/checks/getstandardcheck/polcies/`)
.then(r => {
this.disks = [r.data.disk];
this.diskToEdit = r.data.disk;
@@ -77,7 +77,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("Disk space check was edited!");
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -42,7 +42,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "EditMemCheck",
props: ["agentpk", "editCheckPK"],
props: ["agentpk", "policypk", "editCheckPK"],
mixins: [mixins],
data() {
return {
@@ -69,7 +69,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("Memory check was edited!");
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -45,7 +45,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "EditPingCheck",
props: ["agentpk", "editCheckPK"],
props: ["agentpk", "policypk", "editCheckPK"],
mixins: [mixins],
data() {
return {
@@ -77,7 +77,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("Ping check was edited!");
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -45,7 +45,7 @@ import axios from "axios";
import mixins from "@/mixins/mixins";
export default {
name: "EditScriptCheck",
props: ["agentpk", "editCheckPK"],
props: ["agentpk", "policypk", "editCheckPK"],
mixins: [mixins],
data() {
return {
@@ -76,7 +76,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess(r.data);
})
.catch(e => this.notifyError(e.response.data.error));

View File

@@ -76,7 +76,13 @@ export default {
.patch("/checks/editstandardcheck/", data)
.then(r => {
this.$emit("close");
this.$store.dispatch("loadChecks", this.agentpk);
if (this.policypk) {
this.$store.dispatch("loadPolicyChecks", this.policypk);
} else {
this.$store.dispatch("loadChecks", this.agentpk);
}
this.notifySuccess("Windows service check was edited!");
})
.catch(e => this.notifyError(e.response.data.error));