Index of /files/code/mrtg-rmt
mrtg-rmt is a Perl daemon that responds to certain queries for
statistics. Most of this data is not available via conventional means,
such as SNMP, or is returned in a value not suitable for MRTG.
Listening on a default port of 249, it waits for a connection from
netcat, run via MRTG, then spits out MRTG-compatible output, which might
be something like this:
26
100
21:23:47 up 21 days, 6:19, 19 users, load average: 0.00, 0.00, 0.00
tacolinux.prolixium.com
It can monitor the following things, currently:
* TemperatureMonitor output on OS X
Syntax: "tm,$sensorIN,$sensorOUT"
Details: It parses output from the tempmonitor CLI utlity
Example:
% echo 'tm,CPU Core 1,CPU Core 2'|nc localhost 249
31
35
19:23 up 3 days, 8:18, 7 users, load averages: 0.21 0.15 0.12
apple.prolixium.com
* HDD temperature from the "Temperature_Celsius" S.M.A.R.T. data
Syntax: "ht,$devIN,$devOUT"
Details: It actually runs $smartctl -a [dev] and parses the output
Example:
% echo 'ht,/dev/hda,/dev/hdb'|nc localhost 249
37
34
21:30:00 up 366 days, 10:54, 2 users, load average: 0.02, 0.02, 0.00
nonce.prolixium.com
* Any two values from the lm-sensors 'sensors' output
Syntax: "ls,$chipIN,$sensorIN,$chipOUT,$sensorOUT"
Details: It runs $sensors and parses the output
Example:
% echo ls,w83781d-isa-0290,temp1,w83781d-isa-0290,temp2|nc localhost 249
35
34
21:31:44 up 102 days, 39 min, 2 users, load average: 0.07, 0.02, 0.00
atlantis.prolixium.com
* Smart/USB APC UPS percent load/charge or battery/utility voltage
Syntax: "apcpercent" or "apcvoltage"
Details: It runs $apcaccess and parses the output
Example:
% echo apcvoltage|nc localhost 249
26
123
21:35:57 up 102 days, 43 min, 2 users, load average: 0.00, 0.00, 0.00
atlantis.prolixium.com
* Disk sectors read/written
Syntax: "ds,$node"
Details: Parses data from /sys/block/$node/stat
Example:
% echo ds,hda|nc localhost 249
117137495
1578784088
21:38:51 up 366 days, 11:03, 2 users, load average: 0.17, 0.05, 0.01
nonce.prolixium.com
* Cisco WAP client bitrate
Syntax: "wap,$hostname,$community,$mac"
Details: Actually walks the WAP, finds the right MAC, converts the bitrate
Example:
% echo 'wap,orthogonality,ieW5ooz5,00:17:ab:dd:85:64'|nc localhost 249
54
0
11:17AM up 60 days, 1:59, 19 users, load averages: 0.06, 0.03, 0.00
dax.prolixium.com
Usage for mrtg-rmt is pretty simple. To run it as a daemon, do:
# ./mrtg-rmt.pl -d
To specify a port, and run it in the foreground:
% ./mrtg-rmt.pl -p 1024
For a sample MRTG configuration file, look at the mrtg.cfg in this
directory.
If you want to use the "as" target, get apple_sensors from:
https://github.com/fermion-star/apple_sensors
Then, patch with the following:
diff --git a/temp_sensor.m b/temp_sensor.m
index fda7d58..7f6ddce 100644
--- a/temp_sensor.m
+++ b/temp_sensor.m
@@ -233,7 +233,7 @@ int main () {
dumpNames(thermalNames, "C");
printf("\n"); fflush(stdout);
- while (1) {
+// while (1) {
CFArrayRef currentValues = getPowerValues(currentSensors);
CFArrayRef voltageValues = getPowerValues(voltageSensors);
CFArrayRef thermalValues = getThermalValues(thermalSensors);
@@ -244,11 +244,11 @@ int main () {
// dumpValues(currentValues);
dumpValues(thermalValues);
printf("\n"); fflush(stdout);
- usleep(500000); // usleep - suspend execution for microsecond intervals
+// usleep(500000); // usleep - suspend execution for microsecond intervals
CFRelease(currentValues);
CFRelease(voltageValues);
CFRelease(thermalValues);
- }
+// }
#if 0
NSLog(@"%@\n", CFArrayGetValueAtIndex(currentNames, 0));
This is the only way I've found to query the Apple Silicon sensors from
the command line, unfortunately.