-
Notifications
You must be signed in to change notification settings - Fork 53
Add alerts for high CPU usage and temperature in BlueOS #2115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
efc8515
b3ce45e
b20f8e9
fb9f91a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| <template> | ||
| <ExpansiblePanel :is-expanded="true" no-top-divider> | ||
| <template #title>BlueOS monitoring alerts:</template> | ||
| <template #info> | ||
| Configure alerts for BlueOS system monitoring including CPU temperature and usage thresholds. <br /> | ||
| Set custom thresholds and minimum intervals between alerts to prevent spam. | ||
| </template> | ||
| <template #content> | ||
| <div class="ml-4 mb-4 mr-4"> | ||
| <table class="w-full"> | ||
| <thead> | ||
| <tr> | ||
| <th class="text-center text-sm font-medium text-slate-200 pb-3 w-12"></th> | ||
| <th class="text-center text-sm font-medium text-slate-200 pb-3 w-40">Alert Type</th> | ||
| <th class="text-center text-sm font-medium text-slate-200 pb-3 w-32">Threshold</th> | ||
| <th class="text-center text-sm font-medium text-slate-200 pb-3 w-32">Min Interval (s)</th> | ||
| <th class="text-center text-sm font-medium text-slate-200 pb-3 w-24">Level</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <!-- CPU Temperature Configuration --> | ||
| <tr class="border-b border-slate-600"> | ||
| <td class="py-3 text-center"> | ||
| <input | ||
| v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" | ||
| type="checkbox" | ||
| class="w-4 h-4" | ||
| /> | ||
|
Comment on lines
+24
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the v-checkbox as on the elements below to keep UI consistency |
||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <span class="text-sm font-medium">CPU Temperature</span> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <div class="flex items-center justify-center gap-2"> | ||
| <input | ||
| v-model.number="vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].threshold" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure if this is the correct approach to do that, the system-information page has the /platform endpoint where it returns platform specific data, in this case, for the raspberry, it returns the events such as thermal throttle, under voltage, and others.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! I like the idea of implementing the undervoltage and throttling warns as well. About allowing customization of the threshold for those that have continuous values, it is needed since each platform behaves differently, and the user will know better than anyone what is a safe level for their mission and when they need to be warned to take action. |
||
| type="number" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] w-16 text-sm text-center" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" | ||
| /> | ||
| <span class="text-xs text-slate-300">°C</span> | ||
| </div> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <input | ||
| v-model.number="cpuTemperatureIntervalSeconds" | ||
| type="number" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] w-16 text-sm text-center" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" | ||
| /> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <select | ||
| v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].level" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] text-sm w-24" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" | ||
| > | ||
| <option value="success">Success</option> | ||
| <option value="info">Info</option> | ||
| <option value="warning">Warning</option> | ||
| <option value="error">Error</option> | ||
| <option value="critical">Critical</option> | ||
| </select> | ||
|
Comment on lines
+53
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use v-select on dark mode as a standard to keep UI consistency |
||
| </td> | ||
| </tr> | ||
| <!-- CPU Usage Configuration --> | ||
| <tr> | ||
| <td class="py-3 text-center"> | ||
| <input | ||
| v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" | ||
| type="checkbox" | ||
| class="w-4 h-4" | ||
| /> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <span class="text-sm font-medium">CPU Usage</span> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <div class="flex items-center justify-center gap-2"> | ||
| <input | ||
| v-model.number="vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].threshold" | ||
| type="number" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] w-16 text-sm text-center" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" | ||
| /> | ||
| <span class="text-xs text-slate-300">%</span> | ||
| </div> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <input | ||
| v-model.number="cpuUsageIntervalSeconds" | ||
| type="number" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] w-16 text-sm text-center" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" | ||
| /> | ||
| </td> | ||
| <td class="py-3 text-center"> | ||
| <select | ||
| v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].level" | ||
| class="px-2 py-1 rounded-sm bg-[#FFFFFF22] text-sm w-24" | ||
| :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" | ||
| > | ||
| <option value="success">Success</option> | ||
| <option value="info">Info</option> | ||
| <option value="warning">Warning</option> | ||
| <option value="error">Error</option> | ||
| <option value="critical">Critical</option> | ||
| </select> | ||
| </td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| </template> | ||
| </ExpansiblePanel> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
|
|
||
| import ExpansiblePanel from '@/components/ExpansiblePanel.vue' | ||
| import { useVehicleAlerterStore } from '@/stores/vehicleAlerter' | ||
|
|
||
| const vehicleAlerterStore = useVehicleAlerterStore() | ||
|
|
||
| // Convert between seconds (UI) and milliseconds (store) | ||
| const cpuTemperatureIntervalSeconds = computed({ | ||
| get: () => vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].minInterval / 1000, | ||
| set: (value: number) => { | ||
| vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].minInterval = value * 1000 | ||
| }, | ||
| }) | ||
|
|
||
| const cpuUsageIntervalSeconds = computed({ | ||
| get: () => vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].minInterval / 1000, | ||
| set: (value: number) => { | ||
| vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].minInterval = value * 1000 | ||
| }, | ||
| }) | ||
| </script> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Register BlueOS variables in the data lake | ||
| export const blueOsVariables = { | ||
| cpuTemp: { | ||
| id: 'blueos/cpu/tempC', | ||
| name: 'BlueOS CPU Temperature', | ||
| type: 'number', | ||
| description: 'The average temperature of the BlueOS CPU cores in °C.', | ||
| }, | ||
| cpuUsageAverage: { | ||
| id: 'blueos/cpu/usageAverage', | ||
| name: 'BlueOS CPU Usage', | ||
| type: 'number', | ||
| description: 'The average usage of the BlueOS CPU cores in %.', | ||
| }, | ||
| cpuFrequencyAverage: { | ||
| id: 'blueos/cpu/frequencyAverage', | ||
| name: 'BlueOS CPU Frequency', | ||
| type: 'number', | ||
| description: 'The average frequency of the BlueOS CPU cores in Hz.', | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.