Example #1
0
        public static void Main(string[] args)
        {
            SelectProtocol(args);
            SelectHost(args);
            SelectPort(args);

            bool keepAlive = true;

            var paceMaker = SensuNinja.Get(_host, _port, _type, new HostInfoEnricher());

            paceMaker.Start(new Heartbeat(AppName));
            using (var client = Client())
            {
                var monitor = new SensuMonitor(client, AppName);

                Console.WriteLine("Connected to server.");
                Menu();
                while (keepAlive)
                {
                    Console.WriteLine("");
                    var choice = Console.ReadKey();
                    if (choice.KeyChar == '1')
                    {
                        Console.WriteLine("Output: ");
                        SendOk(monitor, Console.ReadLine());
                    }

                    if (choice.KeyChar == '2')
                    {
                        Console.WriteLine("Output: ");
                        SendAppWarning(monitor, Console.ReadLine());
                    }

                    if (choice.KeyChar == '3')
                    {
                        Console.WriteLine("Output: ");
                        SendAppError(monitor, Console.ReadLine());
                    }

                    if (choice.KeyChar == '0')
                    {
                        Console.WriteLine("Output: ");
                        ManualHeartbeat(monitor, Console.ReadLine());
                    }

                    if (choice.KeyChar == 'q')
                    {
                        keepAlive = false;
                    }

                    Console.WriteLine();
                }
                paceMaker.Stop();
            }
            Environment.Exit(0);
        }
Example #2
0
        public void Get_ATcpPacemakerWithEnrichers_ClientContainsEnrichers()
        {
            var host      = "host";
            var port      = 1;
            var protocol  = ClientType.Tcp;
            var pacemaker = SensuNinja.Get(host, port, protocol, new HostInfoEnricher(), new AssemblyInfoEnricher());

            Assert.Equal(2, pacemaker.Client.Enrichers.Count);
            SensuNinja.Kill(host, port, protocol);
        }
Example #3
0
        public void Get_APacemakerWithTcpClientParam_PacemakerHasTcpClient()
        {
            var host      = "host";
            var port      = 1;
            var protocol  = ClientType.Tcp;
            var pacemaker = SensuNinja.Get(host, port, protocol);

            Assert.Equal(typeof(SensuTcpClient), pacemaker.Client.GetType());
            SensuNinja.Kill(host, port, protocol);
        }
Example #4
0
        public void Get_APacemaker_ReturnsAPacemaker()
        {
            var host      = "host";
            var port      = 1;
            var pacemaker = SensuNinja.Get(host, port);

            Assert.NotNull(pacemaker);
            Assert.IsType <Pacemaker>(pacemaker);
            SensuNinja.Kill(host, port);
        }
Example #5
0
 public void Get_WithNullOrEmptyString_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => SensuNinja.Get(null, 0));
     Assert.Throws <ArgumentNullException>(() => SensuNinja.Get("", 0));
 }