Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c9dfaf37488118913eec28bc42f18e73c29d9b00 (plain) (blame)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
/*******************************************************************************
 * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tm.tcf.services;

import java.util.Map;

import org.eclipse.tm.tcf.protocol.IService;
import org.eclipse.tm.tcf.protocol.IToken;


/**
 * This is optional service that can be implemented by a peer.
 * If implemented, the service can be used for monitoring system activity and utilization.
 * It provides list of running processes, different process attributes like command line, environment, etc.,
 * and some resource utilization data. The service can be used by a client to provide functionality
 * similar to Unix 'top' utility or Windows 'Task Manager'.
 */
public interface ISysMonitor extends IService {

   static final String NAME = "SysMonitor";

    /**
     * Retrieve context info for given context ID.
     *
     * @param id – context ID.
     * @param done - callback interface called when operation is completed.
     */
    IToken getContext(String id, DoneGetContext done);

    /**
     * Client callback interface for getContext().
     */
    interface DoneGetContext {
        /**
         * Called when context data retrieval is done.
         * @param error – error description if operation failed, null if succeeded.
         * @param context – context data.
         */
        void doneGetContext(IToken token, Exception error, SysMonitorContext context);
    }

    /**
     * Retrieve children of given context.
     *
     * @param parent_context_id – parent context ID. Can be null –
     * to retrieve top level of the hierarchy, or one of context IDs retrieved
     * by previous getContext or getChildren commands.
     * @param done - callback interface called when operation is completed.
     */
    IToken getChildren(String parent_context_id, DoneGetChildren done);

    /**
     * Client callback interface for getChildren().
     */
    interface DoneGetChildren {
        /**
         * Called when context list retrieval is done.
         * @param error – error description if operation failed, null if succeeded.
         * @param context_ids – array of available context IDs.
         */
        void doneGetChildren(IToken token, Exception error, String[] context_ids);
    }

    /**
     * Context property names.
     */
    static final String
        /** The TCF context ID */
        PROP_ID = "ID",

        /** The TCF parent context ID */
        PROP_PARENTID = "ParentID",

        /** Current working directory of the process */
        PROP_CWD = "CWD",

        /** The process's root directory (as set by chroot) */
        PROP_ROOT = "Root",

        /** User ID of the process owner */
        PROP_UID = "UID",

        /** Group ID of the process owner */
        PROP_UGID = "UGID",

        /** User name of the process owner */
        PROP_USERNAME = "UserName",

        /** Group name of the process owner */
        PROP_GROUPNAME = "GroupName",

        /** System process ID */
        PROP_PID = "PID",

        /** Executable file of the process */
        PROP_FILE = "File",

        /** One character from the string "RSDZTW"  where  R  is  running,  S  is
         *  sleeping  in  an  interruptible wait, D is waiting in uninterruptible
         *  disk sleep, Z is zombie, T is traced or stopped (on a signal), and  W
         *  is paging.*/
        PROP_STATE = "State",

        /** System ID of the parent process */
        PROP_PPID = "PPID",

        /** The process group ID of the process */
        PROP_PGRP = "PGRP",

        /** The session ID of the process */
        PROP_SESSION = "Session",

        /** The tty the process uses */
        PROP_TTY = "TTY",

        /** The process group ID of the process which currently owns the tty that
         *  the process is connected to. */
        PROP_TGID = "TGID",

        /** ID of a process that has attached this process for tracing or debugging */
        PROP_TRACERPID = "TracerPID",

        /** The kernel flags word of the process. Details depend on the kernel */
        PROP_FLAGS = "Flags",

        /** The  number  of  minor  faults  the  process  has made which have not
         *  required loading a memory page from disk */
        PROP_MINFLT = "MinFlt",

        /** The number of minor faults that  the  process's  waited-for  children have made */
        PROP_CMINFLT = "CMinFlt",

        /** The  number  of major faults the process has made which have required
         *  loading a memory page from disk */
        PROP_MAJFLT = "MajFlt",

        /** The number of major faults that  the  process's  waited-for  children
         *  have made */
        PROP_CMAJFLT = "CMajFlt",

        /** The number of milliseconds that this process has been scheduled in user mode */
        PROP_UTIME = "UTime",

        /** The number of milliseconds that this process has been scheduled in kernel mode */
        PROP_STIME = "STime",

        /** The  number  of  jiffies that this process's waited-for children have
         *  been scheduled in user mode */
        PROP_CUTIME = "CUTime",

        /** The  number  of  jiffies that this process's waited-for children have
         *  been scheduled in user mode */
        PROP_CSTIME = "CSTime",

        /** The standard nice value */
        PROP_PRIORITY = "Priority",

        /** The nice value */
        PROP_NICE = "Nice",

        /** The time in milliseconds before the next SIGALRM is sent  to  the  process
         *  due to an interval timer */
        PROP_ITREALVALUE = "ITRealValue",

        /** The time in milliseconds the process started after system boot */
        PROP_STARTTIME = "StartTime",

        /** Virtual memory size in bytes */
        PROP_VSIZE = "VSize",

        /** Memory pages size in bytes */
        PROP_PSIZE = "PSize",

        /** Resident  Set  Size:  number of pages the process has in real memory,
         *  minus used for administrative purposes. This is  just  the  pages  which
         *  count  towards  text,  data,  or  stack space.  This does not include
         *  pages which have not been demand-loaded in, or which are swapped out */
        PROP_RSS = "RSS",

        /** Current  limit in bytes on the rss of the process */
        PROP_RLIMIT = "RLimit",

        /** The address above which program text can run */
        PROP_CODESTART = "CodeStart",

        /** The address below which program text can run */
        PROP_CODEEND = "CodeEnd",

        /** The address of the start of the stack */
        PROP_STACKSTART = "StackStart",

        /** The bitmap of pending signals */
        PROP_SIGNALS = "Signals",

        /** The bitmap of blocked signals */
        PROP_SIGBLOCK = "SigBlock",

        /** The bitmap of ignored signals */
        PROP_SIGIGNORE = "SigIgnore",

        /** The bitmap of caught signals */
        PROP_SIGCATCH = "SigCatch",

        /** This  is  the  "channel"  in which the process is waiting.  It is the
         *  address of a system call, and can be looked up in a name list  if  you
         *  need  a  textual  name */
        PROP_WCHAN = "WChan",

        /** Number of pages swapped */
        PROP_NSWAP = "NSwap",

        /** Cumulative NSwap for child processes */
        PROP_CNSWAP = "CNSwap",

        /** Signal to be sent to parent when this process exits */
        PROP_EXITSIGNAL = "ExitSignal",

        /** CPU number last executed on */
        PROP_PROCESSOR = "Processor",

        /** Real-time scheduling priority */
        PROP_RTPRIORITY = "RTPriority",

        /** Scheduling policy */
        PROP_POLICY = "Policy";


    /**
     * A context corresponds to an execution thread, process, address space, etc.
     * A context can belong to a parent context. Contexts hierarchy can be simple
     * plain list or it can form a tree. It is up to target agent developers to choose
     * layout that is most descriptive for a given target. Context IDs are valid across
     * all services. In other words, all services access same hierarchy of contexts,
     * with same IDs, however, each service accesses its own subset of context's
     * attributes and functionality, which is relevant to that service.
     */
    interface SysMonitorContext {

        /**
         * Get context ID.
         * Same as getProperties().get(“ID”)
         */
        String getID();

        /**
         * Get parent context ID.
         * Same as getProperties().get(“ParentID”)
         */
        String getParentID();

        /**
         * Get process group ID.
         * Same as getProperties().get(“PGRP”)
         */
        long getPGRP();

        /**
         * Get process ID.
         * Same as getProperties().get(“PID”)
         */
        long getPID();

        /**
         * Get process parent ID.
         * Same as getProperties().get(“PPID”)
         */
        long getPPID();

        /**
         * Get process TTY group ID.
         * Same as getProperties().get(“TGID”)
         */
        long getTGID();

        /**
         * Get tracer process ID.
         * Same as getProperties().get(“TracerPID”)
         */
        long getTracerPID();

        /**
         * Get process owner user ID.
         * Same as getProperties().get(“UID”)
         */
        long getUID();

        /**
         * Get process owner user name.
         * Same as getProperties().get(“UserName”)
         */
        String getUserName();

        /**
         * Get process owner user group ID.
         * Same as getProperties().get(“UGID”)
         */
        long getUGID();

        /**
         * Get process owner user group name.
         * Same as getProperties().get(“GroupName”)
         */
        String getGroupName();

        /**
         * Get process state.
         * Same as getProperties().get(“State”)
         */
        String getState();

        /**
         * Get process virtual memory size in bytes.
         * Same as getProperties().get(“VSize”)
         */
        long getVSize();

        /**
         * Get process virtual memory page size in bytes.
         * Same as getProperties().get(“PSize”)
         */
        long getPSize();

        /**
         * Get number of memory pages in process resident set.
         * Same as getProperties().get(“RSS”)
         */
        long getRSS();

        /**
         * Get context executable file.
         * Same as getProperties().get(“File”)
         */
        String getFile();

        /**
         * Get context current file system root.
         * Same as getProperties().get(“Root”)
         */
        String getRoot();

        /**
         * Get context current working directory.
         * Same as getProperties().get(“CWD”)
         */
        String getCurrentWorkingDirectory();

        /**
         * Get all available context properties.
         * @return Map 'property name' -> 'property value'
         */
        Map<String,Object> getProperties();
    }

    /**
     * Get context command line.
     */
    IToken getCommandLine(String id, DoneGetCommandLine done);

    interface DoneGetCommandLine {
        void doneGetCommandLine(IToken token, Exception error, String[] cmd_line);
    }

    /**
     * Get context environment variables.
     */
    IToken getEnvironment(String id, DoneGetEnvironment done);

    interface DoneGetEnvironment {
        void doneGetEnvironment(IToken token, Exception error, String[] environment);
    }
}

Back to the top