Example #1
0
void
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid)
{
	char buffer [BUFSIZ], *p;

	memset (buf, 0, sizeof (glibtop_proc_kernel));

	if (proc_stat_to_buffer(buffer, sizeof buffer, pid))
		return;

	p = proc_stat_after_cmd (buffer);
	if (!p) return;

	p = skip_multiple_token (p, 6);

	buf->k_flags   = strtoull (p, &p, 0);
	buf->min_flt   = strtoull (p, &p, 0);
	buf->cmin_flt  = strtoull (p, &p, 0);
	buf->maj_flt   = strtoull (p, &p, 0);
	buf->cmaj_flt  = strtoull (p, &p, 0);

	p = skip_multiple_token (p, 15);

	buf->kstk_esp = strtoull (p, &p, 0);
	buf->kstk_eip = strtoull (p, &p, 0);

	p = skip_multiple_token (p, 4);

	buf->nwchan = strtoull (p, &p, 0);

	proc_file_to_buffer(buf->wchan, sizeof buf->wchan, "/proc/%d/wchan", pid),

	buf->flags = _glibtop_sysdeps_proc_kernel;
}
Example #2
0
void
glibtop_get_proc_io_s (glibtop *server, glibtop_proc_io *buf, pid_t pid)
{
	char buffer [BUFSIZ], *p;
    memset (buf, 0, sizeof (glibtop_proc_io));

    if (server->os_version_code < LINUX_VERSION_CODE(2, 6, 20))
      return;

	if (proc_file_to_buffer(buffer, sizeof buffer, "/proc/%d/io", pid))
		return;

	p = skip_token (buffer);
    buf->disk_rchar = g_ascii_strtoull (p, &p, 10);
    p = skip_line (p);
    p = skip_token (p);
    buf->disk_wchar = g_ascii_strtoull (p, &p, 10);
    p = skip_line (p);
    p = skip_line (p);
    p = skip_line (p);
    p = skip_token (p);
    buf->disk_rbytes = g_ascii_strtoull (p, &p, 10);
    p = skip_line (p);
    p = skip_token (p);
    buf->disk_wbytes = g_ascii_strtoull (p, &p, 10);    

    buf->flags = _glibtop_sysdeps_proc_io;
}
Example #3
0
static inline int
proc_statm_to_buffer (char *buffer, size_t bufsiz, pid_t pid)
{
	return proc_file_to_buffer(buffer, bufsiz, "/proc/%d/statm", pid);
}