优化
This commit is contained in:
parent
1eed11b4d4
commit
787c094dbb
4
Makefile
4
Makefile
@ -1,8 +1,8 @@
|
|||||||
CROSS_COMPILE ?=
|
CROSS_COMPILE ?=
|
||||||
CC := $(CROSS_COMPILE)gcc
|
CC := $(CROSS_COMPILE)gcc
|
||||||
CFLAGS += -Wall -Os -g -L../libini -I../libini -fno-builtin
|
CFLAGS += -Wall -Os -g -L../libini -I../libini -fno-builtin
|
||||||
LIB += -Wl,-rpath,/root/libini/ /root/libini/libini.so
|
LIB += -Wl,-rpath,/root/libini/ ../libini/libini.so
|
||||||
BIN = reboot_temperature
|
BIN = boot
|
||||||
|
|
||||||
all: reboot_temperature.o
|
all: reboot_temperature.o
|
||||||
$(CC) $(CFLAGS) $^ -o $(BIN) $(LIB)
|
$(CC) $(CFLAGS) $^ -o $(BIN) $(LIB)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[global]
|
[global]
|
||||||
thermal_zone = "/sys/class/thermal/thermal_zone0/temp";
|
thermal_zone = "/sys/class/thermal/thermal_zone0/temp";
|
||||||
temperature = 85
|
temperature = 70
|
||||||
log_file = "log_reboot.log";
|
log_file = "boot.log";
|
||||||
second = 60
|
second = 30
|
||||||
nice = -20
|
nice = -20
|
||||||
off_power = 0
|
off_power = 0
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ static int error_log(float l_t, int c_t, char *log_file, char *recv_mail, int _i
|
|||||||
|
|
||||||
if (_is == 1)
|
if (_is == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_alert == 1)
|
if (_alert == 1)
|
||||||
{
|
{
|
||||||
// 关机重启时
|
// 关机重启时
|
||||||
@ -126,22 +125,28 @@ int main(int argc, char *argv[], char **env)
|
|||||||
perror("nice");
|
perror("nice");
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
getinikeystring("global", "thermal_zone", inifile, buffer); // 获取thermal_zone路径
|
getinikeystring("global", "thermal_zone", inifile, buffer); // 获取thermal_zone路径
|
||||||
getinikeystring("global", "log_file", inifile, log_file); // 获取日志文件名
|
getinikeystring("global", "log_file", inifile, log_file); // 获取日志文件名
|
||||||
getinikeystring("global", "recv_mail", inifile, recv_mail); // 获取接收者邮箱
|
getinikeystring("global", "recv_mail", inifile, recv_mail); // 获取接收者邮箱
|
||||||
|
|
||||||
if (get_temperature(buffer) >= getinikeyint("global", "temperature", inifile)) // 达到重启或者关机温度
|
if (get_temperature(buffer) >= getinikeyint("global", "temperature", inifile)) // 达到重启或者关机温度
|
||||||
{
|
{
|
||||||
|
sync();
|
||||||
sync();
|
sync();
|
||||||
if (getinikeyint("global", "off_power", inifile) == 1)
|
if (getinikeyint("global", "off_power", inifile) == 1)
|
||||||
{
|
{
|
||||||
error_log(get_temperature(buffer), getinikeyint("global", "temperature", inifile), log_file, recv_mail, getinikeyint("global", "is_alert", inifile), 1);
|
error_log(get_temperature(buffer), getinikeyint("global", "temperature", inifile), log_file, recv_mail, getinikeyint("global", "is_alert", inifile), 1);
|
||||||
return reboot(RB_POWER_OFF); // 关机
|
return reboot(RB_POWER_OFF); // 关机
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (getinikeyint("global", "off_power", inifile) == 0)
|
||||||
|
{
|
||||||
error_log(get_temperature(buffer), getinikeyint("global", "temperature", inifile), log_file, recv_mail, getinikeyint("global", "is_alert", inifile), 1);
|
error_log(get_temperature(buffer), getinikeyint("global", "temperature", inifile), log_file, recv_mail, getinikeyint("global", "is_alert", inifile), 1);
|
||||||
return reboot(RB_AUTOBOOT); // 重启
|
return reboot(RB_AUTOBOOT); // 重启
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else // 未达到重启或者关机温度
|
else // 未达到重启或者关机温度
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user