From db88ea2698ff21cc96c5dd8699ca834a0f374f95 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 3 Nov 2010 13:01:38 +0000 Subject: [PATCH] sensors: Add support for intrusion detection. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5880 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/sensors/chips.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9610788a..72523bf1 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ SVN HEAD Makefile: Check for bison and flex libsensors: Add support for intrusion detection sensors: Display 3 decimal places in raw output + Add support for intrusion detection sensors-detect: Improve LM90 and W83L771 detection Fix error seen if I2C bus numbers are not sequential diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 04b2471b..3946e0e5 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -2,7 +2,7 @@ chips.c - Part of sensors, a user-space program for hardware monitoring Copyright (C) 1998-2003 Frodo Looijaard and Mark D. Studebaker - Copyright (C) 2007 Jean Delvare + Copyright (C) 2007-2010 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -661,6 +661,27 @@ static void print_chip_curr(const sensors_chip_name *name, printf("\n"); } +static void print_chip_intrusion(const sensors_chip_name *name, + const sensors_feature *feature, + int label_size) +{ + char *label; + const sensors_subfeature *subfeature; + double alarm; + + subfeature = sensors_get_subfeature(name, feature, + SENSORS_SUBFEATURE_INTRUSION_ALARM); + if (!subfeature) + return; + + if ((label = sensors_get_label(name, feature)) + && !sensors_get_value(name, subfeature->number, &alarm)) { + print_label(label, label_size); + printf("%s\n", alarm ? "ALARM" : "OK"); + } + free(label); +} + void print_chip(const sensors_chip_name *name) { const sensors_feature *feature; @@ -695,6 +716,9 @@ void print_chip(const sensors_chip_name *name) case SENSORS_FEATURE_CURR: print_chip_curr(name, feature, label_size); break; + case SENSORS_FEATURE_INTRUSION: + print_chip_intrusion(name, feature, label_size); + break; default: continue; }