fix
This commit is contained in:
parent
fb5b1690e6
commit
f436eb959f
2 changed files with 8 additions and 7 deletions
|
@ -7,9 +7,10 @@ a lightweight script that logs the most important stuff about the raspberry pi
|
||||||
CPU temperature is read from `/sys/class/thermal/thermal_zone0/temp` but that should work on every Linux computer \
|
CPU temperature is read from `/sys/class/thermal/thermal_zone0/temp` but that should work on every Linux computer \
|
||||||
Ambient temperature is read from `/sys/bus/w1/devices` so you must have 1wire enabled, if you don't have that set `SENSOR` to `0`
|
Ambient temperature is read from `/sys/bus/w1/devices` so you must have 1wire enabled, if you don't have that set `SENSOR` to `0`
|
||||||
|
|
||||||
# compilation
|
# compilation and usage
|
||||||
`make` or `gcc main.c -o measurer` \
|
`make` or `gcc main.c -o measurer` \
|
||||||
Should throw no warnings
|
Should throw no warnings \
|
||||||
|
`./measurer <output>`
|
||||||
|
|
||||||
# why
|
# why
|
||||||
like heavy ahh like databases grafana etc go away you're a performance monitor why'd you reduce performance
|
like heavy ahh like databases grafana etc go away you're a performance monitor why'd you reduce performance
|
10
main.c
10
main.c
|
@ -7,7 +7,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define SENSOR 1
|
#define SENSOR 0
|
||||||
|
|
||||||
int read_temperature(char *filename) {
|
int read_temperature(char *filename) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -70,7 +70,7 @@ int read_w1_temperature(char *w1_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc == 0) {
|
if (argc < 2) {
|
||||||
printf("Filename required\n");
|
printf("Filename required\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -105,14 +105,14 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
fp = fopen(argv[0], "a");
|
fp = fopen(argv[1], "a");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
printf("Error opening output file");
|
perror("Error opening output file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fprintf(fp, line) != 0) {
|
if (fprintf(fp, line) < 0) {
|
||||||
perror("Error writing to output file");
|
perror("Error writing to output file");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue