Rev 8933 | Rev 8954 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8933 | Rev 8946 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * System Monitor |
2 | * System Monitor |
3 | * version 1.36 |
3 | * version 1.36 |
4 | * Author: Leency |
4 | * Author: Leency |
5 | */ |
5 | */ |
6 | 6 | ||
7 | #define MEMSIZE 4096*30 |
7 | #define MEMSIZE 4096*30 |
8 | 8 | ||
9 | #ifndef AUTOBUILD |
9 | #ifndef AUTOBUILD |
10 | #include "lang.h--" |
10 | #include "lang.h--" |
11 | #endif |
11 | #endif |
12 | 12 | ||
13 | //===================================================// |
13 | //===================================================// |
14 | // // |
14 | // // |
15 | // LIB // |
15 | // LIB // |
16 | // // |
16 | // // |
17 | //===================================================// |
17 | //===================================================// |
18 | 18 | ||
19 | #include "../lib/gui.h" |
19 | #include "../lib/gui.h" |
20 | #include "../lib/fs.h" |
20 | #include "../lib/fs.h" |
21 | #include "../lib/list_box.h" |
21 | #include "../lib/list_box.h" |
22 | 22 | ||
23 | #include "../lib/obj/libimg.h" |
23 | #include "../lib/obj/libimg.h" |
24 | #include "../lib/obj/box_lib.h" |
24 | #include "../lib/obj/box_lib.h" |
25 | 25 | ||
26 | #include "../lib/patterns/select_list.h" |
26 | #include "../lib/patterns/select_list.h" |
27 | #include "../lib/patterns/restart_process.h" |
27 | #include "../lib/patterns/restart_process.h" |
28 | 28 | ||
29 | //===================================================// |
29 | //===================================================// |
30 | // // |
30 | // // |
31 | // CONST // |
31 | // CONST // |
32 | // // |
32 | // // |
33 | //===================================================// |
33 | //===================================================// |
34 | 34 | ||
35 | #define GAP 16 //Window padding |
35 | #define GAP 16 //Window padding |
36 | #define WIN_CONTENT_X GAP |
36 | #define WIN_CONTENT_X GAP |
37 | #define WIN_CONTENT_Y GAP+15 |
37 | #define WIN_CONTENT_Y GAP+15 |
38 | #define PROCESS_LIST_W 260 |
38 | #define PROCESS_LIST_W 260 |
39 | #define RIGHT_X PROCESS_LIST_W + GAP + GAP + 22 |
39 | #define RIGHT_X PROCESS_LIST_W + GAP + GAP + 22 |
40 | #define ICONGAP 26 |
40 | #define ICONGAP 26 |
41 | #define BOTPANEL_H 36 |
41 | #define BOTPANEL_H 36 |
42 | 42 | ||
43 | #ifdef LANG_RUS |
43 | #ifdef LANG_RUS |
44 | #define T_APP_TITLE "¨áâ¥¬ë© ¬®¨â®à" |
44 | #define T_APP_TITLE "¨áâ¥¬ë© ¬®¨â®à" |
45 | #define T_SHOW_SYSTEM "¨á⥬ë¥" |
45 | #define T_SHOW_SYSTEM "¨á⥬ë¥" |
46 | #define T_DETAILS "®¤à®¡¥¥" |
46 | #define T_DETAILS "®¤à®¡¥¥" |
47 | #define T_PROC_KILL "ïâì § ¤ çã" |
47 | #define T_PROC_KILL "ïâì § ¤ çã" |
48 | #define T_PROC_INFO "ä®" |
48 | #define T_PROC_INFO "ä®" |
49 | #define T_PROC_HEADER "à®æ¥áá ¡ %" |
49 | #define T_PROC_HEADER "à®æ¥áá ¡ %" |
50 | #define T_CPU_LOAD " £à㧪 ¯à®æ¥áá®à %i%% " |
50 | #define T_CPU_LOAD " £à㧪 ¯à®æ¥áá®à %i%% " |
51 | #define T_RAM_USAGE " ¬ïâì : %i ¡ ᢮¡®¤® ¨§ %i ¡" |
51 | #define T_RAM_USAGE " ¬ïâì : %i ¡ ᢮¡®¤® ¨§ %i ¡" |
52 | #define T_RD_USAGE "¨áâ¥¬ë© ¤¨áª: %i ¡ ᢮¡®¤® ¨§ 1.4 ¡" |
52 | #define T_RD_USAGE "¨áâ¥¬ë© ¤¨áª: %i ¡ ᢮¡®¤® ¨§ 1.4 ¡" |
53 | #define T_TMP_USAGE "TMP%i ¤¨áª: %i ¡ ᢮¡®¤® ¨§ %i ¡" |
53 | #define T_TMP_USAGE "TMP%i ¤¨áª: %i ¡ ᢮¡®¤® ¨§ %i ¡" |
54 | #else |
54 | #else |
55 | #define T_APP_TITLE "System Monitor" |
55 | #define T_APP_TITLE "System Monitor" |
56 | #define T_SHOW_SYSTEM "System" |
56 | #define T_SHOW_SYSTEM "System" |
57 | #define T_DETAILS "Details" |
57 | #define T_DETAILS "Details" |
58 | #define T_PROC_KILL "Terminate" |
58 | #define T_PROC_KILL "Terminate" |
59 | #define T_PROC_INFO "Info" |
59 | #define T_PROC_INFO "Info" |
60 | #define T_PROC_HEADER "Process RAM Kb CPU %" |
60 | #define T_PROC_HEADER "Process RAM Kb CPU %" |
61 | #define T_CPU_LOAD "CPU load %i%% " |
61 | #define T_CPU_LOAD "CPU load %i%% " |
62 | #define T_RAM_USAGE "RAM usage: %i Mb free of %i Mb" |
62 | #define T_RAM_USAGE "RAM usage: %i Mb free of %i Mb" |
63 | #define T_RD_USAGE "System disk usage: %i Kb free of 1.4 Mb" |
63 | #define T_RD_USAGE "System disk usage: %i Kb free of 1.4 Mb" |
64 | #define T_TMP_USAGE "TMP%i usage: %i Mb free of %i Mb" |
64 | #define T_TMP_USAGE "TMP%i usage: %i Mb free of %i Mb" |
65 | #endif |
65 | #endif |
66 | 66 | ||
67 | enum { |
67 | enum { |
68 | BTN_ID_SHOW_SYSTEM_PROCESSES=200, |
68 | BTN_ID_SHOW_SYSTEM_PROCESSES=200, |
69 | BTN_ID_PROC_KILL, |
69 | BTN_ID_PROC_KILL, |
70 | BTN_ID_PROC_INFO, |
70 | BTN_ID_PROC_INFO, |
71 | BTN_ID_MENU |
71 | BTN_ID_MENU |
72 | }; |
72 | }; |
73 | 73 | ||
74 | //===================================================// |
74 | //===================================================// |
75 | // // |
75 | // // |
76 | // VARS // |
76 | // VARS // |
77 | // // |
77 | // // |
78 | //===================================================// |
78 | //===================================================// |
79 | 79 | ||
80 | int current_process_id = 0; |
80 | int current_process_id = 0; |
81 | int proc_list[256]; |
81 | int proc_list[256]; |
82 | 82 | ||
83 | checkbox show_system = { T_SHOW_SYSTEM, false }; |
83 | checkbox show_system = { T_SHOW_SYSTEM, false }; |
84 | 84 | ||
85 | sensor cpu; |
85 | sensor cpu; |
86 | sensor ram; |
86 | sensor ram; |
87 | sensor rd; |
87 | sensor rd; |
88 | sensor tmp; |
88 | sensor tmp; |
89 | 89 | ||
90 | proc_info Form; |
90 | proc_info Form; |
91 | 91 | ||
92 | int right_w; |
92 | int right_w; |
93 | 93 | ||
94 | //===================================================// |
94 | //===================================================// |
95 | // // |
95 | // // |
96 | // CODE // |
96 | // CODE // |
97 | // // |
97 | // // |
98 | //===================================================// |
98 | //===================================================// |
99 | 99 | ||
100 | void load_lib() |
100 | void load_lib() |
101 | { |
101 | { |
102 | load_dll(libimg, #libimg_init,1); |
102 | load_dll(libimg, #libimg_init,1); |
103 | load_dll(boxlib, #box_lib_init,0); |
103 | load_dll(boxlib, #box_lib_init,0); |
104 | } |
104 | } |
105 | 105 | ||
106 | void main() |
106 | void main() |
107 | { |
107 | { |
108 | int btn; |
108 | int btn; |
109 | load_lib(); |
109 | load_lib(); |
110 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
110 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
111 | loop() switch(@WaitEventTimeout(50)) |
111 | loop() switch(@WaitEventTimeout(50)) |
112 | { |
112 | { |
113 | case evMouse: |
113 | case evMouse: |
114 | SelectList_ProcessMouse(); |
114 | SelectList_ProcessMouse(); |
115 | break; |
115 | break; |
116 | case evKey: |
116 | case evKey: |
117 | GetKeys(); |
117 | GetKeys(); |
118 | if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
118 | if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
119 | if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess(); |
119 | if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess(); |
120 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
120 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
121 | break; |
121 | break; |
122 | case evButton: |
122 | case evButton: |
123 | btn = @GetButtonID(); |
123 | btn = @GetButtonID(); |
124 | if (1==btn) ExitProcess(); |
124 | if (1==btn) ExitProcess(); |
125 | 125 | ||
126 | if (show_system.click(btn)) { |
126 | if (show_system.click(btn)) { |
127 | SelectList_LineChanged(); |
127 | SelectList_LineChanged(); |
128 | } |
128 | } |
129 | if (BTN_ID_PROC_KILL == btn) { |
129 | if (BTN_ID_PROC_KILL == btn) { |
130 | EventKillCurrentProcess(); |
130 | EventKillCurrentProcess(); |
131 | } |
131 | } |
132 | if (BTN_ID_PROC_INFO == btn) { |
132 | if (BTN_ID_PROC_INFO == btn) { |
133 | RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); |
133 | RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); |
134 | } |
134 | } |
135 | break; |
135 | break; |
136 | case evReDraw: |
136 | case evReDraw: |
137 | sc.get(); |
137 | sc.get(); |
138 | DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0); |
138 | DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0); |
139 | GetProcessInfo(#Form, SelfInfo); |
139 | GetProcessInfo(#Form, SelfInfo); |
140 | if (Form.status_window>2) break; |
140 | if (Form.status_window&ROLLED_UP) break; |
141 | if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; } |
141 | if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; } |
142 | if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; } |
142 | if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; } |
143 | right_w = Form.cwidth - RIGHT_X - GAP; |
143 | right_w = Form.cwidth - RIGHT_X - GAP; |
144 | right_w &= ~1; // make sure the number is even |
144 | right_w &= ~1; // make sure the number is even |
145 | WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER); |
145 | WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER); |
146 | 146 | ||
147 | //bool burger_active = false; |
147 | //bool burger_active = false; |
148 | //if (menu_id == OPEN_FILE) burger_active = true; |
148 | //if (menu_id == OPEN_FILE) burger_active = true; |
149 | //DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active); |
149 | //DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active); |
150 | 150 | ||
151 | SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W, |
151 | SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W, |
152 | Form.cheight-BOTPANEL_H-WIN_CONTENT_Y); |
152 | Form.cheight-BOTPANEL_H-WIN_CONTENT_Y); |
153 | SelectList_DrawBorder(); |
153 | SelectList_DrawBorder(); |
154 | 154 | ||
155 | DrawBar(select_list.x-2, select_list.y+select_list.h+2, |
155 | DrawBar(select_list.x-2, select_list.y+select_list.h+2, |
156 | select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work); |
156 | select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work); |
157 | DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5, |
157 | DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5, |
158 | 110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL); |
158 | 110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL); |
159 | DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5, |
159 | DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5, |
160 | 46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO); |
160 | 46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO); |
161 | show_system.draw(GAP-1, select_list.y+select_list.h+10); |
161 | show_system.draw(GAP-1, select_list.y+select_list.h+10); |
162 | 162 | ||
163 | //WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds"); |
163 | //WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds"); |
164 | cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100); |
164 | cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100); |
165 | ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23); |
165 | ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23); |
166 | rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23); |
166 | rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23); |
167 | default: |
167 | default: |
168 | MonitorCpu(); |
168 | MonitorCpu(); |
169 | MonitorRam(); |
169 | MonitorRam(); |
170 | SelectList_LineChanged(); |
170 | SelectList_LineChanged(); |
171 | MonitorRd(); |
171 | MonitorRd(); |
172 | MonitorTmp(); |
172 | MonitorTmp(); |
173 | } |
173 | } |
174 | } |
174 | } |
175 | 175 | ||
176 | void EventKillCurrentProcess() |
176 | void EventKillCurrentProcess() |
177 | { |
177 | { |
178 | KillProcess(current_process_id); |
178 | KillProcess(current_process_id); |
179 | pause(10); |
179 | pause(10); |
180 | SelectList_LineChanged(); |
180 | SelectList_LineChanged(); |
181 | } |
181 | } |
182 | 182 | ||
183 | void Processes__GetProcessList() |
183 | void Processes__GetProcessList() |
184 | { |
184 | { |
185 | int i, j; |
185 | int i, j; |
186 | proc_info Process; |
186 | proc_info Process; |
187 | 187 | ||
188 | select_list.count=0; |
188 | select_list.count=0; |
189 | for (i=0; i |
189 | for (i=0; i |
190 | { |
190 | { |
191 | GetProcessInfo(#Process, i); |
191 | GetProcessInfo(#Process, i); |
192 | if (Process.name) |
192 | if (Process.name) |
193 | { |
193 | { |
194 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
194 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
195 | if (show_system.checked==false) { |
195 | if (show_system.checked==false) { |
196 | //do not show system process |
196 | //do not show system process |
197 | if (Process.name[0]=='@') break; |
197 | if (Process.name[0]=='@') break; |
198 | if (!strcmp(#Process.name, "IDLE")) break; |
198 | if (!strcmp(#Process.name, "IDLE")) break; |
199 | if (!strcmp(#Process.name, "OS")) break; |
199 | if (!strcmp(#Process.name, "OS")) break; |
200 | } |
200 | } |
201 | proc_list[select_list.count] = i; |
201 | proc_list[select_list.count] = i; |
202 | select_list.count++; |
202 | select_list.count++; |
203 | break; |
203 | break; |
204 | } |
204 | } |
205 | } |
205 | } |
206 | } |
206 | } |
207 | } |
207 | } |
208 | 208 | ||
209 | void SelectList_DrawLine(dword i) |
209 | void SelectList_DrawLine(dword i) |
210 | { |
210 | { |
211 | int posy, j, len; |
211 | int posy, j, len; |
212 | char cpu_use[16], mem_use[16], mem_use_pretty[16]; |
212 | char cpu_use[16], mem_use[16], mem_use_pretty[16]; |
213 | dword bg_color; |
213 | dword bg_color; |
214 | proc_info Process; |
214 | proc_info Process; |
215 | static unsigned maxcpu; |
215 | static unsigned maxcpu; |
216 | if (!maxcpu) maxcpu = GetCpuFrequency(); |
216 | if (!maxcpu) maxcpu = GetCpuFrequency(); |
217 | 217 | ||
218 | GetProcessInfo(#Process, proc_list[i+select_list.first]); |
218 | GetProcessInfo(#Process, proc_list[i+select_list.first]); |
219 | 219 | ||
220 | posy = i *select_list.item_h + select_list.y; |
220 | posy = i *select_list.item_h + select_list.y; |
221 | if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0; |
221 | if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0; |
222 | if (i+select_list.first == select_list.cur_y) { |
222 | if (i+select_list.first == select_list.cur_y) { |
223 | current_process_id = Process.ID; |
223 | current_process_id = Process.ID; |
224 | bg_color = 0x67CCEB; |
224 | bg_color = 0x67CCEB; |
225 | } |
225 | } |
226 | DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color); |
226 | DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color); |
227 | 227 | ||
228 | WriteText(GAP+5, posy+select_list.text_y, 0x90, 0, #Process.name); |
228 | WriteText(GAP+5, posy+select_list.text_y, 0x90, 0, #Process.name); |
229 | 229 | ||
230 | if (Process.use_memory < 3670016000) |
230 | if (Process.use_memory < 3670016000) |
231 | { |
231 | { |
232 | sprintf(#mem_use, "%i", Process.use_memory/1024); |
232 | sprintf(#mem_use, "%i", Process.use_memory/1024); |
233 | len = strlen(#mem_use); |
233 | len = strlen(#mem_use); |
234 | strcpy(#mem_use_pretty, " "); |
234 | strcpy(#mem_use_pretty, " "); |
235 | 235 | ||
236 | for (j=1; j<=len; j++) { |
236 | for (j=1; j<=len; j++) { |
237 | EDI = sizeof(mem_use_pretty)-1-j - calc(j/4); |
237 | EDI = sizeof(mem_use_pretty)-1-j - calc(j/4); |
238 | mem_use_pretty[EDI] = mem_use[len-j]; |
238 | mem_use_pretty[EDI] = mem_use[len-j]; |
239 | } |
239 | } |
240 | 240 | ||
241 | WriteText(GAP+109, posy+select_list.text_y, 0x90, 0x444444, #mem_use_pretty+16-9); |
241 | WriteText(GAP+109, posy+select_list.text_y, 0x90, 0x444444, #mem_use_pretty+16-9); |
242 | } |
242 | } |
243 | 243 | ||
244 | sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu); |
244 | sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu); |
245 | if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8), |
245 | if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8), |
246 | posy+select_list.text_y, 0x90, 0x444444, #cpu_use); |
246 | posy+select_list.text_y, 0x90, 0x444444, #cpu_use); |
247 | } |
247 | } |
248 | 248 | ||
249 | void SelectList_LineChanged() |
249 | void SelectList_LineChanged() |
250 | { |
250 | { |
251 | Processes__GetProcessList(); |
251 | Processes__GetProcessList(); |
252 | SelectList_Draw(); |
252 | SelectList_Draw(); |
253 | } |
253 | } |
254 | 254 | ||
255 | void MonitorRd() |
255 | void MonitorRd() |
256 | { |
256 | { |
257 | dword rdempty = malloc(1440*1024); |
257 | dword rdempty = malloc(1440*1024); |
258 | CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty"); |
258 | CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty"); |
259 | free(rdempty); |
259 | free(rdempty); |
260 | rdempty = get_file_size("/rd/1/rdempty") / 1024; |
260 | rdempty = get_file_size("/rd/1/rdempty") / 1024; |
261 | DeleteFile("/rd/1/rdempty"); |
261 | DeleteFile("/rd/1/rdempty"); |
262 | 262 | ||
263 | sprintf(#param, T_RD_USAGE, rdempty); |
263 | sprintf(#param, T_RD_USAGE, rdempty); |
264 | DrawIconWithText(RIGHT_X, rd.y - 25, 5, #param); |
264 | DrawIconWithText(RIGHT_X, rd.y - 25, 5, #param); |
265 | 265 | ||
266 | rd.draw_progress(rdempty * rd.w / 1440); |
266 | rd.draw_progress(rdempty * rd.w / 1440); |
267 | } |
267 | } |
268 | 268 | ||
269 | dword GetTmpDiskFreeSpace(int _id) |
269 | dword GetTmpDiskFreeSpace(int _id) |
270 | { |
270 | { |
271 | DIR_SIZE dir_size; |
271 | DIR_SIZE dir_size; |
272 | sprintf(#param, "/tmp%i/1", _id); |
272 | sprintf(#param, "/tmp%i/1", _id); |
273 | dir_size.get(#param); |
273 | dir_size.get(#param); |
274 | dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size |
274 | dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size |
275 | dir_size.bytes /= 1024*1024; //convert to MiB |
275 | dir_size.bytes /= 1024*1024; //convert to MiB |
276 | return dir_size.bytes; |
276 | return dir_size.bytes; |
277 | } |
277 | } |
278 | 278 | ||
279 | void MonitorTmp() |
279 | void MonitorTmp() |
280 | { |
280 | { |
281 | char text_status[64]; |
281 | char text_status[64]; |
282 | int i, yy=WIN_CONTENT_Y+300; |
282 | int i, yy=WIN_CONTENT_Y+300; |
283 | dword tmp_size[10]; |
283 | dword tmp_size[10]; |
284 | dword free_space; |
284 | dword free_space; |
285 | for (i=0; i<=9; i++) |
285 | for (i=0; i<=9; i++) |
286 | { |
286 | { |
287 | get_file_size( sprintf(#param, "/tmp%i/1", i) ); |
287 | get_file_size( sprintf(#param, "/tmp%i/1", i) ); |
288 | if (EAX) { |
288 | if (EAX) { |
289 | tmp_size[i] = EAX / 1024 / 1024; |
289 | tmp_size[i] = EAX / 1024 / 1024; |
290 | free_space = tmp_size[i] - GetTmpDiskFreeSpace(i); |
290 | free_space = tmp_size[i] - GetTmpDiskFreeSpace(i); |
291 | sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]); |
291 | sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]); |
292 | tmp.set_size(RIGHT_X, yy, right_w, 23); |
292 | tmp.set_size(RIGHT_X, yy, right_w, 23); |
293 | tmp.draw_progress(free_space * right_w / tmp_size[i]); |
293 | tmp.draw_progress(free_space * right_w / tmp_size[i]); |
294 | DrawIconWithText(RIGHT_X, tmp.y - 25, 50, #text_status); |
294 | DrawIconWithText(RIGHT_X, tmp.y - 25, 50, #text_status); |
295 | yy += 65; |
295 | yy += 65; |
296 | } |
296 | } |
297 | } |
297 | } |
298 | } |
298 | } |
299 | 299 | ||
300 | void DrawIconWithText(dword _x, _y, _icon, _title) |
300 | void DrawIconWithText(dword _x, _y, _icon, _title) |
301 | { |
301 | { |
302 | int size = DrawIcon16(_x, _y, sc.work, _icon); |
302 | int size = DrawIcon16(_x, _y, sc.work, _icon); |
303 | WriteTextWithBg(_x+ICONGAP, _y + size - 16, 0xD0, sc.work_text, _title, sc.work); |
303 | WriteTextWithBg(_x+ICONGAP, _y + size - 16, 0xD0, sc.work_text, _title, sc.work); |
304 | } |
304 | } |
305 | 305 | ||
306 | dword GetCpuLoad(dword max_h) |
306 | dword GetCpuLoad(dword max_h) |
307 | { |
307 | { |
308 | dword idle; |
308 | dword idle; |
309 | dword CPU_SEC = GetCpuFrequency() >> 20 + 1; |
309 | dword CPU_SEC = GetCpuFrequency() >> 20 + 1; |
310 | dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h; |
310 | dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h; |
311 | 311 | ||
312 | EAX = IDLE_SEC; |
312 | EAX = IDLE_SEC; |
313 | EBX = CPU_SEC; |
313 | EBX = CPU_SEC; |
314 | $cdq |
314 | $cdq |
315 | $div ebx |
315 | $div ebx |
316 | idle = EAX; |
316 | idle = EAX; |
317 | 317 | ||
318 | return max_h - idle; |
318 | return max_h - idle; |
319 | } |
319 | } |
320 | 320 | ||
321 | int pos=0; |
321 | int pos=0; |
322 | void MonitorCpu() |
322 | void MonitorCpu() |
323 | { |
323 | { |
324 | static dword cpu_stack[1980*3]; |
324 | static dword cpu_stack[1980*3]; |
325 | int i; |
325 | int i; |
326 | if (!cpu.w) return; |
326 | if (!cpu.w) return; |
327 | 327 | ||
328 | cpu_stack[pos] = GetCpuLoad(cpu.h); |
328 | cpu_stack[pos] = GetCpuLoad(cpu.h); |
329 | if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2; |
329 | if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2; |
330 | 330 | ||
331 | sprintf(#param, T_CPU_LOAD, cpu_stack[pos]); |
331 | sprintf(#param, T_CPU_LOAD, cpu_stack[pos]); |
332 | DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param); |
332 | DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param); |
333 | 333 | ||
334 | #define LINEW 8 |
334 | #define LINEW 8 |
335 | for (i=0; i |
335 | for (i=0; i |
336 | DrawBar(i+cpu.x, cpu.y, LINEW, cpu.h-cpu_stack[i], PROGRESS_BG); |
336 | DrawBar(i+cpu.x, cpu.y, LINEW, cpu.h-cpu_stack[i], PROGRESS_BG); |
337 | DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, LINEW, cpu_stack[i], 0xDFA13B); |
337 | DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, LINEW, cpu_stack[i], 0xDFA13B); |
338 | //DrawBar(i+LINEW+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG); |
338 | //DrawBar(i+LINEW+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG); |
339 | } |
339 | } |
340 | 340 | ||
341 | pos++; |
341 | pos++; |
342 | if (pos>=right_w) { |
342 | if (pos>=right_w) { |
343 | pos = right_w-1; |
343 | pos = right_w-1; |
344 | for (i=0; i |
344 | for (i=0; i |
345 | cpu_stack[i] = cpu_stack[i+1]; |
345 | cpu_stack[i] = cpu_stack[i+1]; |
346 | } |
346 | } |
347 | } |
347 | } |
348 | } |
348 | } |
349 | 349 | ||
350 | void MonitorRam() |
350 | void MonitorRam() |
351 | { |
351 | { |
352 | ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM()); |
352 | ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM()); |
353 | sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024); |
353 | sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024); |
354 | DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param); |
354 | DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param); |
355 | }=2)>=9;>=len;>>11;>>> |
355 | }=2)>=9;>=len;>>11;>>> |