001/* 002 * Copyright 2012 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.runtime.plugins.admin.jvmstatus.monitoring; 017 018/** 019 * Monitoring constants. 020 */ 021public interface MonitoringConstants 022{ 023 /** 024 * The name of the monitoring directory, located in the Ametys home 025 * directory 026 */ 027 public static final String RRD_STORAGE_DIRECTORY = "monitoring"; 028 029 /** Extension of RRD files. */ 030 public static final String RRD_EXT = ".rrd"; 031 032 /** Data are fed each minute. */ 033 public static final int FEEDING_PERIOD = 60; 034 035 /** Period to archive and to render. */ 036 public enum Period 037 { 038 /** Last hour. */ 039 LAST_HOUR 040 { 041 @Override 042 public String toString() 043 { 044 return "hour"; 045 } 046 }, 047 /** Last 24 hours. */ 048 LAST_DAY 049 { 050 @Override 051 public String toString() 052 { 053 return "day"; 054 } 055 }, 056 /** Last week. */ 057 LAST_WEEK 058 { 059 @Override 060 public String toString() 061 { 062 return "week"; 063 } 064 }, 065 /** Last month. */ 066 LAST_MONTH 067 { 068 @Override 069 public String toString() 070 { 071 return "month"; 072 } 073 }, 074 /** Last year. */ 075 LAST_YEAR 076 { 077 @Override 078 public String toString() 079 { 080 return "year"; 081 } 082 }; 083 084 /** 085 * Returns the time in seconds for current period. 086 * @return the time. 087 */ 088 public long getTime() 089 { 090 int days = 1; 091 int hours = 1; 092 093 if (this == LAST_YEAR) 094 { 095 days = 365; 096 hours = 24; 097 } 098 else if (this == LAST_MONTH) 099 { 100 days = 31; 101 hours = 24; 102 } 103 else if (this == LAST_WEEK) 104 { 105 days = 7; 106 hours = 24; 107 } 108 else if (this == LAST_DAY) 109 { 110 hours = 24; 111 } 112 113 return 60 * 60 * hours * days; 114 } 115 } 116}