Coder Social home page Coder Social logo

procstat's Introduction

Procstat - library to expose userspace process internal state as FUSE filesystem.

Background and motivation

Currently there is no standard way to expose process internal state, counters and statistics for running application. Some applications following the approach of exposing its state via the external interface they provide for normal operation. Example of such can be MYSQL that exposes statistics and metrics via SQL language, memcached server which exposes its status via specialized "stats" keyword, and others. This approach requires specialized client to be written to gather such statistics, and more specialized tools to perform analysis on such statistics.

Procstat library takes advantage of filesystem interface as a mean to expose process statistics and counters. This approach makes rich set of already existing text processing tools such as grep, awk and others available to perform analysis on exposed statistics and counters.

Installation

mkdir build; cd build; cmake ../; make && sudo make install

Getting Started:

In order to use procstat you need to #include "procstat.h" in your executable.

#include <procstat.h>

Inside your application create procstat context:

struct procstat_context *context;
context = procstat_create(<path to mountpoint>);

Next create a dedicated thread for fuse (which is used by procstat to expose statistics as a file system) Then run:

procstat_loop(context); 

Single-value statistics

It is important to understand that counters are part of you application, hence its validity must be provided by the application from the moment statistics is registered till it unregistered. In order to register single value counter

u64 counter = 0;
procstat_create_u64(context, NULL, "my-counter", &counter);

This will expose value of "counter" object as 'my-counter' file under <mount_point> In order to unregister this counter add the following line

procstat_remove_by_name(context, NULL, "my-counter");

Creating directory hierarchy

Directory hierarchy can be created to organize statistics and counters according to application requirements. In order ot create directory do the following:

struct procstat_item *outer_dir, *inner_dir;
outer_dir = procstat_create_directory(context, NULL, "outer-directory");
inner_dir = procstat_create_directory(context, outer_dir, "inner-directory");
procstat_create_u64(context, inner_dir, "my-counter", &counter);

This will expose counter value as file /outer-directory/inner-directory/my-counter

Advanced Usage

FIXME: add advanced usage examples...

procstat's People

Contributors

adir-lb avatar alexs-lb avatar anton-lb avatar dori-lb avatar efrat-lb avatar elazar-lb avatar lital-lb avatar maor-lb avatar maorv avatar ron-lb avatar sashas-lb avatar shelly-lb avatar solganik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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