Git Product home page Git Product logo

Comments (10)

valpackett avatar valpackett commented on June 18, 2024

Oh, interesting. So network just works without any modifications at all?

It's weird that battery doesn't work. Which Linux distro and kernel version are you using?

from systemstat.

antoyo avatar antoyo commented on June 18, 2024

Yes, just copy-paste the code for the networks from FreeBSD to Linux and the example show the networks and IP addresses.
For the battery, thought, I get the following:

Battery: error: No such file or directory (os error 2), AC power: true

I use ArchLinux, kernel: 4.10.13.

from systemstat.

valpackett avatar valpackett commented on June 18, 2024

What do you have under /sys/class/power_supply? Can you post the output of the tree command there?

from systemstat.

antoyo avatar antoyo commented on June 18, 2024

Here is the output of /sys/class/power_supply/BAT0:

.
├── alarm
├── capacity
├── capacity_level
├── cycle_count
├── device -> ../../../PNP0C0A:00
├── energy_full
├── energy_full_design
├── energy_now
├── manufacturer
├── model_name
├── power
│   ├── async
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_kids
│   ├── runtime_active_time
│   ├── runtime_enabled
│   ├── runtime_status
│   ├── runtime_suspended_time
│   └── runtime_usage
├── power_now
├── present
├── serial_number
├── status
├── subsystem -> ../../../../../../../../../class/power_supply
├── technology
├── type
├── uevent
├── voltage_min_design
└── voltage_now

For the battery status, the code for FreeBSD does not work since sysctlnametomib does not exist on Linux.

from systemstat.

valpackett avatar valpackett commented on June 18, 2024

Hmmm, did they change charge_now to energy_now (and same with _full)? What's in these energy files?

Of course the FreeBSD code does not work. I don't think Linux even has any sysctls for battery status. Linux developers like to invent virtual filesystems for everything :D

from systemstat.

antoyo avatar antoyo commented on June 18, 2024

It looks like this is it:
energy_now:

42600000

energy_full:

43200000

After a quick search, I saw that there's upower that might be worth looking at.

from systemstat.

valpackett avatar valpackett commented on June 18, 2024

Sorry for the late response, was busy with stuff. Extracted network into a common unix module, now works on Linux and OpenBSD. Added the energy_ thing, please test it! (I don't have battery-powered Linux devices right now.)

from systemstat.

antoyo avatar antoyo commented on June 18, 2024

I made some fixes in pull request #5.

Also, I noticed the memory used is not reported correctly.
The example show 2 GB used while I have only 775 MB.

from systemstat.

valpackett avatar valpackett commented on June 18, 2024

Well crap: https://stackoverflow.com/questions/349889/how-do-you-determine-the-amount-of-linux-system-ram-in-c#comment64695386_350046

freeram in sysinfo is not what most people would call "free RAM" […] The best option is to use the MemAvailable (as opposed to MemFree) entry in /proc/meminfo instead

I wanted to avoid opening files and parsing strings as much as possible but oh well, Linux.

And MemAvailable only appeared in 2014. It's not available in old kernels, the Windows Subsystem for Linux, FreeBSD's linprocfs (I should probably write a patch for that :D), maybe in illumos's Linux compatibility too.

I think PlatformMemory on Linux should just be a map of all the key-value pairs from /proc/meminfo, falling back to sysinfo if there's no /proc/meminfo… I'll just implement it now

from systemstat.

valpackett avatar valpackett commented on June 18, 2024

Actually MemAvailable "is not suitable to calculate the used memory" hishamhm/htop#96

But anyway /proc/meminfo is now used, check it out :)

from systemstat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.