コード例 #1
0
        static void Main(string[] args)
        {
            SplunkInterface Interfacer = new SplunkInterface();

            LoadConfig();

            //Send the homemade args to splunk
            if (Interfacer.Connect(SplunkServer, SplunkAdmin, SplunkPass))
            {
                Console.WriteLine("Connected Successfully");
            }

            //Moves the openstream into the loop so if it is disconnected (normally every 20k events sent) it can reconnec
            //Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");

            //Get the dashboard from the REST interface
            RestInterface REST   = new RestInterface();
            XmlInterface  xmlint = new XmlInterface();

            int count = 0;

            foreach (string i in xmlint.Read(REST.Get(Dash, DTUser, DTPass, DTServer)))
            {
                try
                {
                    if (Interfacer.iStream == null)
                    {
                        Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");
                    }
                    Console.WriteLine("{" + i.Remove(i.Length - 2) + "}\n");
                    Console.WriteLine(count);
                    Interfacer.WritetoStream("{" + i.Remove(i.Length - 2) + "}\n");
                    count++;
                }
                catch
                {
                    Interfacer.CloseStream();
                    Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");
                }
            }

            Console.WriteLine("Sent " + count + " events to Splunk Server.");
        }
コード例 #2
0
        static void Main(string[] args)
        {

            SplunkInterface Interfacer = new SplunkInterface();

            LoadConfig();
            
            //Send the homemade args to splunk
            if (Interfacer.Connect(SplunkServer, SplunkAdmin, SplunkPass)) Console.WriteLine("Connected Successfully");

            //Moves the openstream into the loop so if it is disconnected (normally every 20k events sent) it can reconnec
            //Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");

            //Get the dashboard from the REST interface
            RestInterface REST = new RestInterface();
            XmlInterface xmlint = new XmlInterface();

            int count = 0;
            foreach (string i in xmlint.Read(REST.Get(Dash, DTUser, DTPass, DTServer)))
            {
                try
                {
                    if (Interfacer.iStream == null)
                    {
                        Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");
                    }
                    Console.WriteLine("{" + i.Remove(i.Length - 2) + "}\n");
                    Console.WriteLine(count);
                    Interfacer.WritetoStream("{" + i.Remove(i.Length - 2) + "}\n");
                    count++;
                }
                catch
                {
                    Interfacer.CloseStream();
                    Interfacer.OpenStream(SplunkIndex, SplunkHost, "dynaTrace", "_json");

                }
            }

            Console.WriteLine("Sent " + count + " events to Splunk Server.");

        }