3535use Engine;
3636use Capacity_obj;
3737use Formater;
38+ use Databases;
39+ use Group_obj;
3840use Toolkit_helpers;
3941
4042my $version = $Toolkit_helpers::version ;
4143
4244my $resolution = ' d' ;
4345my $output_unit = ' G' ;
46+ my $scope = ' system' ;
47+
4448
4549GetOptions(
4650 ' help|?' => \(my $help ),
4751 ' d|engine=s' => \(my $dx_host ),
52+ ' scope=s' => \($scope ),
4853 ' 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 ),
4959 ' st=s' => \(my $st ),
5060 ' et=s' => \(my $et ),
5161 ' debug:i' => \(my $debug ),
8494 exit (1);
8595}
8696
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+
87107# this array will have all engines to go through (if -d is specified it will be only one engine)
88108my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
89109
90110my $output = new Formater();
91111
92112
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+ }
108139} 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+ }
117167}
118168
119-
120169my $ret = 0;
121170
122171my %reshash = (
151200
152201
153202 # 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+
154215 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 );
158216
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+ }
159228
160229}
161230
@@ -177,6 +246,12 @@ =head1 SYNOPSIS
177246 [-et "YYYY-MM-DD [HH24:MI:SS]" ]
178247 [-resolution d|h ]
179248 [-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 ]
180255 [-format csv|json ]
181256 [-help|? ]
182257 [-debug ]
@@ -223,6 +298,25 @@ =head1 OPTIONS
223298Display usage using different unit. By default GB are used
224299Use K for KiloBytes, G for GigaBytes and M for MegaBytes, T for TeraBytes
225300
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+
226320=item B<-format >
227321Display output in csv or json format
228322If not specified pretty formatting is used.
@@ -269,4 +363,20 @@ =head1 EXAMPLES
269363 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
270364 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
271365
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+
272382=cut
0 commit comments