示例#1
0
 private void GetAllNodeDiagnosticsFiles(string cluster, string nodeid, string startTime, string endTime)
 {
     SALsA.GetInstance(Id).TaskManager.AddTask(
         BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerHostMultiFilename,
                                                GenevaActions.GetNodeDiagnosticsFiles(Id, cluster, nodeid, String.Join(",", Constants.GetNodeDiagnosticsFilesTagsParamMultiHost), startTime, endTime), Id)
         );
 }
示例#2
0
        ARMSubscription AnalyzeARMSubscription(Guid subscriptionId, string ressourceGroupName)
        {
            try
            {
                var arm             = GenevaActions.GetARMSubscriptionRG(Id, subscriptionId, ressourceGroupName).Result;
                var armSubscription = AnalyzeARMSubscriptionResult(arm);

                return(armSubscription);
            }
            catch (Exception ex)
            {
                Log.Error("Unable to get or analyse the ARM subscription {0}", this.SubscriptionId);
                Log.Exception(ex);
                return(null);
            }
        }
示例#3
0
        RDFESubscription AnalyzeRDFESubscription(Guid subscriptionId)
        {
            try
            {
                var rdfe             = GenevaActions.GetRDFESubscription(Id, subscriptionId).Result;
                var rdfeSubscription = AnalyzeRDFESubscriptionResult(rdfe);

                return(rdfeSubscription);
            }
            catch (Exception ex)
            {
                Log.Error("Unable to get or analyse the RDFE subscription {0}", this.SubscriptionId);
                Log.Exception(ex);
                return(null);
            }
        }
示例#4
0
        private void AnalyzerInternal(bool checkARM = true, bool checkRDFE = true)
        {
            (var arm, var rdfe) = CallARMAndRDFE(checkARM, checkRDFE);
            (var type, var dep) = DetectVMType(arm, rdfe);

            if (dep == null && IsCustomRun == false)
            {
                try
                {
                    var instance = AnalyzeARMResourceURI(SubscriptionId.ToString(), ResourceGroupName, VMName);
                    GlobalInfo.Update(
                        new Guid(instance.Last().ContainerId),
                        new Guid(instance.Last().NodeId),
                        instance.Last().Cluster
                        );

                    if (!string.IsNullOrWhiteSpace(instance.FirstOrDefault().Usage_ResourceGroupName))
                    {
                        this.ResourceGroupName = instance.FirstOrDefault().Usage_ResourceGroupName;
                    }
                    this.VMName = instance.FirstOrDefault().RoleInstanceName;
                }
                catch
                {
                    try
                    {
                        var instance = AnalyzeRDFEResourceURI(SubscriptionId.ToString(), ResourceGroupName, VMName);
                        GlobalInfo.Update(
                            new Guid(instance.Last().ContainerId),
                            new Guid(instance.Last().NodeId),
                            instance.Last().Cluster
                            );
                        this.ResourceGroupName = instance.FirstOrDefault().TenantId;
                        this.VMName            = instance.FirstOrDefault().RoleInstanceName;
                    }
                    catch
                    {
                        SALsA.GetInstance(Id).State = SALsAState.NotFound;
                        throw new Exception("VM not found");
                    }
                }

                (type, dep) = DetectVMType(arm, rdfe);

                if (dep == null && IsCustomRun == false)
                {
                    SALsA.GetInstance(Id).ICM.QueueICMDiscussion(String.Format("Could not find VM: {0} in RG: {1}. This VM might have been already deleted or moved",
                                                                               this.VMName, this.ResourceGroupName));

                    // Lets try to check kusto data
                    SALsA.GetInstance(Id).TaskManager.AddTask(
                        BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByContainerId(Id, GlobalInfo), Id));
                }
            }
            CallInternalComputeTypes(type, dep);
        }
示例#5
0
        private void ExecuteAllActionsForPaaS(RDFEDeployment dep)
        {
            var instance = dep.RoleInstances.Where(x => String.Equals(x.RoleInstanceName, VMName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (instance?.RoleInstanceName == null)
            {
                instance = dep.RoleInstances.Where(x => String.Equals(x.RoleInstanceName, TryConvertInstanceNameToVMName(this.VMName), StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
            }
            if (instance?.RoleInstanceName == null)
            {
                instance = dep.RoleInstances.Where(x => String.Equals(x.ID.ToString(), VMName)).FirstOrDefault();
            }

            GlobalInfo = new ShortRDFERoleInstance
            {
                Icm            = Id,
                Fabric         = dep.FabricGeoId,
                DeploymentId   = dep.Id,
                DeploymentName = dep.Name,
                ContainerID    = instance.ID,
                InstanceName   = instance.RoleInstanceName
            };

            Task <string> modelTask = null;

            SALsA.GetInstance(Id).TaskManager.AddTask(
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerVMScreenshotOutputFilename, GenevaActions.GetClassicVMConsoleScreenshot(Id, GlobalInfo), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByDeploymentIdorVMName(Id, GlobalInfo), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerContainerSettings, modelTask = GenevaActions.GetContainerSettings(Id, GlobalInfo), Id)
                );

            try
            {
                var model = Utility.JsonToObject <Json2Class.ContainerSettings>(modelTask.Result);
                GlobalInfo.NodeId = new Guid(model.NodeId);
            }
            catch (Exception ex)
            {
                Log.Critical("Failed to populate NodeId");
                Log.Exception(ex);
            }
            finally
            {
                SALsA.GetInstance(Id)?.ICM.QueueICMDiscussion(GlobalInfo.ToString());
            }
        }
示例#6
0
        private void ExecuteAllActionsForVMSS(ARMDeployment dep)
        {
            int instanceId = TryConvertInstanceNameToInstanceId(this.VMName);

            // TODO instead of using 0, take 5 random and use them
            instanceId = instanceId == -1 ? 0 : instanceId;

            Task <string> modelTask = null;

            SALsA.GetInstance(Id).ICM.QueueICMDiscussion(dep.ToString());
            SALsA.GetInstance(Id).TaskManager.AddTask(
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerConsoleSerialOutputFilename, GenevaActions.GetVMConsoleSerialLogs(Id, dep, instanceId), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerVMScreenshotOutputFilename, GenevaActions.GetVMConsoleScreenshot(Id, dep, instanceId), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerVMModelAndViewOutputFilename, modelTask = GenevaActions.GetVMModelAndInstanceView(Id, dep, instanceId), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerInspectIaaSDiskOutputFilename, GenevaActions.InspectIaaSDiskForARMVM(Id, dep, instanceId), Id)
                );
            var rawInfo = LogContainerId(modelTask, Id);

            if (rawInfo != null)
            {
                GlobalInfo.Update(
                    new Guid(rawInfo.ContainerId),
                    new Guid(rawInfo.NodeId),
                    rawInfo.Cluster
                    );
                SALsA.GetInstance(Id).TaskManager.AddTask(
                    BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByContainerId(Id, GlobalInfo), Id)
                    );
            }
        }
示例#7
0
        /*
         * private bool AnalyzeHost()
         * {
         *  var currentICM = SALsA.GetInstance(Id).ICM;
         *  var title = currentICM.CurrentICM.Title;
         *  var isHostIssue = Regex.Match(title, @"HostGAPlugin.*Cluster.*Node.*(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}", RegexOptions.IgnoreCase).Success;
         *  if (isHostIssue)
         *  {
         *      var splitTitle = title.ToLowerInvariant().Replace(" :", ":").Replace(": ", ":").Replace(",", " ").Replace(".", " ").Replace("nodeid", "node").Split(' ');
         *      splitTitle = Array.FindAll(splitTitle, s => s.Contains(":"));
         *      var dict = splitTitle.ToDictionary(
         *          k => k.Split(':')[0],
         *          e => e.Split(':')[1]
         *      );
         *      var cluster = dict["cluster"];
         *      var nodeid = dict["node"];
         *      var creationTime = currentICM.CurrentICM.CreateDate;
         *      var startTime = creationTime.AddHours(-12);
         *      var endTime = new DateTime(Math.Min(creationTime.AddHours(+12).Ticks, DateTime.UtcNow.Ticks));
         *      SALsA.GetInstance(Id).TaskManager.AddTask(
         *      Utility.SaveAndSendBlobTask(Constants.AnalyzerHostGAPluginFilename,
         *          GenevaActions.GetNodeDiagnosticsFiles(Id, cluster, nodeid, startTime.ToString("s"), endTime.ToString("s")), Id)
         *      );
         *  }
         *  return isHostIssue;
         * }
         */
        private void ExecuteAllActionsForIaaS(ARMDeployment dep)
        {
            Task <string> modelTask = null;

            SALsA.GetInstance(Id).ICM.QueueICMDiscussion(dep.ToString());
            SALsA.GetInstance(Id).TaskManager.AddTask(
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerConsoleSerialOutputFilename, GenevaActions.GetVMConsoleSerialLogs(Id, dep), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerVMScreenshotOutputFilename, GenevaActions.GetVMConsoleScreenshot(Id, dep), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerVMModelAndViewOutputFilename, modelTask = GenevaActions.GetVMModelAndInstanceView(Id, dep), Id),
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerInspectIaaSDiskOutputFilename, GenevaActions.InspectIaaSDiskForARMVM(Id, dep), Id)
                );

            var rawInfo = LogContainerId(modelTask, Id);

            if (rawInfo != null)
            {
                GlobalInfo.Update(
                    new Guid(rawInfo.ContainerId),
                    new Guid(rawInfo.NodeId),
                    rawInfo.Cluster
                    );
                var startTime = SALsA.GetInstance(Id).ICM.ICMImpactStartTime().AddHours(-12);
                var endTime   = new DateTime(Math.Min(startTime.AddHours(+24).Ticks, DateTime.UtcNow.Ticks));
                SALsA.GetInstance(Id).TaskManager.AddTask(
                    BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByContainerId(Id, GlobalInfo), Id)
                    );
            }
        }
示例#8
0
        public Analyzer(int Id, object manualRun)
        {
            this.IsCustomRun = true;
            this.Id          = Id;
            StartTime        = SALsA.GetInstance(Id).ICM.CurrentICM.CreateDate;
            Log.Information("Received ManualRun order type {0} with param {1} : ",
                            manualRun.GetType(), Utility.ObjectToJson(manualRun));
            if (manualRun.GetType() == typeof(ManualRun_ICM))
            {
                ManualRun_ICM manualArm = (ManualRun_ICM)manualRun;

                SubscriptionId    = manualArm.SubscriptionID;
                ResourceGroupName = manualArm.ResourceGroupName;
                VMName            = manualArm.VMName;

                AnalyzerInternal();
            }
            else if (manualRun.GetType() == typeof(ManualRun_IID))
            {
                ManualRun_IID manualIID = (ManualRun_IID)manualRun;

                SubscriptionId    = manualIID.SubscriptionID;
                ResourceGroupName = manualIID.ResourceGroupName;
                VMName            = manualIID.VMName;

                ARMDeployment dep        = null;
                int           instanceId = -1;
                if (String.IsNullOrEmpty(manualIID.Region))
                {
                    Log.Information("Calling automatic ARM VMdetection. No Region parameter provided.");
                    ARMSubscription arm = AnalyzeARMSubscription(SubscriptionId, this.ResourceGroupName);
                    dep        = AnalyzeARMDeployment(arm);
                    instanceId = TryConvertInstanceNameToInstanceId(this.VMName);
                }
                else
                {
                    dep                = new ARMDeployment();
                    dep.Name           = manualIID.VMName;
                    dep.Subscriptions  = manualIID.SubscriptionID.ToString();
                    dep.ResourceGroups = manualIID.ResourceGroupName;
                    dep.Location       = manualIID.Region;
                    instanceId         = manualIID.Instance;
                }
                if (instanceId < 0)
                {
                    Log.Information("No Instance ID detected. Assuming this is a normal single IaaS VM");
                    SALsA.GetInstance(Id).TaskManager.AddTask(
                        BlobStorageUtility.SaveAndSendBlobTask(
                            Constants.AnalyzerInspectIaaSDiskOutputFilename,
                            GenevaActions.InspectIaaSDiskForARMVM(Id, dep), Id));
                }
                else
                {
                    Log.Information("No Instance ID detected. Assuming this is a normal single IaaS VM");
                    SALsA.GetInstance(Id).TaskManager.AddTask(
                        BlobStorageUtility.SaveAndSendBlobTask(
                            Constants.AnalyzerInspectIaaSDiskOutputFilename,
                            GenevaActions.InspectIaaSDiskForARMVM(Id, dep, instanceId), Id));
                }
            }
            else if (manualRun.GetType() == typeof(ManualRun_RDFE_Fabric))
            {
                var rdfe   = (ManualRun_RDFE_Fabric)manualRun;
                var vmInfo = new ShortRDFERoleInstance
                {
                    ContainerID = new Guid(rdfe.ContainerID),
                    Fabric      = rdfe.FabricCluster,
                    NodeId      = new Guid(rdfe.NodeId)
                };
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByContainerId(Id, vmInfo), Id).Wait();
            }
            else if (manualRun.GetType() == typeof(ManualRun_RDFE_Tenant))
            {
                var rdfe   = (ManualRun_RDFE_Tenant)manualRun;
                var vmInfo = new ShortRDFERoleInstance
                {
                    Fabric       = rdfe.FabricCluster,
                    DeploymentId = rdfe.DeploymentID,
                    InstanceName = rdfe.RoleInstanceName
                };
                BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByDeploymentIdorVMName(Id, vmInfo), Id).Wait();
            }
        }