示例#1
0
            public string Explain(string JSON)
            {
                if (JSON == null)
                {
                    return("SMART Data: no data");
                }

                try
                {
                    ReportingSMART rd = JsonConvert.DeserializeObject <ReportingSMART>(JSON);
                    if (rd.UpdatedAttribs == null)
                    {
                        rd.UpdatedAttribs = new List <int>();
                    }

                    string res = "--- ERROR - FAILURE IMMINENT ---\r\n";
                    res += rd.App.Model + "\r\n";
                    res += "SN: " + rd.App.SerialNumber + "\r\n";
                    res += "Firmware: " + rd.App.FirmwareRevision + "\r\n";
                    res += "Size: " + CommonUtilities.NiceSize(rd.App.Size) + "\r\n\r\n";
                    if (rd.App.Attributes == null)
                    {
                        rd.App.Attributes = new Dictionary <int, VulpesSMARTAttribute>();
                    }
                    if (rd.App.Attributes.Count > 0)
                    {
                        res += "Attrib|Name|Ideal|Fail|Value|Threshold|Worst|Raw\r\n";
                    }
                    foreach (KeyValuePair <int, VulpesSMARTAttribute> kvp in rd.App.Attributes)
                    {
                        string Name        = "???";
                        string AttribIdeal = "";
                        if (SMARTDescription.Descriptions.ContainsKey(kvp.Key) == true)
                        {
                            Name = SMARTDescription.Descriptions[kvp.Key].Description;
                            switch (SMARTDescription.Descriptions[kvp.Key].Ideal)
                            {
                            case SMARTDescriptionEnum.Critical: AttribIdeal = "‼"; break;

                            case SMARTDescriptionEnum.LowIdeal: AttribIdeal = "↓"; break;

                            case SMARTDescriptionEnum.HighIdeal: AttribIdeal = "↑"; break;
                            }
                        }

                        res += "0x" + kvp.Value.ID.ToString("X") + "|" + Name + "|" + AttribIdeal + "|" + (kvp.Value.FailureImminent == true ? "!true!" : "false") + "|" +
                               kvp.Value.Value + "|" + kvp.Value.Threshold + "|" + kvp.Value.Worst + "|" + kvp.Value.Vendordata +
                               (SMARTDescription.IsAttribInError(kvp.Value) == true ? " ◄ ◄ ◄ ◄ ◄" : "") +
                               (rd.UpdatedAttribs.Contains(kvp.Key) == true ? "←←" : "") +
                               "\r\n";
                    }
                    return(res);
                }
                catch
                {
                    return("SMART Report Data faulty: " + JSON);
                }
            }
示例#2
0
        void ReportThings(SQLLib sql, string MachineID, string Method, VulpesSMARTInfo ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot, List <int> UpdatedAttribs = null)
        {
            bool   Critical = Method.ToLower() == "error" ? true : false;
            string ID       = (Method.ToLower() == "error" ? "ERROR\\\\" : "") + MachineID + "\\\\" + ar.PNPDeviceID;

            bool ReportToAdmin   = RepElementRoot.ReportToAdmin.Value;
            bool ReportToClient  = RepElementRoot.ReportToClient.Value;
            bool UrgentForAdmin  = RepElementRoot.UrgentForAdmin.Value;
            bool UrgentForClient = RepElementRoot.UrgentForClient.Value;

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0)
                {
                    ReportToAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0)
                {
                    ReportToClient = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0)
                {
                    UrgentForAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0)
                {
                    UrgentForClient = false;
                }
            }

            if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false)
            {
                return;
            }
            ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) |
                                   (ReportToClient == true ? ReportingFlags.ReportToClient : 0) |
                                   (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) |
                                   (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0);

            ReportingSMART sm = new ReportingSMART();

            sm.App            = ar;
            sm.UpdatedAttribs = UpdatedAttribs;

            ReportingProcessor.ReportSMART(sql, MachineID, Method, sm, Flags, Critical);

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                AlreadyReported[ID] |= (Int64)Flags;
            }
            else
            {
                AlreadyReported.Add(ID, (Int64)Flags);
            }
        }
示例#3
0
        public static void ReportSMART(SQLLib sql, string MachineID, string Method, ReportingSMART AR, ReportingFlags Flags, bool Critical)
        {
            Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported);

            AR.Action = Method;

            sql.InsertMultiData("Reporting",
                                new SQLData("MachineID", MachineID),
                                new SQLData("Type", Critical == false ? ReportingPolicyType.SMART : ReportingPolicyType.SMARTCritical),
                                new SQLData("Data", JsonConvert.SerializeObject(AR)),
                                new SQLData("Flags", Flags));
        }