1 | #ifndef SYSTEM_INFOS_H |
---|
2 | #define SYSTEM_INFOS_H |
---|
3 | |
---|
4 | void screensystem_infos(int mode) |
---|
5 | { |
---|
6 | char* tmpstr = NULL; |
---|
7 | int rcret = 0; |
---|
8 | struct skin* system_info = getscreen("system_infos"); |
---|
9 | struct skin* info = getscreennode(system_info, "info"); |
---|
10 | |
---|
11 | addscreenrc(system_info, info); |
---|
12 | |
---|
13 | if(mode == 0) |
---|
14 | { |
---|
15 | char* tmpstr1 = NULL, *tmpstr2 = NULL; |
---|
16 | |
---|
17 | changetitle(system_info, _("System Status")); |
---|
18 | |
---|
19 | tmpstr1 = ostrcat("Date = ", "", 0, 0); |
---|
20 | tmpstr1 = ostrcat(tmpstr1, gettime(NULL, "%d %B %Y"), 1, 1); |
---|
21 | tmpstr = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
22 | |
---|
23 | tmpstr1 = ostrcat("\nTime = ", "", 0, 0); |
---|
24 | tmpstr1 = ostrcat(tmpstr1, gettime(NULL, "%H:%M:%S"), 1, 1); |
---|
25 | tmpstr = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
26 | |
---|
27 | tmpstr1 = ostrcat("\nUptime = ", "", 0, 0); |
---|
28 | tmpstr2 = command("uptime"); |
---|
29 | if(tmpstr2 != NULL) tmpstr2 = strtok(tmpstr2, ","); |
---|
30 | tmpstr1 = ostrcat(tmpstr1, tmpstr2, 1, 1); |
---|
31 | tmpstr = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
32 | |
---|
33 | tmpstr1 = ostrcat("\nBoxtype = ", "", 0, 0); |
---|
34 | tmpstr2 = string_toupper(command("cat /etc/model")); |
---|
35 | tmpstr1 = ostrcat(tmpstr1, tmpstr2, 1, 1); |
---|
36 | tmpstr = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
37 | |
---|
38 | tmpstr1 = ostrcat("\nLoad = ", "", 0, 0); |
---|
39 | tmpstr2 = command("cat /proc/loadavg"); |
---|
40 | tmpstr1 = ostrcat(tmpstr1, tmpstr2, 1, 1); |
---|
41 | tmpstr = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
42 | |
---|
43 | changetext(info, tmpstr); |
---|
44 | free(tmpstr); tmpstr = NULL; |
---|
45 | } |
---|
46 | |
---|
47 | if(mode == 1) |
---|
48 | { |
---|
49 | changetitle(system_info, _("Free Space")); |
---|
50 | system("ls /media/usb/* >/dev/null"); |
---|
51 | system("ls /media/net/* >/dev/null"); |
---|
52 | system("ls /var/swap/* >/dev/null"); |
---|
53 | system("ls /mnt/swapextension/* >/dev/null"); |
---|
54 | system("ls /var/backup/* >/dev/null"); |
---|
55 | system("ls /media/hdd/* >/dev/null"); |
---|
56 | tmpstr = command("df -h"); |
---|
57 | changetext(info, tmpstr); |
---|
58 | |
---|
59 | free(tmpstr); tmpstr = NULL; |
---|
60 | } |
---|
61 | |
---|
62 | if(mode == 2) |
---|
63 | { |
---|
64 | changetitle(system_info, _("Kernel")); |
---|
65 | |
---|
66 | tmpstr = command("cat /proc/version"); |
---|
67 | changetext(info, tmpstr); |
---|
68 | |
---|
69 | free(tmpstr); tmpstr = NULL; |
---|
70 | } |
---|
71 | |
---|
72 | if(mode == 3) |
---|
73 | { |
---|
74 | changetitle(system_info, _("Mounts")); |
---|
75 | system("ls /media/usb/* >/dev/null"); |
---|
76 | system("ls /media/net/* >/dev/null"); |
---|
77 | system("ls /var/swap/* >/dev/null"); |
---|
78 | system("ls /mnt/swapextension/* >/dev/null"); |
---|
79 | system("ls /var/backup/* >/dev/null"); |
---|
80 | system("ls /media/hdd/* >/dev/null"); |
---|
81 | tmpstr = command("mount"); |
---|
82 | changetext(info, tmpstr); |
---|
83 | |
---|
84 | free(tmpstr); tmpstr = NULL; |
---|
85 | } |
---|
86 | |
---|
87 | if(mode == 4) |
---|
88 | { |
---|
89 | char* tmpstr1 = NULL, *tmpstr2 = NULL; |
---|
90 | |
---|
91 | changetitle(system_info, _("Network")); |
---|
92 | |
---|
93 | tmpstr = command("ifconfig"); |
---|
94 | tmpstr1 = command("route -n"); |
---|
95 | tmpstr2 = ostrcat(tmpstr, tmpstr1, 1, 1); |
---|
96 | changetext(info, tmpstr2); |
---|
97 | |
---|
98 | free(tmpstr2); tmpstr2 = NULL; |
---|
99 | } |
---|
100 | |
---|
101 | if(mode == 5) |
---|
102 | { |
---|
103 | changetitle(system_info, _("Ram")); |
---|
104 | |
---|
105 | tmpstr = command("free"); |
---|
106 | changetext(info, tmpstr); |
---|
107 | |
---|
108 | free(tmpstr); tmpstr = NULL; |
---|
109 | } |
---|
110 | |
---|
111 | drawscreen(system_info, 0, 0); |
---|
112 | |
---|
113 | while(1) |
---|
114 | { |
---|
115 | rcret = waitrc(system_info, 0, 0); |
---|
116 | |
---|
117 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
118 | if(rcret == getrcconfigint("rcok", NULL)) break; |
---|
119 | } |
---|
120 | |
---|
121 | delownerrc(system_info); |
---|
122 | clearscreen(system_info); |
---|
123 | //delscreen(system_info); |
---|
124 | } |
---|
125 | |
---|
126 | #endif |
---|