-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
sysinfo.cgi
executable file
·251 lines (213 loc) · 7.68 KB
/
sysinfo.cgi
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
#!/usr/local/bin/perl
#
# Authentic Theme (https://github.com/authentic-theme/authentic-theme)
# Copyright Ilia Rostovtsev <[email protected]>
# Licensed under MIT (https://github.com/authentic-theme/authentic-theme/blob/master/LICENSE)
#
use strict;
our (%in,
%gconfig,
%text,
$current_theme,
$config_directory,
$remote_user,
$title,
%theme_config,
%theme_text,
$get_user_level,
$has_virtualmin,
$has_usermin,
$has_usermin_version,
$has_usermin_conf_dir,
$theme_webprefix,
$trust_unknown_referers);
$trust_unknown_referers = 1;
do($ENV{'THEME_ROOT'} . "/authentic-lib.pl");
do($ENV{'THEME_ROOT'} . "/stats-lib-funcs.pl");
header($title, 'stripped');
print '<div class="container-fluid col-lg-10 col-lg-offset-1" data-dcontainer="1">' . "\n";
# Get system info to show
my @info = theme_list_combined_system_info();
my ($cpu_percent,
$mem_percent,
$virt_percent,
$disk_percent,
$host,
$os,
$webmin_version,
$virtualmin_version,
$cloudmin_version,
$authentic_theme_version,
$local_time,
$kernel_arch,
$cpu_type,
$cpu_temperature,
$cpu_fans,
$hdd_temperature,
$uptime,
$running_proc,
$load,
$real_memory,
$virtual_memory,
$disk_space,
$package_message,
$csf_title,
$csf_data,
$csf_remote_version,
$authentic_remote_version
) = get_sysinfo_vars(\@info);
if ($get_user_level ne '3') {
my $sysinfo = grep { $_->{'id'} eq 'sysinfo' } @info;
my @table_data;
# Hostname
if ($host) {
push @table_data, [theme_text('body_host'), $host, 'sysinfo_host'];
}
# Operating system
if ($os) {
push @table_data, [theme_text('body_os'), $os, 'sysinfo_os'];
}
# Webmin and Usermin versions
if ($webmin_version) {
push @table_data, [theme_text('body_webmin'), $webmin_version, 'sysinfo_webmin_version'];
# Usermin version
if ($has_usermin) {
push @table_data,
[theme_text('body_usermin'), product_version_update($has_usermin_version, 'u'), 'sysinfo_usermin_version'];
}
}
# Virtualmin version
if ($virtualmin_version) {
push @table_data, [$theme_text{'right_virtualmin'}, $virtualmin_version, 'sysinfo_virtualmin_version'];
}
# Cloudmin version
if ($cloudmin_version) {
push @table_data, [$theme_text{'right_vm2'}, $cloudmin_version, 'sysinfo_cloudmin_version'];
}
# Theme version
if ($authentic_theme_version) {
push @table_data, [$theme_text{'theme_version'}, $authentic_theme_version, 'sysinfo_authentic_theme_version'];
}
# ConfigServer Security & Firewall version
if ($csf_title && $csf_data) {
push @table_data, [$csf_title, $csf_data, 'sysinfo_csf_data'];
}
#System time
if ($local_time) {
push @table_data, [theme_text('body_time'), $local_time, 'sysinfo_local_time'];
}
# Kernel and arch
if ($kernel_arch) {
push @table_data, [theme_text('body_kernel'), $kernel_arch, 'sysinfo_kernel_arch'];
}
# CPU Type and cores
if ($cpu_type) {
push @table_data, [$theme_text{'body_cpuinfo'}, $cpu_type, 'sysinfo_cpu_type'];
}
# Temperatures
if ($cpu_temperature) {
my $cores = () = $cpu_temperature =~ /°/g;
my $label = $cores > 1 ? $theme_text{'body_cputemps'} : $theme_text{'body_cputemp'};
push @table_data, [$label, $cpu_temperature, 'sysinfo_cpu_temperature'];
if ($cpu_fans) {
my $fans = () = $cpu_fans =~ /$theme_text{'body_cpufan_rpm'}/g;
$label = $fans > 1 ? $theme_text{'body_cpufans'} : $theme_text{'body_cpufan'};
push @table_data, [$label, $cpu_fans, 'sysinfo_cpu_fans'];
}
}
if ($hdd_temperature) {
push @table_data, [$theme_text{'body_drivetemps'}, $hdd_temperature, 'sysinfo_hdd_temperature'];
}
# System uptime
if ($uptime) {
push @table_data, [$theme_text{'body_uptime'}, $uptime, 'sysinfo_uptime'];
}
# Running processes
if ($running_proc) {
push @table_data, [$theme_text{'body_procs'}, $running_proc, 'sysinfo_proc'];
}
# Load averages
if ($load) {
push @table_data, [$theme_text{'body_cpu'}, $load, 'sysinfo_cpu'];
}
# Real memory details
if ($real_memory) {
push @table_data, [$theme_text{'body_real'}, $real_memory, 'sysinfo_mem'];
}
# Virtual memory details
if ($virtual_memory) {
push @table_data, [$theme_text{'body_virt'}, $virtual_memory, 'sysinfo_virt'];
}
# Local disk space
if ($disk_space) {
push @table_data, [$theme_text{'body_disk'}, $disk_space, 'sysinfo_disk'];
}
# Package updates
if ($package_message) {
push @table_data, [$theme_text{'body_updates'}, $package_message, 'sysinfo_package_message'];
}
# Pre-load history data
print '<script type="text/javascript">vars.stats.history = ' .
convert_to_json(get_stats_history()) . ';</script>' . "\n"
if ($sysinfo && webmin_user_is_admin());
# Print system info table
if (@table_data) {
# Print sysinfo panel start
print_sysstats_panel_start(\@info)
if ($sysinfo);
# Easypie charts
if ($sysinfo && $theme_config{'settings_sysinfo_easypie_charts'} ne 'false') {
print_easypie_charts($cpu_percent, $mem_percent, $virt_percent, $disk_percent);
}
print '<table class="table table-hover margined-top-25"><tbody>' . "\n";
while (scalar(@table_data) > 0) {
my $left = shift(@table_data);
my $right = shift(@table_data);
print_table_row_responsive(@$left, @$right);
}
print '</tbody></table>' . "\n";
# Print System Warning
print get_sysinfo_warning(\@info) if ($sysinfo);
# Print sysinfo panel end
print_sysstats_panel_end() if ($sysinfo);
}
print get_extended_sysinfo(\@info, '-1');
print '<script type="text/javascript">typeof stats === "object" && stats.sys.preRender();</script>' . "\n" if ($sysinfo);
} else {
my @mailbox = grep {$_->{'module'} eq 'mailbox'} @info;
my @quota = grep {$_->{'module'} eq 'quota'} @info;
# Handle theme link if allowed
if (!defined($gconfig{'ui_show'}) || $gconfig{'ui_show'} =~ /\btver\b/) {
my $link =
{ desc => $theme_text{theme_version}, value => get_theme_user_link() };
foreach my $item (@mailbox) {
for (my $i = 0; $i < @{$item->{'table'}}; $i++) {
if ($item->{'table'}->[$i]->{'type'} =~ /^(version|time)$/) {
splice(@{$item->{'table'}}, $i + ($1 eq 'time' ? -1 : 1), 0, $link);
undef($link);
last;
}
}
}
push(@{$mailbox[0]->{'table'}}, $link) if ($link);
}
print_sysstats_panel_start();
print_sysstats_table(\@mailbox, \@quota);
print_sysstats_panel_end();
# Common modules
my @commonmods =
grep {&foreign_available($_)} ("filter", "changepass", "gnupg", "filemin", "mysql", "postgresql", "datastore");
my $commonmods_data = ui_table_start(undef, "data-class=\"no-inner-formatting\"", 2);
if (@commonmods) {
foreach my $mod (@commonmods) {
my %minfo = &get_module_info($mod);
$commonmods_data .=
ui_table_row($minfo{'desc'},
"<a href='$theme_webprefix/$mod/'>" . ($text{ 'common_' . $mod } || $minfo{'longdesc'}) . "</a>");
}
}
$commonmods_data .= ui_table_end();
print_panel(1, 'account_functions', $theme_text{'theme_left_mail_account_functions'}, ($commonmods_data));
}
print '</div>' . "\n";
footer('stripped');