Skip to content

Commit 31ae99f

Browse files
committed
README.md update, sync with master.
1 parent 70a3f7a commit 31ae99f

File tree

2 files changed

+48
-54
lines changed

2 files changed

+48
-54
lines changed

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ For more informations about sysctl see:
2020

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

23+
NOTE: development is done on `master` branch, look for the branch matching your
24+
lua version if you want to build.
25+
2326
## Examples
2427

2528
Reading:
@@ -62,6 +65,51 @@ Writting:
6265
> sysctl.set('security.bsd.see_other_uids', 0)
6366
```
6467

68+
## Functions
69+
70+
NOTE: Both sysctl.get() and sysctl.set() raise an error if any problem occur.
71+
If you don't control the key you're passing to these function you might want to
72+
use lua's protected calls (pcall).
73+
74+
### sysctl.get(key)
75+
Rreturns two values: The first returned value is the sysctl(3) value, the
76+
second value is the format.
77+
78+
#### formats
79+
- _I_ `int`
80+
- _UI_ `unsigned int`
81+
- _IK_ `int`, in (kelv * 10) (used to get temperature)
82+
- _L_ `long`
83+
- _UL_ `unsigned long`
84+
- _A_ `char *`
85+
- _S,clockinfo_ `struct clockinfo`
86+
- _S,loadavg_ `struct loadavg`
87+
- _S,timeval_ `struct timeval`
88+
- _S,vmtotal_ `struct vmtotal`
89+
90+
In lua land, it means that:
91+
- _I_, _UI_, _IK_, _L_, _UL_, are numbers.
92+
- _A_ is a string.
93+
- _S,clockinfo_ is a table of integers
94+
`{ hz, tick, profhz, stathz }`
95+
- _S,loadavg_ is an array of numbers
96+
`{ 1, 2, 3 }`
97+
- _S,timeval_ is a table of integers
98+
`{ sec, sec }`
99+
- _S,vmtotal_ is a table of integers
100+
`{ rq, dw, pw, sl, vm, avm, rm, arm, vmshr, avmshr, rmshr, armshr, free }`
101+
102+
### sysctl.set(key, newval)
103+
Set the sysctl's key to newval. Return nothing and throw lua error if any
104+
problem occur. Note that some sysctl's key are read only or read only tunable
105+
and can not be set at runtime.
106+
107+
### sysctl.IK2celsius(kelv)
108+
Convert a sysctl's IK value into celsius and return it.
109+
110+
### sysctl.IK2farenheit(kelv)
111+
convert a sysctl's IK value into farenheit and return it.
112+
65113
## Limitations
66114

67115
* Some sysctl variables cannot be changed while the system is running (they're

sysctl.lua

-54
Original file line numberDiff line numberDiff line change
@@ -1,55 +1 @@
1-
--[[---------------------------------------------------------------------------
2-
--
3-
-- NOTE:
4-
-- sysctl.get() and sysctl.set() raise an error if any problem occur. If
5-
-- you don't control the key you're passing to these function you might
6-
-- wanna use lua's protected calls (pcall).
7-
-------------------------------------------------------------------------------
8-
--
9-
-- sysctl.get(key)
10-
-- returns two values. first returned value is the sysctl(3) value,
11-
-- second value is the format of returned value
12-
-- - "I" int
13-
-- - "UI" unsigned int
14-
-- - "IK" int, in (kelv * 10) (used to get temperature)
15-
-- - "L" long
16-
-- - "UL" unsigned long
17-
-- - "Q" quad_t
18-
-- - "UQ" unsigned quad_t
19-
-- - "A" char *
20-
-- - "T,dev_t" dev_t
21-
-- - "S,clockinfo" struct clockinfo
22-
-- - "S,loadavg" struct loadavg
23-
-- - "S,timeval" struct timeval
24-
-- - "S,vmtotal" struct vmtotal
25-
--
26-
-- In lua land, it means that:
27-
-- - "I", "UI", "IK", "L", "UL", "Q", "UQ" are numbers.
28-
-- - "A" is a string
29-
-- - "T,dev_t" is a table of integers
30-
-- { minor, major }
31-
-- - "S,clockinfo" is a table of integers
32-
-- { hz, tick, profhz, stathz }
33-
-- - "S,loadavg" is an array of numbers (double)
34-
-- { 1, 2, 3 }
35-
-- - "S,timeval" is a table of integers
36-
-- { sec, sec }
37-
-- - "S,vmtotal" is a table of integers
38-
-- { rq, dw, pw, sl, vm, avm, rm, arm, vmshr, avmshr,
39-
-- rmshr, armshr, free }
40-
-------------------------------------------------------------------------------
41-
--
42-
-- sysctl.set(key, newval)
43-
-- set the sysctl's key to newval. return nothin' and throw lua
44-
-- error if any problem occur. You should notice that some sysctl's key
45-
-- are read only or read only tunable and then can't be set at runtime.
46-
-------------------------------------------------------------------------------
47-
--
48-
-- sysctl.IK2celsius(kelv)
49-
-- convert a sysctl's IK value into celsius and return it.
50-
-------------------------------------------------------------------------------
51-
--
52-
-- sysctl.IK2farenheit(kelv)
53-
-- convert a sysctl's IK value into farenheit and return it.
54-
-----------------------------------------------------------------------------]]
551
require('sysctl.core')

0 commit comments

Comments
 (0)