Пример #1
0
        public static void Main(string[] args)
        {
            Detector d = new Detector();

            Console.WriteLine("Detected CPUs:");
            foreach(ProcessorDTOResponse item in d.GetProcessorsInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected memory:");
            foreach(MemoryDTOResponse item in d.GetMemoryInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected OS:");
            OperatingSystemDTOResponse os = d.GetOperatingSystemInfo();
            PropertiesPrinter.Print(os);

            Console.WriteLine("\nDetected storage:");
            foreach(StorageDTOResponse item in d.GetStorageInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected ethernets:");
            foreach(EthernetDTOResponse item in d.GetEthernetInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected fc cards:");
            foreach(FibreChannelDTOResponse item in d.GetFibreChannelInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected shares:");
            foreach(DiskShareMountDTOResponse item in d.GetDiskShareMountInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected software:");
            foreach(SoftwareDTOResponse item in d.GetSoftwareInfo())
            {
                PropertiesPrinter.Print(item);
            }

            Console.WriteLine("\nDetected device:");
            DeviceDTOResponse dev = d.GetDeviceInfo();
            PropertiesPrinter.Print(dev);

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Пример #2
0
		public void NotifyRalph(object stateObject)
		{
			if (
				RalphURL.Trim().Length == 0 || 
				ApiUser.Trim().Length == 0 || 
				ApiKey.Trim().Length == 0
			)
			{
				Logger.Instance.LogWarning(
					"To send data to Ralph set up ralph_url, api_user and api_key in your config file."
				);
				return;
			}
			
			Detector d = new Detector();
			string jsonData = d.GetAllComponentsJSON();

			Logger.Instance.LogInformation("Sending to: " + ReportURL);

			int tries = 0;
			while (tries < MaxTries)
			{
				tries++;
				try
				{
					apiClient.Post(ReportURL + "/?username="******"&api_key=" + ApiKey, jsonData);
					return;
				}
				catch (System.Net.WebException e)
				{
					string serverMessage = "";
					if (e.Response != null)
					{
						StreamReader s = new StreamReader(e.Response.GetResponseStream());
						serverMessage = s.ReadToEnd();
					}
					Logger.Instance.LogError(
						String.Format(
							"Error while sending data to {0}: {1}. Full response: \"{2}\". Waiting for {3} try.",
							RalphURL, 
							e.Message,
							serverMessage, 
							tries + 1
						)
					);
					System.Threading.Thread.Sleep(SecondsInterval * 1000);
				}
				catch (Exception e)
				{
					Logger.Instance.LogError(e.ToString());
				}
			}
		}
Пример #3
0
		public static void Main(string[] args)
		{
			ArgsParser argsParser = new ArgsParser(args);
			
			if (argsParser.IsSet("help"))
			{
				HelpPrinter.Print();
			}
			else
			{
				Detector detector = new Detector();
				TextPrinter printer = new TextPrinter();
				
				if (argsParser.IsSet("file"))
				{
					string fileName = argsParser.GetArgValue("file");

					TextWriter nativeConsoleOutput = Console.Out;
					FileStream fstream;
					StreamWriter writer;
					
					try
					{
						fstream = new FileStream(
							fileName, 
							FileMode.Create, 
							FileAccess.Write
						);
        				writer = new StreamWriter(fstream);
					}
					catch (Exception e)
					{
						Console.WriteLine (String.Format("Cannot open `{0}` for writing.", fileName));
        				Console.WriteLine (e.Message);
        				return;
					}
					Console.SetOut(writer);
					
					printer.Print(detector, argsParser.IsSet("json"));
					
					Console.SetOut(nativeConsoleOutput);
					writer.Close();
					fstream.Close();
				}
				else
				{
					printer.Print(detector, argsParser.IsSet("json"));
				}
			}
		}
Пример #4
0
        public static void Main(string[] args)
        {
            Detector d = new Detector();

            Console.WriteLine("Detected CPUs:");
            foreach(ProcessorDTOResponse item in d.GetProcessorsInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected memory:");
            foreach(MemoryDTOResponse item in d.GetMemoryInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected OS:");
            OperatingSystemDTOResponse os = d.GetOperatingSystemInfo();
            foreach(var prop in os.GetType().GetProperties()) {
                Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(os, null));
            }
            Console.WriteLine();

            Console.WriteLine("\nDetected storage:");
            foreach(StorageDTOResponse item in d.GetStorageInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected ethernets:");
            foreach(EthernetDTOResponse item in d.GetEthernetInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected fc cards:");
            foreach(FibreChannelDTOResponse item in d.GetFibreChannelInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected shares:");
            foreach(DiskShareMountDTOResponse item in d.GetDiskShareMountInfo())
            {
                foreach(var prop in item.GetType().GetProperties()) {
                    Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(item, null));
                }
                Console.WriteLine();
            }

            Console.WriteLine("\nDetected device:");
            DeviceDTOResponse dev = d.GetDeviceInfo();
            foreach(var prop in dev.GetType().GetProperties()) {
                Console.WriteLine("\t{0}: {1}", prop.Name, prop.GetValue(dev, null));
            }
            Console.WriteLine();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Пример #5
0
		public void Print(Detector d, bool jsonOnly)
		{
			if (jsonOnly)
			{
				Console.WriteLine(d.GetAllComponentsJSON());
			}
			else
			{
				Console.WriteLine("Detected CPUs:");
				foreach(ProcessorDTOResponse item in d.GetProcessorsInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected memory:");
				foreach(MemoryDTOResponse item in d.GetMemoryInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected OS:");
				OperatingSystemDTOResponse os = d.GetOperatingSystemInfo();
				PropertiesPrinter.Print(os);
				
				Console.WriteLine("\nDetected storage:");
				foreach(StorageDTOResponse item in d.GetStorageInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected IP addresses:");
				foreach(IPAddressDTOResponse item in d.GetIPAddressInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected MAC addresses:");
				foreach(MacAddressDTOResponse item in d.GetMacAddressInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected fc cards:");
				foreach(FibreChannelDTOResponse item in d.GetFibreChannelInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected shares:");
				foreach(DiskShareMountDTOResponse item in d.GetDiskShareMountInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected software:");
				foreach(SoftwareDTOResponse item in d.GetSoftwareInfo())
				{
					PropertiesPrinter.Print(item);
				}
				
				Console.WriteLine("\nDetected device:");
				DeviceDTOResponse dev = d.GetDeviceInfo();
				PropertiesPrinter.Print(dev);
			}
		}