Shards will now show when they're unresponsive in .shardstats command

This commit is contained in:
Master Kwoth 2017-07-05 15:16:06 +02:00
parent 6b51dbd330
commit 9fddfe77c4
6 changed files with 16 additions and 7 deletions

View File

@ -12,5 +12,6 @@ namespace NadekoBot.DataStructures.ShardCom
public int ShardId { get; set; }
public ConnectionState ConnectionState { get; set; }
public int Guilds { get; set; }
public DateTime Time { get; set; }
}
}

View File

@ -270,7 +270,7 @@ namespace NadekoBot.Modules.Music
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
var mps = mp.MaxPlaytimeSeconds;
if (mps > 0)
add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("g"))) + "\n";
add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss"))) + "\n";
if (mp.RepeatCurrentSong)
add += "🔂 " + GetText("repeating_cur_song") + "\n";
else if (mp.Shuffle)

View File

@ -295,8 +295,13 @@ namespace NadekoBot.Modules.Utility
var allShardStrings = statuses
.Select(x =>
GetText("shard_stats_txt", x.ShardId.ToString(),
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString())))
{
var timeDiff = DateTime.UtcNow - x.Time;
if (timeDiff > TimeSpan.FromSeconds(20))
return $"Shard #{x.ShardId.ToString()} **UNRESPONSIVE** for {timeDiff.ToString(@"hh\:mm\:ss")}";
return GetText("shard_stats_txt", x.ShardId.ToString(),
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString()), timeDiff.ToString(@"hh\:mm\:ss"));
})
.ToArray();
await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>

View File

@ -130,8 +130,9 @@ namespace NadekoBot
ConnectionState = Client.ConnectionState,
Guilds = Client.ConnectionState == ConnectionState.Connected ? Client.Guilds.Count : 0,
ShardId = Client.ShardId,
Time = DateTime.UtcNow,
});
await Task.Delay(1000);
await Task.Delay(5000);
}
});
}

View File

@ -3,6 +3,7 @@ using NadekoBot.Services;
using NadekoBot.Services.Impl;
using NLog;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@ -40,6 +41,7 @@ namespace NadekoBot
private Task _comServer_OnDataReceived(ShardComMessage msg)
{
Statuses[msg.ShardId] = msg;
if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting)
_log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState.ToString());
return Task.CompletedTask;
@ -87,7 +89,7 @@ namespace NadekoBot
_log.Info(string.Join("\n", Statuses
.ToArray()
.Where(x => x != null)
.Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers")) + "\n" + groupStr);
.Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers. {(DateTime.UtcNow - x.Time).ToString(@"hh\:mm\:ss")} ago")) + "\n" + groupStr);
break;
default:
break;

View File

@ -678,7 +678,7 @@
"utility_server_info": "Server info",
"utility_shard": "Shard",
"utility_shard_stats": "Shard stats",
"utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers",
"utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers - {3} ago",
"utility_showemojis": "**Name:** {0} **Link:** {1}",
"utility_showemojis_none": "No special emojis found.",
"utility_stats_songs": "Playing {0} songs, {1} queued.",