MeshCentral icon indicating copy to clipboard operation
MeshCentral copied to clipboard

Feature Request: Power Events Report for Devices

Open adnan29979 opened this issue 11 months ago • 20 comments

Problem Description Currently, I manage a number of Raspberry Pis that are tasked with sending data to a custom web application almost whenever it turns on. To ensure reliability and proper operation, it's crucial for me to verify that each Raspberry Pi's power events correlate with the data transmission times to the web application. This involves checking if a Raspberry Pi was powered on but failed to send data to the web app as expected.

Currently, this process requires manually checking the power events for each device within MeshCentral, which is both time-consuming and repetitive. Because I work with many devices, this task really slows me down and makes it hard to keep track of everything.

Proposed Solution I propose a feature addition to the "Generate Report..." feature under Events>Reports within MeshCentral. Specifically, I suggest adding a new report type focused on device power events. This feature would greatly streamline the monitoring process by providing a consolidated view of power events across all devices for a specified period and downloading the report. The suggested options for the report generation include:

  • Type: (Add) Power Events to the existing options like Remote Sessions, User Traffic Usage, User Logins, and Database Records.
  • Device Group: Allow selection of specific device groups or all devices.
  • Event: Provide options to filter by "Power On", "Power Off", or "All" power events.
  • Time: Offer selections for Time Range, Last Day, Last 7 Days, and Last 30 Days, including a custom Time Range option.

Additional Context To better illustrate the proposed feature, I have included edited images showcasing how it might look within MeshCentral: Screenshot 2024-03-07 152636 Screenshot 2024-03-07 152656 Screenshot 2024-03-07 160258

(P.S. I love Meshcentral and the developers who have made this)

adnan29979 avatar Mar 07 '24 11:03 adnan29979

this is an extension of my issue from a 2 years ago https://github.com/Ylianst/MeshCentral/issues/4207 i have been looking into this recently, so fingers n toes!

EDIT: once ive added the events into the db (my issue), then the reports can come after! (your issue)

si458 avatar Mar 07 '24 11:03 si458

Wow okay, 2 years ago! Interesting. Do you mean adding new events into the db like computer switched on (startup), computer online (maybe internet came back online), etc? (your issue) Kudos to you for working on it. Rooting for you, brother.

adnan29979 avatar Mar 07 '24 13:03 adnan29979

@adnan29979 yes, once I can get it inserting that type of info into the DB, then I can add your issue where u want to show a report for this information! baby steps 👣

also don't forget to donate! https://www.si458.co.uk/2024/01/05/donation/ every penny helps keep me motivated and carrying on with bug fixes and improvements!

si458 avatar Mar 07 '24 15:03 si458

Device Powered On - Device Turned On - Device Switched On

what sounds best?

si458 avatar Mar 07 '24 18:03 si458

Yup. Baby steps are the way to go. 'Device Powered On' sounds cool and goes well with the existing nomenclature of MeshCentral such as "Power off devices", "Power off". Thanks for asking, Simon. I'm honored.

adnan29979 avatar Mar 07 '24 19:03 adnan29979

how does this look? its only very basic information but its a start! so it shows 'Device Powered On' BUT the time it shows in the web ui is the time on the meshcentral server, where as if you click the event, you get the time the computer said it powered on sadly i cant control the time displayed in the events as this is the time the event is INSERTED into the DB image

si458 avatar Mar 08 '24 10:03 si458

Wow. Thank you for sharing this; it indeed represents an excellent start to this feature. It looks good as well. Regarding the time discrepancy you mentioned, I don't see it posing a significant issue. IMO, if both the machine's and the server's clocks are synchronized with a time server online, the difference should be small, averaging at most a minute. This seems entirely manageable under most circumstances.

Another thought - what if we added an option in config.json or somewhere else, to hide power events from the 'My Events' tab if the admin wants to? These events would still be INSERTED in the database, just not visible in that tab. This could really help when managing lots of devices, like 1000 or so, preventing the tab from getting swamped with power events. It'd make it easier to keep track of other key events, like user logins, failures, etc for administrative purpose.

adnan29979 avatar Mar 08 '24 12:03 adnan29979

@adnan29979 baby steps... 👣

si458 avatar Mar 08 '24 12:03 si458

im currently just checking the last boot up time thats already displayed in the details tab and IF its within 5 minutes of running the sysinfo in meshcore.js, then the machine must of just started up!

this however will cause an issue IF the meshagent service crashes and keeps restarting itself within the first 5 minutes of startup, you will get notifications like mad!

and also in the past i had a machine which altho windows set the lastbootuptime to say 10.05am, the machine took 15mins to load to the desktop, which is when meshagent connected, SO that means it didnt catch the fact it started up as it wasnt within 5 mins!

si458 avatar Mar 08 '24 12:03 si458

Ah okay. The meshagent service crashing and sending indefinite notifications is a big issue. I'm wondering, could diving into the system's logs via the Event Viewer help get a handle on this? Maybe using the logs as a sort of confirmation check to ensure it's genuinely a startup event.

adnan29979 avatar Mar 08 '24 14:03 adnan29979

im not an advanced C developer sadly so thats beyond my scope!

but as for the crashing, im only talking about IF meshagent crashed over n over within the first 5 mins, afterwards it wouldnt be effected because it the time would be > 5 mins. its the same if you restart the meshagent service but not the actual computer, the checker would see the lastbootuptime is > 5mins from when it ran!

im still looking into the shutdown feature, as windows can KILL the meshagent process during shutdown, so the meshagent would have no way of knowing the machine was shutting down

si458 avatar Mar 08 '24 15:03 si458

Hey, how's the addition of new events like computer switched on (startup), computer online (maybe internet came back online), etc going on? Just curious.

adnan29979 avatar Mar 29 '24 06:03 adnan29979

sorry, i started it but i didnt push/merge it cuz i wanted to do a little more testing

si458 avatar Mar 29 '24 13:03 si458

Ahh okay. No worries. Take your time.

adnan29979 avatar Mar 30 '24 16:03 adnan29979

right ok so ive added the first one 'Device Powered On' and it used the lastbootuptime and checks if less then 5 minutes! not ideal but works a treat! im still thinking how to do other ones, like requesting to shutdown, resquest to reboot, etc...

si458 avatar Apr 07 '24 18:04 si458

Alright. Thanks for notifying me. I will use the master files to test it and provide you feedback.

adnan29979 avatar Apr 08 '24 19:04 adnan29979

While this is indeed a useful feature, it does not fit well on large environments(~3000 devices in our case) - we have vast amount of log events about devices powered on with rare amount of another useful ones . Can we make this feature optional? Maybe not the logging itself, but displaying those kind of logs. Some kind of checkbox filter in 'My Events'?

Also, filtering does not work well, no matter what i chose in 'Filter' - current view is still spammed with new 'Device powered on' events

Pinkbyte avatar Jun 18 '24 07:06 Pinkbyte

@Pinkbyte that's OK! Always happy to have community feedback! I never through about 3000 devices showing on and off to be honest I only manage 100 devices and most of them stay on, as they arent laptops.

Would you prefer a new filter box to only show certain events? Or an option in config.json to not show powerevents? Or both?

si458 avatar Jun 18 '24 08:06 si458

@si458, checkbox is good , but option in config.json would be fine too - whatever is easier to implement. Also - should i make another bugreport about filtering issue i mentioned(new events showing on 'My Events' page regardless of chosen filter) or it would be fine to leave it here as a comment?

Pinkbyte avatar Jun 18 '24 08:06 Pinkbyte

@Pinkbyte no plz open another bug report issue about that As I'm sure the filter works? It just filters based on event types rather than the events itself!?

si458 avatar Jun 18 '24 08:06 si458