Package io.antmedia.statistic
Class StatsCollector
java.lang.Object
io.antmedia.statistic.StatsCollector
- All Implemented Interfaces:
IStatsCollector,Aware,DisposableBean,ApplicationContextAware
public class StatsCollector
extends Object
implements IStatsCollector, ApplicationContextAware, DisposableBean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringstatic final Stringstatic final Stringprivate intprivate static intprivate longstatic final Stringstatic final Stringprivate static final Stringprivate static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static com.google.gson.Gsonprivate longprivate booleanprivate intstatic final Stringstatic final Stringprivate static final Stringprivate Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final Stringstatic final Stringstatic final Stringstatic final Stringprivate Stringprivate longstatic final Stringprivate ILicenceServicestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final org.slf4j.Loggerprivate Stringstatic final Stringstatic final Stringstatic final Stringprivate static final Stringprivate intprivate intMemory limit in percentageprivate intMin Free Ram Size that free memory should be always more than min UsememoryLimitstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static intstatic final Stringprivate static final Stringprivate static final Stringstatic final Stringprivate static final Stringstatic final Stringprivate intprivate static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final Stringprivate static final Stringstatic final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringstatic final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate longstatic final Stringstatic final Stringstatic final Stringprivate Stringprivate Versionprivate io.vertx.core.Vertxprivate static final Stringprivate static final Stringprivate static io.vertx.ext.dropwizard.MetricsServiceprivate static final Stringstatic final Stringprivate StringWebhook url to notify high resource usage, unexpected shutdown.private static final Stringstatic final Stringprivate static final Stringprivate static final Stringprivate io.vertx.core.Vertxprivate static io.vertx.ext.dropwizard.MetricsServiceprivate intFields inherited from interface io.antmedia.statistic.IStatsCollector
BEAN_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCpuMeasurement(int systemCpuLoad, int processCpu) voidvoidvoiddestroy()booleanCheck if cpu usage and ram usage does not exceed the limitprivate StringfindAdminUser(List<User> userList) static AdminApplicationgetAdminAppAdaptor(ApplicationContext appContext) static AntMediaApplicationAdaptergetAppAdaptor(ApplicationContext appContext) static com.google.gson.JsonObjectintIt's configurable and it's based on percentage.intIt calculates the average CPU usage for a specified time.private static intgetDASHViewers(IScope scope) longprivate static com.google.gson.JsonArraygetDeadLockedThreads(long[] deadLockedThreads) static com.google.gson.JsonObjectintIn MBstatic com.google.gson.JsonArraystatic com.google.gson.JsonObjectgetGPUInfoJSObject(int deviceIndex, GPUUtils gpuUtils) intprivate static intgetHLSViewers(IScope scope) org.apache.http.impl.client.CloseableHttpClientstatic com.google.gson.JsonObjectstatic com.google.gson.JsonObjectintintintintIt's configurable In MBintstatic intstatic com.google.gson.JsonObjectReturns server uptime and startime in millisecondsintstatic com.google.gson.JsonObjectstatic com.google.gson.JsonObjectstatic com.google.gson.JsonObjectgetSystemResourcesInfo(Queue<IScope> scopes) static ThreadInfo[]static com.google.gson.JsonArraystatic com.google.gson.JsonObjectlongintprivate static intio.vertx.core.VertxgetVertx()intprivate static intintbooleanvoidsend2Kafka(com.google.gson.JsonElement jsonElement, String topicName) voidsend2Kafka(String jsonString, String topicName) voidsendInstanceStats(Queue<IScope> scopes) intvoidsendUnexpectedShutdownHook(List<String> appNames) private voidvoidsendWebRTCClientStats2Kafka(List<WebRTCClientStats> webRTCClientStatList, String streamId) voidsetApplicationContext(ApplicationContext applicationContext) voidsetCpuLimit(int cpuLimit) voidsetCpuLoad(int cpuLoad) voidsetHeartBeatEnabled(boolean heartBeatEnabled) voidsetHeartbeatPeriodMs(int heartbeatPeriodMs) voidsetKafkaBrokers(String kafkaBrokers) voidsetKafkaProducer(org.apache.kafka.clients.producer.Producer<Long, String> kafkaProducer) voidsetMemoryLimit(int memoryLimit) voidsetMinFreeRamSize(int ramLimit) voidvoidsetStaticSendPeriod(int staticSendPeriod) voidsetUnexpectedShutDownDelayMs(long unexpectedShutDownDelayMs) voidsetUserEmail(String userEmail) voidsetVertx(io.vertx.core.Vertx vertx) voidsetWebhookURL(String webhookURL) voidsetWebRTCVertx(io.vertx.core.Vertx webRTCVertx) voidsetWindowSize(int windowSize) voidstart()voidprivate void
-
Field Details
-
FREE_NATIVE_MEMORY
- See Also:
-
TOTAL_NATIVE_MEMORY
- See Also:
-
IN_USE_NATIVE_MEMORY
- See Also:
-
AVAILABLE_MEMORY
- See Also:
-
IN_USE_SWAP_SPACE
- See Also:
-
FREE_SWAP_SPACE
- See Also:
-
TOTAL_SWAP_SPACE
- See Also:
-
VIRTUAL_MEMORY
- See Also:
-
PROCESSOR_COUNT
- See Also:
-
JAVA_VERSION
- See Also:
-
OS_ARCH
- See Also:
-
OS_NAME
- See Also:
-
IN_USE_SPACE
- See Also:
-
FREE_SPACE
- See Also:
-
TOTAL_SPACE
- See Also:
-
USABLE_SPACE
- See Also:
-
IN_USE_MEMORY
- See Also:
-
FREE_MEMORY
- See Also:
-
TOTAL_MEMORY
- See Also:
-
MAX_MEMORY
- See Also:
-
PROCESS_CPU_LOAD
- See Also:
-
SYSTEM_LOAD_AVERAGE_IN_LAST_MINUTE
- See Also:
-
SYSTEM_CPU_LOAD
- See Also:
-
PROCESS_CPU_TIME
- See Also:
-
CPU_USAGE
- See Also:
-
INSTANCE_ID
- See Also:
-
MARKETPLACE_NAME
- See Also:
-
USER_EMAIL
- See Also:
-
LICENSE_VALID
- See Also:
-
INSTANCE_TYPE
- See Also:
-
INSTANCE_VERSION
- See Also:
-
INSTANCE_BUILD_NUMBER
- See Also:
-
JVM_MEMORY_USAGE
- See Also:
-
NATIVE_MEMORY_USAGE
- See Also:
-
SYSTEM_INFO
- See Also:
-
SYSTEM_MEMORY_INFO
- See Also:
-
FILE_SYSTEM_INFO
- See Also:
-
GPU_UTILIZATION
- See Also:
-
GPU_ENCODER_UTILIZATION
- See Also:
-
GPU_DECODER_UTILIZATION
- See Also:
-
GPU_DEVICE_INDEX
- See Also:
-
GPU_MEMORY_UTILIZATION
- See Also:
-
GPU_MEMORY_TOTAL
- See Also:
-
GPU_MEMORY_FREE
- See Also:
-
GPU_MEMORY_USED
- See Also:
-
GPU_DEVICE_NAME
- See Also:
-
GPU_USAGE_INFO
- See Also:
-
FFMPEG_BUILD_INFO
- See Also:
-
TOTAL_LIVE_STREAMS
- See Also:
-
LOCAL_WEBRTC_LIVE_STREAMS
- See Also:
-
DB_AVERAGE_QUERY_TIME_MS
- See Also:
-
LOCAL_LIVE_STREAMS
- See Also:
-
LOCAL_WEBRTC_VIEWERS
- See Also:
-
LOCAL_HLS_VIEWERS
- See Also:
-
LOCAL_DASH_VIEWERS
- See Also:
-
TIME
- See Also:
-
logger
protected static final org.slf4j.Logger logger -
MEASURED_BITRATE
- See Also:
-
SEND_BITRATE
- See Also:
-
AUDIO_FRAME_SEND_PERIOD
- See Also:
-
VIDEO_FRAME_SEND_PERIOD
- See Also:
-
STREAM_ID
- See Also:
-
WEBRTC_CLIENT_ID
- See Also:
-
WEBRTC_VIEWER_INFO
- See Also:
-
scopes
-
GA_TRACKING_ID
- See Also:
-
vertx
private io.vertx.core.Vertx vertx -
cpuMeasurements
-
processCpuMeasurements
-
gson
private static com.google.gson.Gson gson -
windowSize
private int windowSize -
measurementPeriod
private int measurementPeriod -
staticSendPeriod
private int staticSendPeriod -
cpuLoad
private static int cpuLoad -
processCpuLoad
private static int processCpuLoad -
cpuLimit
private int cpuLimit -
memoryLimit
private int memoryLimitMemory limit in percentage -
minFreeRamSize
private int minFreeRamSizeMin Free Ram Size that free memory should be always more than min UsememoryLimit -
kafkaBrokers
-
INSTANCE_STATS_TOPIC_NAME
- See Also:
-
WEBRTC_STATS_TOPIC_NAME
- See Also:
-
UP_TIME
- See Also:
-
START_TIME
- See Also:
-
SERVER_TIMING
- See Also:
-
ENCODERS_BLOCKED
- See Also:
-
ENCODERS_NOT_OPENED
- See Also:
-
PUBLISH_TIMEOUT_ERRORS
- See Also:
-
THREAD_DUMP
- See Also:
-
DEAD_LOCKED_THREAD
- See Also:
-
THREAD_COUNT
- See Also:
-
THREAD_PEEK_COUNT
- See Also:
-
THREAD_NAME
- See Also:
-
THREAD_ID
- See Also:
-
THREAD_BLOCKED_TIME
- See Also:
-
THREAD_BLOCKED_COUNT
- See Also:
-
THREAD_WAITED_TIME
- See Also:
-
THREAD_WAITED_COUNT
- See Also:
-
THREAD_LOCK_NAME
- See Also:
-
THREAD_LOCK_OWNER_ID
- See Also:
-
THREAD_LOCK_OWNER_NAME
- See Also:
-
THREAD_IN_NATIVE
- See Also:
-
THREAD_SUSPENDED
- See Also:
-
THREAD_STATE
- See Also:
-
THREAD_CPU_TIME
- See Also:
-
THREAD_USER_TIME
- See Also:
-
IN_USE_JVM_NATIVE_MEMORY
- See Also:
-
MAX_JVM_NATIVE_MEMORY
- See Also:
-
JVM_NATIVE_MEMORY_USAGE
- See Also:
-
HOST_ADDRESS
- See Also:
-
IP_ADDRESS
- See Also:
-
VERTX_WORKER_QUEUE_SIZE
- See Also:
-
VERTX_WORKER_THREAD_QUEUE_SIZE
- See Also:
-
WEBRTC_VERTX_WORKER_THREAD_QUEUE_SIZE
- See Also:
-
HOOK_HIGH_RESOURCE_USAGE
- See Also:
-
HOOK_UNEXPECTED_SERVER_SHUTDOWN
- See Also:
-
SOFTWARE_VERSION
- See Also:
-
kafkaProducer
-
cpuMeasurementTimerId
private long cpuMeasurementTimerId -
kafkaTimerId
private long kafkaTimerId -
heartBeatEnabled
private boolean heartBeatEnabled -
hearbeatPeriodicTask
private long hearbeatPeriodicTask -
heartbeatPeriodMs
private int heartbeatPeriodMs -
hostAddress
-
webRTCVertx
private io.vertx.core.Vertx webRTCVertx -
time2Log
private int time2Log -
marketplace
-
vertXMetrics
private static io.vertx.ext.dropwizard.MetricsService vertXMetrics -
webRTCVertxMetrics
private static io.vertx.ext.dropwizard.MetricsService webRTCVertxMetrics -
licenseService
-
userEmail
-
webhookURL
Webhook url to notify high resource usage, unexpected shutdown. More callbacks can be added -
unexpectedShutDownDelayMs
private long unexpectedShutDownDelayMs -
version
-
-
Constructor Details
-
StatsCollector
public StatsCollector()
-
-
Method Details
-
start
public void start() -
startKafkaProducer
private void startKafkaProducer() -
getVertWorkerQueueSizeStatic
private static int getVertWorkerQueueSizeStatic() -
getVertWorkerQueueSize
public int getVertWorkerQueueSize() -
getWebRTCVertxWorkerQueueSizeStatic
private static int getWebRTCVertxWorkerQueueSizeStatic() -
getWebRTCVertxWorkerQueueSize
public int getWebRTCVertxWorkerQueueSize() -
sendWebRTCClientStats
private void sendWebRTCClientStats() -
collectAndSendWebRTCClientsStats
public void collectAndSendWebRTCClientsStats() -
sendWebRTCClientStats2Kafka
public void sendWebRTCClientStats2Kafka(List<WebRTCClientStats> webRTCClientStatList, String streamId) -
createKafkaProducer
-
getFileSystemInfoJSObject
public static com.google.gson.JsonObject getFileSystemInfoJSObject() -
getGPUInfoJSObject
-
getGPUInfoJSObject
public static com.google.gson.JsonArray getGPUInfoJSObject() -
getCPUInfoJSObject
public static com.google.gson.JsonObject getCPUInfoJSObject() -
getThreadDump
-
getThreadDumpJSON
public static com.google.gson.JsonArray getThreadDumpJSON() -
getDeadLockedThreads
private static com.google.gson.JsonArray getDeadLockedThreads(long[] deadLockedThreads) -
getThreadInfoJSONObject
public static com.google.gson.JsonObject getThreadInfoJSONObject() -
getJVMMemoryInfoJSObject
public static com.google.gson.JsonObject getJVMMemoryInfoJSObject() -
getSystemInfoJSObject
public static com.google.gson.JsonObject getSystemInfoJSObject() -
getSysteMemoryInfoJSObject
public static com.google.gson.JsonObject getSysteMemoryInfoJSObject() -
getJVMNativeMemoryInfoJSObject
public static com.google.gson.JsonObject getJVMNativeMemoryInfoJSObject() -
getServerTime
public static com.google.gson.JsonObject getServerTime()Returns server uptime and startime in milliseconds- Returns:
-
getAdminAppAdaptor
-
getAppAdaptor
-
getSystemResourcesInfo
-
getDBQueryAverageTimeMs
public long getDBQueryAverageTimeMs() -
getHLSViewers
-
getDASHViewers
-
sendInstanceStats
-
send2Kafka
-
send2Kafka
-
addCpuMeasurement
public void addCpuMeasurement(int systemCpuLoad, int processCpu) -
getMemoryLoad
public int getMemoryLoad() -
getOSType
public int getOSType() -
enoughResource
public boolean enoughResource()Description copied from interface:IStatsCollectorCheck if cpu usage and ram usage does not exceed the limit- Specified by:
enoughResourcein interfaceIStatsCollector- Returns:
- true if not exceeding the limit, false if exceeding limit
-
sendUnexpectedShutdownHook
-
sendPOST
- Throws:
IOException
-
getFreeRam
public int getFreeRam()Description copied from interface:IStatsCollectorIn MB- Specified by:
getFreeRamin interfaceIStatsCollector- Returns:
- the free RAM that server can use
-
getMinFreeRamSize
public int getMinFreeRamSize()Description copied from interface:IStatsCollectorIt's configurable In MB- Specified by:
getMinFreeRamSizein interfaceIStatsCollector- Returns:
- the free RAM size that server should have all the time
-
setMinFreeRamSize
public void setMinFreeRamSize(int ramLimit) -
setCpuLoad
public void setCpuLoad(int cpuLoad) -
getCpuLoad
public int getCpuLoad()Description copied from interface:IStatsCollectorIt calculates the average CPU usage for a specified time.- Specified by:
getCpuLoadin interfaceIStatsCollector- Returns:
- the current CPU usage
-
getProcessCpuLoad
public static int getProcessCpuLoad() -
getWindowSize
public int getWindowSize() -
setWindowSize
public void setWindowSize(int windowSize) -
getVertx
public io.vertx.core.Vertx getVertx() -
setVertx
public void setVertx(io.vertx.core.Vertx vertx) -
setWebRTCVertx
public void setWebRTCVertx(io.vertx.core.Vertx webRTCVertx) -
setCpuLimit
public void setCpuLimit(int cpuLimit) -
getCpuLimit
public int getCpuLimit()Description copied from interface:IStatsCollectorIt's configurable and it's based on percentage. Max value is 100.- Specified by:
getCpuLimitin interfaceIStatsCollector- Returns:
- the CPU limit that server does not exceed.
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
getStaticSendPeriod
public int getStaticSendPeriod() -
setStaticSendPeriod
public void setStaticSendPeriod(int staticSendPeriod) -
setKafkaProducer
-
getKafkaBrokers
-
setKafkaBrokers
-
setScopes
-
cancelHeartBeat
public void cancelHeartBeat() -
isHeartBeatEnabled
public boolean isHeartBeatEnabled() -
setHeartBeatEnabled
public void setHeartBeatEnabled(boolean heartBeatEnabled) -
getHeartbeatPeriodMs
public int getHeartbeatPeriodMs() -
setHeartbeatPeriodMs
public void setHeartbeatPeriodMs(int heartbeatPeriodMs) -
destroy
- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception
-
getMeasurementPeriod
public int getMeasurementPeriod() -
startAnalytic
public void startAnalytic() -
setUserEmail
-
getUserEmail
-
findAdminUser
-
getHttpClient
public org.apache.http.impl.client.CloseableHttpClient getHttpClient() -
getUnexpectedShutDownDelayMs
public long getUnexpectedShutDownDelayMs() -
setUnexpectedShutDownDelayMs
public void setUnexpectedShutDownDelayMs(long unexpectedShutDownDelayMs) -
setWebhookURL
-
getMemoryLimit
public int getMemoryLimit() -
setMemoryLimit
public void setMemoryLimit(int memoryLimit) -
getVersion
-