bootchart.c revision 6d2679917919f1d59bf677d719fb84aedf8b9558
/***
bootchart.c - This file is part of systemd-bootchart
Copyright (C) 2009-2013 Intel Coproration
Authors:
Auke Kok <auke-jan.h.kok@intel.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/***
Many thanks to those who contributed ideas and code:
- Ziga Mahkovec - Original bootchart author
- Anders Norgaard - PyBootchartgui
- Michael Meeks - bootchart2
- Scott James Remnant - Ubuntu C-based logger
- Arjan van der Ven - for the idea to merge bootgraph.pl functionality
***/
#include <sys/resource.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <getopt.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include "bootchart.h"
#include "util.h"
#include "fileio.h"
#include "macro.h"
#include "conf-parser.h"
#include "strxcpyx.h"
#include "path-util.h"
double graph_start;
double log_start;
double sampletime[MAXSAMPLES];
int entropy_avail[MAXSAMPLES];
int pscount;
int cpus;
double interval;
int overrun = 0;
static int exiting = 0;
int sysfd=-1;
/* graph defaults */
bool entropy = false;
bool initcall = true;
bool relative = false;
bool filter = true;
bool pss = false;
int samples;
static void signal_handler(int sig)
{
if (sig++)
sig--;
exiting = 1;
}
{
char output_file[PATH_MAX];
char datestr[200];
time_t t = 0;
const char *fn;
_cleanup_fclose_ FILE *f;
int gind;
int i, r;
const ConfigTableItem items[] = {
};
fn = "/etc/systemd/bootchart.conf";
if (f) {
if (r < 0)
}
while (1) {
};
gind = 0;
if (i == -1)
break;
switch (i) {
case 'r':
relative = true;
break;
case 'f':
if (r < 0)
log_warning("failed to parse --freq/-f argument '%s': %s",
break;
case 'F':
filter = false;
break;
case 'n':
if (r < 0)
log_warning("failed to parse --samples/-n argument '%s': %s",
break;
case 'o':
break;
case 'i':
break;
case 'p':
pss = true;
break;
case 'x':
if (r < 0)
log_warning("failed to parse --scale-x/-x argument '%s': %s",
break;
case 'y':
if (r < 0)
log_warning("failed to parse --scale-y/-y argument '%s': %s",
break;
case 'e':
entropy = true;
break;
case 'h':
exit (EXIT_SUCCESS);
break;
default:
break;
}
}
if (len > MAXSAMPLES) {
}
if (hz <= 0.0) {
}
/*
* If the kernel executed us through init=/usr/lib/systemd/systemd-bootchart, then
* fork:
* - child logs data
*/
if (getpid() == 1) {
if (fork()) {
/* parent */
}
}
argv[0][0] = '@';
/* start with empty ps LL */
if (!ps_first) {
perror("calloc(ps_struct)");
}
log_uptime();
/* main program loop */
while (!exiting) {
int res;
double sample_stop;
long newint_ns;
double elapsed;
double timeleft;
}
if (sysfd < 0) {
}
if (!build) {
"PRETTY_NAME", &build,
NULL);
}
/* wait for /proc to become available, discarding samples */
if (!(graph_start > 0.0))
log_uptime();
else
sample_stop = gettime_ns();
/*
* check if we have not consumed our entire timeslice. If we
* do, don't sleep and take a new sample right away.
* we'll lose all the missed samples and overrun our total
* time
*/
if (res) {
/* caught signal, probably HUP! */
break;
}
perror("nanosleep()");
exit (EXIT_FAILURE);
}
} else {
overrun++;
/* calculate how many samples we lost and scrap them */
}
samples++;
break;
}
/* do some cleanup, close fd's */
}
if (!of) {
}
if (!of) {
exit (EXIT_FAILURE);
}
/* nitpic cleanups */
}
/* don't complain when overrun once, happens most commonly on 1st sample */
if (overrun > 1)
return 0;
}