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
Modifier and TypeFieldDescriptionprivate static final String
static final String
static final String
private int
private int
private long
static final String
static final String
private static final String
private static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
private static com.google.gson.Gson
private long
private boolean
private int
static final String
static final String
private static final String
private String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
private static final String
static final String
static final String
static final String
private String
private long
static final String
private ILicenceService
static final String
static final String
static final String
static final String
static final String
protected static final org.slf4j.Logger
private String
static final String
static final String
static final String
private static final String
private int
private int
Memory limit in percentageprivate int
Min Free Ram Size that free memory should be always more than min UsememoryLimit
static final String
static final String
static final String
static final String
static final String
static final String
private static final String
private static final String
static final String
private static final String
static final String
private int
private static final String
static final String
static final String
static final String
static final String
private static final String
private static final String
static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private int
static final String
static final String
static final String
static final String
static final String
private long
static final String
static final String
static final String
private String
private io.vertx.core.Vertx
private static final String
private static final String
private static io.vertx.ext.dropwizard.MetricsService
private static final String
static final String
private String
Webhook url to notify high resource usage, unexpected shutdown.private static final String
static final String
private static final String
private static final String
private io.vertx.core.Vertx
private static io.vertx.ext.dropwizard.MetricsService
private int
Fields inherited from interface io.antmedia.statistic.IStatsCollector
BEAN_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCpuMeasurement
(int measurment) void
void
void
destroy()
boolean
Check if cpu usage and ram usage does not exceed the limitprivate String
findAdminUser
(List<User> userList) static AdminApplication
getAdminAppAdaptor
(ApplicationContext appContext) static AntMediaApplicationAdapter
getAppAdaptor
(ApplicationContext appContext) static com.google.gson.JsonObject
int
It's configurable and it's based on percentage.int
It calculates the average CPU usage for a specified time.private static int
getDASHViewers
(IScope scope) long
private static com.google.gson.JsonArray
getDeadLockedThreads
(long[] deadLockedThreads) static com.google.gson.JsonObject
int
In MBstatic com.google.gson.JsonArray
static com.google.gson.JsonObject
getGPUInfoJSObject
(int deviceIndex, GPUUtils gpuUtils) int
private static int
getHLSViewers
(IScope scope) org.apache.http.impl.client.CloseableHttpClient
static com.google.gson.JsonObject
static com.google.gson.JsonObject
int
int
int
int
It's configurable In MBint
static com.google.gson.JsonObject
Returns server uptime and startime in millisecondsint
static com.google.gson.JsonObject
static com.google.gson.JsonObject
static com.google.gson.JsonObject
getSystemResourcesInfo
(Queue<IScope> scopes) static ThreadInfo[]
static com.google.gson.JsonArray
static com.google.gson.JsonObject
long
int
private static int
io.vertx.core.Vertx
getVertx()
int
private static int
int
boolean
void
send2Kafka
(com.google.gson.JsonElement jsonElement, String topicName) void
sendInstanceStats
(Queue<IScope> scopes) int
void
sendUnexpectedShutdownHook
(List<String> appNames) private void
void
sendWebRTCClientStats2Kafka
(List<WebRTCClientStats> webRTCClientStatList, String streamId) void
setApplicationContext
(ApplicationContext applicationContext) void
setCpuLimit
(int cpuLimit) void
setCpuLoad
(int cpuLoad) void
setHeartBeatEnabled
(boolean heartBeatEnabled) void
setHeartbeatPeriodMs
(int heartbeatPeriodMs) void
setKafkaBrokers
(String kafkaBrokers) void
setKafkaProducer
(org.apache.kafka.clients.producer.Producer<Long, String> kafkaProducer) void
setMemoryLimit
(int memoryLimit) void
setMinFreeRamSize
(int ramLimit) void
void
setStaticSendPeriod
(int staticSendPeriod) void
setUnexpectedShutDownDelayMs
(long unexpectedShutDownDelayMs) void
setUserEmail
(String userEmail) void
setVertx
(io.vertx.core.Vertx vertx) void
setWebhookURL
(String webhookURL) void
setWebRTCVertx
(io.vertx.core.Vertx webRTCVertx) void
setWindowSize
(int windowSize) void
start()
void
private 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:
-
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
-
gson
private static com.google.gson.Gson gson -
windowSize
private int windowSize -
measurementPeriod
private int measurementPeriod -
staticSendPeriod
private int staticSendPeriod -
cpuLoad
private int cpuLoad -
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
-
-
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
-
addCpuMeasurement
public void addCpuMeasurement(int measurment) -
getMemoryLoad
public int getMemoryLoad() -
getOSType
public int getOSType() -
enoughResource
public boolean enoughResource()Description copied from interface:IStatsCollector
Check if cpu usage and ram usage does not exceed the limit- Specified by:
enoughResource
in interfaceIStatsCollector
- Returns:
- true if not exceeding the limit, false if exceeding limit
-
sendUnexpectedShutdownHook
-
sendPOST
- Throws:
IOException
-
getFreeRam
public int getFreeRam()Description copied from interface:IStatsCollector
In MB- Specified by:
getFreeRam
in interfaceIStatsCollector
- Returns:
- the free RAM that server can use
-
getMinFreeRamSize
public int getMinFreeRamSize()Description copied from interface:IStatsCollector
It's configurable In MB- Specified by:
getMinFreeRamSize
in 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:IStatsCollector
It calculates the average CPU usage for a specified time.- Specified by:
getCpuLoad
in interfaceIStatsCollector
- Returns:
- the current CPU usage
-
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:IStatsCollector
It's configurable and it's based on percentage. Max value is 100.- Specified by:
getCpuLimit
in interfaceIStatsCollector
- Returns:
- the CPU limit that server does not exceed.
-
setApplicationContext
- Specified by:
setApplicationContext
in 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:
destroy
in 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)
-