• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A pythonic library to parse /proc/meminfo

hazelnut hazelnut

PyPi Version

hazelnut is an APACHE licensed library written in Python designed to provide a simple and pythonic way to parse the /proc/meminfo file on LINUX based systems. This library has been tested with Python 2.7.x and Python 3.6.x.

Installation:

From source use

	$ python setup.py install

or install from PyPi

	$ pip install hazelnut

Documentation:

  • Basic use:
>>> from hazelnut import MemInfo
>>> mem = MemInfo()
>>> mem
MemTotal:        8092460 kB
MemFree:          499880 kB
MemAvailable:    5454920 kB
Buffers:          219088 kB
Cached:          4980040 kB
SwapCached:         7576 kB
Active:          5647392 kB
Inactive:        1628708 kB
Active(anon):    1794356 kB
Inactive(anon):   492656 kB
Active(file):    3853036 kB
Inactive(file):  1136052 kB
Unevictable:         200 kB
Mlocked:             200 kB
SwapTotal:      16776188 kB
SwapFree:       16639112 kB
Dirty:               172 kB
Writeback:             0 kB
AnonPages:       2070440 kB
Mapped:           204800 kB
Shmem:            210036 kB
Slab:             247884 kB
SReclaimable:     219356 kB
SUnreclaim:        28528 kB
KernelStack:        4144 kB
PageTables:        11904 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    20822416 kB
Committed_AS:    3317504 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      362844 kB
VmallocChunk:   34359347296 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       83644 kB
DirectMap2M:     8202240 kB
  • Return output as dict:
>>> mem.dict()
{
	"WritebackTmp": "0 kB",
	"SwapTotal": "16776188 kB",
	"Active(anon)": "1794356 kB",
	"SwapFree": "16639112 kB",
	"DirectMap4k": "83644 kB",
	"KernelStack": "4144 kB",
	"MemFree": "499880 kB",
	"HugePages_Rsvd": "0",
	"Committed_AS": "3317504 kB",
	"SUnreclaim": "28528 kB",
	"NFS_Unstable": "0 kB",
	"VmallocChunk": "34359347296 kB",
	"Writeback": "0 kB",
	"Inactive(file)": "1136052 kB",
	"MemTotal": "8092460 kB",
	"VmallocUsed": "362844 kB",
	"HugePages_Free": "0",
	"AnonHugePages": "0 kB",
	"Shmem": "210036 kB",
	"AnonPages": "2070440 kB",
	"Active": "5647392 kB",
	"Inactive(anon)": "492656 kB",
	"HugePages_Total": "0",
	"Hugepagesize": "2048 kB",
	"Cached": "4980040 kB",
	"SwapCached": "7576 kB",
	"VmallocTotal": "34359738367 kB",
	"Dirty": "172 kB",
	"Mapped": "204800 kB",
	"Unevictable": "200 kB",
	"SReclaimable": "219356 kB",
	"MemAvailable": "5454920 kB",
	"Slab": "247884 kB",
	"DirectMap2M": "8202240 kB",
	"HugePages_Surp": "0",
	"Bounce": "0 kB",
	"Inactive": "1628708 kB",
	"PageTables": "11904 kB",
	"HardwareCorrupted": "0 kB",
	"CommitLimit": "20822416 kB",
	"Mlocked": "200 kB",
	"Buffers": "219088 kB",
	"Active(file)": "3853036 kB"
}
  • Search (is case insensitive):
>>> mem.search('Swap')
['SwapCached:         7576 kB\n', 'SwapTotal:      16776188 kB\n', 'SwapFree:       16639112 kB\n']
  • Get memory usage as int (is case sensitive):
>>> mem.get('Inactive(anon)')
492656

License:

Copyright 2014-2017 Martin Simon

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Buy me a coffee?

If you feel like buying me a coffee (or a beer?), donations are welcome:

WDC : WbcWJzVD8yXt3yLnnkCZtwQo4YgSUdELkj
HBN : F2Zs4igv8r4oJJzh4sh4bGmeqoUxLQHPki
DOGE: DRBkryyau5CMxpBzVmrBAjK6dVdMZSBsuS

More Repositories

1

coinmarketcap

A python wrapper around the https://coinmarketcap.com API.
Python
434
star
2

alacritty-debian

Debian packages for alacritty.
Shell
107
star
3

ares

A python wrapper around https://cve.circl.lu.
Python
55
star
4

zola-debian

Debian packages for zola.
Shell
39
star
5

i3-gaps-debian

Debian packages for i3-gaps.
Shell
18
star
6

scaphandre-debian

Debian packages for scaphandre.
Shell
16
star
7

wookie

wookie is a simple, open source, easy-to-use iRC RSS bot written in Python. It was designed to announce new torrent releases in a given iRC channel.
Python
14
star
8

tweetuoso

Tweetuoso is a very light Twitter Command-line client developed in Python. The main goal of Tweetuoso is to become a fully-fledged twitter client with the same functions as the online version.
Python
10
star
9

wiki

Personal wiki built with MkDocs, Material for MkDocs, giscus and deployed with Github Actions.
HTML
9
star
10

berry-debian

Debian packages for berry.
Shell
9
star
11

vault

A tiny, serverless pastebin-like service built on Cloudflare Pages Functions and Workers KV
JavaScript
9
star
12

certifier

Get all the information you need about your SSL/TLS certificates.
Python
9
star
13

action-forge-publish

GitHub Action to build and publish modules to Puppet Forge.
Shell
8
star
14

i3blocks-debian

Debian packages for i3blocks.
Shell
7
star
15

GH60-RevCHN

Everything I need for my GH60-RevCHN/Satan.
C
6
star
16

dockerfiles

🐳 This is a collection of Dockerfiles I use.
6
star
17

pyiptoasn

A python wrapper around https://iptoasn.com.
Python
6
star
18

sublime-debian

Debian packaging file syntax highlighting for Sublime Text.
6
star
19

delta-debian

Debian packages for delta.
Shell
6
star
20

qnap-plex-updater

Shell script aimed at updating Plex Media Server on QNAP servers.
Shell
6
star
21

contra

Everything I need for my Contra 40% ortholinear keyboard.
C
6
star
22

walnut

A pythonic library to parse /proc/cpuinfo
Python
6
star
23

flumble

Run a Mumble server on Fly.io.
5
star
24

WDCiNFO

[❗DEPRECATED] Get all the information you need about the Worldcoin cryptocurrency
Python
4
star
25

darkcoin-api

Python API for the Darkcoin cryptocurrency.
Python
4
star
26

qwak

Python API wrapper for MPOS.
Python
4
star
27

lychee

Minimal static blog generator based on Flask.
Python
3
star
28

whadup

A Python wrapper around the GitHub Status API.
Python
3
star
29

gotypist-debian

Debian packages for gotypist.
Shell
3
star
30

weatherbot

Twitter weather bot written in Python.
Python
3
star
31

hobonickels-api

Python API for the Hobonickels cryptocurrency.
Python
3
star
32

dns325_utils

All the stuff I use to customize my D-Link DNS-325 NAS
Shell
3
star
33

alpine-pdk

Puppet Development Kit (PDK) Docker Image based on Alpine Linux.
Dockerfile
3
star
34

skinport

A Python wrapper around the Skinport API.
Python
3
star
35

wylie

Get Jenkins build notifications on OSX.
Python
2
star
36

salopette

salopette is an APACHE licensed library written in Python.
Python
2
star
37

ragnar

Python decorator allowing you to run your code in a separate thread.
Python
2
star
38

modlist-api

Python API wrapper for MCF Modlist.
Python
2
star
39

website

My personal website.
HTML
2
star
40

lu-postcodes

CSV, JSON and XML dump of Luxembourg's postcodes (as of February 5th 2018).
2
star
41

worldcoin-api

Python API for the Worldcoin cryptocurrency.
Python
2
star
42

puppet-rinetd

Install and manage rinetd(8) - internet “redirection server” via Puppet.
Puppet
2
star
43

kyra

Small logging library I made for my own use.
Python
2
star
44

keysets

All the "fancy" keysets I currently own.
SCSS
2
star
45

i3lock-color-debian

Debian packages for i3lock-color.
Shell
2
star
46

dotfiles

Lua
2
star
47

homelab.lu

Source for homelab.lu.
HTML
2
star
48

sublime-irc

IRC log file syntax highlighting for Sublime Text.
2
star
49

puppet-zipkin

This module installs, configures and upgrades OpenZipkin via Puppet.
Puppet
2
star
50

sjoa

Command-line tool to read metadata from torrent files or magnet URLs.
Python
2
star
51

sublm

1
star
52

todo_by

Runtime lifetimes for comments.
Python
1
star
53

xd96

Everything I need for my XD96 keyboard.
C
1
star
54

saga-templates

Custom, hand-crafted templates for Saga.
1
star
55

i3-autodisplay-debian

Debian packages for i3-autodisplay.
Shell
1
star
56

0xff

A tiny, serverless URL shortener built on Cloudflare Workers and Workers KV.
JavaScript
1
star
57

letsencrypt-padavan

Let's Encrypt certificates for padavan / rt-n56u devices.
Shell
1
star
58

mandown-debian

Debian packages for mandown.
Shell
1
star
59

topgrade-debian

Debian packages for topgrade.
Shell
1
star
60

sublime-bruno

1
star