001/*
002 * Copyright 2014-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2014-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2014-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.monitors;
037
038
039
040import java.util.Collections;
041import java.util.Date;
042import java.util.LinkedHashMap;
043import java.util.List;
044import java.util.Map;
045
046import com.unboundid.ldap.sdk.Entry;
047import com.unboundid.ldap.sdk.unboundidds.AlarmSeverity;
048import com.unboundid.util.NotExtensible;
049import com.unboundid.util.NotNull;
050import com.unboundid.util.Nullable;
051import com.unboundid.util.StaticUtils;
052import com.unboundid.util.ThreadSafety;
053import com.unboundid.util.ThreadSafetyLevel;
054
055import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*;
056
057
058
059/**
060 * This class defines the base class for gauge monitor entries, which provide
061 * information common to all types of gauges.  Subclasses may provide more
062 * specific information for that specific type of gauge.
063 * <BR>
064 * <BLOCKQUOTE>
065 *   <B>NOTE:</B>  This class, and other classes within the
066 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
067 *   supported for use against Ping Identity, UnboundID, and
068 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
069 *   for proprietary functionality or for external specifications that are not
070 *   considered stable or mature enough to be guaranteed to work in an
071 *   interoperable way with other types of LDAP servers.
072 * </BLOCKQUOTE>
073 */
074@NotExtensible()
075@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
076public class GaugeMonitorEntry
077       extends MonitorEntry
078{
079  /**
080   * The base structural object class used in gauge monitor entries.
081   */
082  @NotNull static final String GAUGE_MONITOR_OC = "ds-gauge-monitor-entry";
083
084
085
086  /**
087   * The serial version UID for this serializable class.
088   */
089  private static final long   serialVersionUID = -6092840651638645538L;
090
091
092
093  // The current severity for the gauge.
094  @Nullable private final AlarmSeverity currentSeverity;
095
096  // The previous severity for the gauge.
097  @Nullable private final AlarmSeverity previousSeverity;
098
099  // The time the gauge entered the current severity.
100  @Nullable private final Date currentSeverityStartTime;
101
102  // The time the gauge last exited the critical state.
103  @Nullable private final Date lastCriticalStateEndTime;
104
105  // The time the gauge last entered the critical state.
106  @Nullable private final Date lastCriticalStateStartTime;
107
108  // The time the gauge last exited the major state.
109  @Nullable private final Date lastMajorStateEndTime;
110
111  // The time the gauge last entered the major state.
112  @Nullable private final Date lastMajorStateStartTime;
113
114  // The time the gauge last exited the minor state.
115  @Nullable private final Date lastMinorStateEndTime;
116
117  // The time the gauge last entered the minor state.
118  @Nullable private final Date lastMinorStateStartTime;
119
120  // The time the gauge last exited the normal state.
121  @Nullable private final Date lastNormalStateEndTime;
122
123  // The time the gauge last entered the normal state.
124  @Nullable private final Date lastNormalStateStartTime;
125
126  // The time the gauge last exited the warning state.
127  @Nullable private final Date lastWarningStateEndTime;
128
129  // The time the gauge last entered the normal state.
130  @Nullable private final Date lastWarningStateStartTime;
131
132  // The time the gauge information was initialized.
133  @Nullable private final Date initTime;
134
135  // The time the gauge information was last updated.
136  @Nullable private final Date updateTime;
137
138  // The error messages.
139  @NotNull private final List<String> errorMessages;
140
141  // The current severity duration in milliseconds.
142  @Nullable private final Long currentSeverityDurationMillis;
143
144  // The last critical state duration in milliseconds.
145  @Nullable private final Long lastCriticalStateDurationMillis;
146
147  // The last major state duration in milliseconds.
148  @Nullable private final Long lastMajorStateDurationMillis;
149
150  // The last minor state duration in milliseconds.
151  @Nullable private final Long lastMinorStateDurationMillis;
152
153  // The last normal state duration in milliseconds.
154  @Nullable private final Long lastNormalStateDurationMillis;
155
156  // The last warning state duration in milliseconds.
157  @Nullable private final Long lastWarningStateDurationMillis;
158
159  // The number of samples taken in the current interval.
160  @Nullable private final Long samplesThisInterval;
161
162  // The total critical state duration in milliseconds.
163  @Nullable private final Long totalCriticalStateDurationMillis;
164
165  // The total major state duration in milliseconds.
166  @Nullable private final Long totalMajorStateDurationMillis;
167
168  // The total minor state duration in milliseconds.
169  @Nullable private final Long totalMinorStateDurationMillis;
170
171  // The total normal state duration in milliseconds.
172  @Nullable private final Long totalNormalStateDurationMillis;
173
174  // The total warning state duration in milliseconds.
175  @Nullable private final Long totalWarningStateDurationMillis;
176
177  // The string representation of the current severity duration.
178  @Nullable private final String currentSeverityDurationString;
179
180  // The name for the gauge.
181  @Nullable private final String gaugeName;
182
183  // The string representation of the last critical state duration.
184  @Nullable private final String lastCriticalStateDurationString;
185
186  // The string representation of the last major state duration.
187  @Nullable private final String lastMajorStateDurationString;
188
189  // The string representation of the last minor state duration.
190  @Nullable private final String lastMinorStateDurationString;
191
192  // The string representation of the last normal state duration.
193  @Nullable private final String lastNormalStateDurationString;
194
195  // The string representation of the last warning state duration.
196  @Nullable private final String lastWarningStateDurationString;
197
198  // The resource for the gauge.
199  @Nullable private final String resource;
200
201  // The resource type for the gauge.
202  @Nullable private final String resourceType;
203
204  // The summary message.
205  @Nullable private final String summary;
206
207  // The string representation of the total critical state duration.
208  @Nullable private final String totalCriticalStateDurationString;
209
210  // The string representation of the total major state duration.
211  @Nullable private final String totalMajorStateDurationString;
212
213  // The string representation of the total minor state duration.
214  @Nullable private final String totalMinorStateDurationString;
215
216  // The string representation of the total normal state duration.
217  @Nullable private final String totalNormalStateDurationString;
218
219  // The string representation of the total warning state duration.
220  @Nullable private final String totalWarningStateDurationString;
221
222
223
224  /**
225   * Creates a new gauge monitor entry from the provided entry.
226   *
227   * @param  entry  The entry to be parsed as a gauge monitor entry.  It must
228   *                not be {@code null}.
229   */
230  public GaugeMonitorEntry(@NotNull final Entry entry)
231  {
232    super(entry);
233
234    gaugeName = getString("gauge-name");
235    resource = getString("resource");
236    resourceType = getString("resource-type");
237
238    final String currentSeverityStr = getString("severity");
239    if (currentSeverityStr == null)
240    {
241      currentSeverity = null;
242    }
243    else
244    {
245      currentSeverity = AlarmSeverity.forName(currentSeverityStr);
246    }
247
248    final String previousSeverityStr = getString("previous-severity");
249    if (previousSeverityStr == null)
250    {
251      previousSeverity = null;
252    }
253    else
254    {
255      previousSeverity = AlarmSeverity.forName(previousSeverityStr);
256    }
257
258    summary = getString("summary");
259    errorMessages = getStrings("error-message");
260    initTime = getDate("gauge-init-time");
261    updateTime = getDate("update-time");
262    samplesThisInterval = getLong("samples-this-interval");
263
264    currentSeverityStartTime = getDate("current-severity-start-time");
265    currentSeverityDurationString = getString("current-severity-duration");
266    currentSeverityDurationMillis = getLong("current-severity-duration-millis");
267
268    lastNormalStateStartTime = getDate("last-normal-state-start-time");
269    lastNormalStateEndTime = getDate("last-normal-state-end-time");
270    lastNormalStateDurationString = getString("last-normal-state-duration");
271    lastNormalStateDurationMillis =
272         getLong("last-normal-state-duration-millis");
273    totalNormalStateDurationString = getString("total-normal-state-duration");
274    totalNormalStateDurationMillis =
275         getLong("total-normal-state-duration-millis");
276
277    lastWarningStateStartTime = getDate("last-warning-state-start-time");
278    lastWarningStateEndTime = getDate("last-warning-state-end-time");
279    lastWarningStateDurationString = getString("last-warning-state-duration");
280    lastWarningStateDurationMillis =
281         getLong("last-warning-state-duration-millis");
282    totalWarningStateDurationString = getString("total-warning-state-duration");
283    totalWarningStateDurationMillis =
284         getLong("total-warning-state-duration-millis");
285
286    lastMinorStateStartTime = getDate("last-minor-state-start-time");
287    lastMinorStateEndTime = getDate("last-minor-state-end-time");
288    lastMinorStateDurationString = getString("last-minor-state-duration");
289    lastMinorStateDurationMillis = getLong("last-minor-state-duration-millis");
290    totalMinorStateDurationString = getString("total-minor-state-duration");
291    totalMinorStateDurationMillis =
292         getLong("total-minor-state-duration-millis");
293
294    lastMajorStateStartTime = getDate("last-major-state-start-time");
295    lastMajorStateEndTime = getDate("last-major-state-end-time");
296    lastMajorStateDurationString = getString("last-major-state-duration");
297    lastMajorStateDurationMillis = getLong("last-major-state-duration-millis");
298    totalMajorStateDurationString = getString("total-major-state-duration");
299    totalMajorStateDurationMillis =
300         getLong("total-major-state-duration-millis");
301
302    lastCriticalStateStartTime = getDate("last-critical-state-start-time");
303    lastCriticalStateEndTime = getDate("last-critical-state-end-time");
304    lastCriticalStateDurationString = getString("last-critical-state-duration");
305    lastCriticalStateDurationMillis =
306         getLong("last-critical-state-duration-millis");
307    totalCriticalStateDurationString =
308         getString("total-critical-state-duration");
309    totalCriticalStateDurationMillis =
310         getLong("total-critical-state-duration-millis");
311  }
312
313
314
315  /**
316   * Retrieves the name for the gauge, if available.
317   *
318   * @return  The name for the gauge, or {@code null} if it was not included
319   *          in the monitor entry.
320   */
321  @Nullable()
322  public final String getGaugeName()
323  {
324    return gaugeName;
325  }
326
327
328
329  /**
330   * Retrieves the resource for the gauge, if available.
331   *
332   * @return  The resource for the gauge, or {@code null} if it was not included
333   *          in the monitor entry.
334   */
335  @Nullable()
336  public final String getResource()
337  {
338    return resource;
339  }
340
341
342
343  /**
344   * Retrieves the resource type for the gauge, if available.
345   *
346   * @return  The resource type for the gauge, or {@code null} if it was not
347   *          included in the monitor entry.
348   */
349  @Nullable()
350  public final String getResourceType()
351  {
352    return resourceType;
353  }
354
355
356
357  /**
358   * Retrieves the current severity for the gauge, if available.
359   *
360   * @return  The current severity for the gauge, or {@code null} if it was not
361   *          included in the monitor entry.
362   */
363  @Nullable()
364  public final AlarmSeverity getCurrentSeverity()
365  {
366    return currentSeverity;
367  }
368
369
370
371  /**
372   * Retrieves the previous severity for the gauge, if available.
373   *
374   * @return  The previous severity for the gauge, or {@code null} if it was not
375   *          included in the monitor entry.
376   */
377  @Nullable()
378  public final AlarmSeverity getPreviousSeverity()
379  {
380    return previousSeverity;
381  }
382
383
384
385  /**
386   * Retrieves the summary message for the gauge, if available.
387   *
388   * @return  The summary message for the gauge, or {@code null} if it was not
389   *          included in the monitor entry.
390   */
391  @Nullable()
392  public final String getSummary()
393  {
394    return summary;
395  }
396
397
398
399  /**
400   * Retrieves the error messages for the gauge, if available.
401   *
402   * @return  The list of error messages for the gauge, or an empty list if it
403   *          was not included in the monitor entry.
404   */
405  @NotNull()
406  public final List<String> getErrorMessages()
407  {
408    return errorMessages;
409  }
410
411
412
413  /**
414   * Retrieves the time the gauge was initialized, if available.
415   *
416   * @return  The time the gauge was initialized, or {@code null} if it was not
417   *          included in the monitor entry.
418   */
419  @Nullable()
420  public final Date getInitTime()
421  {
422    return initTime;
423  }
424
425
426
427  /**
428   * Retrieves the time the gauge was last updated, if available.
429   *
430   * @return  The time the gauge was last updated, or {@code null} if it was not
431   *          included in the monitor entry.
432   */
433  @Nullable()
434  public final Date getUpdateTime()
435  {
436    return updateTime;
437  }
438
439
440
441  /**
442   * Retrieves the number of samples taken in the current interval, if
443   * available.
444   *
445   * @return  The number of samples taken in the current interval, or
446   *          {@code null} if it was not included in the monitor entry.
447   */
448  @Nullable()
449  public final Long getSamplesThisInterval()
450  {
451    return samplesThisInterval;
452  }
453
454
455
456  /**
457   * Retrieves the time the gauge entered the current severity, if available.
458   *
459   * @return  The time the gauge entered the current severity, or {@code null}
460   *          if it was not included in the monitor entry.
461   */
462  @Nullable()
463  public final Date getCurrentSeverityStartTime()
464  {
465    return currentSeverityStartTime;
466  }
467
468
469
470  /**
471   * Retrieves the current severity duration as a human-readable string, if
472   * available.
473   *
474   * @return  The current severity duration as a human-readable string, or
475   *          {@code null} if it was not included in the monitor entry.
476   */
477  @Nullable()
478  public final String getCurrentSeverityDurationString()
479  {
480    return currentSeverityDurationString;
481  }
482
483
484
485  /**
486   * Retrieves the current severity duration in milliseconds, if available.
487   *
488   * @return  The current severity duration in milliseconds, or {@code null} if
489   *          it was not included in the monitor entry.
490   */
491  @Nullable()
492  public final Long getCurrentSeverityDurationMillis()
493  {
494    return currentSeverityDurationMillis;
495  }
496
497
498
499  /**
500   * Retrieves the time the gauge last entered the normal state, if available.
501   *
502   * @return  The time the gauge last entered the normal state, or {@code null}
503   *          if it was not included in the monitor entry.
504   */
505  @Nullable()
506  public final Date getLastNormalStateStartTime()
507  {
508    return lastNormalStateStartTime;
509  }
510
511
512
513  /**
514   * Retrieves the time the gauge last exited the normal state, if available.
515   *
516   * @return  The time the gauge last exited the normal state, or {@code null}
517   *          if it was not included in the monitor entry.
518   */
519  @Nullable()
520  public final Date getLastNormalStateEndTime()
521  {
522    return lastNormalStateEndTime;
523  }
524
525
526
527  /**
528   * Retrieves the duration of the last normal state as a human-readable string,
529   * if available.
530   *
531   * @return  The duration of the last normal state as a human-readable string,
532   *          or {@code null} if it was not included in the monitor entry.
533   */
534  @Nullable()
535  public final String getLastNormalStateDurationString()
536  {
537    return lastNormalStateDurationString;
538  }
539
540
541
542  /**
543   * Retrieves the duration of the last normal state in milliseconds, if
544   * available.
545   *
546   * @return  The duration of the last normal state in milliseconds, or
547   *          {@code null} if it was not included in the monitor entry.
548   */
549  @Nullable()
550  public final Long getLastNormalStateDurationMillis()
551  {
552    return lastNormalStateDurationMillis;
553  }
554
555
556
557  /**
558   * Retrieves the total length of time the gauge has been in the normal state
559   * as a human-readable string, if available.
560   *
561   * @return  The total length of time the gauge has been in the normal state as
562   *          a human-readable string, or {@code null} if it was not included in
563   *          the monitor entry.
564   */
565  @Nullable()
566  public final String getTotalNormalStateDurationString()
567  {
568    return totalNormalStateDurationString;
569  }
570
571
572
573  /**
574   * Retrieves the total length of time the gauge has been in the normal state
575   * in milliseconds, if available.
576   *
577   * @return  The total length of time the gauge has been in the normal state in
578   *          milliseconds, or {@code null} if it was not included in the
579   *          monitor entry.
580   */
581  @Nullable()
582  public final Long getTotalNormalStateDurationMillis()
583  {
584    return totalNormalStateDurationMillis;
585  }
586
587
588
589  /**
590   * Retrieves the time the gauge last entered the warning state, if available.
591   *
592   * @return  The time the gauge last entered the warning state, or {@code null}
593   *          if it was not included in the monitor entry.
594   */
595  @Nullable()
596  public final Date getLastWarningStateStartTime()
597  {
598    return lastWarningStateStartTime;
599  }
600
601
602
603  /**
604   * Retrieves the time the gauge last exited the warning state, if available.
605   *
606   * @return  The time the gauge last exited the warning state, or {@code null}
607   *          if it was not included in the monitor entry.
608   */
609  @Nullable()
610  public final Date getLastWarningStateEndTime()
611  {
612    return lastWarningStateEndTime;
613  }
614
615
616
617  /**
618   * Retrieves the duration of the last warning state as a human-readable
619   * string, if available.
620   *
621   * @return  The duration of the last warning state as a human-readable string,
622   *          or {@code null} if it was not included in the monitor entry.
623   */
624  @Nullable()
625  public final String getLastWarningStateDurationString()
626  {
627    return lastWarningStateDurationString;
628  }
629
630
631
632  /**
633   * Retrieves the duration of the last warning state in milliseconds, if
634   * available.
635   *
636   * @return  The duration of the last warning state in milliseconds, or
637   *          {@code null} if it was not included in the monitor entry.
638   */
639  @Nullable()
640  public final Long getLastWarningStateDurationMillis()
641  {
642    return lastWarningStateDurationMillis;
643  }
644
645
646
647  /**
648   * Retrieves the total length of time the gauge has been in the warning state
649   * as a human-readable string, if available.
650   *
651   * @return  The total length of time the gauge has been in the warning state
652   *          as a human-readable string, or {@code null} if it was not included
653   *          in the monitor entry.
654   */
655  @Nullable()
656  public final String getTotalWarningStateDurationString()
657  {
658    return totalWarningStateDurationString;
659  }
660
661
662
663  /**
664   * Retrieves the total length of time the gauge has been in the warning state
665   * in milliseconds, if available.
666   *
667   * @return  The total length of time the gauge has been in the warning state
668   *          in milliseconds, or {@code null} if it was not included in the
669   *          monitor entry.
670   */
671  @Nullable()
672  public final Long getTotalWarningStateDurationMillis()
673  {
674    return totalWarningStateDurationMillis;
675  }
676
677
678
679  /**
680   * Retrieves the time the gauge last entered the minor state, if available.
681   *
682   * @return  The time the gauge last entered the minor state, or {@code null}
683   *          if it was not included in the monitor entry.
684   */
685  @Nullable()
686  public final Date getLastMinorStateStartTime()
687  {
688    return lastMinorStateStartTime;
689  }
690
691
692
693  /**
694   * Retrieves the time the gauge last exited the minor state, if available.
695   *
696   * @return  The time the gauge last exited the minor state, or {@code null}
697   *          if it was not included in the monitor entry.
698   */
699  @Nullable()
700  public final Date getLastMinorStateEndTime()
701  {
702    return lastMinorStateEndTime;
703  }
704
705
706
707  /**
708   * Retrieves the duration of the last minor state as a human-readable string,
709   * if available.
710   *
711   * @return  The duration of the last minor state as a human-readable string,
712   *          or {@code null} if it was not included in the monitor entry.
713   */
714  @Nullable()
715  public final String getLastMinorStateDurationString()
716  {
717    return lastMinorStateDurationString;
718  }
719
720
721
722  /**
723   * Retrieves the duration of the last minor state in milliseconds, if
724   * available.
725   *
726   * @return  The duration of the last minor state in milliseconds, or
727   *          {@code null} if it was not included in the monitor entry.
728   */
729  @Nullable()
730  public final Long getLastMinorStateDurationMillis()
731  {
732    return lastMinorStateDurationMillis;
733  }
734
735
736
737  /**
738   * Retrieves the total length of time the gauge has been in the minor state
739   * as a human-readable string, if available.
740   *
741   * @return  The total length of time the gauge has been in the minor state as
742   *          a human-readable string, or {@code null} if it was not included in
743   *          the monitor entry.
744   */
745  @Nullable()
746  public final String getTotalMinorStateDurationString()
747  {
748    return totalMinorStateDurationString;
749  }
750
751
752
753  /**
754   * Retrieves the total length of time the gauge has been in the minor state
755   * in milliseconds, if available.
756   *
757   * @return  The total length of time the gauge has been in the minor state in
758   *          milliseconds, or {@code null} if it was not included in the
759   *          monitor entry.
760   */
761  @Nullable()
762  public final Long getTotalMinorStateDurationMillis()
763  {
764    return totalMinorStateDurationMillis;
765  }
766
767
768
769  /**
770   * Retrieves the time the gauge last entered the major state, if available.
771   *
772   * @return  The time the gauge last entered the major state, or {@code null}
773   *          if it was not included in the monitor entry.
774   */
775  @Nullable()
776  public final Date getLastMajorStateStartTime()
777  {
778    return lastMajorStateStartTime;
779  }
780
781
782
783  /**
784   * Retrieves the time the gauge last exited the major state, if available.
785   *
786   * @return  The time the gauge last exited the major state, or {@code null}
787   *          if it was not included in the monitor entry.
788   */
789  @Nullable()
790  public final Date getLastMajorStateEndTime()
791  {
792    return lastMajorStateEndTime;
793  }
794
795
796
797  /**
798   * Retrieves the duration of the last major state as a human-readable string,
799   * if available.
800   *
801   * @return  The duration of the last major state as a human-readable string,
802   *          or {@code null} if it was not included in the monitor entry.
803   */
804  @Nullable()
805  public final String getLastMajorStateDurationString()
806  {
807    return lastMajorStateDurationString;
808  }
809
810
811
812  /**
813   * Retrieves the duration of the last major state in milliseconds, if
814   * available.
815   *
816   * @return  The duration of the last major state in milliseconds, or
817   *          {@code null} if it was not included in the monitor entry.
818   */
819  @Nullable()
820  public final Long getLastMajorStateDurationMillis()
821  {
822    return lastMajorStateDurationMillis;
823  }
824
825
826
827  /**
828   * Retrieves the total length of time the gauge has been in the major state
829   * as a human-readable string, if available.
830   *
831   * @return  The total length of time the gauge has been in the major state as
832   *          a human-readable string, or {@code null} if it was not included in
833   *          the monitor entry.
834   */
835  @Nullable()
836  public final String getTotalMajorStateDurationString()
837  {
838    return totalMajorStateDurationString;
839  }
840
841
842
843  /**
844   * Retrieves the total length of time the gauge has been in the major state
845   * in milliseconds, if available.
846   *
847   * @return  The total length of time the gauge has been in the major state in
848   *          milliseconds, or {@code null} if it was not included in the
849   *          monitor entry.
850   */
851  @Nullable()
852  public final Long getTotalMajorStateDurationMillis()
853  {
854    return totalMajorStateDurationMillis;
855  }
856
857
858
859  /**
860   * Retrieves the time the gauge last entered the critical state, if available.
861   *
862   * @return  The time the gauge last entered the critical state, or
863   *          {@code null} if it was not included in the monitor entry.
864   */
865  @Nullable()
866  public final Date getLastCriticalStateStartTime()
867  {
868    return lastCriticalStateStartTime;
869  }
870
871
872
873  /**
874   * Retrieves the time the gauge last exited the critical state, if available.
875   *
876   * @return  The time the gauge last exited the critical state, or {@code null}
877   *          if it was not included in the monitor entry.
878   */
879  @Nullable()
880  public final Date getLastCriticalStateEndTime()
881  {
882    return lastCriticalStateEndTime;
883  }
884
885
886
887  /**
888   * Retrieves the duration of the last critical state as a human-readable
889   * string, if available.
890   *
891   * @return  The duration of the last critical state as a human-readable
892   *          string, or {@code null} if it was not included in the monitor
893   *          entry.
894   */
895  @Nullable()
896  public final String getLastCriticalStateDurationString()
897  {
898    return lastCriticalStateDurationString;
899  }
900
901
902
903  /**
904   * Retrieves the duration of the last critical state in milliseconds, if
905   * available.
906   *
907   * @return  The duration of the last critical state in milliseconds, or
908   *          {@code null} if it was not included in the monitor entry.
909   */
910  @Nullable()
911  public final Long getLastCriticalStateDurationMillis()
912  {
913    return lastCriticalStateDurationMillis;
914  }
915
916
917
918  /**
919   * Retrieves the total length of time the gauge has been in the critical state
920   * as a human-readable string, if available.
921   *
922   * @return  The total length of time the gauge has been in the critical state
923   *          as a human-readable string, or {@code null} if it was not included
924   *          in the monitor entry.
925   */
926  @Nullable()
927  public final String getTotalCriticalStateDurationString()
928  {
929    return totalCriticalStateDurationString;
930  }
931
932
933
934  /**
935   * Retrieves the total length of time the gauge has been in the critical state
936   * in milliseconds, if available.
937   *
938   * @return  The total length of time the gauge has been in the critical state
939   *          in milliseconds, or {@code null} if it was not included in the
940   *          monitor entry.
941   */
942  @Nullable()
943  public final Long getTotalCriticalStateDurationMillis()
944  {
945    return totalCriticalStateDurationMillis;
946  }
947
948
949
950  /**
951   * {@inheritDoc}
952   */
953  @Override()
954  @NotNull()
955  public String getMonitorDisplayName()
956  {
957    return INFO_GAUGE_MONITOR_DISPNAME.get();
958  }
959
960
961
962  /**
963   * {@inheritDoc}
964   */
965  @Override()
966  @NotNull()
967  public String getMonitorDescription()
968  {
969    return INFO_GAUGE_MONITOR_DESC.get();
970  }
971
972
973
974  /**
975   * {@inheritDoc}
976   */
977  @Override()
978  @NotNull()
979  public Map<String,MonitorAttribute> getMonitorAttributes()
980  {
981    final LinkedHashMap<String,MonitorAttribute> attrs =
982         new LinkedHashMap<>(StaticUtils.computeMapCapacity(43));
983
984    if (gaugeName != null)
985    {
986      addMonitorAttribute(attrs,
987           "gauge-name",
988           INFO_GAUGE_DISPNAME_GAUGE_NAME.get(),
989           INFO_GAUGE_DESC_GAUGE_NAME.get(),
990           gaugeName);
991    }
992
993    if (resource != null)
994    {
995      addMonitorAttribute(attrs,
996           "resource",
997           INFO_GAUGE_DISPNAME_RESOURCE.get(),
998           INFO_GAUGE_DESC_RESOURCE.get(),
999           resource);
1000    }
1001
1002    if (resourceType != null)
1003    {
1004      addMonitorAttribute(attrs,
1005           "resource-type",
1006           INFO_GAUGE_DISPNAME_RESOURCE_TYPE.get(),
1007           INFO_GAUGE_DESC_RESOURCE_TYPE.get(),
1008           resourceType);
1009    }
1010
1011    if (currentSeverity != null)
1012    {
1013      addMonitorAttribute(attrs,
1014           "severity",
1015           INFO_GAUGE_DISPNAME_CURRENT_SEVERITY.get(),
1016           INFO_GAUGE_DESC_CURRENT_SEVERITY.get(),
1017           currentSeverity.name());
1018    }
1019
1020    if (previousSeverity != null)
1021    {
1022      addMonitorAttribute(attrs,
1023           "previous-severity",
1024           INFO_GAUGE_DISPNAME_PREVIOUS_SEVERITY.get(),
1025           INFO_GAUGE_DESC_PREVIOUS_SEVERITY.get(),
1026           previousSeverity.name());
1027    }
1028
1029    if (summary != null)
1030    {
1031      addMonitorAttribute(attrs,
1032           "summary",
1033           INFO_GAUGE_DISPNAME_SUMMARY.get(),
1034           INFO_GAUGE_DESC_SUMMARY.get(),
1035           summary);
1036    }
1037
1038    if (! errorMessages.isEmpty())
1039    {
1040      addMonitorAttribute(attrs,
1041           "error-message",
1042           INFO_GAUGE_DISPNAME_ERROR_MESSAGE.get(),
1043           INFO_GAUGE_DESC_ERROR_MESSAGE.get(),
1044           errorMessages);
1045    }
1046
1047    if (initTime != null)
1048    {
1049      addMonitorAttribute(attrs,
1050           "gauge-init-time",
1051           INFO_GAUGE_DISPNAME_INIT_TIME.get(),
1052           INFO_GAUGE_DESC_INIT_TIME.get(),
1053           initTime);
1054    }
1055
1056    if (updateTime != null)
1057    {
1058      addMonitorAttribute(attrs,
1059           "update-time",
1060           INFO_GAUGE_DISPNAME_UPDATE_TIME.get(),
1061           INFO_GAUGE_DESC_UPDATE_TIME.get(),
1062           updateTime);
1063    }
1064
1065    if (samplesThisInterval != null)
1066    {
1067      addMonitorAttribute(attrs,
1068           "samples-this-interval",
1069           INFO_GAUGE_DISPNAME_SAMPLES_THIS_INTERVAL.get(),
1070           INFO_GAUGE_DESC_SAMPLES_THIS_INTERVAL.get(),
1071           samplesThisInterval);
1072    }
1073
1074    if (currentSeverityStartTime != null)
1075    {
1076      addMonitorAttribute(attrs,
1077           "current-severity-start-time",
1078           INFO_GAUGE_DISPNAME_CURRENT_START_TIME.get(),
1079           INFO_GAUGE_DESC_CURRENT_START_TIME.get(),
1080           currentSeverityStartTime);
1081    }
1082
1083    if (currentSeverityDurationString != null)
1084    {
1085      addMonitorAttribute(attrs,
1086           "current-severity-duration",
1087           INFO_GAUGE_DISPNAME_CURRENT_DURATION_STRING.get(),
1088           INFO_GAUGE_DESC_CURRENT_DURATION_STRING.get(),
1089           currentSeverityDurationString);
1090    }
1091
1092    if (currentSeverityDurationMillis != null)
1093    {
1094      addMonitorAttribute(attrs,
1095           "current-severity-duration-millis",
1096           INFO_GAUGE_DISPNAME_CURRENT_DURATION_MILLIS.get(),
1097           INFO_GAUGE_DESC_CURRENT_DURATION_MILLIS.get(),
1098           currentSeverityDurationMillis);
1099    }
1100
1101    if (lastNormalStateStartTime != null)
1102    {
1103      addMonitorAttribute(attrs,
1104           "last-normal-state-start-time",
1105           INFO_GAUGE_DISPNAME_LAST_NORMAL_START_TIME.get(),
1106           INFO_GAUGE_DESC_LAST_NORMAL_START_TIME.get(),
1107           lastNormalStateStartTime);
1108    }
1109
1110    if (lastNormalStateEndTime != null)
1111    {
1112      addMonitorAttribute(attrs,
1113           "last-normal-state-end-time",
1114           INFO_GAUGE_DISPNAME_LAST_NORMAL_END_TIME.get(),
1115           INFO_GAUGE_DESC_LAST_NORMAL_END_TIME.get(),
1116           lastNormalStateEndTime);
1117    }
1118
1119    if (lastNormalStateDurationString != null)
1120    {
1121      addMonitorAttribute(attrs,
1122           "last-normal-state-duration",
1123           INFO_GAUGE_DISPNAME_LAST_NORMAL_DURATION_STRING.get(),
1124           INFO_GAUGE_DESC_LAST_NORMAL_DURATION_STRING.get(),
1125           lastNormalStateDurationString);
1126    }
1127
1128    if (lastNormalStateDurationMillis != null)
1129    {
1130      addMonitorAttribute(attrs,
1131           "last-normal-state-duration-millis",
1132           INFO_GAUGE_DISPNAME_LAST_NORMAL_DURATION_MILLIS.get(),
1133           INFO_GAUGE_DESC_LAST_NORMAL_DURATION_MILLIS.get(),
1134           lastNormalStateDurationMillis);
1135    }
1136
1137    if (totalNormalStateDurationString != null)
1138    {
1139      addMonitorAttribute(attrs,
1140           "total-normal-state-duration",
1141           INFO_GAUGE_DISPNAME_TOTAL_NORMAL_DURATION_STRING.get(),
1142           INFO_GAUGE_DESC_TOTAL_NORMAL_DURATION_STRING.get(),
1143           totalNormalStateDurationString);
1144    }
1145
1146    if (totalNormalStateDurationMillis != null)
1147    {
1148      addMonitorAttribute(attrs,
1149           "total-normal-state-duration-millis",
1150           INFO_GAUGE_DISPNAME_TOTAL_NORMAL_DURATION_MILLIS.get(),
1151           INFO_GAUGE_DESC_TOTAL_NORMAL_DURATION_MILLIS.get(),
1152           totalNormalStateDurationMillis);
1153    }
1154
1155    if (lastWarningStateStartTime != null)
1156    {
1157      addMonitorAttribute(attrs,
1158           "last-warning-state-start-time",
1159           INFO_GAUGE_DISPNAME_LAST_WARNING_START_TIME.get(),
1160           INFO_GAUGE_DESC_LAST_WARNING_START_TIME.get(),
1161           lastWarningStateStartTime);
1162    }
1163
1164    if (lastWarningStateEndTime != null)
1165    {
1166      addMonitorAttribute(attrs,
1167           "last-warning-state-end-time",
1168           INFO_GAUGE_DISPNAME_LAST_WARNING_END_TIME.get(),
1169           INFO_GAUGE_DESC_LAST_WARNING_END_TIME.get(),
1170           lastWarningStateEndTime);
1171    }
1172
1173    if (lastWarningStateDurationString != null)
1174    {
1175      addMonitorAttribute(attrs,
1176           "last-warning-state-duration",
1177           INFO_GAUGE_DISPNAME_LAST_WARNING_DURATION_STRING.get(),
1178           INFO_GAUGE_DESC_LAST_WARNING_DURATION_STRING.get(),
1179           lastWarningStateDurationString);
1180    }
1181
1182    if (lastWarningStateDurationMillis != null)
1183    {
1184      addMonitorAttribute(attrs,
1185           "last-warning-state-duration-millis",
1186           INFO_GAUGE_DISPNAME_LAST_WARNING_DURATION_MILLIS.get(),
1187           INFO_GAUGE_DESC_LAST_WARNING_DURATION_MILLIS.get(),
1188           lastWarningStateDurationMillis);
1189    }
1190
1191    if (totalWarningStateDurationString != null)
1192    {
1193      addMonitorAttribute(attrs,
1194           "total-warning-state-duration",
1195           INFO_GAUGE_DISPNAME_TOTAL_WARNING_DURATION_STRING.get(),
1196           INFO_GAUGE_DESC_TOTAL_WARNING_DURATION_STRING.get(),
1197           totalWarningStateDurationString);
1198    }
1199
1200    if (totalWarningStateDurationMillis != null)
1201    {
1202      addMonitorAttribute(attrs,
1203           "total-warning-state-duration-millis",
1204           INFO_GAUGE_DISPNAME_TOTAL_WARNING_DURATION_MILLIS.get(),
1205           INFO_GAUGE_DESC_TOTAL_WARNING_DURATION_MILLIS.get(),
1206           totalWarningStateDurationMillis);
1207    }
1208
1209    if (lastMinorStateStartTime != null)
1210    {
1211      addMonitorAttribute(attrs,
1212           "last-minor-state-start-time",
1213           INFO_GAUGE_DISPNAME_LAST_MINOR_START_TIME.get(),
1214           INFO_GAUGE_DESC_LAST_MINOR_START_TIME.get(),
1215           lastMinorStateStartTime);
1216    }
1217
1218    if (lastMinorStateEndTime != null)
1219    {
1220      addMonitorAttribute(attrs,
1221           "last-minor-state-end-time",
1222           INFO_GAUGE_DISPNAME_LAST_MINOR_END_TIME.get(),
1223           INFO_GAUGE_DESC_LAST_MINOR_END_TIME.get(),
1224           lastMinorStateEndTime);
1225    }
1226
1227    if (lastMinorStateDurationString != null)
1228    {
1229      addMonitorAttribute(attrs,
1230           "last-minor-state-duration",
1231           INFO_GAUGE_DISPNAME_LAST_MINOR_DURATION_STRING.get(),
1232           INFO_GAUGE_DESC_LAST_MINOR_DURATION_STRING.get(),
1233           lastMinorStateDurationString);
1234    }
1235
1236    if (lastMinorStateDurationMillis != null)
1237    {
1238      addMonitorAttribute(attrs,
1239           "last-minor-state-duration-millis",
1240           INFO_GAUGE_DISPNAME_LAST_MINOR_DURATION_MILLIS.get(),
1241           INFO_GAUGE_DESC_LAST_MINOR_DURATION_MILLIS.get(),
1242           lastMinorStateDurationMillis);
1243    }
1244
1245    if (totalMinorStateDurationString != null)
1246    {
1247      addMonitorAttribute(attrs,
1248           "total-minor-state-duration",
1249           INFO_GAUGE_DISPNAME_TOTAL_MINOR_DURATION_STRING.get(),
1250           INFO_GAUGE_DESC_TOTAL_MINOR_DURATION_STRING.get(),
1251           totalMinorStateDurationString);
1252    }
1253
1254    if (totalMinorStateDurationMillis != null)
1255    {
1256      addMonitorAttribute(attrs,
1257           "total-minor-state-duration-millis",
1258           INFO_GAUGE_DISPNAME_TOTAL_MINOR_DURATION_MILLIS.get(),
1259           INFO_GAUGE_DESC_TOTAL_MINOR_DURATION_MILLIS.get(),
1260           totalMinorStateDurationMillis);
1261    }
1262
1263    if (lastMajorStateStartTime != null)
1264    {
1265      addMonitorAttribute(attrs,
1266           "last-major-state-start-time",
1267           INFO_GAUGE_DISPNAME_LAST_MAJOR_START_TIME.get(),
1268           INFO_GAUGE_DESC_LAST_MAJOR_START_TIME.get(),
1269           lastMajorStateStartTime);
1270    }
1271
1272    if (lastMajorStateEndTime != null)
1273    {
1274      addMonitorAttribute(attrs,
1275           "last-major-state-end-time",
1276           INFO_GAUGE_DISPNAME_LAST_MAJOR_END_TIME.get(),
1277           INFO_GAUGE_DESC_LAST_MAJOR_END_TIME.get(),
1278           lastMajorStateEndTime);
1279    }
1280
1281    if (lastMajorStateDurationString != null)
1282    {
1283      addMonitorAttribute(attrs,
1284           "last-major-state-duration",
1285           INFO_GAUGE_DISPNAME_LAST_MAJOR_DURATION_STRING.get(),
1286           INFO_GAUGE_DESC_LAST_MAJOR_DURATION_STRING.get(),
1287           lastMajorStateDurationString);
1288    }
1289
1290    if (lastMajorStateDurationMillis != null)
1291    {
1292      addMonitorAttribute(attrs,
1293           "last-major-state-duration-millis",
1294           INFO_GAUGE_DISPNAME_LAST_MAJOR_DURATION_MILLIS.get(),
1295           INFO_GAUGE_DESC_LAST_MAJOR_DURATION_MILLIS.get(),
1296           lastMajorStateDurationMillis);
1297    }
1298
1299    if (totalMajorStateDurationString != null)
1300    {
1301      addMonitorAttribute(attrs,
1302           "total-major-state-duration",
1303           INFO_GAUGE_DISPNAME_TOTAL_MAJOR_DURATION_STRING.get(),
1304           INFO_GAUGE_DESC_TOTAL_MAJOR_DURATION_STRING.get(),
1305           totalMajorStateDurationString);
1306    }
1307
1308    if (totalMajorStateDurationMillis != null)
1309    {
1310      addMonitorAttribute(attrs,
1311           "total-major-state-duration-millis",
1312           INFO_GAUGE_DISPNAME_TOTAL_MAJOR_DURATION_MILLIS.get(),
1313           INFO_GAUGE_DESC_TOTAL_MAJOR_DURATION_MILLIS.get(),
1314           totalMajorStateDurationMillis);
1315    }
1316
1317    if (lastCriticalStateStartTime != null)
1318    {
1319      addMonitorAttribute(attrs,
1320           "last-critical-state-start-time",
1321           INFO_GAUGE_DISPNAME_LAST_CRITICAL_START_TIME.get(),
1322           INFO_GAUGE_DESC_LAST_CRITICAL_START_TIME.get(),
1323           lastCriticalStateStartTime);
1324    }
1325
1326    if (lastCriticalStateEndTime != null)
1327    {
1328      addMonitorAttribute(attrs,
1329           "last-critical-state-end-time",
1330           INFO_GAUGE_DISPNAME_LAST_CRITICAL_END_TIME.get(),
1331           INFO_GAUGE_DESC_LAST_CRITICAL_END_TIME.get(),
1332           lastCriticalStateEndTime);
1333    }
1334
1335    if (lastCriticalStateDurationString != null)
1336    {
1337      addMonitorAttribute(attrs,
1338           "last-critical-state-duration",
1339           INFO_GAUGE_DISPNAME_LAST_CRITICAL_DURATION_STRING.get(),
1340           INFO_GAUGE_DESC_LAST_CRITICAL_DURATION_STRING.get(),
1341           lastCriticalStateDurationString);
1342    }
1343
1344    if (lastCriticalStateDurationMillis != null)
1345    {
1346      addMonitorAttribute(attrs,
1347           "last-critical-state-duration-millis",
1348           INFO_GAUGE_DISPNAME_LAST_CRITICAL_DURATION_MILLIS.get(),
1349           INFO_GAUGE_DESC_LAST_CRITICAL_DURATION_MILLIS.get(),
1350           lastCriticalStateDurationMillis);
1351    }
1352
1353    if (totalCriticalStateDurationString != null)
1354    {
1355      addMonitorAttribute(attrs,
1356           "total-critical-state-duration",
1357           INFO_GAUGE_DISPNAME_TOTAL_CRITICAL_DURATION_STRING.get(),
1358           INFO_GAUGE_DESC_TOTAL_CRITICAL_DURATION_STRING.get(),
1359           totalCriticalStateDurationString);
1360    }
1361
1362    if (totalCriticalStateDurationMillis != null)
1363    {
1364      addMonitorAttribute(attrs,
1365           "total-critical-state-duration-millis",
1366           INFO_GAUGE_DISPNAME_TOTAL_CRITICAL_DURATION_MILLIS.get(),
1367           INFO_GAUGE_DESC_TOTAL_CRITICAL_DURATION_MILLIS.get(),
1368           totalCriticalStateDurationMillis);
1369    }
1370
1371    return Collections.unmodifiableMap(attrs);
1372  }
1373}