Removed /usr/local from CDPATH
[clearscm.git] / clearadm / getTimestamp.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: getTimestamp.cgi,v $
6
7 Get a list of timestamps startTimestamp or endTimestamp elementID
8
9 =head1 VERSION
10
11 =over
12
13 =item Author
14
15 Andrew DeFaria <Andrew@ClearSCM.com>
16
17 =item Revision
18
19 $Revision: 1.6 $
20
21 =item Created:
22
23 Mon Dec 13 09:13:27 EST 2010
24
25 =item Modified:
26
27 $Date: 2011/01/20 14:34:24 $
28
29 =back
30
31 =head1 SYNOPSIS
32
33  Usage getTimestamp.cgi: system=<system> elementID=<elementID>
34                          [filesytem=<filesystem>] [scaling=<scaling>] 
35
36  Where:
37    <system>:       Name of the system defined in the Clearadm database to
38                    retrieve the timestamps for.
39    <elementID>:    Element's ID name. Must be one of startTimestamp or 
40                    endTimeStamp. This is needed by makeTimestampDropdown to
41                    determine whether to default the dropdown to Earliest or
42                    Latest.
43    [<filesystem>]: If specified then we look at clearadm.filesystem otherwise
44                    we look at clearadm.loadavg.
45    <scaling>:      Currently one of Minute, Hour, Day or Month. Specifies how
46                    Clearadm::GetLoadavg|GetFS will scale the data returned.
47    
48 =head1 DESCRIPTION
49
50 Retrieve a list of timestamps for a given system/filesystem and put out a web
51 page that specifies the <select> dropdown representing the timestamps. If 
52 filesystem is specified then we retrieve information about filesystem snapshots
53 in clearadm.fs, otherwise we retrieve information about loadavg snapshots in
54 clearadm.loadavg for the given system. Data is scaled by scaling and elementID
55 is used to determine if we should make 'Earliest' or 'Latest' the default. This
56 script is intended to be called by AJAX to fill in a dropdown list on a web page
57 in response to JavaScript action on another dropdown (a system dropdown or an
58 interval dropdown).
59
60 =cut
61
62 use strict;
63 use warnings;
64
65 use FindBin;
66
67 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
68
69 use Clearadm;
70 use ClearadmWeb;
71 use Display;
72
73 use CGI qw (:standard :cgi-lib);
74
75 my %opts = Vars;
76
77 error "System not specified", 1
78   unless $opts{system};
79   
80 error "ElementID not specified", 1
81   unless $opts{elementID};
82   
83 error 'ElementID must be either "startTimestamp" or "endTimestamp"', 1
84   unless $opts{elementID} eq 'startTimestamp' or $opts{elementID} eq 'endTimestamp';
85   
86 my $default = $opts{elementID} eq 'startTimestamp' ? 'Earliest' : 'Latest';
87
88 my $clearadm = Clearadm->new;
89
90 heading undef, 'short';
91
92 my $name = $opts{elementID} eq 'startTimestamp'
93          ? 'start'
94          : $opts{elementID} eq 'endTimestamp'
95          ? 'end'
96          : 'unknown';
97           
98 if ($opts{filesystem}) {
99   display makeTimeDropdown 
100     'filesystem', 
101     $opts{elementID},
102     $opts{system},
103     $opts{filesystem},
104     $opts{label},
105     $default,
106     $opts{scaling},
107     $name;
108 } else {
109   display makeTimeDropdown 
110     'loadavg',
111     $opts{elementID},
112     $opts{system},
113     ucfirst $name,
114     $opts{label},
115     $default,
116     $opts{scaling},
117     $name;
118 } # if
119
120 display end_html;
121
122 =pod
123
124 =head1 CONFIGURATION AND ENVIRONMENT
125
126 DEBUG: If set then $debug is set to this level.
127
128 VERBOSE: If set then $verbose is set to this level.
129
130 TRACE: If set then $trace is set to this level.
131
132 =head1 DEPENDENCIES
133
134 =head2 Perl Modules
135
136 L<FindBin>
137
138 =head2 ClearSCM Perl Modules
139
140 =begin man 
141
142  Clearadm
143  ClearadmWeb
144  Display
145
146 =end man
147
148 =begin html
149
150 <blockquote>
151 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
152 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
153 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
154 </blockquote>
155
156 =end html
157
158 =head1 BUGS AND LIMITATIONS
159
160 There are no known bugs in this script
161
162 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
163
164 =head1 LICENSE AND COPYRIGHT
165
166 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
167
168 =cut