|
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 | | ------------------------------------------------------------------------------]] |
55 | 1 | require('sysctl.core') |
0 commit comments