Ejemplo n.º 1
0
        public void SendMessage()
        {
            try
            {
                string message;

                CollectedInfo info = PCStatus.CollectAllInfo();

                Checking_Alerting(info);

                message = JsonConvert.SerializeObject(info);

                byte[] data = Encoding.Unicode.GetBytes(message);
                Thread.Sleep(40);
                stream.Write(data, 0, data.Length);
            }
            catch (Exception ex)
            {
                //Close();
                //sending_info.Interrupt();
                //Environment.Exit(0);
                MessageBox.Show(ex.Message + Environment.NewLine);
            }
        }
Ejemplo n.º 2
0
        void Edit_Boxes(CollectedInfo info)
        {
            string elems = "";

            foreach (string elem in info.processes)
            {
                elems += elem + "\r\n";
            }

            if (processes_richTextBox.InvokeRequired)
            {
                processes_richTextBox.Invoke(new MethodInvoker(delegate
                {
                    processes_richTextBox.Text = elems;
                }));
            }
            else
            {
                processes_richTextBox.Text = elems;
            }

            if (virtmem_richTextBox.InvokeRequired)
            {
                virtmem_richTextBox.Invoke(new MethodInvoker(delegate
                {
                    virtmem_richTextBox.Text = info.av_virt_mem.ToString();
                }));
            }
            else
            {
                virtmem_richTextBox.Text = info.av_virt_mem.ToString();
            }

            if (physmem_richTextBox.InvokeRequired)
            {
                physmem_richTextBox.Invoke(new MethodInvoker(delegate
                {
                    physmem_richTextBox.Text = info.av_phys_mem.ToString();
                }));
            }
            else
            {
                physmem_richTextBox.Text = info.av_phys_mem.ToString();
            }

            elems = "";
            foreach (DiskInfo elem in info.disks_info)
            {
                elems += elem.GetFields();
                elems += Environment.NewLine + "\r\n";
            }

            if (disks_richTextBox.InvokeRequired)
            {
                disks_richTextBox.Invoke(new MethodInvoker(delegate
                {
                    disks_richTextBox.Text = elems;
                }));
            }
            else
            {
                disks_richTextBox.Text = elems;
            }

            if (sys_richTextBox.InvokeRequired)
            {
                sys_richTextBox.Invoke(new MethodInvoker(delegate
                {
                    sys_richTextBox.Text = info.sys_info.GetFields();
                }));
            }
            else
            {
                sys_richTextBox.Text = info.sys_info.GetFields();
            }
        }
Ejemplo n.º 3
0
 void Checking_Alerting(CollectedInfo info)
 {
     if (take && iteration < first_message_counter)
     {
         E_p            += info.av_phys_mem;
         E_v            += info.av_virt_mem;
         phys[iteration] = info.av_phys_mem;
         virt[iteration] = info.av_virt_mem;
         iteration++;
     }
     else
     {
         if (!is_in)
         {
             E_p /= first_message_counter;
             E_v /= first_message_counter;
             double sum = 0;
             foreach (double x in phys)
             {
                 sum += Math.Pow(x - E_p, 2);
             }
             sum /= first_message_counter - 1;
             D_p  = sum; sum = 0; //есть физ-дисперсия
             foreach (double x in virt)
             {
                 sum += Math.Pow(x - E_v, 2);
             }
             sum      /= first_message_counter - 1;
             D_v       = sum; sum = 0; //есть вирт-дисперсия
             take      = false; is_in = true;
             iteration = 0; iteration_1 = 0;
         }
         else
         {
             bool option = !((info.av_phys_mem > (E_p - 3 * D_p)) && (info.av_phys_mem < (E_p + 3 * D_p)));
             if (option)
             {
                 iteration++;
                 if (iteration >= message_control_count)
                 {
                     alert = true;
                 }
             }
             else
             {
                 iteration = 0;
                 alert     = false;
             }
             option = (info.av_virt_mem <E_v - 3 * D_v || info.av_virt_mem> E_v + 3 * D_v);
             if (option)
             {
                 iteration_1++;
                 if (iteration_1 >= message_control_count)
                 {
                     alert_1 = true;
                 }
             }
             else
             {
                 iteration_1 = 0;
                 alert_1     = false;
             }
             info.need_alert = alert || alert_1;
             if (alert)
             {
                 alert = !alert; iteration = 0;
             }
             if (alert_1)
             {
                 alert_1 = !alert_1; iteration_1 = 0;
             }
         }
     }
 }