libsysactivity 0.6.2
|
00001 /* 00002 * libsysactivity 00003 * http://sourceforge.net/projects/libsysactivity/ 00004 * Copyright (c) 2009, 2010 Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00025 #ifndef SA_PROCESS_H_ 00026 #define SA_PROCESS_H_ 00027 00028 #include <sys/types.h> 00029 00033 SA_EXPORT enum sa_process_state { 00034 SA_UNKNOWN = 0, 00035 SA_RUNNING = 1, 00036 SA_SLEEPING = 2, 00037 SA_SLEEPING_UNINTERRUPTIBLE = 3, 00038 SA_ZOMBIE = 4, 00039 SA_STOPPED = 5, 00040 }; 00041 00045 SA_EXPORT struct sa_process_activity { 00046 #ifdef SA_PROCESS_PID 00047 pid_t pid; 00048 #endif 00049 #ifdef SA_PROCESS_STATE 00050 enum sa_process_state state; 00051 #endif 00052 #ifdef SA_PROCESS_USER_TIME // TODO Explain these better 00053 uint64_t user_time; 00054 #endif 00055 #ifdef SA_PROCESS_SYS_TIME 00056 uint64_t sys_time; 00057 #endif 00058 #ifdef SA_PROCESS_THREADS 00059 uint32_t threads; 00060 #endif 00061 #ifdef SA_PROCESS_VM_SIZE 00062 uint32_t vm_size; 00063 #endif 00064 #ifdef SA_PROCESS_RSS 00065 uint32_t rss; 00066 #endif 00067 }; 00068 00072 SA_EXPORT struct sa_process { 00073 #ifdef SA_PROCESS_PID 00074 pid_t pid; 00075 #endif 00076 #ifdef SA_PROCESS_UID 00077 uid_t uid; 00078 #endif 00079 #ifdef SA_PROCESS_GID 00080 gid_t gid; 00081 #endif 00082 #ifdef SA_PROCESS_FILENAME 00083 char filename[SA_PROCESS_FILENAME]; 00084 #endif 00085 #ifdef SA_PROCESS_CMDLINE 00086 char cmdline[SA_PROCESS_CMDLINE]; 00087 #endif 00088 #ifdef SA_PROCESS_PARENT_PID 00089 pid_t parent_pid; 00090 #endif 00091 #ifdef SA_PROCESS_PGRP 00092 pid_t pgrp; 00093 #endif 00094 #ifdef SA_PROCESS_SID 00095 pid_t sid; 00096 #endif 00097 #ifdef SA_PROCESS_TTY 00098 pid_t tty; 00099 #endif 00100 #ifdef SA_PROCESS_NICE 00101 int8_t nice; 00102 #endif 00103 #ifdef SA_PROCESS_START_TIME 00104 uint64_t start_time; 00105 #endif 00106 struct sa_process_activity activity; 00107 }; 00108 00109 #ifdef SA_OPEN_PROCESS 00110 00115 int sa_open_process() SA_EXPORT; 00116 #endif 00117 00118 #ifdef SA_CLOSE_PROCESS 00119 00124 int sa_close_process() SA_EXPORT; 00125 #endif 00126 00132 int sa_count_processes(uint32_t* number) SA_EXPORT SA_NONNULL; 00133 00142 int sa_get_processes_ids(pid_t* dst, uint32_t dst_size, uint32_t* written) SA_EXPORT SA_NONNULL; 00143 00150 int sa_get_process(pid_t pid, struct sa_process* dst) SA_EXPORT SA_NONNULL; 00151 00159 int sa_get_process_activity(pid_t pid, struct sa_process_activity* dst) SA_EXPORT SA_NONNULL; 00160 00162 #endif /* SA_PROCESS_H_ */