forked from jonmatifa/zfsmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.cgi
executable file
·173 lines (152 loc) · 7.78 KB
/
status.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
#!/usr/local/bin/perl
# status.cgi
require './zfsmanager-lib.pl';
&ReadParse();
use Data::Dumper;
# Show pool status
if ($in{'pool'}) {
&ui_print_header(undef, $text{'status_title'}, "", undef, 1, 1);
# Show pool information
&ui_zpool_list($in{'pool'});
# Show properties for pool
&ui_zpool_properties($in{'pool'});
# Show associated file systems
&ui_zfs_list("-r ".$in{'pool'});
# Show device configuration
# TODO: show devices by vdev hierarchy
my %status = zpool_status($in{'pool'});
print &ui_columns_start([ "Virtual Device", "State", "Read", "Write", "Cksum" ]);
foreach $key (sort {$a <=> $b} (keys %status)) {
if (($status{$key}{parent} =~ /pool/) && ($key != 0)) {
print &ui_columns_row(["<a href='config-vdev.cgi?pool=".$status{0}{pool}.'&dev='.$key."'>".$status{$key}{name}."</a>", $status{$key}{state}, $status{$key}{read}, $status{$key}{write}, $status{$key}{cksum}]);
} elsif ($key != 0) {
print &ui_columns_row(["<a href='config-vdev.cgi?pool=".$status{0}{pool}.'&dev='.$key."'>|_".$status{$key}{name}."</a>", $status{$key}{state}, $status{$key}{read}, $status{$key}{write}, $status{$key}{cksum}]);
}
}
print &ui_columns_end();
print &ui_table_start("Status", "width=100%", "10");
print &ui_table_row("Scan:", $status{0}{scan});
print &ui_table_row("Read:", $status{0}{read});
print &ui_table_row("Write:", $status{0}{write});
print &ui_table_row("Checkum:", $status{0}{cksum});
print &ui_table_row("Errors:", $status{0}{errors});
print &ui_table_end();
if ($status{0}{status} or $status{0}{action} or $status{pool}{see}) {
print &ui_table_start("Attention", "width=100%", "10");
if ($status{0}{status}) { print &ui_table_row("Status:", $status{0}{status}); }
if ($status{0}{action}) { print &ui_table_row("Action:", $status{0}{action}); }
if ($status{0}{see}) { print &ui_table_row("See:", $status{0}{see}); }
print &ui_table_end();
}
#--Tasks table--
print &ui_table_start("Tasks", "width=100%", "10", ['align=left'] );
if ($config{'zfs_properties'} =~ /1/) {
print &ui_table_row("New file system: ", "<a href='create.cgi?create=zfs&parent=$in{pool}'>Create file system</a>");
}
if ($config{'pool_properties'} =~ /1/) {
if ($status{0}{scan} =~ /scrub in progress/) { print &ui_table_row('Scrub ',"<a href='cmd.cgi?cmd=scrub&stop=y&pool=$in{pool}'>Stop scrub</a>"); }
else { print &ui_table_row('Scrub ', "<a href='cmd.cgi?cmd=scrub&pool=$in{pool}'>Scrub pool</a>");}
print &ui_table_row('Upgrade ', "<a href='cmd.cgi?cmd=upgrade&pool=$in{pool}'>Upgrade pool</a>");
print &ui_table_row('Export ', "<a href='cmd.cgi?cmd=export&pool=$in{pool}'>Export pool</a>");
}
if ($config{'pool_destroy'} =~ /1/) { print &ui_table_row("Destroy ", "<a href='cmd.cgi?cmd=pooldestroy&pool=$in{pool}'>Destroy this pool</a>"); }
print &ui_table_end();
&ui_print_footer('', $text{'index_return'});
}
# Show filesystem status
if ($in{'zfs'}) {
&ui_print_header(undef, "ZFS File System", "", undef, 1, 1);
# Start status tab
&ui_zfs_list($in{'zfs'});
# Show properties for filesystem
&ui_zfs_properties($in{'zfs'});
# Show list of snapshots based on filesystem
&ui_list_snapshots('-rd1 '.$in{'zfs'}, 1);
my %hash = zfs_get($in{'zfs'}, "all");
#--Tasks table--
print &ui_table_start("Tasks", "width=100%", "10");
if ($config{'snap_properties'} =~ /1/) { print &ui_table_row("Snapshot: ", &ui_create_snapshot($in{'zfs'})); }
if ($config{'zfs_properties'} =~ /1/) {
print &ui_table_row("New file system: ", "<a href='create.cgi?create=zfs&parent=".$in{'zfs'}."'>Create child file system</a>");
if (index($in{'zfs'}, '/') != -1) { print &ui_table_row("Rename: ", "<a href='create.cgi?rename=".$in{'zfs'}."'>Rename ".$in{'zfs'}."</a>"); }
if ($hash{$in{'zfs'}}{origin}) { print &ui_table_row("Promote: ", "This file system is a clone, <a href='cmd.cgi?cmd=promote&zfs=$in{zfs}'>promote $in{zfs}</a>"); }
}
if ($config{'zfs_destroy'} =~ /1/) { print &ui_table_row("Destroy: ", "<a href='cmd.cgi?cmd=zfsdestroy&zfs=$in{zfs}'>Destroy this file system</a>"); }
print &ui_table_end();
&ui_print_footer('index.cgi?mode=zfs', $text{'zfs_return'});
}
# Show snapshot status
# Show status of current snapshot
if ($in{'snap'}) {
&ui_print_header(undef, $text{'snapshot_title'}, "", undef, 1, 1);
%snapshot = list_snapshots($in{'snap'});
print &ui_columns_start([ "Snapshot", "Used", "Refer" ]);
foreach $key (sort(keys %snapshot)) {
print &ui_columns_row(["<a href='status.cgi?snap=$snapshot{$key}{name}'>$snapshot{$key}{name}</a>", $snapshot{$key}{used}, $snapshot{$key}{refer} ]);
}
print &ui_columns_end();
&ui_zfs_properties($in{'snap'});
my $zfs = $in{'snap'};
$zfs =~ s/\@.*//;
#--Tasks table--
print &ui_table_start('Tasks', 'width=100%', undef);
print &ui_table_row('Differences', "<a href='diff.cgi?snap=$in{snap}'>Show differences in $in{'snap'}</a>");
if ($config{'snap_properties'} =~ /1/) {
print &ui_table_row("Snapshot: ", &ui_create_snapshot($zfs));
print &ui_table_row("Rename: ", "<a href='create.cgi?rename=".$in{'snap'}."'>Rename ".$in{'snap'}."</a>");
print &ui_table_row("Send: ", "<a href='cmd.cgi?cmd=send&snap=".$in{'snap'}."'>Send ".$in{'snap'}." to gzip</a>");
}
if ($config{'zfs_properties'} =~ /1/) {
print &ui_table_row('Clone:', "<a href='create.cgi?clone=$in{snap}'>Clone $in{'snap'} to new file system</a>");
print &ui_table_row('Rollback:', "Rollback $zfs to $in{'snap'}");
}
if (($config{'snap_properties'} =~ /1/) && ($config{'zfs_properties'} =~ /1/)) {
}
if ($config{'snap_destroy'} =~ /1/) { print &ui_table_row('Destroy:',"<a href='cmd.cgi?cmd=snpdestroy&snapshot=$in{snap}'>Destroy snapshot</a>", ); }
print &ui_table_end();
%parent = find_parent($in{'snap'});
&ui_print_footer('status.cgi?zfs='.$parent{'filesystem'}, $parent{'filesystem'});
}
# List boot environments.
if ($in{'bootenv'}) {
#&ui_print_header(undef, $text{'index_bootenv'}, "", undef, 1, 1);
my $version = &get_beadm_version();
&ui_print_header(undef, $text{'index_bootenv'}, "", "intro", 1, 1, 0,
&help_search_link("beadm", "man", "doc", "google"), undef, undef,
&text('index_beversion', "$text{'index_modver'} $version"));
%bootenv = &list_bootenvs($in{'bootenv'});
print &ui_columns_start([ "$text{'colprop_name'}", "$text{'colprop_active'}", "$text{'colprop_mountdir'}", "$text{'colprop_space'}", "$text{'colprop_created'}" ]);
foreach $key (sort(keys %bootenv)) {
if ($bootenv{$key}{'mountpoint'} =~ "$config{'be_mountpath'}") {
$bootenv{$key}{'mountpoint'} = "<a href='../filemin/index.cgi?path=$bootenv{$key}{'mountpoint'}'>$bootenv{$key}{'mountpoint'}</a>";
}
print &ui_columns_row(["<a href='status.cgi?bootenv=$bootenv{$key}{'name'}'>$bootenv{$key}{'name'}</a>", $bootenv{$key}{'active'}, $bootenv{$key}{'mountpoint'}, $bootenv{$key}{'space'}, $bootenv{$key}{'created'} ]);
}
print &ui_columns_end();
my $zfsbe = $in{'bootenv'};
$zfsbe =~ s/\@.*//;
# Tasks table.
#print &ui_table_start("$text{'index_tasks'} for : <i>".$zfsbe, 'width=100%', undef);
print &ui_table_start("$text{'index_tasks'}", 'width=100%', undef);
if ($config{'bootenv_tasks'} =~ /1/) {
#print &ui_hr();
print &ui_table_row(&ui_activate_bootenv($zfsbe));
print &ui_table_row(&ui_rename_bootenv($zfsbe));
print &ui_table_row(&ui_mount_bootenv($zfsbe));
print &ui_table_row(&ui_create_bootenv($zfsbe));
print &ui_table_row(&ui_backup_bootenv($zfsbe));
print &ui_table_row(&ui_restore_bootenv($zfsbe));
if ($config{'bootenv_destroy'} =~ /1/) {
# Destroy task table.
print &ui_table_start("$text{'index_destroy'}", 'width=100%', undef);
print &ui_table_row(&ui_destroy_bootenv($zfsbe));
print &ui_table_end();
}
}
print &ui_table_end();
print "<br><b>$text{'index_notes'}<b/><br>";
print "$text{'index_notebackup'}<br/>";
print "$text{'index_notetasks'}<br/>";
print "$text{'index_noteprocess'}";
&ui_print_footer('index.cgi?mode=bootenv', $text{'index_bootenv'});
}