-
Notifications
You must be signed in to change notification settings - Fork 86
/
test_disk.php
49 lines (46 loc) · 1.43 KB
/
test_disk.php
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
<?php
set_time_limit(0);
if (defined('HAS_BEEN_COMPILED') === false) {
require __DIR__ . '/common.php';
}
header('Content-type: application/json');
check_password();
$file_name = 'disk_speedtest' . md5(time());
if (!check_permission($file_name)) {
?>
{
"status": false,
"message": "chown -R www ./",
"result": {
"disk_write_512k" :"×",
"disk_read_512k" :"×",
"disk_write_4k" :"×",
"disk_read_4k" :"×"
}
}
<?php
} else {
ob_start();
// Write 1 GiB
$disk_write_512k = trim(system('dd if=/dev/zero of=' . $file_name . ' bs=524288 count=512 conv=fdatasync oflag=direct,nonblock 2>&1 |awk \'/copied/ {print $8 " " $9}\''));
$disk_read_512k = trim(system('dd if=' . $file_name . ' of=/dev/null bs=524288 iflag=direct,nonblock 2>&1 |awk \'/copied/ {print $8 " " $9}\''));
unlink($file_name);
// Write 128 MiB
$disk_write_4k = trim(system('dd if=/dev/zero of=' . $file_name . ' bs=4096 count=32768 conv=fdatasync oflag=direct,nonblock 2>&1 |awk \'/copied/ {print $8 " " $9}\''));
$disk_read_4k = trim(system('dd if=' . $file_name . ' of=/dev/null bs=4096 iflag=direct,nonblock 2>&1 |awk \'/copied/ {print $8 " " $9}\''));
unlink($file_name);
ob_end_clean();
?>
{
"status": true,
"message": "",
"result": {
"disk_write_512k" :"<?php echo $disk_write_512k; ?>",
"disk_read_512k" :"<?php echo $disk_read_512k; ?>",
"disk_write_4k" :"<?php echo $disk_write_4k; ?>",
"disk_read_4k" :"<?php echo $disk_read_4k; ?>"
}
}
<?php
}
?>