35
35
use Engine;
36
36
use Capacity_obj;
37
37
use Formater;
38
+ use Databases;
39
+ use Group_obj;
38
40
use Toolkit_helpers;
39
41
40
42
my $version = $Toolkit_helpers::version ;
41
43
42
44
my $resolution = ' d' ;
43
45
my $output_unit = ' G' ;
46
+ my $scope = ' system' ;
47
+
44
48
45
49
GetOptions(
46
50
' help|?' => \(my $help ),
47
51
' d|engine=s' => \(my $dx_host ),
52
+ ' scope=s' => \($scope ),
48
53
' format=s' => \(my $format ),
54
+ ' name=s' => \(my $dbname ),
55
+ ' type=s' => \(my $type ),
56
+ ' group=s' => \(my $group ),
57
+ ' dsource=s' => \(my $dsource ),
58
+ ' host=s' => \(my $host ),
49
59
' st=s' => \(my $st ),
50
60
' et=s' => \(my $et ),
51
61
' debug:i' => \(my $debug ),
84
94
exit (1);
85
95
}
86
96
97
+
98
+ if (!((lc $scope eq ' system' ) || (lc $scope eq ' object' ))) {
99
+ print " Option scope can have only value system or object \n " ;
100
+ pod2usage(-verbose => 1, -input => \*DATA );
101
+ exit (1);
102
+ }
103
+
104
+
105
+ Toolkit_helpers::check_filer_options (undef ,$type , $group , $host , $dbname );
106
+
87
107
# this array will have all engines to go through (if -d is specified it will be only one engine)
88
108
my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
89
109
90
110
my $output = new Formater();
91
111
92
112
93
- if (defined ($details )) {
94
- $output -> addHeader(
95
- {' Engine' , 30},
96
- {' Timestamp' , 30},
97
- {Toolkit_helpers::get_unit(' dS total' ,$output_unit ) , 15},
98
- {Toolkit_helpers::get_unit(' dS current' ,$output_unit ) ,15},
99
- {Toolkit_helpers::get_unit(' dS log' ,$output_unit ) ,15},
100
- {Toolkit_helpers::get_unit(' dS snaps' ,$output_unit ) ,15},
101
- {Toolkit_helpers::get_unit(' VDB total' ,$output_unit ) ,15},
102
- {Toolkit_helpers::get_unit(' VDB current' ,$output_unit ) ,15},
103
- {Toolkit_helpers::get_unit(' VDB log' ,$output_unit ) ,15},
104
- {Toolkit_helpers::get_unit(' VDB snaps' ,$output_unit ) ,15},
105
- {Toolkit_helpers::get_unit(' Total' ,$output_unit ) , 15},
106
- {' Usage [%]' , 12}
107
- );
113
+ if (lc $scope eq ' system' ) {
114
+ if (defined ($details )) {
115
+ $output -> addHeader(
116
+ {' Engine' , 30},
117
+ {' Timestamp' , 30},
118
+ {Toolkit_helpers::get_unit(' dS total' ,$output_unit ) , 15},
119
+ {Toolkit_helpers::get_unit(' dS current' ,$output_unit ) ,15},
120
+ {Toolkit_helpers::get_unit(' dS log' ,$output_unit ) ,15},
121
+ {Toolkit_helpers::get_unit(' dS snaps' ,$output_unit ) ,15},
122
+ {Toolkit_helpers::get_unit(' VDB total' ,$output_unit ) ,15},
123
+ {Toolkit_helpers::get_unit(' VDB current' ,$output_unit ) ,15},
124
+ {Toolkit_helpers::get_unit(' VDB log' ,$output_unit ) ,15},
125
+ {Toolkit_helpers::get_unit(' VDB snaps' ,$output_unit ) ,15},
126
+ {Toolkit_helpers::get_unit(' Total' ,$output_unit ) , 15},
127
+ {' Usage [%]' , 12}
128
+ );
129
+ } else {
130
+ $output -> addHeader(
131
+ {' Engine' , 30},
132
+ {' Timestamp' , 30},
133
+ {Toolkit_helpers::get_unit(' dSource' ,$output_unit ), 12},
134
+ {Toolkit_helpers::get_unit(' Virtual' ,$output_unit ), 12},
135
+ {Toolkit_helpers::get_unit(' Total' ,$output_unit ), 12},
136
+ {' Usage [%]' , 12}
137
+ );
138
+ }
108
139
} else {
109
- $output -> addHeader(
110
- {' Engine' , 30},
111
- {' Timestamp' , 30},
112
- {Toolkit_helpers::get_unit(' dSource' ,$output_unit ), 12},
113
- {Toolkit_helpers::get_unit(' Virtual' ,$output_unit ), 12},
114
- {Toolkit_helpers::get_unit(' Total' ,$output_unit ), 12},
115
- {' Usage [%]' , 12}
116
- );
140
+ if (defined ($details )) {
141
+ $output -> addHeader(
142
+ {' Engine' , 30},
143
+ {' Timestamp' , 30},
144
+ {' Group' , 30},
145
+ {' Name' , 30},
146
+ {Toolkit_helpers::get_unit(' total' ,$output_unit ), 12},
147
+ {Toolkit_helpers::get_unit(' current' ,$output_unit ), 12},
148
+ {Toolkit_helpers::get_unit(' logS' ,$output_unit ), 12},
149
+ {Toolkit_helpers::get_unit(' snaps' ,$output_unit ), 12},
150
+ {Toolkit_helpers::get_unit(' locked snaps' ,$output_unit ), 12},
151
+ {Toolkit_helpers::get_unit(' held snaps' ,$output_unit ), 12},
152
+ {Toolkit_helpers::get_unit(' policy' ,$output_unit ), 12},
153
+ {Toolkit_helpers::get_unit(' manual' ,$output_unit ), 12}
154
+ );
155
+ } else {
156
+ $output -> addHeader(
157
+ {' Engine' , 30},
158
+ {' Timestamp' , 30},
159
+ {' Group' , 30},
160
+ {' Name' , 30},
161
+ {Toolkit_helpers::get_unit(' total' ,$output_unit ), 12},
162
+ {Toolkit_helpers::get_unit(' current' ,$output_unit ), 12},
163
+ {Toolkit_helpers::get_unit(' logS' ,$output_unit ), 12},
164
+ {Toolkit_helpers::get_unit(' snaps' ,$output_unit ), 12}
165
+ );
166
+ }
117
167
}
118
168
119
-
120
169
my $ret = 0;
121
170
122
171
my %reshash = (
151
200
152
201
153
202
# load objects for current engine
203
+ my $databases = new Databases( $engine_obj , $debug );
204
+ my $groups = new Group_obj($engine_obj , $debug );
205
+
206
+ # filter implementation
207
+
208
+ my $db_list = Toolkit_helpers::get_dblist_from_filter($type , $group , $host , $dbname , $databases , $groups , undef , $dsource , undef , undef , undef , undef , undef , $debug );
209
+ if (! defined ($db_list )) {
210
+ print " There is no DB selected to process on $engine . Please check filter definitions. \n " ;
211
+ $ret = 1;
212
+ next ;
213
+ }
214
+
154
215
my $capacity = new Capacity_obj($engine_obj , $debug );
155
- # $capacity->LoadDatabases();
156
- $capacity -> LoadSystemHistory($st_timestamp , $et_timestamp , $reshash {$resolution });
157
- $capacity -> processSystemHistory($output ,$details , $output_unit );
158
216
217
+ if (lc $scope eq ' system' ) {
218
+ # load objects for current engine
219
+ $capacity -> LoadSystemHistory($st_timestamp , $et_timestamp , $reshash {$resolution });
220
+ $capacity -> processSystemHistory($output ,$details , $output_unit );
221
+ } else {
222
+ for my $db_ref (@{$db_list }) {
223
+ my $db_obj = $databases -> getDB($db_ref );
224
+ $capacity -> LoadObjectHistory($db_ref , $st_timestamp , $et_timestamp , $reshash {$resolution });
225
+ $capacity -> processObjectHistory($output ,$details , $output_unit );
226
+ }
227
+ }
159
228
160
229
}
161
230
@@ -177,6 +246,12 @@ =head1 SYNOPSIS
177
246
[-et "YYYY-MM-DD [HH24:MI:SS]" ]
178
247
[-resolution d|h ]
179
248
[-output_unit K|M|G|T]
249
+ [-scope system | object ]
250
+ [-name database_name ]
251
+ [-type vdb | dsource ]
252
+ [-group group_name ]
253
+ [-dsource dsource_name ]
254
+ [-host host_name ]
180
255
[-format csv|json ]
181
256
[-help|? ]
182
257
[-debug ]
@@ -223,6 +298,25 @@ =head1 OPTIONS
223
298
Display usage using different unit. By default GB are used
224
299
Use K for KiloBytes, G for GigaBytes and M for MegaBytes, T for TeraBytes
225
300
301
+ =item B<-scope system | object >
302
+ Switch to display system capacity history or object capacity history.
303
+ Default value is system
304
+
305
+ =item B<-name database_name >
306
+ If scope is set to object, display capacity history of the database_name
307
+
308
+ =item B<-type vdb | dsource >
309
+ If scope is set to object, display capacity history of the objects with db type VDB or dSource
310
+
311
+ =item B<-group group_name >
312
+ If scope is set to object, display capacity history of the objects from group_name
313
+
314
+ =item B<-dsource dsource_name >
315
+ If scope is set to object, display capacity history of the objects with dSource dsource_name
316
+
317
+ =item B<-host host_name >
318
+ If scope is set to object, display capacity history of the objects located on the host host_name
319
+
226
320
=item B<-format >
227
321
Display output in csv or json format
228
322
If not specified pretty formatting is used.
@@ -269,4 +363,20 @@ =head1 EXAMPLES
269
363
Landshark51 2017-03-09 09:52:50 GMT 1.22 1.21 0.00 0.00 0.03 0.03 0.00 0.00 1.25 4.34
270
364
Landshark51 2017-03-09 13:22:50 GMT 1.23 1.21 0.00 0.01 0.05 0.03 0.01 0.00 1.28 4.46
271
365
366
+ Display a history of Delphix Engine utilization of the database oratest
367
+
368
+ dx_get_capacity_history -d dxtest -scope object -name oratest -output_unit M
369
+
370
+ Engine Timestamp Group Name total [MB] current [MB] logS [MB] snaps [MB]
371
+ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------ ------------ ------------ ------------
372
+ dxtest 2023-10-31 02:43:46 PDT Analytics oratest 589.91 166.58 147.63 250.62
373
+ dxtest 2023-11-01 02:33:46 PDT Analytics oratest 761.77 164.85 233.53 338.27
374
+ dxtest 2023-11-02 02:33:46 PDT Analytics oratest 922.44 166.20 306.78 424.38
375
+ dxtest 2023-11-03 02:33:46 PDT Analytics oratest 1045.52 166.66 351.34 502.41
376
+ dxtest 2023-11-06 02:21:50 PST Analytics oratest 907.87 166.67 213.66 502.42
377
+ dxtest 2023-11-06 03:11:50 PST Analytics oratest 907.87 166.67 213.66 502.42
378
+
379
+
380
+
381
+
272
382
=cut
0 commit comments