2018-09-14 21:07:55 +03:00
|
|
|
|
/*
|
|
|
|
|
* System Monitor
|
2022-01-07 01:02:02 +03:00
|
|
|
|
* version 1.41
|
2018-09-14 21:07:55 +03:00
|
|
|
|
* Author: Leency
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-06 02:18:43 +03:00
|
|
|
|
#define MEMSIZE 1024*60
|
2022-01-07 01:02:02 +03:00
|
|
|
|
//#define NO_DLL_INIT
|
2019-03-19 01:31:13 +03:00
|
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// LIB //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
2018-09-14 21:07:55 +03:00
|
|
|
|
|
|
|
|
|
#include "../lib/gui.h"
|
2018-09-15 13:48:42 +03:00
|
|
|
|
#include "../lib/fs.h"
|
2019-03-19 01:31:13 +03:00
|
|
|
|
#include "../lib/list_box.h"
|
2018-09-14 21:07:55 +03:00
|
|
|
|
|
2019-03-19 01:31:13 +03:00
|
|
|
|
#include "../lib/obj/box_lib.h"
|
2022-01-07 01:02:02 +03:00
|
|
|
|
#include "../lib/obj/libini.h"
|
2019-03-19 01:31:13 +03:00
|
|
|
|
|
|
|
|
|
#include "../lib/patterns/select_list.h"
|
|
|
|
|
#include "../lib/patterns/restart_process.h"
|
2018-09-14 21:07:55 +03:00
|
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
2020-11-29 03:37:47 +03:00
|
|
|
|
// CONST //
|
2018-09-14 21:07:55 +03:00
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define GAP 16 //Window padding
|
|
|
|
|
#define WIN_CONTENT_X GAP
|
|
|
|
|
#define WIN_CONTENT_Y GAP+15
|
|
|
|
|
#define PROCESS_LIST_W 260
|
|
|
|
|
#define RIGHT_X PROCESS_LIST_W + GAP + GAP + 22
|
2020-05-10 04:44:40 +03:00
|
|
|
|
#define ICONGAP 26
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define BOTPANEL_H 36
|
2018-09-14 21:07:55 +03:00
|
|
|
|
|
2020-05-10 04:44:40 +03:00
|
|
|
|
#ifdef LANG_RUS
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define T_APP_TITLE "<22><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#define T_SHOW_SYSTEM "<22><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD>"
|
|
|
|
|
#define T_DETAILS "<22><><EFBFBD><EFBFBD><E0AEA1><EFBFBD>"
|
|
|
|
|
#define T_PROC_KILL "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#define T_PROC_INFO "<22><><EFBFBD><EFBFBD>"
|
2022-01-06 02:18:43 +03:00
|
|
|
|
#define T_PROC_HEADER "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><> %"
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define T_CPU_LOAD "<22><><EFBFBD><EFBFBD>㧪<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %i%% "
|
|
|
|
|
#define T_RAM_USAGE "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>: %i <20><> <><E1A2AE><EFBFBD><EFBFBD><EFBFBD> <20><> %i <20><>"
|
|
|
|
|
#define T_RD_USAGE "<22><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20><><EFBFBD><EFBFBD>: %i <20><> <><E1A2AE><EFBFBD><EFBFBD><EFBFBD> <20><> 1.4 <20><>"
|
|
|
|
|
#define T_TMP_USAGE "TMP%i <20><><EFBFBD><EFBFBD>: %i <20><> <><E1A2AE><EFBFBD><EFBFBD><EFBFBD> <20><> %i <20><>"
|
2020-05-10 04:44:40 +03:00
|
|
|
|
#else
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define T_APP_TITLE "System Monitor"
|
|
|
|
|
#define T_SHOW_SYSTEM "System"
|
|
|
|
|
#define T_DETAILS "Details"
|
|
|
|
|
#define T_PROC_KILL "Terminate"
|
|
|
|
|
#define T_PROC_INFO "Info"
|
2022-01-06 02:18:43 +03:00
|
|
|
|
#define T_PROC_HEADER "Process RAM KB CPU %"
|
2020-11-29 03:37:47 +03:00
|
|
|
|
#define T_CPU_LOAD "CPU load %i%% "
|
2021-11-22 17:14:42 +03:00
|
|
|
|
#define T_RAM_USAGE "RAM usage: %i MB free of %i MB"
|
|
|
|
|
#define T_RD_USAGE "System disk usage: %i MB free of 1.4 MB"
|
|
|
|
|
#define T_TMP_USAGE "TMP%i usage: %i MB free of %i MB"
|
2020-05-10 04:44:40 +03:00
|
|
|
|
#endif
|
2018-09-15 13:48:42 +03:00
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
enum {
|
2022-01-06 02:18:43 +03:00
|
|
|
|
BTN_SHOW_SYSTEM_PROCESSES=200,
|
|
|
|
|
BTN_PROC_KILL,
|
|
|
|
|
BTN_PROC_INFO,
|
|
|
|
|
BTN_MENU,
|
|
|
|
|
BTN_SHOWHIDE_SENSORS
|
2020-11-29 03:37:47 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// VARS //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
|
|
int current_process_id = 0;
|
2022-01-07 01:02:02 +03:00
|
|
|
|
int proc_list[MAX_PROCESS_COUNT];
|
2020-11-29 03:37:47 +03:00
|
|
|
|
|
|
|
|
|
checkbox show_system = { T_SHOW_SYSTEM, false };
|
|
|
|
|
|
|
|
|
|
sensor cpu;
|
|
|
|
|
sensor ram;
|
|
|
|
|
sensor rd;
|
|
|
|
|
sensor tmp;
|
|
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
|
|
|
|
|
int right_w;
|
2020-05-10 04:44:40 +03:00
|
|
|
|
|
2022-01-07 01:02:02 +03:00
|
|
|
|
bool show_sensors;
|
|
|
|
|
|
|
|
|
|
_ini ini = { "/sys/settings/app.ini", "Sysmon" };
|
2022-01-06 02:18:43 +03:00
|
|
|
|
|
2020-05-10 04:44:40 +03:00
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
2020-11-29 03:37:47 +03:00
|
|
|
|
// CODE //
|
2020-05-10 04:44:40 +03:00
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
2018-09-14 21:07:55 +03:00
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
void main()
|
2018-09-14 21:07:55 +03:00
|
|
|
|
{
|
2020-11-29 03:37:47 +03:00
|
|
|
|
int btn;
|
2022-01-06 02:18:43 +03:00
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
2022-01-07 01:02:02 +03:00
|
|
|
|
load_dll(libini, #lib_init,1);
|
|
|
|
|
ReadIni();
|
2020-12-14 18:54:00 +03:00
|
|
|
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
2020-12-13 03:32:34 +03:00
|
|
|
|
loop() switch(@WaitEventTimeout(50))
|
2020-11-29 03:37:47 +03:00
|
|
|
|
{
|
2022-01-07 01:02:02 +03:00
|
|
|
|
case evMouse:
|
|
|
|
|
SelectList_ProcessMouse();
|
|
|
|
|
if (mouse.up) && (mouse.pkm) || (mouse.mkm) EventShowTinfo();
|
2020-11-29 03:37:47 +03:00
|
|
|
|
break;
|
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
2022-01-07 01:02:02 +03:00
|
|
|
|
switch(key_scancode) {
|
|
|
|
|
case SCAN_CODE_ESC:
|
|
|
|
|
EventExit();
|
|
|
|
|
case SCAN_CODE_DEL:
|
|
|
|
|
EventKillCurrentProcess();
|
|
|
|
|
break;
|
|
|
|
|
case SCAN_CODE_SPACE:
|
|
|
|
|
show_sensors ^= 1;
|
|
|
|
|
goto _DRAW_WINDOW;
|
|
|
|
|
case SCAN_CODE_ENTER:
|
|
|
|
|
EventShowTinfo();
|
|
|
|
|
break;
|
|
|
|
|
case SCAN_CODE_TAB:
|
|
|
|
|
show_system.checked ^= 1;
|
|
|
|
|
SelectList_LineChanged();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (select_list.ProcessKey(key_scancode)) {
|
|
|
|
|
SelectList_LineChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-29 03:37:47 +03:00
|
|
|
|
break;
|
|
|
|
|
case evButton:
|
2020-12-14 18:54:00 +03:00
|
|
|
|
btn = @GetButtonID();
|
2022-01-07 01:02:02 +03:00
|
|
|
|
if (1==btn) EventExit();
|
2020-11-29 03:37:47 +03:00
|
|
|
|
|
|
|
|
|
if (show_system.click(btn)) {
|
|
|
|
|
SelectList_LineChanged();
|
|
|
|
|
}
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (BTN_PROC_KILL == btn) {
|
2020-11-29 03:37:47 +03:00
|
|
|
|
EventKillCurrentProcess();
|
|
|
|
|
}
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (BTN_PROC_INFO == btn) {
|
2022-01-07 01:02:02 +03:00
|
|
|
|
EventShowTinfo();
|
2020-11-29 03:37:47 +03:00
|
|
|
|
}
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (BTN_SHOWHIDE_SENSORS == btn) {
|
|
|
|
|
show_sensors ^= 1;
|
|
|
|
|
GOTO _DRAW_WINDOW;
|
|
|
|
|
}
|
2020-11-29 03:37:47 +03:00
|
|
|
|
break;
|
|
|
|
|
case evReDraw:
|
|
|
|
|
sc.get();
|
2022-01-07 01:02:02 +03:00
|
|
|
|
DefineAndDrawWindow(Form.left, Form.top, Form.width, Form.height, 0x33, sc.work, T_APP_TITLE,0);
|
2022-01-06 02:18:43 +03:00
|
|
|
|
_DRAW_WINDOW:
|
2020-11-29 03:37:47 +03:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2021-06-26 10:59:13 +03:00
|
|
|
|
if (Form.status_window&ROLLED_UP) break;
|
2020-11-29 03:37:47 +03:00
|
|
|
|
if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; }
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (show_sensors) {
|
|
|
|
|
if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; }
|
|
|
|
|
} else {
|
|
|
|
|
if (Form.width != RIGHT_X+5) { MoveSize(OLD,OLD,RIGHT_X+5,OLD); break; }
|
|
|
|
|
}
|
2020-11-29 03:37:47 +03:00
|
|
|
|
right_w = Form.cwidth - RIGHT_X - GAP;
|
|
|
|
|
right_w &= ~1; // make sure the number is even
|
|
|
|
|
WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
|
|
|
|
|
|
2022-01-07 01:02:02 +03:00
|
|
|
|
DefineButton(RIGHT_X-38,WIN_CONTENT_Y-25,18,18,BTN_SHOWHIDE_SENSORS,sc.button);
|
2022-01-06 02:18:43 +03:00
|
|
|
|
DrawRectangle3D(RIGHT_X-38,WIN_CONTENT_Y-25,19,18,sc.work_graph,sc.work_light);
|
|
|
|
|
PutPixel(RIGHT_X-38+19,WIN_CONTENT_Y-25,sc.work_light);
|
|
|
|
|
EDX = "<\0>";
|
|
|
|
|
EDX += show_sensors * 2;
|
2022-01-07 01:02:02 +03:00
|
|
|
|
WriteText(RIGHT_X-38+5,WIN_CONTENT_Y-25+2,0x90,sc.button_text, EDX);
|
2022-01-06 02:18:43 +03:00
|
|
|
|
//EBX += 5 << 16;
|
|
|
|
|
//$int 64
|
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
//bool burger_active = false;
|
|
|
|
|
//if (menu_id == OPEN_FILE) burger_active = true;
|
2022-01-06 02:18:43 +03:00
|
|
|
|
//DrawTopPanelButton(BTN_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
|
|
|
|
|
SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W,
|
2021-06-24 23:42:19 +03:00
|
|
|
|
Form.cheight-BOTPANEL_H-WIN_CONTENT_Y);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
SelectList_DrawBorder();
|
|
|
|
|
|
|
|
|
|
DrawBar(select_list.x-2, select_list.y+select_list.h+2,
|
|
|
|
|
select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work);
|
|
|
|
|
DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5,
|
2022-01-06 02:18:43 +03:00
|
|
|
|
110,23,BTN_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5,
|
2022-01-06 02:18:43 +03:00
|
|
|
|
46,23,BTN_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
show_system.draw(GAP-1, select_list.y+select_list.h+10);
|
|
|
|
|
|
|
|
|
|
//WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds");
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (show_sensors) {
|
|
|
|
|
cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100);
|
|
|
|
|
ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23);
|
|
|
|
|
rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23);
|
|
|
|
|
}
|
2020-11-29 03:37:47 +03:00
|
|
|
|
default:
|
2020-12-13 03:32:34 +03:00
|
|
|
|
SelectList_LineChanged();
|
2022-01-06 02:18:43 +03:00
|
|
|
|
if (show_sensors) {
|
|
|
|
|
MonitorCpu();
|
|
|
|
|
MonitorRam();
|
|
|
|
|
MonitorRd();
|
|
|
|
|
MonitorTmp();
|
|
|
|
|
}
|
2020-11-29 03:37:47 +03:00
|
|
|
|
}
|
2018-09-14 21:07:55 +03:00
|
|
|
|
}
|
2019-03-19 01:31:13 +03:00
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
void EventKillCurrentProcess()
|
2020-05-10 04:44:40 +03:00
|
|
|
|
{
|
2020-11-29 03:37:47 +03:00
|
|
|
|
KillProcess(current_process_id);
|
|
|
|
|
pause(10);
|
|
|
|
|
SelectList_LineChanged();
|
2020-05-10 04:44:40 +03:00
|
|
|
|
}
|
2019-03-19 01:31:13 +03:00
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
void Processes__GetProcessList()
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
proc_info Process;
|
2020-05-10 04:44:40 +03:00
|
|
|
|
|
2020-11-29 03:37:47 +03:00
|
|
|
|
select_list.count=0;
|
|
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++)
|
|
|
|
|
{
|
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
|
if (Process.name)
|
|
|
|
|
{
|
|
|
|
|
for (j=0; j<11; j++) if (Process.name[j]!=' ') {
|
|
|
|
|
if (show_system.checked==false) {
|
|
|
|
|
//do not show system process
|
|
|
|
|
if (Process.name[0]=='@') break;
|
|
|
|
|
if (!strcmp(#Process.name, "IDLE")) break;
|
|
|
|
|
if (!strcmp(#Process.name, "OS")) break;
|
|
|
|
|
}
|
|
|
|
|
proc_list[select_list.count] = i;
|
|
|
|
|
select_list.count++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectList_DrawLine(dword i)
|
2020-05-10 04:44:40 +03:00
|
|
|
|
{
|
2020-12-09 15:43:36 +03:00
|
|
|
|
int posy, j, len;
|
|
|
|
|
char cpu_use[16], mem_use[16], mem_use_pretty[16];
|
2020-11-29 03:37:47 +03:00
|
|
|
|
dword bg_color;
|
|
|
|
|
proc_info Process;
|
|
|
|
|
static unsigned maxcpu;
|
|
|
|
|
if (!maxcpu) maxcpu = GetCpuFrequency();
|
|
|
|
|
|
|
|
|
|
GetProcessInfo(#Process, proc_list[i+select_list.first]);
|
|
|
|
|
|
|
|
|
|
posy = i *select_list.item_h + select_list.y;
|
|
|
|
|
if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0;
|
|
|
|
|
if (i+select_list.first == select_list.cur_y) {
|
|
|
|
|
current_process_id = Process.ID;
|
|
|
|
|
bg_color = 0x67CCEB;
|
|
|
|
|
}
|
|
|
|
|
DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color);
|
|
|
|
|
|
|
|
|
|
WriteText(GAP+5, posy+select_list.text_y, 0x90, 0, #Process.name);
|
|
|
|
|
|
2020-12-09 15:43:36 +03:00
|
|
|
|
if (Process.use_memory < 3670016000)
|
|
|
|
|
{
|
2020-11-29 03:37:47 +03:00
|
|
|
|
sprintf(#mem_use, "%i", Process.use_memory/1024);
|
2020-12-09 15:43:36 +03:00
|
|
|
|
len = strlen(#mem_use);
|
|
|
|
|
strcpy(#mem_use_pretty, " ");
|
|
|
|
|
|
|
|
|
|
for (j=1; j<=len; j++) {
|
|
|
|
|
EDI = sizeof(mem_use_pretty)-1-j - calc(j/4);
|
|
|
|
|
mem_use_pretty[EDI] = mem_use[len-j];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WriteText(GAP+109, posy+select_list.text_y, 0x90, 0x444444, #mem_use_pretty+16-9);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu);
|
|
|
|
|
if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8),
|
|
|
|
|
posy+select_list.text_y, 0x90, 0x444444, #cpu_use);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectList_LineChanged()
|
|
|
|
|
{
|
|
|
|
|
Processes__GetProcessList();
|
|
|
|
|
SelectList_Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorRd()
|
|
|
|
|
{
|
|
|
|
|
dword rdempty = malloc(1440*1024);
|
|
|
|
|
CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty");
|
|
|
|
|
free(rdempty);
|
2020-12-13 15:31:53 +03:00
|
|
|
|
rdempty = get_file_size("/rd/1/rdempty") / 1024;
|
2020-11-29 03:37:47 +03:00
|
|
|
|
DeleteFile("/rd/1/rdempty");
|
|
|
|
|
|
|
|
|
|
sprintf(#param, T_RD_USAGE, rdempty);
|
|
|
|
|
DrawIconWithText(RIGHT_X, rd.y - 25, 5, #param);
|
|
|
|
|
|
|
|
|
|
rd.draw_progress(rdempty * rd.w / 1440);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dword GetTmpDiskFreeSpace(int _id)
|
|
|
|
|
{
|
|
|
|
|
DIR_SIZE dir_size;
|
|
|
|
|
sprintf(#param, "/tmp%i/1", _id);
|
|
|
|
|
dir_size.get(#param);
|
|
|
|
|
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
|
|
|
|
|
dir_size.bytes /= 1024*1024; //convert to MiB
|
|
|
|
|
return dir_size.bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorTmp()
|
|
|
|
|
{
|
|
|
|
|
char text_status[64];
|
|
|
|
|
int i, yy=WIN_CONTENT_Y+300;
|
|
|
|
|
dword tmp_size[10];
|
|
|
|
|
dword free_space;
|
|
|
|
|
for (i=0; i<=9; i++)
|
|
|
|
|
{
|
2020-12-13 15:31:53 +03:00
|
|
|
|
get_file_size( sprintf(#param, "/tmp%i/1", i) );
|
|
|
|
|
if (EAX) {
|
|
|
|
|
tmp_size[i] = EAX / 1024 / 1024;
|
2020-11-29 03:37:47 +03:00
|
|
|
|
free_space = tmp_size[i] - GetTmpDiskFreeSpace(i);
|
|
|
|
|
sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]);
|
|
|
|
|
tmp.set_size(RIGHT_X, yy, right_w, 23);
|
|
|
|
|
tmp.draw_progress(free_space * right_w / tmp_size[i]);
|
|
|
|
|
DrawIconWithText(RIGHT_X, tmp.y - 25, 50, #text_status);
|
|
|
|
|
yy += 65;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawIconWithText(dword _x, _y, _icon, _title)
|
|
|
|
|
{
|
2021-12-18 18:21:21 +03:00
|
|
|
|
if (draw_icon_16w(_x, _y, _icon)) _x += ICONGAP;
|
|
|
|
|
WriteTextWithBg(_x, _y + 2, 0xD0, sc.work_text, _title, sc.work);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dword GetCpuLoad(dword max_h)
|
|
|
|
|
{
|
|
|
|
|
dword idle;
|
|
|
|
|
dword CPU_SEC = GetCpuFrequency() >> 20 + 1;
|
|
|
|
|
dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h;
|
|
|
|
|
|
|
|
|
|
EAX = IDLE_SEC;
|
|
|
|
|
EBX = CPU_SEC;
|
|
|
|
|
$cdq
|
|
|
|
|
$div ebx
|
|
|
|
|
idle = EAX;
|
|
|
|
|
|
|
|
|
|
return max_h - idle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pos=0;
|
|
|
|
|
void MonitorCpu()
|
|
|
|
|
{
|
|
|
|
|
static dword cpu_stack[1980*3];
|
|
|
|
|
int i;
|
|
|
|
|
if (!cpu.w) return;
|
|
|
|
|
|
|
|
|
|
cpu_stack[pos] = GetCpuLoad(cpu.h);
|
|
|
|
|
if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
|
|
|
|
|
|
|
|
|
|
sprintf(#param, T_CPU_LOAD, cpu_stack[pos]);
|
|
|
|
|
DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param);
|
|
|
|
|
|
2020-12-13 03:32:34 +03:00
|
|
|
|
#define LINEW 8
|
|
|
|
|
for (i=0; i<right_w; i+=LINEW) {
|
|
|
|
|
DrawBar(i+cpu.x, cpu.y, LINEW, cpu.h-cpu_stack[i], PROGRESS_BG);
|
|
|
|
|
DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, LINEW, cpu_stack[i], 0xDFA13B);
|
|
|
|
|
//DrawBar(i+LINEW+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG);
|
2020-11-29 03:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos++;
|
|
|
|
|
if (pos>=right_w) {
|
|
|
|
|
pos = right_w-1;
|
|
|
|
|
for (i=0; i<pos; i++) {
|
|
|
|
|
cpu_stack[i] = cpu_stack[i+1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorRam()
|
|
|
|
|
{
|
|
|
|
|
ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
|
|
|
|
|
sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024);
|
|
|
|
|
DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param);
|
|
|
|
|
}
|
2020-05-10 15:49:02 +03:00
|
|
|
|
|
2022-01-07 01:02:02 +03:00
|
|
|
|
void EventShowTinfo()
|
|
|
|
|
{
|
|
|
|
|
RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id)));
|
|
|
|
|
}
|
2020-05-10 15:49:02 +03:00
|
|
|
|
|
2022-01-07 01:02:02 +03:00
|
|
|
|
void ReadIni()
|
|
|
|
|
{
|
|
|
|
|
Form.left = ini.GetInt("x", screen.width/2 - 350);
|
|
|
|
|
Form.top = ini.GetInt("y", 100);
|
|
|
|
|
Form.width = ini.GetInt("w", 700);
|
|
|
|
|
Form.height = ini.GetInt("h", 490);
|
|
|
|
|
show_sensors = ini.GetInt("show_sensors", true);
|
|
|
|
|
show_system.checked = ini.GetInt("show_system", false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventExit()
|
|
|
|
|
{
|
|
|
|
|
ini.SetInt("x", Form.left);
|
|
|
|
|
ini.SetInt("y", Form.top);
|
|
|
|
|
ini.SetInt("w", Form.width);
|
|
|
|
|
ini.SetInt("h", Form.height);
|
|
|
|
|
ini.SetInt("show_sensors", show_sensors);
|
|
|
|
|
ini.SetInt("show_system", show_system.checked);
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|