Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.09k stars 549 forks source link

Feature Request: Power Events Report for Devices #5912

Open adnan29979 opened 7 months ago

adnan29979 commented 7 months ago

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:

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)

si458 commented 7 months ago

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)

adnan29979 commented 7 months ago

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.

si458 commented 7 months ago

@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 commented 7 months ago

Device Powered On - Device Turned On - Device Switched On

what sounds best?

adnan29979 commented 7 months ago

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.

si458 commented 7 months ago

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

adnan29979 commented 7 months ago

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.

si458 commented 7 months ago

@adnan29979 baby steps... 👣

si458 commented 7 months ago

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!

adnan29979 commented 7 months ago

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.

si458 commented 7 months ago

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

adnan29979 commented 6 months ago

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.

si458 commented 6 months ago

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

adnan29979 commented 6 months ago

Ahh okay. No worries. Take your time.

si458 commented 6 months ago

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...

adnan29979 commented 6 months ago

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

Pinkbyte commented 3 months ago

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

si458 commented 3 months ago

@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?

Pinkbyte commented 3 months ago

@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?

si458 commented 3 months ago

@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!?