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