Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/init/bootchartd.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/init/bootchartd.c
r2725 r3232 4 4 */ 5 5 6 //applet:IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP))6 //applet:IF_BOOTCHARTD(APPLET(bootchartd, BB_DIR_SBIN, BB_SUID_DROP)) 7 7 8 8 //kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o … … 209 209 } 210 210 211 static void do_logging(unsigned sample_period_us) 212 { 213 //# Enable process accounting if configured 214 //if [ "$PROCESS_ACCOUNTING" = "yes" ]; then 215 // [ -e kernel_pacct ] || : > kernel_pacct 216 // accton kernel_pacct 217 //fi 218 211 static void do_logging(unsigned sample_period_us, int process_accounting) 212 { 219 213 FILE *proc_stat = xfopen("proc_stat.log", "w"); 220 214 FILE *proc_diskstats = xfopen("proc_diskstats.log", "w"); … … 223 217 int look_for_login_process = (getppid() == 1); 224 218 unsigned count = 60*1000*1000 / sample_period_us; /* ~1 minute */ 219 220 if (process_accounting) { 221 close(xopen("kernel_pacct", O_WRONLY | O_CREAT | O_TRUNC)); 222 acct("kernel_pacct"); 223 } 225 224 226 225 while (--count && !bb_got_signal) { … … 254 253 usleep(sample_period_us); 255 254 } 256 257 // [ -e kernel_pacct ] && accton off 258 } 259 260 static void finalize(char *tempdir, const char *prog) 255 } 256 257 static void finalize(char *tempdir, const char *prog, int process_accounting) 261 258 { 262 259 //# Stop process accounting if configured … … 265 262 266 263 FILE *header_fp = xfopen("header", "w"); 264 265 if (process_accounting) 266 acct(NULL); 267 267 268 268 if (prog) … … 308 308 309 309 /* Package log files */ 310 system( "tar -zcf /var/log/bootchart.tgz header *.log"); // + $pacct310 system(xasprintf("tar -zcf /var/log/bootlog.tgz header %s *.log", process_accounting ? "kernel_pacct" : "")); 311 311 /* Clean up (if we are not in detached tmpfs) */ 312 312 if (tempdir) { … … 316 316 //unlink("proc_netdev.log"); 317 317 unlink("proc_ps.log"); 318 if (process_accounting) 319 unlink("kernel_pacct"); 318 320 rmdir(tempdir); 319 321 } … … 328 330 //usage:#define bootchartd_full_usage "\n\n" 329 331 //usage: "Create /var/log/bootchart.tgz with boot chart data\n" 330 //usage: "\nOptions:"331 332 //usage: "\nstart: start background logging; with PROG, run PROG, then kill logging with USR1" 332 333 //usage: "\nstop: send USR1 to all bootchartd processes" … … 340 341 pid_t parent_pid, logger_pid; 341 342 smallint cmd; 343 int process_accounting; 342 344 enum { 343 345 CMD_STOP = 0, … … 373 375 /* Read config file: */ 374 376 sample_period_us = 200 * 1000; 377 process_accounting = 0; 375 378 if (ENABLE_FEATURE_BOOTCHARTD_CONFIG_FILE) { 376 379 char* token[2]; … … 381 384 if (strcmp(token[0], "SAMPLE_PERIOD") == 0 && token[1]) 382 385 sample_period_us = atof(token[1]) * 1000000; 386 if (strcmp(token[0], "PROCESS_ACCOUNTING") == 0 && token[1] 387 && (strcmp(token[1], "on") == 0 || strcmp(token[1], "yes") == 0) 388 ) { 389 process_accounting = 1; 390 } 383 391 } 384 392 config_close(parser); 385 }386 if ((int)sample_period_us <= 0)387 sample_period_us = 1; /* prevent division by 0 */393 if ((int)sample_period_us <= 0) 394 sample_period_us = 1; /* prevent division by 0 */ 395 } 388 396 389 397 /* Create logger child: */ … … 413 421 414 422 tempdir = make_tempdir(); 415 do_logging(sample_period_us );416 finalize(tempdir, cmd == CMD_START ? argv[2] : NULL );423 do_logging(sample_period_us, process_accounting); 424 finalize(tempdir, cmd == CMD_START ? argv[2] : NULL, process_accounting); 417 425 return EXIT_SUCCESS; 418 426 } 419 427 420 428 /* parent */ 429 430 USE_FOR_NOMMU(argv[0][0] &= 0x7f); /* undo fork_or_rexec() damage */ 421 431 422 432 if (DO_SIGNAL_SYNC) { … … 442 452 if (pid == 0) { /* child */ 443 453 argv += 2; 444 execvp(argv[0], argv); 445 bb_perror_msg_and_die("can't execute '%s'", argv[0]); 454 BB_EXECVP_or_die(argv); 446 455 } 447 456 /* parent */
Note:
See TracChangeset
for help on using the changeset viewer.