new: [app] Added instance up diagnostic

This commit is contained in:
Sami Mokaddem 2024-07-01 14:31:29 +02:00
parent 423de92f05
commit c7e707368c
3 changed files with 38 additions and 8 deletions

View file

@ -46,6 +46,10 @@ def doRestQuery(authkey: str, request_method: str, url: str, payload: dict = {})
return get(url, payload, api_key=authkey)
def getVersion() -> Union[None, dict]:
return get(f'/servers/getVersion.json')
def getSettings() -> Union[None, dict]:
SETTING_TO_QUERY = [
'Plugin.ZeroMQ_enable',

View file

@ -124,10 +124,15 @@ def get_context(data: dict) -> dict:
def getDiagnostic() -> dict:
diagnostic = {}
misp_version = misp_api.getVersion()
if misp_version is None:
diagnostic['online'] = False
return diagnostic
diagnostic['version'] = misp_version
misp_settings = misp_api.getSettings()
return {
'settings': misp_settings,
}
diagnostic['settings'] = misp_settings
return diagnostic
# Function to forward zmq messages to Socket.IO
@ -152,4 +157,4 @@ if __name__ == "__main__":
eventlet.spawn_n(forward_zmq_to_socketio)
# Run the Socket.IO server
eventlet.wsgi.server(eventlet.listen(('0.0.0.0', 4000)), app)
eventlet.wsgi.server(eventlet.listen(('0.0.0.0', 3000)), app)

View file

@ -1,11 +1,14 @@
<script setup>
import { ref, onMounted } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { exercises, selected_exercises, diagnostic, resetAllExerciseProgress, changeExerciseSelection, fetchDiagnostic } from "@/socket";
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faScrewdriverWrench, faTrash, faSuitcaseMedical, faGraduationCap } from '@fortawesome/free-solid-svg-icons'
const admin_modal = ref(null)
const diagnosticLoading = computed(() => Object.keys(diagnostic.value).length == 0)
const isMISPOnline = computed(() => diagnostic.value.version?.version !== undefined)
function changeSelectionState(state_enabled, exec_uuid) {
changeExerciseSelection(exec_uuid, state_enabled);
}
@ -63,7 +66,7 @@
type="checkbox"
:checked="selected_exercises.includes(exercise.uuid)"
:value="exercise.uuid"
:class="`checkbox ${selected_exercises.includes(exercise.uuid) ? 'checkbox-success' : ''}`"
:class="`checkbox ${selected_exercises.includes(exercise.uuid) ? 'checkbox-success' : ''} [--fallback-bc:#94a3b8]`"
/>
<span class="font-mono font-semibold text-base ml-3">{{ exercise.name }}</span>
</label>
@ -73,8 +76,26 @@
<FontAwesomeIcon :icon="faSuitcaseMedical" class="mr-1"></FontAwesomeIcon>
Diagnostic
</h3>
<h4 class="font-semibold ml-1 my-2">
<strong>MISP Status:</strong>
<span class="ml-2">
<span :class="{
'rounded-lg py-1 px-2': true,
'dark:bg-neutral-800 bg-neutral-400 text-slate-800 dark:text-slate-200': diagnosticLoading,
'dark:bg-green-700 bg-green-500 text-slate-800 dark:text-slate-200': !diagnosticLoading && isMISPOnline,
'dark:bg-red-700 bg-red-700 text-slate-200 dark:text-slate-200': !diagnosticLoading && !isMISPOnline,
}">
<span v-if="diagnosticLoading" class="loading loading-dots loading-sm h-4 inline-block align-middle"></span>
<span v-else class="font-bold">
{{ !isMISPOnline ? 'Unreachable' : `Online (${diagnostic['version']['version']})` }}
</span>
</span>
</span>
</h4>
<h4 class="font-semibold ml-1"><strong>MISP Settings:</strong></h4>
<div class="ml-3">
<div v-if="Object.keys(diagnostic).length == 0" class="flex justify-center">
<div v-if="diagnosticLoading" class="flex justify-center">
<span class="loading loading-dots loading-lg"></span>
</div>
<div
@ -87,7 +108,7 @@
type="checkbox"
:checked="value"
:value="setting"
:class="`checkbox ${value ? 'checkbox-success' : 'checkbox-danger'}`"
:class="`checkbox ${value ? 'checkbox-success' : 'checkbox-danger'} [--fallback-bc:#cbd5e1]`"
disabled
/>
<span class="font-mono font-semibold text-base ml-3">{{ setting }}</span>