/* * sensord * * A daemon that periodically logs sensor information to syslog. * * Copyright (c) 1999-2002 Merlin Hughes * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "sensord.h" #include "lib/error.h" #include "version.h" #define MAX_CHIP_NAMES 32 int isDaemon = 0; const char *sensorsCfgFile = NULL; const char *pidFile = "/var/run/sensord.pid"; const char *rrdFile = NULL; const char *cgiDir = NULL; int scanTime = 60; int logTime = 30 * 60; int rrdTime = 5 * 60; int rrdNoAverage = 0; int syslogFacility = LOG_LOCAL4; int doScan = 0; int doSet = 0; int doCGI = 0; int doLoad = 0; int debug = 0; sensors_chip_name chipNames[MAX_CHIP_NAMES]; int numChipNames = 0; static int parseTime (char *arg) { char *end; int value = strtoul (arg, &end, 10); if ((end > arg) && (*end == 's')) { ++ end; } else if ((end > arg) && (*end == 'm')) { value *= 60; ++ end; } else if ((end > arg) && (*end == 'h')) { value *= 60 * 60; ++ end; } if ((end == arg) || *end) { fprintf (stderr, "Error parsing time value `%s'.\n", arg); return -1; } return value; } static struct { const char *name; int id; } facilities[] = { { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { "daemon", LOG_DAEMON }, { "user", LOG_USER }, { NULL, 0 } }; static int parseFacility (char *arg) { int i = 0; while (facilities[i].name && strcasecmp (arg, facilities[i].name)) ++ i; if (!facilities[i].name) { fprintf (stderr, "Error parsing facility value `%s'.\n", arg); return -1; } return facilities[i].id; } static const char *daemonSyntax = " -i, --interval