private void OnPerfMonStartRequest(INetworkConnection con, Packet r) { Log1.Logger("Zeus").Debug("Performance Monitor Start request from " + ServerUser.AccountName + "."); if (!ServerUser.Profile.IsUserInRole("Administrator")) { Log1.Logger("Zeus").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to start performance monitor."); r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can start the performance monitor."); return; } PacketGenericMessage msg = r as PacketGenericMessage; r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, ""); string[] counters = msg.Parms.GetStringArrayProperty(2); if (counters.Length == 0) { r.ReplyPacket.ReplyCode = ReplyType.Failure; r.ReplyPacket.ReplyMessage = "Must specify at least one counter to start."; return; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < counters.Length; i++) { string key = counters[i]; PerfHistory h = null; if (PerfMon.History.TryGetValue(key, out h)) { h.IsEnabled = true; if (sb.Length == 0) { sb.Append("Enabled performance counter "); } sb.Append(key.Replace("|", " -> ") + ", "); } } if (sb.Length >= 2) { sb.Remove(sb.Length - 2, 1); PerfMon.InstallCounters(); PerfMon.StartSamplingCounters(); } else if (sb.Length == 0) { r.ReplyPacket.ReplyCode = ReplyType.Failure; sb.Append("No performance counters were activated."); } r.ReplyPacket.ReplyMessage = sb.ToString(); }