| 1 | /* |
|---|
| 2 | * sensord |
|---|
| 3 | * |
|---|
| 4 | * A daemon that periodically logs sensor information to syslog. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 1999-2002 Merlin Hughes <merlin@merlin.org> |
|---|
| 7 | * |
|---|
| 8 | * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | * it under the terms of the GNU General Public License as published by |
|---|
| 10 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | * (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, |
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | * GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * You should have received a copy of the GNU General Public License |
|---|
| 19 | * along with this program; if not, write to the Free Software |
|---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|---|
| 21 | * MA 02110-1301 USA. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | #include "lib/sensors.h" |
|---|
| 25 | |
|---|
| 26 | extern void sensorLog(int priority, const char *fmt, ...); |
|---|
| 27 | |
|---|
| 28 | /* from args.c */ |
|---|
| 29 | |
|---|
| 30 | extern int isDaemon; |
|---|
| 31 | extern const char *sensorsCfgFile; |
|---|
| 32 | extern const char *pidFile; |
|---|
| 33 | extern const char *rrdFile; |
|---|
| 34 | extern const char *cgiDir; |
|---|
| 35 | extern int scanTime; |
|---|
| 36 | extern int logTime; |
|---|
| 37 | extern int rrdTime; |
|---|
| 38 | extern int rrdNoAverage; |
|---|
| 39 | extern int syslogFacility; |
|---|
| 40 | extern int doScan; |
|---|
| 41 | extern int doSet; |
|---|
| 42 | extern int doCGI; |
|---|
| 43 | extern int doLoad; |
|---|
| 44 | extern int debug; |
|---|
| 45 | extern sensors_chip_name chipNames[]; |
|---|
| 46 | extern int numChipNames; |
|---|
| 47 | |
|---|
| 48 | extern int parseArgs(int argc, char **argv); |
|---|
| 49 | extern int parseChips(int argc, char **argv); |
|---|
| 50 | |
|---|
| 51 | /* from lib.c */ |
|---|
| 52 | |
|---|
| 53 | extern int loadLib(const char *cfgPath); |
|---|
| 54 | extern int reloadLib(const char *cfgPath); |
|---|
| 55 | extern int unloadLib(void); |
|---|
| 56 | |
|---|
| 57 | /* from sense.c */ |
|---|
| 58 | |
|---|
| 59 | extern int readChips(void); |
|---|
| 60 | extern int scanChips(void); |
|---|
| 61 | extern int setChips(void); |
|---|
| 62 | extern int rrdChips(void); |
|---|
| 63 | |
|---|
| 64 | /* from rrd.c */ |
|---|
| 65 | |
|---|
| 66 | extern char rrdBuff[]; |
|---|
| 67 | extern int rrdInit(void); |
|---|
| 68 | extern int rrdUpdate(void); |
|---|
| 69 | extern int rrdCGI(void); |
|---|
| 70 | |
|---|
| 71 | /* from chips.c */ |
|---|
| 72 | |
|---|
| 73 | #define MAX_DATA 5 |
|---|
| 74 | |
|---|
| 75 | typedef const char *(*FormatterFN) (const double values[], int alarm, |
|---|
| 76 | int beep); |
|---|
| 77 | |
|---|
| 78 | typedef const char *(*RRDFN) (const double values[]); |
|---|
| 79 | |
|---|
| 80 | typedef enum { |
|---|
| 81 | DataType_voltage = 0, |
|---|
| 82 | DataType_rpm, |
|---|
| 83 | DataType_temperature, |
|---|
| 84 | DataType_other = -1 |
|---|
| 85 | } DataType; |
|---|
| 86 | |
|---|
| 87 | typedef struct { |
|---|
| 88 | FormatterFN format; |
|---|
| 89 | RRDFN rrd; |
|---|
| 90 | DataType type; |
|---|
| 91 | int alarmNumber; |
|---|
| 92 | int beepNumber; |
|---|
| 93 | const sensors_feature *feature; |
|---|
| 94 | int dataNumbers[MAX_DATA + 1]; |
|---|
| 95 | } FeatureDescriptor; |
|---|
| 96 | |
|---|
| 97 | typedef struct { |
|---|
| 98 | const sensors_chip_name *name; |
|---|
| 99 | FeatureDescriptor *features; |
|---|
| 100 | } ChipDescriptor; |
|---|
| 101 | |
|---|
| 102 | extern ChipDescriptor * knownChips; |
|---|
| 103 | extern int initKnownChips(void); |
|---|
| 104 | extern void freeKnownChips(void); |
|---|