Coder Social home page Coder Social logo

bnyro / libmacchina Goto Github PK

View Code? Open in Web Editor NEW

This project forked from macchina-cli/libmacchina

1.0 0.0 0.0 603 KB

A library providing access to all sorts of system information.

Home Page: https://crates.io/crates/libmacchina

License: MIT License

Rust 100.00%

libmacchina's Introduction

libmacchina

A library providing access to all sorts of system information.

Linux • macOS • Windows • NetBSD • FreeBSD • Android • OpenWrt

version docs

Disclaimer

libmacchina utilizes unsafe code in the form of calls to system libraries that haven't been natively implemented in Rust, we do this for performance reasons.

Usage

Add the following to your project's Cargo.toml file:

libmacchina = "7"

Notes

On distributions like openSUSE that use the ndb RPM database format, librpm (which is usually provided by the rpm-devel package) is required for the RPM package count readout to work.

Examples

// Let's import two of the several available types.
use libmacchina::{GeneralReadout, MemoryReadout};

fn main() {
    // Let's import the GeneralReadout trait so we
    // can fetch some general information about the host.
    use libmacchina::traits::GeneralReadout as _;

    let general_readout = GeneralReadout::new();

    // There are many more metrics we can query
    // i.e. username, distribution, terminal, shell, etc.
    let cpu_cores = general_readout.cpu_cores().unwrap(); // 8 [logical cores]
    let cpu = general_readout.cpu_model_name().unwrap();  // Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    let uptime = general_readout.uptime().unwrap();       // 1500 [in seconds]

    // Now we'll import the MemoryReadout trait to get an
    // idea of what the host's memory usage looks like.
    use libmacchina::traits::MemoryReadout as _;

    let memory_readout = MemoryReadout::new();

    let total_mem = memory_readout.total(); // 20242204 [in kB]
    let used_mem = memory_readout.used();   // 3894880 [in kB]
}

libmacchina's People

Contributors

grtcdr avatar fantasyteddy avatar 123marvin123 avatar gobidev avatar uttarayan21 avatar rolv-apneseth avatar demoninthecloset avatar coolgi69 avatar xarblu avatar rexkyng avatar ci4ic4 avatar rubixdev avatar rtzoeller avatar markos-th09 avatar kianmeng avatar thecactusvert avatar curiouslycurious avatar absolpega avatar

Stargazers

 avatar

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.