lavalink.client.io.RemoteStats Java Examples
The following examples show how to use
lavalink.client.io.RemoteStats.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiscordExports.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
private MetricFamilySamples getLavaLinkSamples() { if (lavaAudioService.getLavaLink() == null) { return null; } List<MetricFamilySamples.Sample> samples = new ArrayList<>(lavaAudioService .getLavaLink().getNodes().size() * 2); lavaAudioService.getLavaLink().getNodes().forEach(node -> { RemoteStats stats = node.getStats(); if (stats == null) { return; } samples.add(sampleBuilder.createSample(LAVALINK_METRIC_NAME, "_total_players", Collections.singletonList("nodeName"), Collections.singletonList(node.getName()), stats.getPlayers())); samples.add(sampleBuilder.createSample(LAVALINK_METRIC_NAME, "_playing_players", Collections.singletonList("nodeName"), Collections.singletonList(node.getName()), stats.getPlayingPlayers())); samples.add(sampleBuilder.createSample(LAVALINK_METRIC_NAME, "_system_load", Collections.singletonList("nodeName"), Collections.singletonList(node.getName()), stats.getSystemLoad())); samples.add(sampleBuilder.createSample(LAVALINK_METRIC_NAME, "_up", Collections.singletonList("nodeName"), Collections.singletonList(node.getName()), node.isAvailable() ? 1 : 0)); }); return new MetricFamilySamples(LAVALINK_METRIC_NAME, Type.SUMMARY, getHelpMessage(LAVALINK_METRIC_NAME), samples); }
Example #2
Source File: LavalinkCollector.java From Lavalink-Client with MIT License | 4 votes |
@Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<>(); List<String> labelNames = Collections.singletonList("node"); GaugeMetricFamily players = new GaugeMetricFamily("lavalink_players_current", "Amount of players", labelNames); mfs.add(players); GaugeMetricFamily playingPlayers = new GaugeMetricFamily("lavalink_playing_players_current", "Amount of playing players", labelNames); mfs.add(playingPlayers); GaugeMetricFamily uptimeSeconds = new GaugeMetricFamily("lavalink_uptime_seconds", "Uptime of the node", labelNames); mfs.add(uptimeSeconds); GaugeMetricFamily memFree = new GaugeMetricFamily("lavalink_mem_free_bytes", "Amount of free memory", labelNames); mfs.add(memFree); GaugeMetricFamily memUsed = new GaugeMetricFamily("lavalink_mem_used_bytes", "Amount of used memory", labelNames); mfs.add(memUsed); GaugeMetricFamily memAllocated = new GaugeMetricFamily("lavalink_mem_allocated_bytes", "Amount of allocated memory", labelNames); mfs.add(memAllocated); GaugeMetricFamily memReservable = new GaugeMetricFamily("lavalink_mem_reservable_bytes", "Amount of reservable memory", labelNames); mfs.add(memReservable); GaugeMetricFamily cpuCores = new GaugeMetricFamily("lavalink_cpu_cores", "Amount of cpu cores", labelNames); mfs.add(cpuCores); GaugeMetricFamily systemLoad = new GaugeMetricFamily("lavalink_load_system", "Total load of the system", labelNames); mfs.add(systemLoad); GaugeMetricFamily lavalinkLoad = new GaugeMetricFamily("lavalink_load_lavalink", "Load caused by Lavalink", labelNames); mfs.add(lavalinkLoad); GaugeMetricFamily averageFramesSentPerMinute = new GaugeMetricFamily("lavalink_average_frames_sent_per_minute", "Average frames sent per minute", labelNames); mfs.add(averageFramesSentPerMinute); GaugeMetricFamily averageFramesNulledPerMinute = new GaugeMetricFamily("lavalink_average_frames_nulled_per_minute", "Average frames nulled per minute", labelNames); mfs.add(averageFramesNulledPerMinute); GaugeMetricFamily averageFramesDeficitPerMinute = new GaugeMetricFamily("lavalink_average_frames_deficit_per_minute", "Average frames deficit per minute", labelNames); mfs.add(averageFramesDeficitPerMinute); //noinspection unchecked List<LavalinkSocket> nodes = lavalink.getNodes(); for (LavalinkSocket node : nodes) { List<String> labels = Collections.singletonList(node.getName()); RemoteStats stats = node.getStats(); if (stats == null) { continue; } players.addMetric(labels, stats.getPlayers()); playingPlayers.addMetric(labels, stats.getPlayingPlayers()); uptimeSeconds.addMetric(labels, stats.getUptime() / 1000); memFree.addMetric(labels, stats.getMemFree()); memUsed.addMetric(labels, stats.getMemUsed()); memAllocated.addMetric(labels, stats.getMemAllocated()); memReservable.addMetric(labels, stats.getMemReservable()); cpuCores.addMetric(labels, stats.getCpuCores()); systemLoad.addMetric(labels, stats.getSystemLoad()); lavalinkLoad.addMetric(labels, stats.getLavalinkLoad()); averageFramesSentPerMinute.addMetric(labels, stats.getAvgFramesSentPerMinute()); averageFramesNulledPerMinute.addMetric(labels, stats.getAvgFramesNulledPerMinute()); averageFramesDeficitPerMinute.addMetric(labels, stats.getAvgFramesDeficitPerMinute()); } return mfs; }
Example #3
Source File: StatusQueueListener.java From JuniperBot with GNU General Public License v3.0 | 4 votes |
@RabbitListener(queues = RabbitConfiguration.QUEUE_STATUS_REQUEST) public StatusDto getStatus(String dummy) { Map<String, Metric> metricMap = metricRegistry.getMetrics(); StatusDto result = new StatusDto(); result.setGuildCount(getMetricGauge(metricMap, DiscordMetricsRegistry.GAUGE_GUILDS)); result.setUserCount(getMetricGauge(metricMap, DiscordMetricsRegistry.GAUGE_USERS)); result.setTextChannelCount(getMetricGauge(metricMap, DiscordMetricsRegistry.GAUGE_TEXT_CHANNELS)); result.setVoiceChannelCount(getMetricGauge(metricMap, DiscordMetricsRegistry.GAUGE_VOICE_CHANNELS)); result.setActiveConnections(getMetricGauge(metricMap, PlayerService.ACTIVE_CONNECTIONS)); result.setExecutedCommands(getMetricGauge(metricMap, "commands.executions.persist")); result.setUptimeDuration(getMetricGauge(metricMap, "jvm.uptime")); result.setShards(discordService.getShardManager().getShards().stream() .sorted(Comparator.comparing(e -> e.getShardInfo().getShardId())) .map(e -> { ShardDto dto = new ShardDto(); dto.setId(e.getShardInfo().getShardId()); dto.setGuilds(e.getGuildCache().size()); dto.setUsers(e.getUserCache().size()); dto.setChannels(e.getTextChannelCache().size() + e.getVoiceChannelCache().size()); dto.setPing(e.getGatewayPing()); dto.setConnected(JDA.Status.CONNECTED.equals(e.getStatus())); return dto; }) .collect(Collectors.toList())); if (workerProperties.getAudio().getLavalink().isEnabled()) { result.setLinkNodes(lavaAudioService.getLavaLink().getNodes().stream() .sorted(Comparator.comparing(LavalinkSocket::getName)) .map(e -> { LavaLinkNodeDto nodeDto = new LavaLinkNodeDto(); nodeDto.setName(e.getName()); nodeDto.setAvailable(e.isAvailable()); RemoteStats stats = e.getStats(); if (stats != null) { nodeDto.setPlayers(stats.getPlayers()); nodeDto.setPlayingPlayers(stats.getPlayingPlayers()); nodeDto.setLavalinkLoad(stats.getLavalinkLoad()); nodeDto.setSystemLoad(stats.getSystemLoad()); } return nodeDto; }).collect(Collectors.toList())); } return result; }