Project

General

Profile

« Previous | Next » 

Revision 804f6a16

Added by Jim Pingle over 8 years ago

Sync up status.php with master, but keep the 2.3/10.3-specific parts. Fixes #7246

View differences:

src/usr/local/www/status.php
70 70
/* include all configuration functions */
71 71
require_once("guiconfig.inc");
72 72
require_once("functions.inc");
73
require_once("gwlb.inc");
73 74
$output_path = "/tmp/status_output/";
74 75
$output_file = "/tmp/status_output.tgz";
75 76

  
......
80 81
unlink_if_exists($output_file);
81 82
mkdir($output_path);
82 83

  
83
function doCmdT($title, $command) {
84
function doCmdT($title, $command, $method) {
84 85
	global $output_path, $output_file;
85 86
	/* Fixup output directory */
86 87

  
......
134 135
		$ofd = @fopen("{$output_path}/{$title}.txt", "w");
135 136
		$execOutput = "";
136 137
		$execStatus = "";
137
		exec ($command . " 2>&1", $execOutput, $execStatus);
138
		if ($method == "exec") {
139
			exec($command . " 2>&1", $execOutput, $execStatus);
140
		} elseif ($method == "php_func") {
141
			$execOutput = explode("\n", $command());
142
		}
138 143
		for ($i = 0; isset($execOutput[$i]); $i++) {
139 144
			if ($i > 0) {
140 145
				echo "\n";
......
151 156
}
152 157

  
153 158
/* Define a command, with a title, to be executed later. */
154
function defCmdT($title, $command) {
159
function defCmdT($title, $command, $method = "exec") {
155 160
	global $commands;
156 161
	$title = htmlspecialchars($title, ENT_NOQUOTES);
157
	$commands[] = array($title, $command);
162
	$commands[] = array($title, $command, $method);
158 163
}
159 164

  
160 165
/* List all of the commands as an index. */
......
165 170
	$rubbish = array('|', '-', '/', '.', ' ');	/* fixes the <a> tag to be W3C compliant */
166 171

  
167 172
	print('<div class="panel panel-default">');
168
	print('<div class="panel-heading"><h2 class="panel-title">' . gettext("System Status on ") . $currentDate . '</h2></div>');
173
	print('<div class="panel-heading"><h2 class="panel-title">' . sprintf(gettext("Firewall Status on %s"), $currentDate) . '</h2></div>');
169 174
	print('<div class="panel-body">');
170 175
	print('    <div class="content">');
171 176
	print("\n<p>" . gettext("This status page includes the following information") . ":\n");
......
184 189
function execCmds() {
185 190
	global $commands;
186 191
	for ($i = 0; isset($commands[$i]); $i++) {
187
		doCmdT($commands[$i][0], $commands[$i][1]);
192
		doCmdT($commands[$i][0], $commands[$i][1], $commands[$i][2]);
188 193
	}
189 194
}
190 195

  
196
function get_firewall_info() {
197
	global $g, $output_path;
198
	/* Firewall Platform/Serial */
199
	$firewall_info = "Product Name: " . htmlspecialchars($g['product_name']);
200
	$platform = system_identify_specific_platform();
201
	if (!empty($platform['descr'])) {
202
		$firewall_info .= "<br/>Platform: " . htmlspecialchars($platform['descr']);
203
	}
204
	$serial = system_get_serial();
205
	if (!empty($serial)) {
206
		$firewall_info .= "<br/>SN/UUID: " . htmlspecialchars($serial);
207
	}
208

  
209
	if (!empty($g['product_version_string'])) {
210
		$firewall_info .= "<br/>" . htmlspecialchars($g['product_name']) .
211
		    " version: " . htmlspecialchars($g['product_version_string']);
212
	}
213

  
214
	if (file_exists('/etc/version.buildtime')) {
215
		$build_time = file_get_contents('/etc/version.buildtime');
216
		if (!empty($build_time)) {
217
			$firewall_info .= "<br/>Built On: " . htmlspecialchars($build_time);
218
		}
219
	}
220
	if (file_exists('/etc/version.lastcommit')) {
221
		$build_commit = file_get_contents('/etc/version.lastcommit');
222
		if (!empty($build_commit)) {
223
			$firewall_info .= "<br/>Last Commit: " . htmlspecialchars($build_commit);
224
		}
225
	}
226

  
227
	if (file_exists('/etc/version.gitsync')) {
228
		$gitsync = file_get_contents('/etc/version.gitsync');
229
		if (!empty($gitsync)) {
230
			$firewall_info .= "<br/>A gitsync was performed at " .
231
			    date("D M j G:i:s T Y", filemtime('/etc/version.gitsync')) .
232
			    " to commit " . htmlspecialchars($gitsync);
233
		}
234
	}
235

  
236
	file_put_contents("{$output_path}/Product Info.txt", str_replace("<br/>", "\n", $firewall_info) . "\n");
237
	return $firewall_info;
238
}
239

  
240
function get_gateway_status() {
241
	return return_gateways_status_text(true, false);
242
}
243

  
191 244
global $g, $config;
192 245

  
193 246
/* Set up all of the commands we want to execute. */
194 247

  
195
/* System stats/info */
196
defCmdT("System Uptime", "/usr/bin/uptime");
197
defCmdT("Interfaces", "/sbin/ifconfig -a");
198
defCmdT("Interface Statistics", "/usr/bin/netstat -nWi");
199
defCmdT("Top Process Info", "/usr/bin/top | /usr/bin/head -n5");
200
defCmdT("Processes", "/bin/ps xauww");
201
defCmdT("Mounted Filesystems", "/sbin/mount");
202
defCmdT("Free Disk Space", "/bin/df -hi");
203
defCmdT("Routing tables", "/usr/bin/netstat -nWr");
204
defCmdT("Mbuf Usage", "/usr/bin/netstat -mb");
205
defCmdT("VMStat", "/usr/bin/vmstat -afimsz");
206
defCmdT("Sockets", "/usr/bin/sockstat");
248
/* OS stats/info */
249
defCmdT("OS-Uptime", "/usr/bin/uptime");
250
defCmdT("Network-Interfaces", "/sbin/ifconfig -a");
251
defCmdT("Network-Interface Statistics", "/usr/bin/netstat -nWi");
252
defCmdT("Process-Top Usage", "/usr/bin/top | /usr/bin/head -n5");
253
defCmdT("Process-List", "/bin/ps xauwwd");
254
defCmdT("Disk-Mounted Filesystems", "/sbin/mount");
255
defCmdT("Disk-Free Space", "/bin/df -hi");
256
defCmdT("Network-Routing tables", "/usr/bin/netstat -nWr");
257
defCmdT("Network-Gateway Status", 'get_gateway_status', "php_func");
258
defCmdT("Network-Mbuf Usage", "/usr/bin/netstat -mb");
259
defCmdT("Network-Protocol Statistics", "/usr/bin/netstat -s");
260
defCmdT("Network-Sockets", "/usr/bin/sockstat");
261
defCmdT("Network-ARP Table", "/usr/sbin/arp -an");
262
defCmdT("Network-NDP Table", "/usr/sbin/ndp -na");
263
defCmdT("OS-Kernel VMStat", "/usr/bin/vmstat -afimsz");
207 264

  
208 265
/* Firewall rules and info */
209
defCmdT("Generated Ruleset", "/bin/cat {$g['tmp_path']}/rules.debug");
210
defCmdT("Generated Ruleset Limiters", "/bin/cat {$g['tmp_path']}/rules.limiter");
211
defCmdT("Generated Ruleset Limits", "/bin/cat {$g['tmp_path']}/rules.limits");
212
defCmdT("pf NAT Rules", "/sbin/pfctl -vvsn");
213
defCmdT("pf Firewall Rules", "/sbin/pfctl -vvsr");
214
defCmdT("pf Tables", "/sbin/pfctl -vs Tables");
215
defCmdT("pf State Table Contents", "/sbin/pfctl -vvss");
216
defCmdT("pf Info", "/sbin/pfctl -si");
217
defCmdT("pf Show All", "/sbin/pfctl -sa");
218
defCmdT("pf Queues", "/sbin/pfctl -s queue -v");
219
defCmdT("pf OSFP", "/sbin/pfctl -s osfp");
220
defCmdT("pfsync Stats", "/usr/bin/netstat -s -ppfsync");
221
defCmdT("pftop Default", "/usr/local/sbin/pftop -a -b");
222
defCmdT("pftop Long", "/usr/local/sbin/pftop -w 150 -a -b -v long");
223
defCmdT("pftop Queue", "/usr/local/sbin/pftop -w 150 -a -b -v queue");
224
defCmdT("pftop Rules", "/usr/local/sbin/pftop -w 150 -a -b -v rules");
225
defCmdT("pftop Size", "/usr/local/sbin/pftop -w 150 -a -b -v size");
226
defCmdT("pftop Speed", "/usr/local/sbin/pftop -w 150 -a -b -v speed");
266
defCmdT("Firewall-Generated Ruleset", "/bin/cat {$g['tmp_path']}/rules.debug");
267
defCmdT("Firewall-Generated Ruleset Limiters", "/bin/cat {$g['tmp_path']}/rules.limiter");
268
defCmdT("Firewall-Generated Ruleset Limits", "/bin/cat {$g['tmp_path']}/rules.limits");
269
defCmdT("Firewall-pf NAT Rules", "/sbin/pfctl -vvsn");
270
defCmdT("Firewall-pf Firewall Rules", "/sbin/pfctl -vvsr");
271
defCmdT("Firewall-pf Tables", "/sbin/pfctl -vs Tables");
272
defCmdT("Firewall-pf State Table Contents", "/sbin/pfctl -vvss");
273
defCmdT("Firewall-pf Info", "/sbin/pfctl -si");
274
defCmdT("Firewall-pf Show All", "/sbin/pfctl -sa");
275
defCmdT("Firewall-pf Queues", "/sbin/pfctl -s queue -v");
276
defCmdT("Firewall-pf OSFP", "/sbin/pfctl -s osfp");
277
defCmdT("Firewall-pftop Default", "/usr/local/sbin/pftop -a -b");
278
defCmdT("Firewall-pftop Long", "/usr/local/sbin/pftop -w 150 -a -b -v long");
279
defCmdT("Firewall-pftop Queue", "/usr/local/sbin/pftop -w 150 -a -b -v queue");
280
defCmdT("Firewall-pftop Rules", "/usr/local/sbin/pftop -w 150 -a -b -v rules");
281
defCmdT("Firewall-pftop Size", "/usr/local/sbin/pftop -w 150 -a -b -v size");
282
defCmdT("Firewall-pftop Speed", "/usr/local/sbin/pftop -w 150 -a -b -v speed");
283
defCmdT("Firewall-IPFW Limiter Info", "/sbin/ipfw pipe show");
284
defCmdT("Firewall-IPFW Queue Info", "/sbin/ipfw queue show");
227 285
if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
228 286
	foreach ($config['captiveportal'] as $cpZone => $cpdata) {
229 287
		if (isset($cpdata['enable'])) {
230
			defCmdT("IPFW Rules for {$cpdata['zone']}", "/sbin/ipfw -x " . escapeshellarg($cpdata['zoneid']) . " show");
288
			defCmdT("Firewall-IPFW Rules for Captive Portal {$cpdata['zone']}", "/sbin/ipfw -x " . escapeshellarg($cpdata['zoneid']) . " show");
231 289
		}
232 290
	}
233 291
}
234 292

  
293

  
294
if (is_array($config['load_balancer']['lbpool']) && is_array($config['load_balancer']['virtual_server'])) {
295
	defCmdT("Load Balancer-Redirects", "/usr/local/sbin/relayctl show redirects");
296
	defCmdT("Load Balancer-Relays", "/usr/local/sbin/relayctl show relays");
297
	defCmdT("Load Balancer-Summary", "/usr/local/sbin/relayctl show summary");
298
}
299

  
235 300
/* Configuration Files */
236
defCmdT("Contents of var run", "/bin/ls /var/run");
237
defCmdT("Contents of conf", "/bin/ls /conf");
301
defCmdT("Disk-Contents of var run", "/bin/ls /var/run");
302
defCmdT("Disk-Contents of conf", "/bin/ls /conf");
238 303
defCmdT("config.xml", "dumpconfigxml");
239
defCmdT("resolv.conf", "/bin/cat /etc/resolv.conf");
240
defCmdT("DHCP Configuration", "/bin/cat /var/dhcpd/etc/dhcpd.conf");
241
defCmdT("DHCPv6 Configuration", "/bin/cat /var/dhcpd/etc/dhcpdv6.conf");
242
defCmdT("strongSwan Configuration", "/bin/cat /var/etc/ipsec/strongswan.conf");
243
defCmdT("IPsec Configuration", "/bin/cat /var/etc/ipsec/ipsec.conf");
244
defCmdT("IPsec Status", "/usr/local/sbin/ipsec statusall");
245
defCmdT("SPD", "/sbin/setkey -DP");
246
defCmdT("SAD", "/sbin/setkey -D");
304
defCmdT("DNS-Resolution Configuration", "/bin/cat /etc/resolv.conf");
305
defCmdT("DHCP-IPv4 Configuration", "/bin/cat /var/dhcpd/etc/dhcpd.conf");
306
defCmdT("DHCP-IPv6-Configuration", "/bin/cat /var/dhcpd/etc/dhcpdv6.conf");
307
defCmdT("IPsec-strongSwan Configuration", "/bin/cat /var/etc/ipsec/strongswan.conf");
308
defCmdT("IPsec-Configuration", "/bin/cat /var/etc/ipsec/ipsec.conf");
309
defCmdT("IPsec-Status", "/usr/local/sbin/ipsec statusall");
310
defCmdT("IPsec-SPD", "/sbin/setkey -DP");
311
defCmdT("IPsec-SAD", "/sbin/setkey -D");
247 312
if (file_exists("/cf/conf/upgrade_log.txt")) {
248
	defCmdT("Upgrade Log", "/bin/cat /cf/conf/upgrade_log.txt");
313
	defCmdT("OS-Upgrade Log", "/bin/cat /cf/conf/upgrade_log.txt");
249 314
}
250 315
if (file_exists("/boot/loader.conf")) {
251
	defCmdT("Loader Configuration", "/bin/cat /boot/loader.conf");
316
	defCmdT("OS-Boot Loader Configuration", "/bin/cat /boot/loader.conf");
252 317
}
253 318
if (file_exists("/boot/loader.conf.local")) {
254
	defCmdT("Loader Configuration (Local)", "/bin/cat /boot/loader.conf.local");
319
	defCmdT("OS-Boot Loader Configuration (Local)", "/bin/cat /boot/loader.conf.local");
255 320
}
256 321
if (file_exists("/var/etc/filterdns.conf")) {
257
	defCmdT("Filter DNS Daemon Configuration", "/bin/cat /var/etc/filterdns.conf");
322
	defCmdT("DNS-filterdns Daemon Configuration", "/bin/cat /var/etc/filterdns.conf");
258 323
}
259
defCmdT("last 1000 system log entries", "/usr/local/sbin/clog /var/log/system.log 2>&1 | tail -n 1000");
260
defCmdT("last 1000 DHCP log entries", "/usr/local/sbin/clog /var/log/dhcpd.log 2>&1 | tail -n 1000");
261
defCmdT("last 500 filter log entries", "/usr/local/sbin/clog /var/log/filter.log 2>&1 | tail -n 500");
262
defCmdT("last 1000 gateways log entries", "/usr/local/sbin/clog /var/log/gateways.log 2>&1 | tail -n 1000");
263
defCmdT("last 1000 IPsec log entries", "/usr/local/sbin/clog /var/log/ipsec.log 2>&1 | tail -n 1000");
264
defCmdT("last 1000 L2TP log entries", "/usr/local/sbin/clog /var/log/l2tps.log 2>&1 | tail -n 1000");
265
defCmdT("last 1000 NTP log entries", "/usr/local/sbin/clog /var/log/ntpd.log 2>&1 | tail -n 1000");
266
defCmdT("last 1000 OpenVPN log entries", "/usr/local/sbin/clog /var/log/openvpn.log 2>&1 | tail -n 1000");
267
defCmdT("last 1000 Captive Portal auth log entries", "/usr/local/sbin/clog /var/log/portalauth.log 2>&1 | tail -n 1000");
268
defCmdT("last 1000 PPP log entries", "/usr/local/sbin/clog /var/log/poes.log 2>&1 | tail -n 1000");
269
defCmdT("last 1000 relayd log entries", "/usr/local/sbin/clog /var/log/relayd.log 2>&1 | tail -n 1000");
270
defCmdT("last 1000 resolver log entries", "/usr/local/sbin/clog /var/log/resolver.log 2>&1 | tail -n 1000");
271
defCmdT("last 1000 routing log entries", "/usr/local/sbin/clog /var/log/routing.log 2>&1 | tail -n 1000");
272
defCmdT("last 1000 wireless log entries", "/usr/local/sbin/clog /var/log/wireless.log 2>&1 | tail -n 1000");
324

  
325
/* Logs */
326
defCmdT("Log-System-Last 1000 entries", "/usr/local/sbin/clog /var/log/system.log 2>&1 | tail -n 1000");
327
defCmdT("Log-DHCP-Last 1000 entries", "/usr/local/sbin/clog /var/log/dhcpd.log 2>&1 | tail -n 1000");
328
defCmdT("Log-Filter-Last 500 entries", "/usr/local/sbin/clog /var/log/filter.log 2>&1 | tail -n 500");
329
defCmdT("Log-Gateways-Last 1000 entries", "/usr/local/sbin/clog /var/log/gateways.log 2>&1 | tail -n 1000");
330
defCmdT("Log-IPsec-Last 1000 entries", "/usr/local/sbin/clog /var/log/ipsec.log 2>&1 | tail -n 1000");
331
defCmdT("Log-L2TP-Last 1000 entries", "/usr/local/sbin/clog /var/log/l2tps.log 2>&1 | tail -n 1000");
332
defCmdT("Log-NTP-Last 1000 entries", "/usr/local/sbin/clog /var/log/ntpd.log 2>&1 | tail -n 1000");
333
defCmdT("Log-OpenVPN-Last 1000 entries", "/usr/local/sbin/clog /var/log/openvpn.log 2>&1 | tail -n 1000");
334
defCmdT("Log-Captive Portal Authentication-Last 1000 entries", "/usr/local/sbin/clog /var/log/portalauth.log 2>&1 | tail -n 1000");
335
defCmdT("Log-PPP-Last 1000 entries", "/usr/local/sbin/clog /var/log/poes.log 2>&1 | tail -n 1000");
336
defCmdT("Log-relayd-Last 1000 entries", "/usr/local/sbin/clog /var/log/relayd.log 2>&1 | tail -n 1000");
337
defCmdT("Log-DNS-Last 1000 entries", "/usr/local/sbin/clog /var/log/resolver.log 2>&1 | tail -n 1000");
338
defCmdT("Log-Routing-Last 1000 entries", "/usr/local/sbin/clog /var/log/routing.log 2>&1 | tail -n 1000");
339
defCmdT("Log-Wireless-Last 1000 entries", "/usr/local/sbin/clog /var/log/wireless.log 2>&1 | tail -n 1000");
273 340
if (file_exists("/tmp/PHP_errors.log")) {
274
	defCmdT("PHP Error Log", "/bin/cat /tmp/PHP_errors.log");
341
	defCmdT("Log-PHP Errors", "/bin/cat /tmp/PHP_errors.log");
342
}
343
defCmdT("OS-Message Buffer", "/sbin/dmesg -a");
344
defCmdT("OS-Message Buffer (Boot)", "/bin/cat /var/log/dmesg.boot");
345

  
346
/* OS/Hardware Status */
347
defCmdT("OS-sysctl values", "/sbin/sysctl -a");
348
defCmdT("OS-Kernel Environment", "/bin/kenv");
349
defCmdT("OS-Installed Packages", "/usr/sbin/pkg info");
350
defCmdT("Hardware-PCI Devices", "/usr/sbin/pciconf -lvb");
351
defCmdT("Hardware-USB Devices", "/usr/sbin/usbconfig dump_device_desc");
352

  
353
if (is_module_loaded("zfs.ko")) {
354
	defCmdT("Disk-ZFS List", "/sbin/zfs list");
355
	defCmdT("Disk-ZFS Properties", "/sbin/zfs get all");
356
	defCmdT("Disk-ZFS Pool List", "/sbin/zpool list");
357
	defCmdT("Disk-ZFS Pool Status", "/sbin/zpool status");
275 358
}
276
defCmdT("System Message Buffer", "/sbin/dmesg -a");
277
defCmdT("System Message Buffer (Boot)", "/bin/cat /var/log/dmesg.boot");
278
defCmdT("sysctl values", "/sbin/sysctl -a");
279
defCmdT("Kernel Environment", "/bin/kenv");
280
defCmdT("Installed OS Packages", "/usr/sbin/pkg info");
281
defCmdT("System Devices-PCI", "/usr/sbin/pciconf -lvb");
282
defCmdT("System Devices-USB", "/usr/sbin/usbconfig dump_device_desc");
359
defCmdT("Disk-GEOM Mirror Status", "/sbin/gmirror status");
283 360

  
284 361
exec("/bin/date", $dateOutput, $dateStatus);
285 362
$currentDate = $dateOutput[0];
286 363

  
287
$pgtitle = array("{$g['product_name']}", "Status");
364
$pgtitle = array($g['product_name'], "Status");
288 365
include("head.inc");
289 366

  
290
print_info_box(gettext("Make sure all sensitive information is removed! (Passwords, etc.) before posting " .
291
			   "information from this page in public places (like mailing lists).") . '<br />' .
292
		gettext("Common password fields in config.xml have been automatically redacted.") . '<br />' .
293
		gettext("When the page has finished loading, the output will be stored in {$output_file}. It may be downloaded via scp or ") .
294
		"<a href=\"/diag_command.php?dlPath={$output_file}\">" . gettext("Diagnostics > Command Prompt.") . '</a>');
367
print_info_box(
368
	gettext("Make sure all sensitive information is removed! (Passwords, etc.) before posting information from this page in public places (like mailing lists).") .
369
	'<br />' .
370
	gettext("Common password fields in config.xml have been automatically redacted.") .
371
	'<br />' .
372
	sprintf(gettext('When the page has finished loading, the output will be stored in %1$s. It may be downloaded via scp or %2$sDiagnostics > Command Prompt%3$s.'),
373
	$output_file, '<a href="/diag_command.php?dlPath=' . $output_file . '">', '</a>'));
374

  
375
print_info_box(get_firewall_info(), 'info', false);
295 376

  
296 377
listCmds();
297 378
execCmds();
......
305 386
}
306 387

  
307 388
print(gettext("Done."));
308

  
309
include("foot.inc");

Also available in: Unified diff