more updates to checks

This commit is contained in:
wh1te909
2020-04-06 02:24:55 +00:00
parent a7ee28cb8f
commit b5efc486c6
6 changed files with 172 additions and 109 deletions

View File

@@ -1,35 +1,44 @@
<template>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Add CPU Load Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Add CPU Load Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-form @submit.prevent="addCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average utilization > (%)"
:rules="[
<q-form @submit.prevent="addCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average utilization > (%)"
:rules="[
val => !!val || '*Required',
val => val >= 1 || 'Minimum threshold is 1',
val => val < 100 || 'Maximum threshold is 99'
]"
/>
</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>
/>
</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 { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddCpuLoadCheck",
@@ -37,7 +46,9 @@ export default {
mixins: [mixins],
data() {
return {
threshold: 85
threshold: 85,
failure: 5,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},
methods: {
@@ -45,7 +56,8 @@ export default {
const data = {
pk: this.agentpk,
check_type: "cpuload",
threshold: this.threshold
threshold: this.threshold,
failure: this.failure
};
axios
.post("/checks/addstandardcheck/", data)

View File

@@ -52,7 +52,7 @@ export default {
threshold: 25,
disks: [],
firstdisk: "",
failure: 1,
failure: 2,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},

View File

@@ -1,35 +1,44 @@
<template>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Add Memory Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Add Memory Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-form @submit.prevent="addCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average memory usage > (%)"
:rules="[
<q-form @submit.prevent="addCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average memory usage > (%)"
:rules="[
val => !!val || '*Required',
val => val >= 1 || 'Minimum threshold is 1',
val => val < 100 || 'Maximum threshold is 99'
]"
/>
</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>
/>
</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 { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddMemCheck",
@@ -37,7 +46,9 @@ export default {
mixins: [mixins],
data() {
return {
threshold: 85
threshold: 85,
failure: 5,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},
methods: {
@@ -45,7 +56,8 @@ export default {
const data = {
pk: this.agentpk,
check_type: "mem",
threshold: this.threshold
threshold: this.threshold,
failure: this.failure
};
axios
.post("/checks/addstandardcheck/", data)

View File

@@ -7,13 +7,22 @@
</q-card-section>
<q-form @submit.prevent="addCheck">
<q-card-section>
<q-select :rules="[val => !!val || '*Required']" dense outlined v-model="displayName" :options="svcDisplayNames" label="Service" @input="getRawName" />
<q-select
:rules="[val => !!val || '*Required']"
dense
outlined
v-model="displayName"
:options="svcDisplayNames"
label="Service"
@input="getRawName"
/>
</q-card-section>
<q-card-section>
<q-checkbox v-model="passIfStartPending" label="PASS if service is in 'Start Pending' mode" />
<q-checkbox
v-model="passIfStartPending"
label="PASS if service is in 'Start Pending' mode"
/>
<q-checkbox v-model="restartIfStopped" label="RESTART service if it's stopped" />
</q-card-section>
<q-card-section>
@@ -48,13 +57,13 @@ export default {
rawName: [],
passIfStartPending: false,
restartIfStopped: false,
failure: 1,
failure: 2,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},
computed: {
svcDisplayNames() {
return this.servicesData.map(k => k.display_name).sort()
return this.servicesData.map(k => k.display_name).sort();
}
},
methods: {
@@ -67,7 +76,9 @@ export default {
}
},
getRawName() {
let svc = this.servicesData.find(k => k.display_name === this.displayName);
let svc = this.servicesData.find(
k => k.display_name === this.displayName
);
this.rawName = [svc].map(j => j.name);
},
addCheck() {
@@ -92,6 +103,6 @@ export default {
},
mounted() {
this.getServices();
},
}
};
</script>

View File

@@ -1,35 +1,44 @@
<template>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Edit CPU Load Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Edit CPU Load Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-form @submit.prevent="editCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average utilization > (%)"
:rules="[
<q-form @submit.prevent="editCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average utilization > (%)"
:rules="[
val => !!val || '*Required',
val => val >= 1 || 'Minimum threshold is 1',
val => val < 100 || 'Maximum threshold is 99'
]"
/>
</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>
/>
</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 { mapState } from 'vuex';
import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "EditCpuLoadCheck",
@@ -37,20 +46,26 @@ export default {
mixins: [mixins],
data() {
return {
threshold: null
threshold: null,
failure: null,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},
methods: {
getCheck() {
axios
.get(`/checks/getstandardcheck/cpuload/${this.editCheckPK}/`)
.then(r => this.threshold = r.data.cpuload);
.then(r => {
this.threshold = r.data.cpuload;
this.failure = r.data.failures;
});
},
editCheck() {
const data = {
pk: this.editCheckPK,
check_type: "cpuload",
threshold: this.threshold
threshold: this.threshold,
failure: this.failure
};
axios
.patch("/checks/editstandardcheck/", data)

View File

@@ -1,35 +1,44 @@
<template>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Edit Memory Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-card style="min-width: 400px">
<q-card-section class="row items-center">
<div class="text-h6">Edit Memory Check</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-form @submit.prevent="editCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average memory usage > (%)"
:rules="[
<q-form @submit.prevent="editCheck">
<q-card-section>
<q-input
outlined
v-model.number="threshold"
label="Alert if average memory usage > (%)"
:rules="[
val => !!val || '*Required',
val => val >= 1 || 'Minimum threshold is 1',
val => val < 100 || 'Maximum threshold is 99'
]"
/>
</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>
/>
</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 { mapState } from 'vuex';
import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "EditMemCheck",
@@ -37,20 +46,24 @@ export default {
mixins: [mixins],
data() {
return {
threshold: null
threshold: null,
failure: null,
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
};
},
methods: {
getCheck() {
axios
.get(`/checks/getstandardcheck/mem/${this.editCheckPK}/`)
.then(r => this.threshold = r.data.threshold);
axios.get(`/checks/getstandardcheck/mem/${this.editCheckPK}/`).then(r => {
this.threshold = r.data.threshold;
this.failure = r.data.failures;
});
},
editCheck() {
const data = {
pk: this.editCheckPK,
check_type: "mem",
threshold: this.threshold
threshold: this.threshold,
failure: this.failure
};
axios
.patch("/checks/editstandardcheck/", data)