Skip to content

Commit

Permalink
README.md update, sync with master.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaworu committed Dec 23, 2016
1 parent 70a3f7a commit 31ae99f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 54 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ For more informations about sysctl see:

Thanks to garga@ **lua-sysctl** is in the port tree under _devel/lua-sysctl_.

NOTE: development is done on `master` branch, look for the branch matching your
lua version if you want to build.

## Examples

Reading:
Expand Down Expand Up @@ -62,6 +65,51 @@ Writting:
> sysctl.set('security.bsd.see_other_uids', 0)
```

## Functions

NOTE: Both sysctl.get() and sysctl.set() raise an error if any problem occur.
If you don't control the key you're passing to these function you might want to
use lua's protected calls (pcall).

### sysctl.get(key)
Rreturns two values: The first returned value is the sysctl(3) value, the
second value is the format.

#### formats
- _I_ `int`
- _UI_ `unsigned int`
- _IK_ `int`, in (kelv * 10) (used to get temperature)
- _L_ `long`
- _UL_ `unsigned long`
- _A_ `char *`
- _S,clockinfo_ `struct clockinfo`
- _S,loadavg_ `struct loadavg`
- _S,timeval_ `struct timeval`
- _S,vmtotal_ `struct vmtotal`

In lua land, it means that:
- _I_, _UI_, _IK_, _L_, _UL_, are numbers.
- _A_ is a string.
- _S,clockinfo_ is a table of integers
`{ hz, tick, profhz, stathz }`
- _S,loadavg_ is an array of numbers
`{ 1, 2, 3 }`
- _S,timeval_ is a table of integers
`{ sec, sec }`
- _S,vmtotal_ is a table of integers
`{ rq, dw, pw, sl, vm, avm, rm, arm, vmshr, avmshr, rmshr, armshr, free }`

### sysctl.set(key, newval)
Set the sysctl's key to newval. Return nothing and throw lua error if any
problem occur. Note that some sysctl's key are read only or read only tunable
and can not be set at runtime.

### sysctl.IK2celsius(kelv)
Convert a sysctl's IK value into celsius and return it.

### sysctl.IK2farenheit(kelv)
convert a sysctl's IK value into farenheit and return it.

## Limitations

* Some sysctl variables cannot be changed while the system is running (they're
Expand Down
54 changes: 0 additions & 54 deletions sysctl.lua
Original file line number Diff line number Diff line change
@@ -1,55 +1 @@
--[[---------------------------------------------------------------------------
--
-- NOTE:
-- sysctl.get() and sysctl.set() raise an error if any problem occur. If
-- you don't control the key you're passing to these function you might
-- wanna use lua's protected calls (pcall).
-------------------------------------------------------------------------------
--
-- sysctl.get(key)
-- returns two values. first returned value is the sysctl(3) value,
-- second value is the format of returned value
-- - "I" int
-- - "UI" unsigned int
-- - "IK" int, in (kelv * 10) (used to get temperature)
-- - "L" long
-- - "UL" unsigned long
-- - "Q" quad_t
-- - "UQ" unsigned quad_t
-- - "A" char *
-- - "T,dev_t" dev_t
-- - "S,clockinfo" struct clockinfo
-- - "S,loadavg" struct loadavg
-- - "S,timeval" struct timeval
-- - "S,vmtotal" struct vmtotal
--
-- In lua land, it means that:
-- - "I", "UI", "IK", "L", "UL", "Q", "UQ" are numbers.
-- - "A" is a string
-- - "T,dev_t" is a table of integers
-- { minor, major }
-- - "S,clockinfo" is a table of integers
-- { hz, tick, profhz, stathz }
-- - "S,loadavg" is an array of numbers (double)
-- { 1, 2, 3 }
-- - "S,timeval" is a table of integers
-- { sec, sec }
-- - "S,vmtotal" is a table of integers
-- { rq, dw, pw, sl, vm, avm, rm, arm, vmshr, avmshr,
-- rmshr, armshr, free }
-------------------------------------------------------------------------------
--
-- sysctl.set(key, newval)
-- set the sysctl's key to newval. return nothin' and throw lua
-- error if any problem occur. You should notice that some sysctl's key
-- are read only or read only tunable and then can't be set at runtime.
-------------------------------------------------------------------------------
--
-- sysctl.IK2celsius(kelv)
-- convert a sysctl's IK value into celsius and return it.
-------------------------------------------------------------------------------
--
-- sysctl.IK2farenheit(kelv)
-- convert a sysctl's IK value into farenheit and return it.
-----------------------------------------------------------------------------]]
require('sysctl.core')

0 comments on commit 31ae99f

Please sign in to comment.