1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/*
* mon_procd - Write process data to the z/VM monitor strea
*
* Definitions used by mon_procd
*
* Copyright IBM Corp. 2007, 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef __mon_procd_h__
#define __mon_procd_h__
#include <linux/types.h>
#include "lib/zt_common.h"
/* mon_function values */
#define MONWRITE_START_INTERVAL 0x00 /* start interval recording */
#define MONWRITE_STOP_INTERVAL 0x01 /* stop interval or config recording */
#define SMALL_MON_RECORD_LEN 512
#define MAX_REC_LEN 1500
#define PROCD_APPLID 0x02
#define SUM_FLAG 0x00
#define TASK_FLAG 0x01
#define BUF_SIZE 4096
#define MAX_NAME_LEN 64
#define MAX_CMD_LEN 1024
#define MAX_TASK_REC 100
#define Hertz 100
struct monwrite_hdr {
unsigned char mon_function;
unsigned short applid;
unsigned char record_num;
unsigned short version;
unsigned short release;
unsigned short mod_level;
unsigned short datalen;
unsigned char hdrlen;
} __attribute__((packed));
struct procd_hdr {
__u64 time_stamp;
__u16 data_len;
__u16 data_offset;
} __attribute__((packed));
struct task_sum_t {
__u32 total;
__u32 running;
__u32 sleeping;
__u32 stopped;
__u32 zombie;
};
struct cpu_t {
__u32 num_cpus;
__u16 puser;
__u16 pnice;
__u16 psystem;
__u16 pidle;
__u16 piowait;
__u16 pirq;
__u16 psoftirq;
__u16 psteal;
};
struct mem_t {
__u64 total;
__u64 used;
__u64 free;
__u64 buffers;
__u64 pgpgin;
__u64 pgpgout;
};
struct swap_t {
__u64 total;
__u64 used;
__u64 free;
__u64 cached;
__u64 pswpin;
__u64 pswpout;
};
struct proc_sum_t {
__u64 uptime;
__u32 users;
char loadavg_1[6];
char loadavg_5[6];
char loadavg_15[6];
struct task_sum_t task;
struct cpu_t cpu;
struct mem_t mem;
struct swap_t swap;
} __attribute__((packed));
struct task_t {
__u32 pid;
__u32 ppid;
__u32 euid;
__u16 tty;
__s16 priority;
__s16 nice;
__u32 processor;
__u16 pcpu;
__u16 pmem;
__u64 total_time;
__u64 ctotal_time;
__u64 size;
__u64 swap;
__u64 resident;
__u64 trs;
__u64 drs;
__u64 share;
__u64 dt;
__u64 maj_flt;
char state;
__u32 flags;
} __attribute__((packed));
struct cpudata_t {
__u32 id;
__u64 usr;
__u64 nice;
__u64 sys;
__u64 idle;
__u64 iowt;
__u64 irq;
__u64 sirq;
__u64 steal;
__u64 usr_prev;
__u64 nice_prev;
__u64 sys_prev;
__u64 idle_prev;
__u64 iowt_prev;
__u64 irq_prev;
__u64 sirq_prev;
__u64 steal_prev;
};
struct task_sort_t {
__u32 pid;
__u64 tics;
__u16 cpu_mem_usage;
char state;
};
static struct option options[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"attach", no_argument, NULL, 'a'},
{"interval", required_argument, NULL, 'i'},
{NULL, 0, NULL, 0}
};
static const char opt_string[] = "+hvai:";
static const char help_text[] =
"mon_procd: Daemon that writes process data information\n"
"to the z/VM monitor stream.\n"
"\n"
"Usage: mon_procd [OPTIONS]\n"
"\n"
"Options:\n"
"-h, --help Print this help, then exit\n"
"-v, --version Print version information, then exit\n"
"-a, --attach Run in foreground\n"
"-i, --interval=<seconds> Sample interval\n"
"\n"
"Please report bugs to: linux390@de.ibm.com\n";
#endif
|