lmsensors 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +1 -1
- data/Rakefile +8 -0
- data/ext/lmsensors_base/extconf.rb +1 -1
- data/ext/lmsensors_base/lmsensors_base.c +315 -0
- data/ext/lmsensors_base/lmsensors_base.h +271 -0
- data/lib/lmsensors/features/alarm.rb +1 -1
- data/lib/lmsensors/features/beep.rb +1 -1
- data/lib/lmsensors/features/current.rb +17 -15
- data/lib/lmsensors/features/fan.rb +11 -9
- data/lib/lmsensors/features/humidity.rb +1 -1
- data/lib/lmsensors/features/power.rb +19 -17
- data/lib/lmsensors/features/temp.rb +17 -15
- data/lib/lmsensors/features/voltage.rb +17 -15
- data/lib/lmsensors/lm_constants.rb +1 -1
- data/lib/lmsensors/lmsensors.rb +1 -1
- data/lib/lmsensors/sensors/abssensor.rb +1 -1
- data/lib/lmsensors/version.rb +1 -1
- metadata +5 -3
- data/lib/lmsensors_base/lmsensors_base.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 858f04b62fbb7681a9c3359a9a896b2000ef7ed46ccfd1c2c8ecb18ed80fe3e8
|
4
|
+
data.tar.gz: b1ece2b715f45c8b0a31a750d618bf8d98fcee82981e36238054797296436e19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd44fd770fddaad0dbb16c386b60ad0834151c93660d41b58fc0859c1f9cbba127633558d3801e4c29adddf0639e0735a61a8b27b05b203a00063d1614e30069
|
7
|
+
data.tar.gz: f494c372bba145664b5cad4e8f04ab98586ae6104c5e0534409b5afd8f5813d2822a5d03c5e5797e94152ad034b9ba8e87ed7cb4e8ff8584a88be4362d64addb
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,5 @@
|
|
1
1
|
### CHANGELOG -- (Ruby LmSensors) ###
|
2
|
-
1) 0.1.0, unreleased: 2021-May-26 -- Several major changes to the API access functionality. Massive levels of abstraction, per use cases noted from the Ruby programming server. [t. Edelweiss]
|
2
|
+
1) 0.1.0, unreleased: 2021-May-26 -- Several major changes to the API access functionality. Massive levels of abstraction, per use cases noted from the Ruby programming server. [t. Edelweiss]
|
3
|
+
1) 0.1.1, [CRITICAL PATCH] immediate pre-release: 2021-Jul-22 -- **CRITICAL PATCH (but does not change interface) -- please read** ``changes/0.1.1-critical.md`` **for information.** [t. Edelweiss]
|
4
|
+
1) 0.1.1, immediate pre-release: 2021-Jul-22 -- The default formatting has been fixed, because some sensors do not report the values requested. As such, they will not output a formatted value, if one does not exist -- this came to me on testing with my NAS, where the iGPU on my Ryzen APU does not report voltage, but as "N/A", so it shows as ``nil`` to Ruby. [t. Edelweiss]
|
5
|
+
1) 0.1.1, immediate pre-release: 2021-Jul-22 -- Fixed the README, as there was a typo. Also added the necessary above-mentioned critical change file. [t. Edelweiss]
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ s.reset_fmap # Reset it back to the default
|
|
52
52
|
# Sensor object to sobj.
|
53
53
|
sobj = items[:idx]
|
54
54
|
sobj.name # Name of Sensor
|
55
|
-
sobj.
|
55
|
+
sobj.adapter # Adapter of Sensor
|
56
56
|
sobj.path # Path of Sensor
|
57
57
|
sobj.info # Return the name, adapter, and path of a Sensor
|
58
58
|
sobj.read # Raw data from the :stat part of the Sensor
|
data/Rakefile
ADDED
@@ -0,0 +1,315 @@
|
|
1
|
+
// ext/lmsensors_base/lmsensors_base.c
|
2
|
+
/* Last backed-up version: < 2021-May-21 @ 22:18:35 */
|
3
|
+
#include "lmsensors_base.h"
|
4
|
+
|
5
|
+
#define LMSLOADER sensors_obj* sensor; TypedData_Get_Struct(self, sensors_obj, &sensors_type, sensor);
|
6
|
+
|
7
|
+
#define LMSVALIDATE if (!LMS_OPEN) {\
|
8
|
+
return rb_str_new2(\
|
9
|
+
"ERROR: Sensors were not configured! Run `LmSensors.init [filename|nil]`"); }
|
10
|
+
|
11
|
+
// ---------------------------
|
12
|
+
// LMSENSORS MODULE METHODS BELOW
|
13
|
+
// ---------------------------
|
14
|
+
|
15
|
+
/*
|
16
|
+
* sensors_init works ACROSS different sensor objects and
|
17
|
+
* should, therefore, be handled by the module.
|
18
|
+
*/
|
19
|
+
VALUE lmsensors_init(VALUE self, VALUE filename) {
|
20
|
+
// First, check if the sensors were already initialized
|
21
|
+
if (LMS_OPEN) {
|
22
|
+
return LMS_OPEN;
|
23
|
+
} // End init check
|
24
|
+
|
25
|
+
// Inheriting class should override this with either NULL of value
|
26
|
+
FILE *input = NULL;
|
27
|
+
// If no file is chosen, just pass NULL -- usually is NULL
|
28
|
+
if (RB_TYPE_P(filename, T_STRING)) {
|
29
|
+
FILE *input = fopen(StringValueCStr(filename), "r");
|
30
|
+
} // Otherwise, don't try to open, leave NULL
|
31
|
+
|
32
|
+
int err = 0; // Errors are stored here
|
33
|
+
err = sensors_init(input);
|
34
|
+
if (err) { return LMS_OPEN; } // There was an error -- return Qfalse
|
35
|
+
else {
|
36
|
+
LMS_OPEN = Qtrue;
|
37
|
+
return LMS_OPEN;
|
38
|
+
} // No error -- initialized
|
39
|
+
} // End module init
|
40
|
+
|
41
|
+
/*
|
42
|
+
* Document-method: pro_cleanup
|
43
|
+
*
|
44
|
+
* (LmSensors::SensorsBase lmsensors_cleanup)
|
45
|
+
*
|
46
|
+
* Cleans up the resources used by the LmSensors module
|
47
|
+
*/
|
48
|
+
// Cleanup sensors
|
49
|
+
VALUE lmsensors_cleanup() {
|
50
|
+
LMS_OPEN = Qfalse;
|
51
|
+
sensors_cleanup();
|
52
|
+
return LMS_OPEN;
|
53
|
+
} // End module cleanup
|
54
|
+
|
55
|
+
// ---------------------------
|
56
|
+
// SENSORS METHODS BELOW
|
57
|
+
// ---------------------------
|
58
|
+
|
59
|
+
/*
|
60
|
+
* The sensors_obj struct stores
|
61
|
+
* iterable constant fields to be used
|
62
|
+
* when accessing available chips, as well
|
63
|
+
* as their features and subfeatures.
|
64
|
+
*
|
65
|
+
* Despite being const, they are actually altered by
|
66
|
+
* pointer to their internal structure, as per the
|
67
|
+
* lmsensors API.
|
68
|
+
*
|
69
|
+
* The previous chip_name_str was abstracted to the Ruby side.
|
70
|
+
*/
|
71
|
+
typedef struct {
|
72
|
+
const sensors_chip_name *chip_ptr;
|
73
|
+
const sensors_feature *feat_ptr;
|
74
|
+
const sensors_subfeature *subfeat_ptr;
|
75
|
+
} sensors_obj; // End sensors object struct
|
76
|
+
|
77
|
+
// Free the data in the sensors object
|
78
|
+
void sensors_free(void* data) {
|
79
|
+
free(data);
|
80
|
+
} // End sensors free
|
81
|
+
|
82
|
+
// Get the size of the sensors object
|
83
|
+
size_t sensors_size(const void* data) {
|
84
|
+
return sizeof(data);
|
85
|
+
} // End size getter
|
86
|
+
|
87
|
+
// Encapsulate the sensors object for use with
|
88
|
+
// Ruby's side of the code
|
89
|
+
static const rb_data_type_t sensors_type = {
|
90
|
+
.wrap_struct_name = "sensors_obj",
|
91
|
+
.function = {
|
92
|
+
.dmark = NULL,
|
93
|
+
.dfree = sensors_free,
|
94
|
+
.dsize = sensors_size,
|
95
|
+
},
|
96
|
+
.data = NULL,
|
97
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
98
|
+
}; // End encapsulation
|
99
|
+
|
100
|
+
// Allocate space for the object
|
101
|
+
VALUE sensors_obj_alloc(VALUE self) {
|
102
|
+
// Allocate memory for object
|
103
|
+
sensors_obj* sensor = malloc(sizeof(sensors_obj));
|
104
|
+
// Wrap it within a sensors type struct
|
105
|
+
return TypedData_Wrap_Struct(self, &sensors_type, sensor);
|
106
|
+
} // End memory allocation
|
107
|
+
|
108
|
+
// Constructor
|
109
|
+
VALUE method_sensors_initialize(VALUE self) {
|
110
|
+
// Create the pointers
|
111
|
+
sensors_chip_name *chip;
|
112
|
+
sensors_feature *feat;
|
113
|
+
sensors_subfeature *subfeat;
|
114
|
+
|
115
|
+
// Attach them to struct
|
116
|
+
sensors_obj s = {
|
117
|
+
.chip_ptr = chip,
|
118
|
+
.feat_ptr = feat,
|
119
|
+
.subfeat_ptr = subfeat,
|
120
|
+
};
|
121
|
+
|
122
|
+
LMSLOADER; // Shorthand load sensor
|
123
|
+
*sensor = s; // Bind the struct
|
124
|
+
return self;
|
125
|
+
} // End constructor
|
126
|
+
|
127
|
+
/*
|
128
|
+
* Get the subfeature data for each chip's features.
|
129
|
+
*/
|
130
|
+
VALUE method_sensors_get_subfeatures(VALUE self) {
|
131
|
+
LMSLOADER; // Shorthand load sensor
|
132
|
+
LMSVALIDATE; // Shorthand early return, if not loaded
|
133
|
+
int snr = 0;
|
134
|
+
int err = 0;
|
135
|
+
double value;
|
136
|
+
VALUE subfeatures = rb_hash_new();
|
137
|
+
// On Ruby side, will determine feature unit type
|
138
|
+
// from the type.
|
139
|
+
rb_hash_aset(subfeatures, rb_id2sym(rb_intern("type")),
|
140
|
+
INT2NUM(sensor->feat_ptr->type));
|
141
|
+
|
142
|
+
// Loop through all the features
|
143
|
+
while ((sensor->subfeat_ptr = sensors_get_all_subfeatures(
|
144
|
+
sensor->chip_ptr, sensor->feat_ptr, &snr))) {
|
145
|
+
// Set the core values for the card, such as ID
|
146
|
+
VALUE sf = rb_hash_new();
|
147
|
+
|
148
|
+
VALUE sf_name = rb_str_new2(sensor->subfeat_ptr->name);
|
149
|
+
|
150
|
+
// Set the main keys
|
151
|
+
// Name of the subfeature
|
152
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("name")), sf_name);
|
153
|
+
// This is included, because it will usually be put in
|
154
|
+
// the subfeature, anyway, and it's faster to do in C
|
155
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("type")),
|
156
|
+
INT2NUM(sensor->feat_ptr->type));
|
157
|
+
// This is the subfeature type
|
158
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("subtype")),
|
159
|
+
INT2NUM(sensor->subfeat_ptr->type));
|
160
|
+
// Number of the subfeature
|
161
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("number")),
|
162
|
+
INT2NUM(sensor->subfeat_ptr->number));
|
163
|
+
// Number of the feature the subfeature is mapped to
|
164
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("mapping")),
|
165
|
+
INT2NUM(sensor->subfeat_ptr->mapping));
|
166
|
+
// RWX flags
|
167
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("flags")),
|
168
|
+
INT2NUM(sensor->subfeat_ptr->flags));
|
169
|
+
|
170
|
+
// Set the value, if it can be found
|
171
|
+
err = sensors_get_value(sensor->chip_ptr, (snr - 1), &value);
|
172
|
+
if (!err) {
|
173
|
+
rb_hash_aset(sf, rb_id2sym(rb_intern("value")),
|
174
|
+
DBL2NUM(value));
|
175
|
+
} // End value setter
|
176
|
+
|
177
|
+
// Attach the individual subfeature
|
178
|
+
rb_hash_aset(subfeatures, rb_id2sym(rb_intern(StringValueCStr(sf_name))), sf);
|
179
|
+
} // End feature loop
|
180
|
+
return subfeatures;
|
181
|
+
} // End subfeatures getter
|
182
|
+
|
183
|
+
/*
|
184
|
+
* Get a list of features for a chip.
|
185
|
+
*/
|
186
|
+
VALUE method_sensors_get_features(VALUE self) {
|
187
|
+
LMSLOADER; // Shorthand load sensor
|
188
|
+
LMSVALIDATE; // Shorthand early return, if not loaded
|
189
|
+
int nr = 0;
|
190
|
+
VALUE features = rb_hash_new();
|
191
|
+
|
192
|
+
// Loop through all the features
|
193
|
+
while ((sensor->feat_ptr = sensors_get_features(sensor->chip_ptr, &nr))) {
|
194
|
+
char *label = sensors_get_label(sensor->chip_ptr, sensor->feat_ptr);
|
195
|
+
rb_hash_aset(features, rb_id2sym(rb_intern(label)),
|
196
|
+
method_sensors_get_subfeatures(self));
|
197
|
+
free(label);
|
198
|
+
} // End feature loop
|
199
|
+
|
200
|
+
return features;
|
201
|
+
} // End features getter
|
202
|
+
|
203
|
+
/*
|
204
|
+
* Enumerate all the chips that can be read from.
|
205
|
+
*
|
206
|
+
* If a chip name is set, only read chips of that type.
|
207
|
+
*
|
208
|
+
* If show_data is true, stat each chip of that type.
|
209
|
+
*
|
210
|
+
* The different way to call this should be abstracted
|
211
|
+
* into the Ruby side wrapping this.
|
212
|
+
*/
|
213
|
+
VALUE method_sensors_enumerate_chips(VALUE self, VALUE show_data, VALUE name) {
|
214
|
+
LMSLOADER; // Shorthand load sensor
|
215
|
+
int chip_nr = 0;
|
216
|
+
int cnt = 0;
|
217
|
+
int err = 0;
|
218
|
+
int success = 0;
|
219
|
+
|
220
|
+
// Create temporary buffer for data
|
221
|
+
char buffer[BUFSIZE];
|
222
|
+
size_t size = BUFSIZE;
|
223
|
+
|
224
|
+
LMSVALIDATE; // Shorthand early return, if not loaded
|
225
|
+
|
226
|
+
// Intermediary chip item
|
227
|
+
sensors_chip_name chip_raw;
|
228
|
+
const sensors_chip_name *chip = NULL;
|
229
|
+
|
230
|
+
if (RB_TYPE_P(name, T_STRING)) {
|
231
|
+
err = sensors_parse_chip_name(StringValueCStr(name), &chip_raw);
|
232
|
+
if (err) { return rb_str_new2("Failed to load requested chip"); }
|
233
|
+
else { chip = &chip_raw; }
|
234
|
+
} else { chip = sensor->chip_ptr; }
|
235
|
+
|
236
|
+
// If not early return, sensors are valid
|
237
|
+
VALUE data = rb_hash_new();
|
238
|
+
while ((sensor->chip_ptr = sensors_get_detected_chips(chip, &chip_nr))) {
|
239
|
+
// Make sure the chip data can be collected
|
240
|
+
err = sensors_do_chip_sets(sensor->chip_ptr);
|
241
|
+
if (err) { // If anything but 0, it can't load
|
242
|
+
rb_hash_aset(data, rb_id2sym(rb_intern("fatal_err")), rb_str_new2(
|
243
|
+
"Cannot load chip sets. Have you already done 'sensors-detect?'"));
|
244
|
+
break;
|
245
|
+
} else {
|
246
|
+
VALUE idx = rb_sprintf("item%d", cnt);
|
247
|
+
const char *adapter = sensors_get_adapter_name(&sensor->chip_ptr->bus);
|
248
|
+
success = sensors_snprintf_chip_name(buffer, size, sensor->chip_ptr);
|
249
|
+
if (success > 0) {
|
250
|
+
// Create a new chip entry
|
251
|
+
VALUE curr_chip = rb_hash_new();
|
252
|
+
rb_hash_aset(curr_chip, rb_id2sym(rb_intern("adapter")),
|
253
|
+
rb_str_new2(adapter)); // Attach the adapter
|
254
|
+
// Attach the name of the chip
|
255
|
+
rb_hash_aset(curr_chip, rb_id2sym(rb_intern("name")), rb_str_new2(buffer));
|
256
|
+
// Get the chip path
|
257
|
+
VALUE path = rb_str_new2(sensor->chip_ptr->path);
|
258
|
+
rb_hash_aset(curr_chip, rb_id2sym(rb_intern("path")), path);
|
259
|
+
|
260
|
+
/*
|
261
|
+
* Stat the features for the card, if set
|
262
|
+
* Had to double-check against NIL, b/c doesn't
|
263
|
+
* fail the same way as in Ruby.
|
264
|
+
*/
|
265
|
+
if (show_data && !NIL_P(show_data)) {
|
266
|
+
rb_hash_aset(curr_chip, rb_id2sym(rb_intern("stat")),
|
267
|
+
method_sensors_get_features(self)); }
|
268
|
+
|
269
|
+
// Add the chip entry to the list
|
270
|
+
rb_hash_aset(data, path, curr_chip);
|
271
|
+
} else {
|
272
|
+
rb_hash_aset(data, rb_id2sym(rb_intern("chip_error")), idx);
|
273
|
+
break;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
cnt++; // Update the count of available chips
|
277
|
+
}
|
278
|
+
chip = NULL; // Disconnect the chip placeholder
|
279
|
+
return data;
|
280
|
+
} // End enumerate method
|
281
|
+
|
282
|
+
/*
|
283
|
+
* Initialize the LmSensors wrapper
|
284
|
+
*/
|
285
|
+
void Init_lmsensors_base() {
|
286
|
+
LmSensors = rb_define_module("LmSensors"); // Module
|
287
|
+
|
288
|
+
/*
|
289
|
+
* Document-class: LmSensors::SensorsBase
|
290
|
+
*
|
291
|
+
* This is an abstract representation of a sensor chip struct used
|
292
|
+
* by the lm-sensors library (https://github.com/lm-sensors/lm-sensors).
|
293
|
+
*
|
294
|
+
* This class directly interacts with the C-side of the code, and it should
|
295
|
+
* not be instantiated on its own. It is abstracted in LmSensors::AbsSensor
|
296
|
+
* and its subclasses. If you wish to used this, you should inherit from
|
297
|
+
* the AbsSensor class.
|
298
|
+
*/
|
299
|
+
Sensors = rb_define_class_under(LmSensors, "SensorsBase", rb_cData); // Main class
|
300
|
+
|
301
|
+
// Define the globals
|
302
|
+
VALUE dec = declare_globals(LmSensors);
|
303
|
+
rb_global_variable(&LMS_OPEN);
|
304
|
+
|
305
|
+
// Module methods
|
306
|
+
rb_define_module_function(LmSensors, "pro_init", lmsensors_init, 1);
|
307
|
+
rb_define_module_function(LmSensors, "pro_cleanup", lmsensors_cleanup, 0);
|
308
|
+
|
309
|
+
// Sensors methods
|
310
|
+
rb_define_alloc_func(Sensors, sensors_obj_alloc);
|
311
|
+
rb_define_protected_method(Sensors, "pro_initialize", method_sensors_initialize, 0);
|
312
|
+
rb_define_protected_method(Sensors, "pro_enum", method_sensors_enumerate_chips, 2);
|
313
|
+
rb_define_protected_method(Sensors, "pro_features", method_sensors_get_features, 0);
|
314
|
+
rb_define_protected_method(Sensors, "pro_subfeatures", method_sensors_get_subfeatures, 0);
|
315
|
+
} // End module and class initialization
|
@@ -0,0 +1,271 @@
|
|
1
|
+
// ext/lmsensors_base/lmsensors_base.h
|
2
|
+
#include <ruby.h>
|
3
|
+
#include <stdbool.h>
|
4
|
+
#include <string.h>
|
5
|
+
#include <sensors/sensors.h>
|
6
|
+
|
7
|
+
#define BUFSIZE 1024
|
8
|
+
|
9
|
+
VALUE LmSensors = Qnil;
|
10
|
+
VALUE Sensors = Qnil;
|
11
|
+
VALUE LMS_OPEN = Qfalse;
|
12
|
+
|
13
|
+
/*
|
14
|
+
* Declare all the global mapping constants
|
15
|
+
*/
|
16
|
+
VALUE declare_globals(VALUE mod) {
|
17
|
+
// Map-exporting constants
|
18
|
+
/* Voltage input */
|
19
|
+
rb_define_const(mod, "SF_IN", INT2NUM(SENSORS_FEATURE_IN));
|
20
|
+
/* Fan speeds in RPM */
|
21
|
+
rb_define_const(mod, "SF_FAN", INT2NUM(SENSORS_FEATURE_FAN));
|
22
|
+
/* Temperature in degrees Celsius */
|
23
|
+
rb_define_const(mod, "SF_TEMP", INT2NUM(SENSORS_FEATURE_TEMP));
|
24
|
+
/* Power (Watts) */
|
25
|
+
rb_define_const(mod, "SF_POWER", INT2NUM(SENSORS_FEATURE_POWER));
|
26
|
+
/* Energy (Joules) */
|
27
|
+
rb_define_const(mod, "SF_ENERGY", INT2NUM(SENSORS_FEATURE_ENERGY));
|
28
|
+
/* Current (Amps) */
|
29
|
+
rb_define_const(mod, "SF_CURR", INT2NUM(SENSORS_FEATURE_CURR));
|
30
|
+
/* Relative humidity (% RH) */
|
31
|
+
rb_define_const(mod, "SF_HUMIDITY", INT2NUM(SENSORS_FEATURE_HUMIDITY));
|
32
|
+
/* Video type (also measured in Volts) */
|
33
|
+
rb_define_const(mod, "SF_VID", INT2NUM(SENSORS_FEATURE_VID));
|
34
|
+
/* Intrusion alarm for the case */
|
35
|
+
rb_define_const(mod, "SF_INTRUSION", INT2NUM(SENSORS_FEATURE_INTRUSION));
|
36
|
+
/* Whether case beeper / pcspkr is enabled */
|
37
|
+
rb_define_const(mod, "SF_BEEP_ENABLE", INT2NUM(SENSORS_FEATURE_BEEP_ENABLE));
|
38
|
+
/* Unknown feature placeholder */
|
39
|
+
rb_define_const(mod, "SF_UNKNOWN", INT2NUM(SENSORS_FEATURE_UNKNOWN));
|
40
|
+
|
41
|
+
// Unclear features
|
42
|
+
/* SENSORS_FEATURE_MAX_MAIN */
|
43
|
+
rb_define_const(mod, "SF_MAX_MAIN", INT2NUM(SENSORS_FEATURE_MAX_MAIN));
|
44
|
+
/* SENSORS_FEATURE_MAX_OTHER */
|
45
|
+
rb_define_const(mod, "SF_MAX_OTHER", INT2NUM(SENSORS_FEATURE_MAX_OTHER));
|
46
|
+
/* SENSORS_FEATURE_MAX */
|
47
|
+
rb_define_const(mod, "SF_MAX", INT2NUM(SENSORS_FEATURE_MAX));
|
48
|
+
|
49
|
+
// Map-exporting limit types, for analysis
|
50
|
+
// ex.: critical, critical low, input, max, min
|
51
|
+
// Voltage
|
52
|
+
/* Present voltage */
|
53
|
+
rb_define_const(mod, "SSF_IN_INPUT", INT2NUM(SENSORS_SUBFEATURE_IN_INPUT));
|
54
|
+
/* Minimum allowed voltage */
|
55
|
+
rb_define_const(mod, "SSF_IN_MIN", INT2NUM(SENSORS_SUBFEATURE_IN_MIN));
|
56
|
+
/* Maximum allowed voltage */
|
57
|
+
rb_define_const(mod, "SSF_IN_MAX", INT2NUM(SENSORS_SUBFEATURE_IN_MAX));
|
58
|
+
/* Critical low voltage */
|
59
|
+
rb_define_const(mod, "SSF_IN_LCRIT", INT2NUM(SENSORS_SUBFEATURE_IN_LCRIT));
|
60
|
+
/* Critical high voltage */
|
61
|
+
rb_define_const(mod, "SSF_IN_CRIT", INT2NUM(SENSORS_SUBFEATURE_IN_CRIT));
|
62
|
+
/* Average voltage */
|
63
|
+
rb_define_const(mod, "SSF_IN_AVG", INT2NUM(SENSORS_SUBFEATURE_IN_AVERAGE));
|
64
|
+
/* Lowest detected voltage input */
|
65
|
+
rb_define_const(mod, "SSF_IN_LOW", INT2NUM(SENSORS_SUBFEATURE_IN_LOWEST));
|
66
|
+
/* Highest detected voltage input */
|
67
|
+
rb_define_const(mod, "SSF_IN_HIGH", INT2NUM(SENSORS_SUBFEATURE_IN_HIGHEST));
|
68
|
+
|
69
|
+
// Voltage alarms
|
70
|
+
/* Voltage alarm */
|
71
|
+
rb_define_const(mod, "SSF_IN_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_ALARM));
|
72
|
+
/* Voltage alarm for minimum voltage */
|
73
|
+
rb_define_const(mod, "SSF_IN_MIN_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_MIN_ALARM));
|
74
|
+
/* Voltage alarm for max voltage */
|
75
|
+
rb_define_const(mod, "SSF_IN_MAX_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_MAX_ALARM));
|
76
|
+
/* Beep for voltage alarms */
|
77
|
+
rb_define_const(mod, "SSF_IN_BEEP", INT2NUM(SENSORS_SUBFEATURE_IN_BEEP));
|
78
|
+
/* Critical low voltage alarm */
|
79
|
+
rb_define_const(mod, "SSF_IN_LCRIT_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_LCRIT_ALARM));
|
80
|
+
/* Critical high voltage alarm */
|
81
|
+
rb_define_const(mod, "SSF_IN_CRIT_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_CRIT_ALARM));
|
82
|
+
|
83
|
+
// Current
|
84
|
+
/* Present current input */
|
85
|
+
rb_define_const(mod, "SSF_CURR_INPUT", INT2NUM(SENSORS_SUBFEATURE_CURR_INPUT));
|
86
|
+
/* Minimum allowed current */
|
87
|
+
rb_define_const(mod, "SSF_CURR_MIN", INT2NUM(SENSORS_SUBFEATURE_CURR_MIN));
|
88
|
+
/* Maximum allowed current */
|
89
|
+
rb_define_const(mod, "SSF_CURR_MAX", INT2NUM(SENSORS_SUBFEATURE_CURR_MAX));
|
90
|
+
/* Critical low current */
|
91
|
+
rb_define_const(mod, "SSF_CURR_LCRIT", INT2NUM(SENSORS_SUBFEATURE_CURR_LCRIT));
|
92
|
+
/* Critical high current */
|
93
|
+
rb_define_const(mod, "SSF_CURR_CRIT", INT2NUM(SENSORS_SUBFEATURE_CURR_CRIT));
|
94
|
+
/* Average current */
|
95
|
+
rb_define_const(mod, "SSF_CURR_AVG",INT2NUM(SENSORS_SUBFEATURE_CURR_AVERAGE));
|
96
|
+
/* Lowest current detected */
|
97
|
+
rb_define_const(mod, "SSF_CURR_LOW", INT2NUM(SENSORS_SUBFEATURE_CURR_LOWEST));
|
98
|
+
/* Highest current detected */
|
99
|
+
rb_define_const(mod, "SSF_CURR_HIGH", INT2NUM(SENSORS_SUBFEATURE_CURR_HIGHEST));
|
100
|
+
|
101
|
+
// Current alarms
|
102
|
+
/* Current alarm */
|
103
|
+
rb_define_const(mod, "SSF_CURR_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_ALARM));
|
104
|
+
/* Current alarm for minimum current */
|
105
|
+
rb_define_const(mod, "SSF_CURR_MIN_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_MIN_ALARM));
|
106
|
+
/* Current alarm for max current */
|
107
|
+
rb_define_const(mod, "SSF_CURR_MAX_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_MAX_ALARM));
|
108
|
+
/* Beep for current alarms */
|
109
|
+
rb_define_const(mod, "SSF_CURR_BEEP", INT2NUM(SENSORS_SUBFEATURE_IN_BEEP));
|
110
|
+
/* Critical low current alarm */
|
111
|
+
rb_define_const(mod, "SSF_CURR_LCRIT_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_LCRIT_ALARM));
|
112
|
+
/* Critical high current alarm */
|
113
|
+
rb_define_const(mod, "SSF_CURR_CRIT_ALARM", INT2NUM(SENSORS_SUBFEATURE_IN_CRIT_ALARM));
|
114
|
+
|
115
|
+
// Power
|
116
|
+
/* Average power */
|
117
|
+
rb_define_const(mod, "SSF_POWER_AVG", INT2NUM(SENSORS_SUBFEATURE_POWER_AVERAGE));
|
118
|
+
rb_define_const(mod, "SSF_POWER_AVG_HIGH",
|
119
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_AVERAGE_HIGHEST));
|
120
|
+
rb_define_const(mod, "SSF_POWER_AVG_LOW",
|
121
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_AVERAGE_LOWEST));
|
122
|
+
/*
|
123
|
+
* Present power input, but this seems to be usually handled by
|
124
|
+
* SSF_POWER_AVG, at least for my devices.
|
125
|
+
*/
|
126
|
+
rb_define_const(mod, "SSF_POWER_INPUT", INT2NUM(SENSORS_SUBFEATURE_POWER_INPUT));
|
127
|
+
/* Highest detected power input */
|
128
|
+
rb_define_const(mod, "SSF_POWER_INPUT_HIGH",
|
129
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_INPUT_HIGHEST));
|
130
|
+
/* Lowest detected power input */
|
131
|
+
rb_define_const(mod, "SSF_POWER_INPUT_LOW",
|
132
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_INPUT_LOWEST));
|
133
|
+
/* User- or system- defined limit on power consumption */
|
134
|
+
rb_define_const(mod, "SSF_POWER_CAP", INT2NUM(SENSORS_SUBFEATURE_POWER_CAP));
|
135
|
+
rb_define_const(mod, "SSF_POWER_CAP_HYST",
|
136
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_CAP_HYST));
|
137
|
+
/* Power maximum usage level */
|
138
|
+
rb_define_const(mod, "SSF_POWER_MAX", INT2NUM(SENSORS_SUBFEATURE_POWER_MAX));
|
139
|
+
/* Power critical usage level */
|
140
|
+
rb_define_const(mod, "SSF_POWER_CRIT", INT2NUM(SENSORS_SUBFEATURE_POWER_CRIT));
|
141
|
+
/* Power minimum usage level */
|
142
|
+
rb_define_const(mod, "SSF_POWER_MIN", INT2NUM(SENSORS_SUBFEATURE_POWER_MIN));
|
143
|
+
/* Power critical low level */
|
144
|
+
rb_define_const(mod, "SSF_POWER_LCRIT", INT2NUM(SENSORS_SUBFEATURE_POWER_LCRIT));
|
145
|
+
/* Interval used by this power sensor to generate averages */
|
146
|
+
rb_define_const(mod, "SSF_POWER_AVG_INTERVAL",
|
147
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL));
|
148
|
+
|
149
|
+
// Power alarms
|
150
|
+
/* Alarm for power */
|
151
|
+
rb_define_const(mod, "SSF_POWER_ALARM",
|
152
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_ALARM));
|
153
|
+
/* Alarm if power is approaching the defined cap */
|
154
|
+
rb_define_const(mod, "SSF_POWER_CAP_ALARM",
|
155
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_CAP_ALARM));
|
156
|
+
/* Alarm if power usage is nearing max */
|
157
|
+
rb_define_const(mod, "SSF_POWER_MAX_ALARM",
|
158
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_MAX_ALARM));
|
159
|
+
/* Alarm if power usage is critical */
|
160
|
+
rb_define_const(mod, "SSF_POWER_CRIT_ALARM",
|
161
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_CRIT_ALARM));
|
162
|
+
/* Alarm if power usage is too low */
|
163
|
+
rb_define_const(mod, "SSF_POWER_MIN_ALARM",
|
164
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_MIN_ALARM));
|
165
|
+
/* Alarm if power usage is nearing critical low */
|
166
|
+
rb_define_const(mod, "SSF_POWER_LCRIT_ALARM",
|
167
|
+
INT2NUM(SENSORS_SUBFEATURE_POWER_LCRIT_ALARM));
|
168
|
+
|
169
|
+
// Temps
|
170
|
+
/* Present temperature input */
|
171
|
+
rb_define_const(mod, "SSF_TEMP_INPUT", INT2NUM(SENSORS_SUBFEATURE_TEMP_INPUT));
|
172
|
+
/* Maximum temperature allowed */
|
173
|
+
rb_define_const(mod, "SSF_TEMP_MAX", INT2NUM(SENSORS_SUBFEATURE_TEMP_MAX));
|
174
|
+
rb_define_const(mod, "SSF_TEMP_MAX_HYST", INT2NUM(SENSORS_SUBFEATURE_TEMP_MAX_HYST));
|
175
|
+
/* Minimum temperature allowed */
|
176
|
+
rb_define_const(mod, "SSF_TEMP_MIN", INT2NUM(SENSORS_SUBFEATURE_TEMP_MIN));
|
177
|
+
/* Critical high temperature */
|
178
|
+
rb_define_const(mod, "SSF_TEMP_CRIT", INT2NUM(SENSORS_SUBFEATURE_TEMP_CRIT));
|
179
|
+
rb_define_const(mod, "SSF_TEMP_CRIT_HYST", INT2NUM(SENSORS_SUBFEATURE_TEMP_CRIT_HYST));
|
180
|
+
/* Critical low temperature */
|
181
|
+
rb_define_const(mod, "SSF_TEMP_LCRIT", INT2NUM(SENSORS_SUBFEATURE_TEMP_LCRIT));
|
182
|
+
/* Emergency-level high temperature */
|
183
|
+
rb_define_const(mod, "SSF_TEMP_EMERG", INT2NUM(SENSORS_SUBFEATURE_TEMP_EMERGENCY));
|
184
|
+
rb_define_const(mod, "SSF_TEMP_EMERG_HYST",
|
185
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_EMERGENCY_HYST));
|
186
|
+
/* Lowest detected temperature */
|
187
|
+
rb_define_const(mod, "SSF_TEMP_LOW", INT2NUM(SENSORS_SUBFEATURE_TEMP_LOWEST));
|
188
|
+
/* Highest detected temperature */
|
189
|
+
rb_define_const(mod, "SSF_TEMP_HIGH", INT2NUM(SENSORS_SUBFEATURE_TEMP_HIGHEST));
|
190
|
+
rb_define_const(mod, "SSF_TEMP_MIN_HYST", INT2NUM(SENSORS_SUBFEATURE_TEMP_MIN_HYST));
|
191
|
+
rb_define_const(mod, "SSF_TEMP_LCRIT_HYST",
|
192
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_LCRIT_HYST));
|
193
|
+
|
194
|
+
// Other temp subfeatures
|
195
|
+
/* Type of the temperature feature */
|
196
|
+
rb_define_const(mod, "SSF_TEMP_TYPE", INT2NUM(SENSORS_SUBFEATURE_TEMP_TYPE));
|
197
|
+
/* Temperature feature reading offset */
|
198
|
+
rb_define_const(mod, "SSF_TEMP_OFFSET", INT2NUM(SENSORS_SUBFEATURE_TEMP_OFFSET));
|
199
|
+
|
200
|
+
// Temperature alarm and error subfeatures
|
201
|
+
/* Temperature alarm */
|
202
|
+
rb_define_const(mod, "SSF_TEMP_ALARM", INT2NUM(SENSORS_SUBFEATURE_TEMP_ALARM));
|
203
|
+
/* Alarm when temperature is nearing max */
|
204
|
+
rb_define_const(mod, "SSF_TEMP_MAX_ALARM",
|
205
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_MAX_ALARM));
|
206
|
+
/* Alarm when temperature is nearing min */
|
207
|
+
rb_define_const(mod, "SSF_TEMP_MIN_ALARM",
|
208
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_MIN_ALARM));
|
209
|
+
/* Alarm when temperature is critical */
|
210
|
+
rb_define_const(mod, "SSF_TEMP_CRIT_ALARM",
|
211
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_CRIT_ALARM));
|
212
|
+
/* Beep for temperature alarms */
|
213
|
+
rb_define_const(mod, "SSF_TEMP_BEEP", INT2NUM(SENSORS_SUBFEATURE_TEMP_BEEP));
|
214
|
+
/* If the temperature sensors has faulted or detected fault */
|
215
|
+
rb_define_const(mod, "SSF_TEMP_FAULT", INT2NUM(SENSORS_SUBFEATURE_TEMP_FAULT));
|
216
|
+
/* Alarm for when temperature is at emergency-level */
|
217
|
+
rb_define_const(mod, "SSF_TEMP_EMERGENCY_ALARM",
|
218
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_EMERGENCY_ALARM));
|
219
|
+
/* Alarm for when temperature approaches critical low */
|
220
|
+
rb_define_const(mod, "SSF_TEMP_LCRIT_ALARM",
|
221
|
+
INT2NUM(SENSORS_SUBFEATURE_TEMP_LCRIT_ALARM));
|
222
|
+
|
223
|
+
// Fans
|
224
|
+
/* Present fan input speed */
|
225
|
+
rb_define_const(mod, "SSF_FAN_INPUT", INT2NUM(SENSORS_SUBFEATURE_FAN_INPUT));
|
226
|
+
/* Minimum fan speed */
|
227
|
+
rb_define_const(mod, "SSF_FAN_MIN", INT2NUM(SENSORS_SUBFEATURE_FAN_MIN));
|
228
|
+
/* Maximum fan speed */
|
229
|
+
rb_define_const(mod, "SSF_FAN_MAX", INT2NUM(SENSORS_SUBFEATURE_FAN_MAX));
|
230
|
+
|
231
|
+
// Additional fan feature exports
|
232
|
+
/* Alarm for fan */
|
233
|
+
rb_define_const(mod, "SSF_FAN_ALARM", INT2NUM(SENSORS_SUBFEATURE_FAN_ALARM));
|
234
|
+
/* Whether fan sensor has detected fault */
|
235
|
+
rb_define_const(mod, "SSF_FAN_FAULT", INT2NUM(SENSORS_SUBFEATURE_FAN_FAULT));
|
236
|
+
rb_define_const(mod, "SSF_FAN_DIV", INT2NUM(SENSORS_SUBFEATURE_FAN_DIV));
|
237
|
+
/* Beep for fan alarms */
|
238
|
+
rb_define_const(mod, "SSF_FAN_BEEP", INT2NUM(SENSORS_SUBFEATURE_FAN_BEEP));
|
239
|
+
/* PWM / pulse settings for fan */
|
240
|
+
rb_define_const(mod, "SSF_FAN_PULSES", INT2NUM(SENSORS_SUBFEATURE_FAN_PULSES));
|
241
|
+
/* Alarm if fans approach minimum-allowed speed */
|
242
|
+
rb_define_const(mod, "SSF_FAN_MIN_ALARM", INT2NUM(SENSORS_SUBFEATURE_FAN_MIN_ALARM));
|
243
|
+
/* Alarm if fans approach maximum-allowed speed */
|
244
|
+
rb_define_const(mod, "SSF_FAN_MAX_ALARM", INT2NUM(SENSORS_SUBFEATURE_FAN_MAX_ALARM));
|
245
|
+
|
246
|
+
// Alarms
|
247
|
+
/* Intrusion alarm subtype */
|
248
|
+
rb_define_const(mod, "SSF_INTRUDE_ALARM",
|
249
|
+
INT2NUM(SENSORS_SUBFEATURE_INTRUSION_ALARM));
|
250
|
+
/* Intrusion beep subtype */
|
251
|
+
rb_define_const(mod, "SSF_INTRUDE_BEEP",
|
252
|
+
INT2NUM(SENSORS_SUBFEATURE_INTRUSION_BEEP));
|
253
|
+
|
254
|
+
// Other exports, which only have 1 subtype, exported for convenience ONLY
|
255
|
+
/* Energy input subtype */
|
256
|
+
rb_define_const(mod, "SSF_ENERGY_INPUT",
|
257
|
+
INT2NUM(SENSORS_SUBFEATURE_ENERGY_INPUT));
|
258
|
+
/* Beep enable subtype */
|
259
|
+
rb_define_const(mod, "SSF_BEEP_ENABLE",
|
260
|
+
INT2NUM(SENSORS_SUBFEATURE_BEEP_ENABLE));
|
261
|
+
/* Video input subfeature */
|
262
|
+
rb_define_const(mod, "SSF_VID", INT2NUM(SENSORS_SUBFEATURE_VID));
|
263
|
+
/* Humidity input subfeature */
|
264
|
+
rb_define_const(mod, "SSF_HUMIDITY_INPUT",
|
265
|
+
INT2NUM(SENSORS_SUBFEATURE_HUMIDITY_INPUT));
|
266
|
+
/* Currently-unknown subfeature */
|
267
|
+
rb_define_const(mod, "SSF_UNKNOWN", INT2NUM(SENSORS_SUBFEATURE_UNKNOWN));
|
268
|
+
|
269
|
+
// Return complete
|
270
|
+
return Qtrue;
|
271
|
+
}
|
@@ -22,7 +22,7 @@ module LmSensors
|
|
22
22
|
# Only check is alarm is enabled.
|
23
23
|
# The other option SSF_INTRUDE_BEEP
|
24
24
|
# is not formatted in the normal sensor program
|
25
|
-
if v[:subtype] == SSF_INTRUDE_ALARM then
|
25
|
+
if v[:value] and (v[:subtype] == SSF_INTRUDE_ALARM) then
|
26
26
|
out[k] = unit.call(v[:value]) end
|
27
27
|
end # End value mapper for alarm
|
28
28
|
out
|
@@ -19,22 +19,24 @@ module LmSensors
|
|
19
19
|
# Format the outputs
|
20
20
|
# Strip each, in case the unit is empty
|
21
21
|
feature.subfs.values.map do |v|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
if v[:value] then
|
23
|
+
case v[:subtype]
|
24
|
+
when SSF_CURR_INPUT
|
25
|
+
tmp[:input] = v[:value]
|
26
|
+
out[:input] = "#{v[:value].round(2)} #{unit}".strip
|
27
|
+
when SSF_CURR_MAX
|
28
|
+
if v[:value] != 0 then
|
29
|
+
tmp[:max] = v[:value]
|
30
|
+
out[:max] = "#{v[:value].round(2)} #{unit}".strip
|
31
|
+
end
|
32
|
+
when SSF_CURR_CRIT
|
33
|
+
if v[:value] != 0 then
|
34
|
+
tmp[:crit] = v[:value]
|
35
|
+
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
36
|
+
end
|
37
|
+
when SSF_CURR_MIN
|
38
|
+
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
30
39
|
end
|
31
|
-
when SSF_CURR_CRIT
|
32
|
-
if v[:value] != 0 then
|
33
|
-
tmp[:crit] = v[:value]
|
34
|
-
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
35
|
-
end
|
36
|
-
when SSF_CURR_MIN
|
37
|
-
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
38
40
|
end
|
39
41
|
end # End value mapper for fan
|
40
42
|
|
@@ -20,15 +20,17 @@ module LmSensors
|
|
20
20
|
# Format the outputs
|
21
21
|
# Strip each, in case the unit is empty
|
22
22
|
feature.subfs.values.map do |v|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
if v[:value] then
|
24
|
+
case v[:subtype]
|
25
|
+
when SSF_FAN_INPUT
|
26
|
+
tmp[:input] = v[:value]
|
27
|
+
out[:input] = "#{v[:value]} #{unit}".strip
|
28
|
+
when SSF_FAN_MAX
|
29
|
+
tmp[:max] = v[:value]
|
30
|
+
out[:max] = "#{v[:value]} #{unit}".strip
|
31
|
+
when SSF_FAN_MIN
|
32
|
+
out[:min] = "#{v[:value]} #{unit}".strip
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end # End value mapper for fan
|
34
36
|
|
@@ -19,23 +19,25 @@ module LmSensors
|
|
19
19
|
# Format the outputs
|
20
20
|
# Strip each, in case the unit is empty
|
21
21
|
feature.subfs.values.map do |v|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
if v[:value] then
|
23
|
+
case v[:subtype]
|
24
|
+
when SSF_POWER_INPUT
|
25
|
+
out[:input] = "#{v[:value].round(2)} #{unit}".strip
|
26
|
+
when SSF_POWER_AVG
|
27
|
+
tmp[:average] = v[:value]
|
28
|
+
out[:average] = "#{v[:value].round(2)} #{unit}".strip
|
29
|
+
when SSF_POWER_MAX
|
30
|
+
tmp[:max] = v[:value]
|
31
|
+
out[:max] = "#{v[:value].round(2)} #{unit}".strip
|
32
|
+
when SSF_POWER_CRIT
|
33
|
+
tmp[:crit] = v[:value]
|
34
|
+
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
35
|
+
when SSF_POWER_CAP
|
36
|
+
tmp[:cap] = v[:value]
|
37
|
+
out[:cap] = "#{v[:value].round(2)} #{unit}".strip
|
38
|
+
when SSF_POWER_MIN
|
39
|
+
out[:min] = "#{v[:value].round(2)} #{unit}".strip
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end # End value mapper for fan
|
41
43
|
|
@@ -19,22 +19,24 @@ module LmSensors
|
|
19
19
|
# Format the outputs
|
20
20
|
# Strip each, in case the unit is empty
|
21
21
|
feature.subfs.values.map do |v|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
if v[:value] then
|
23
|
+
case v[:subtype]
|
24
|
+
when SSF_TEMP_INPUT
|
25
|
+
tmp[:input] = v[:value]
|
26
|
+
out[:input] = "#{v[:value].round(2)} #{unit}".strip
|
27
|
+
when SSF_TEMP_MAX
|
28
|
+
if v[:value] != 0 then
|
29
|
+
tmp[:max] = v[:value]
|
30
|
+
out[:max] = "#{v[:value].round(2)} #{unit}".strip
|
31
|
+
end
|
32
|
+
when SSF_TEMP_CRIT
|
33
|
+
if v[:value] != 0 then
|
34
|
+
tmp[:crit] = v[:value]
|
35
|
+
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
36
|
+
end
|
37
|
+
when SSF_TEMP_MIN
|
38
|
+
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
30
39
|
end
|
31
|
-
when SSF_TEMP_CRIT
|
32
|
-
if v[:value] != 0 then
|
33
|
-
tmp[:crit] = v[:value]
|
34
|
-
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
35
|
-
end
|
36
|
-
when SSF_TEMP_MIN
|
37
|
-
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
38
40
|
end
|
39
41
|
end # End value mapper for fan
|
40
42
|
|
@@ -19,22 +19,24 @@ module LmSensors
|
|
19
19
|
# Format the outputs
|
20
20
|
# Strip each, in case the unit is empty
|
21
21
|
feature.subfs.values.map do |v|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
if v[:value] then
|
23
|
+
case v[:subtype]
|
24
|
+
when SSF_IN_INPUT
|
25
|
+
tmp[:input] = v[:value]
|
26
|
+
out[:input] = "#{v[:value].round(2)} #{unit}".strip
|
27
|
+
when SSF_IN_MAX
|
28
|
+
if v[:value] != 0 then
|
29
|
+
tmp[:max] = v[:value]
|
30
|
+
out[:max] = "#{v[:value].round(2)} #{unit}".strip
|
31
|
+
end
|
32
|
+
when SSF_IN_CRIT
|
33
|
+
if v[:value] != 0 then
|
34
|
+
tmp[:crit] = v[:value]
|
35
|
+
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
36
|
+
end
|
37
|
+
when SSF_IN_MIN
|
38
|
+
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
30
39
|
end
|
31
|
-
when SSF_IN_CRIT
|
32
|
-
if v[:value] != 0 then
|
33
|
-
tmp[:crit] = v[:value]
|
34
|
-
out[:crit] = "#{v[:value].round(2)} #{unit}".strip
|
35
|
-
end
|
36
|
-
when SSF_IN_MIN
|
37
|
-
if v[:value] != 0 then out[:min] = "#{v[:value].round(2)} #{unit}".strip end
|
38
40
|
end
|
39
41
|
end # End value mapper for fan
|
40
42
|
|
data/lib/lmsensors/lmsensors.rb
CHANGED
data/lib/lmsensors/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lmsensors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edelweiss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "Wrapper for the ``lm-sensors`` library, which provides the programs,
|
14
14
|
\n``sensors`` and ``sensors-detect``, for Linux systems. This library \nand its
|
@@ -30,7 +30,10 @@ files:
|
|
30
30
|
- FMAPPER.md
|
31
31
|
- LICENSE.txt
|
32
32
|
- README.md
|
33
|
+
- Rakefile
|
33
34
|
- ext/lmsensors_base/extconf.rb
|
35
|
+
- ext/lmsensors_base/lmsensors_base.c
|
36
|
+
- ext/lmsensors_base/lmsensors_base.h
|
34
37
|
- lib/lmsensors.rb
|
35
38
|
- lib/lmsensors/feature.rb
|
36
39
|
- lib/lmsensors/features/abs_feature.rb
|
@@ -48,7 +51,6 @@ files:
|
|
48
51
|
- lib/lmsensors/sensors/sensor.rb
|
49
52
|
- lib/lmsensors/sensors/sensorspawner.rb
|
50
53
|
- lib/lmsensors/version.rb
|
51
|
-
- lib/lmsensors_base/lmsensors_base.so
|
52
54
|
homepage: https://github.com/KleineEdelweiss/lmsensors_rb
|
53
55
|
licenses:
|
54
56
|
- LGPL-3.0
|
Binary file
|