Beispiel #1
0
 private static void LoadRegisteredDevice(int RegisteredDevicePK, RegisteredDevice device)
 {
     try
     {
         using (SqlCommand sql = new SqlCommand("GetRegisteredDevice"))
         {
             sql.CommandType = System.Data.CommandType.StoredProcedure;
             sql.Parameters.AddWithValue("@RegisteredDevicePK", RegisteredDevicePK);
             using (var reader = DataAccess.ExecuteReader(sql))
             {
                 device.RegisteredDevicePK = ValidationHelper.GetInteger(reader["RegisteredDevicePK"], 0);
                 device.IP       = string.Join(".", ValidationHelper.GetBinary(reader["IP"], new byte[1]));
                 device.Name     = ValidationHelper.GetString(reader["Name"], null);
                 device.Hostname = ValidationHelper.GetString(reader["Hostname"], null);
                 if (Enum.TryParse <DeviceType>(ValidationHelper.GetString(reader["Type"], null), out var temp))
                 {
                     device.Type = temp;
                 }
                 device.Port = ValidationHelper.GetShort(reader["Port"], 161);
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogEntry(SystemCategories.GeneralError, $"{ex.Message} {ex.StackTrace}");
     }
 }
Beispiel #2
0
        public static void DeviceNotResponse(RegisteredDevice device)
        {
            SendDebugEmail($"ALERT! Device {device.IP} doesn't response!", $@"
						Device:<br>
                        Name: <b>{device.Name}</b><br>                        
                        Hostname: <b>{device.Hostname}</b><br>
                        IP: <b>{device.IP}</b><br>
                        Device type: <b>{device.Type}</b><br>
                        <b>DOESN'T RESPONSE!<b>");
        }
Beispiel #3
0
        public static List <RegisteredDevice> GetRegisteredDevices()
        {
            List <RegisteredDevice> devices = new List <RegisteredDevice>();

            try
            {
                using (SqlCommand sql = new SqlCommand("GetRegisteredDevices"))
                {
                    sql.CommandType = System.Data.CommandType.StoredProcedure;
                    using (var reader = DataAccess.ExecuteReader(sql))
                    {
                        while (reader.Read())
                        {
                            var device = new RegisteredDevice
                            {
                                RegisteredDevicePK = ValidationHelper.GetInteger(reader["RegisteredDevicePK"], 0),
                                IP       = string.Join(".", ValidationHelper.GetBinary(reader["IP"], new byte[1])),
                                Name     = ValidationHelper.GetString(reader["Name"], null),
                                Hostname = ValidationHelper.GetString(reader["Hostname"], null),
                                Port     = ValidationHelper.GetShort(reader["Port"], 161)
                            };
                            if (Enum.TryParse <DeviceType>(ValidationHelper.GetString(reader["Type"], null), out var temp))
                            {
                                device.Type = temp;
                            }



                            devices.Add(device);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogEntry(SystemCategories.GeneralError, $"{ex.Message} {ex.StackTrace}");
                throw;
            }
            return(devices);
        }
Beispiel #4
0
        public static void CheckHighLoad(RegisteredDevice device, int curLoadCPU, int curLoadRAM)
        {
            if (curLoadCPU >= Properties.Settings.Default.HighCPULoad &&
                curLoadRAM >= Properties.Settings.Default.HighRAMLoad)
            {
                SendDebugEmail($"ALERT! HIGH RAM and CPU USAGE of {device.IP}", $@"
                    Device:<br>
                    Name: <b>{device.Name}</b><br>                        
                    Hostname: <b>{device.Hostname}</b><br>
                    IP: <b>{device.IP}</b><br>
                    Device type: <b>{device.Type}</b><br>
					<b>CPU Load: {curLoadCPU}%<br>
					RAM Load: {curLoadRAM}</b>"                    );
            }
            else if (curLoadCPU >= Properties.Settings.Default.HighCPULoad)
            {
                SendDebugEmail($"ALERT! HIGH CPU USAGE of {device.IP}", $@"
                    Device:<br>
                    Name: <b>{device.Name}</b><br>                        
                    Hostname: <b>{device.Hostname}</b><br>
                    IP: <b>{device.IP}</b><br>
                    Device type: <b>{device.Type}</b><br>
					<b>CPU Load: {curLoadCPU}</b><br>
					RAM Load: {curLoadRAM}"                    );
            }
            else if (curLoadRAM >= Properties.Settings.Default.HighRAMLoad)
            {
                SendDebugEmail($"ALERT! HIGH RAM USAGE of {device.IP}", $@"
                    Device:<br>
                    Name: <b>{device.Name}</b><br>                        
                    Hostname: <b>{device.Hostname}</b><br>
                    IP: <b>{device.IP}</b><br>
                    Device type: <b>{device.Type}</b><br>
					CPU Load: {curLoadCPU}<br>
					<b>RAM Load: {curLoadRAM}</b>"                    );
            }
        }