Changeset 5718
- Timestamp:
- 05/13/09 18:03:23 (4 years ago)
- Location:
- lm-sensors/trunk/prog/sensord
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/sensord/args.c
r5679 r5718 44 44 int rrdNoAverage = 0; 45 45 int syslogFacility = LOG_LOCAL4; 46 int doScan = 0;47 int doSet = 0;48 46 int doCGI = 0; 49 47 int doLoad = 0; … … 128 126 "your configuration changes, delete the old RRD file and restart sensord.\n"; 129 127 130 static const char *appSyntax = 131 " -a, --alarm-scan -- only scan for alarms\n" 132 " -s, --set -- execute set statements (root only)\n" 133 " -r, --rrd-file <file> -- only update RRD file\n" 134 " -c, --config-file <file> -- configuration file\n" 135 " -d, --debug -- display some debug information\n" 136 " -v, --version -- display version and exit\n" 137 " -h, --help -- display help and exit\n" 138 "\n" 139 "Specify the filename `-' to read the config file from stdin.\n" 140 "\n" 141 "If no chips are specified, all chip info will be printed.\n"; 142 143 static const char *daemonShortOptions = "i:l:t:Tf:r:c:p:advhg:"; 144 145 static const struct option daemonLongOptions[] = { 128 static const char *shortOptions = "i:l:t:Tf:r:c:p:advhg:"; 129 130 static const struct option longOptions[] = { 146 131 { "interval", required_argument, NULL, 'i' }, 147 132 { "log-interval", required_argument, NULL, 'l' }, … … 160 145 }; 161 146 162 static const char *appShortOptions = "asr:c:dvh";163 164 static const struct option appLongOptions[] = {165 { "alarm-scan", no_argument, NULL, 'a' },166 { "set", no_argument, NULL, 's' },167 { "rrd-file", required_argument, NULL, 'r' },168 { "config-file", required_argument, NULL, 'c' },169 { "debug", no_argument, NULL, 'd' },170 { "version", no_argument, NULL, 'v' },171 { "help", no_argument, NULL, 'h' },172 { NULL, 0, NULL, 0 }173 };174 175 147 int parseArgs(int argc, char **argv) 176 148 { 177 149 int c; 178 const char *shortOptions;179 const struct option *longOptions;180 150 181 151 isDaemon = (argv[0][strlen (argv[0]) - 1] == 'd'); 182 shortOptions = isDaemon ? daemonShortOptions : appShortOptions; 183 longOptions = isDaemon ? daemonLongOptions : appLongOptions; 152 if (!isDaemon) { 153 fprintf(stderr, "Sensord no longer runs as an commandline" 154 " application.\n"); 155 return -1; 156 } 184 157 185 158 while ((c = getopt_long(argc, argv, shortOptions, longOptions, NULL)) … … 206 179 break; 207 180 case 'a': 208 if (isDaemon) 209 doLoad = 1; 210 else 211 doScan = 1; 212 break; 213 case 's': 214 doSet = 1; 181 doLoad = 1; 215 182 break; 216 183 case 'c': … … 236 203 case 'h': 237 204 printf("Syntax: %s {options} {chips}\n%s", argv[0], 238 isDaemon ? daemonSyntax : appSyntax);205 daemonSyntax); 239 206 exit(EXIT_SUCCESS); 240 207 break; … … 251 218 break; 252 219 } 253 }254 255 if (doScan && doSet) {256 fprintf(stderr,257 "Error: Incompatible --set and --alarm-scan.\n");258 return -1;259 }260 261 if (rrdFile && doSet) {262 fprintf(stderr,263 "Error: Incompatible --set and --rrd-file.\n");264 return -1;265 }266 267 if (doScan && rrdFile) {268 fprintf(stderr,269 "Error: Incompatible --rrd-file and --alarm-scan.\n");270 return -1;271 220 } 272 221 -
lm-sensors/trunk/prog/sensord/sensord.c
r5678 r5718 213 213 exit(EXIT_FAILURE); 214 214 215 if (isDaemon)216 openLog(); 217 if (rrdFile) 215 openLog(); 216 217 if (rrdFile) { 218 218 ret = rrdInit(); 219 220 if (ret) { 221 } else if (doCGI) { 219 if (ret) 220 exit(EXIT_FAILURE); 221 } 222 223 if (doCGI) { 222 224 ret = rrdCGI(); 223 } else if (isDaemon){225 } else { 224 226 daemonize(); 225 227 ret = sensord(); 226 228 undaemonize(); 227 } else {228 if (doSet)229 ret = setChips();230 else if (doScan)231 ret = scanChips();232 else if (rrdFile)233 ret = rrdUpdate();234 else235 ret = readChips();236 229 } 237 230 -
lm-sensors/trunk/prog/sensord/sensord.h
r5678 r5718 38 38 extern int rrdNoAverage; 39 39 extern int syslogFacility; 40 extern int doScan;41 extern int doSet;42 40 extern int doCGI; 43 41 extern int doLoad;
