fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
2.92k stars 409 forks source link

Show Windows battery health #19619

Open ddribeiro opened 3 months ago

ddribeiro commented 3 months ago

Goal

User story
As an IT admin on the Host details page and My device page,
I want to see Windows battery health
so that I can know if a Windows workstation should be replaced.

Context

At some point we shipped this improvement for macOS. Here's the story w/ UI/API wireframes: #4904

When we shipped this for macOS, the battery condition table (docs here) didn't work for Windows. Now it works for Windows. (Figma)

Product Changes

Windows offers ability to generate battery report Generating a battery report, (Example of battery report). I (@randy-fleet) am unable to verify what fully gets reported, but ideally we can map to and align on Apple's pre-defined conditions:

We currently map for macOS:

This information will only show for Mac and Windows Hosts initially, and should be consistent between the two. iOS and iPadOS also support these conditions, but can be added at a later time.

Engineering

ℹ️  Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".

QA

Risk assessment

Manual testing steps

  1. Step 1
  2. Step 2
  3. Step 3

Testing notes

Confirmation

  1. [ ] Engineer (@____): Added comment to user story confirming successful completion of QA.
  2. [ ] QA (@____): Added comment to user story confirming successful completion of QA.
sharon-fdm commented 3 months ago

@ddribeiro I queried a Win device on our dogfood and got results. Any specific way to reproduce? 'battery' table was added in 5.12.1. Can you give the osquery version, please?

xpkoala commented 3 months ago

@sharon-fdm I think there are two issues here:

  1. Battery query not returning results: When running a similar query on a host in Dogfood I get the following. In this case there is no data to return, so this doesn't appear to be an issue.
image
  1. Battery information not showing on a hosts manage page.
Screenshot 2024-06-13 at 10 24 44 AM

Part of the response from this page:

"packs": [],
    "batteries": null,
    "status": "online",
    "display_text": "brock-win",

You can see battery information on a Mac host details page here

Here is a response when running select * from battery on the same Windows host. I'm not sure how we are extrapolating battery health, but I assume we have enough data to determine that from the current response.

image
sharon-fdm commented 2 months ago

We need to check the table and see if somthing is broken. (That what the estimation is for)

Also, from @rachaelshaw: let's take this to feature_fest.

getvictor commented 2 months ago

@sharon-fdm Can you try this on your Windows machine, running osquery 5.12.1 or later: SELECT serial_number, cycle_count FROM battery

BROCK-WIN is a VM, so not expected to work.

health column is only available on macOS, so not expected to work on Windows. Docs: https://fleetdm.com/tables/battery

sharon-fdm commented 2 months ago

@getvictor I removed my win machine from dogfood. Will re install agent so we can try it.

sharon-fdm commented 2 months ago

@getvictor image

getvictor commented 2 months ago

@sharon-fdm Looks like your computer returns some data. I think we can close this bug.

noahtalerman commented 2 months ago

SELECT serial_number, cycle_count, health FROM battery;

Hey @getvictor do we expect @ddribeiro's query (above) to return no results on Windows? Do you think Dale ran the query on a version of osquery prior to 5.12.1 (when we added Windows support for battery table)

battery health does not appear on the host details page for Windows computers that have batteries like it does for Macs. The GET /api/v1/fleet/hosts/:id endpoint also includes a battery key with a null value.

It looks like this is the expected behavior. We added battery condition to the UI/API for macOS hosts (not Windows) in this story: #4904

@ddribeiro if we confirm that querying the table works as expected can you please transform this bug into a feature request and add it to feature fest: Surface Windows battery condition on the Host details page

ddribeiro commented 2 months ago

It's possible my test was on a computer with an oquery version prior to 5.12.1, unfortunately I did not think to check when I did my initial testing.

I can confirm that I just ran the SELECT serial_number, cycle_count, health FROM battery; on Windows device in Dogfood with osquery version 5.12.2 and got results back.

@noahtalerman I'll switch this over to a feature request since the query itself seems to be working.

noahtalerman commented 4 weeks ago

Moved the original issue description here for safekeeping:

Fleet version: v4.50.0, Dogfood: SNAPSHOT-a8a8ab1

Web browser and operating system: Likely all supported versions of Windows, but at reproduced on Windows 11 Pro 23H2 10.0.22631.3447 and Windows 10 Pro 22H2 10.0.19041.3930.


💥  Actual behavior

When querying the battery table on Windows computers, the host always responds with no results, even though the battery table is supported on Windows.

🧑‍💻  Steps to reproduce

  1. Identify a physical Windows computer with a battery to run the query against.
  2. SELECT serial_number, cycle_count, health FROM battery;
  3. Wait for the host to respond, Fleet will show that the query returned no results.

🕯️ More info (optional)

Because this query returns no results, battery health does not appear on the host details page for Windows computers that have batteries like it does for Macs. The GET /api/v1/fleet/hosts/:id endpoint also includes a battery key with a null value.

randy-fleet commented 2 weeks ago

References to Battery Health in Windows:

randy-fleet commented 2 weeks ago

References to Battery Health in macOS, iOS, and iPadOS:

randy-fleet commented 1 week ago

From @noahtalerman: Let’s return exactly what we get from osquery in the Fleet API. We can do translation in the UI. This gives us more flexibility in the future to change these translations

noahtalerman commented 1 week ago

Hey @randy-fleet, can you please take a crack at filling out the TODOs in the "Product" section in this issue?

We want to make sure there are no TODOs prior to estimation so that the requirements are clear. I realize we already estimated this one which is ok!

Please feel free to schedule some time w/ me (or bring this to our 1:1) if you have questions.

cc @sharon-fdm

jacobshandling commented 1 week ago

per @noahtalerman's comment above, estimations we added at today's session factored in whatever ambiguity the team perceived in the specs

noahtalerman commented 1 week ago

@jacobshandling and @sharon-fdm, to move quickly I think we can lean on the engineer working on this issue to open a draft PR w/ proposed API design (instead of product).

What do you think?

I moved the "API changes" TODO to the "Engineering" section in this issue description.

cc @lukeheath

sharon-fdm commented 3 days ago

@noahtalerman, yeh, we can propose it as part of the work when we pick it up.