예제 #1
0
        static int Main(string[] args)
        {
            // This tool generates the javascript as seen in sample Web-UI/agent_trending_data.js
            // This requires quite a few SQL queries, so I'll probably start with this.

            if (args.Length > 0)
            {
                string arg = args[0].ToLower();
                if (arg == "-h" || arg == "--help")
                {
                    Console.WriteLine(help_msg);
                    return(1);
                }
                else if (arg == "-v" || arg == "--version")
                {
                    Console.WriteLine(version);
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }

            DataHandler h = new DataHandler();
            JSformatter f = new JSformatter();

            // Start with the agent options (dynamic)
            DataTable agent_list = h.GetAgent_List();

            foreach (DataRow r in agent_list.Rows)
            {
                string agent    = (string)r[0];
                string version  = h.GetAgentVersion(agent);
                string var_name = f.GetAgentTableName(agent).Replace("_table", "_options");
                Console.WriteLine("var {0} = {{title: '{1} ({2})'}};", var_name, agent, version);
            }
            Console.WriteLine();

            Console.WriteLine("var candlestick_allagents_options = {legend:'none', title:'Agents installed'}");
            Console.WriteLine("var candlestick_outagents_options = {legend:'none', title:'Agents to upgrade'};");
            Console.WriteLine();

            // Generate the gauge tables
            string agent_gauge = f.GetJSONFromTable(h.GetAgent_Gauge_Stats(), "agent_gauge_table", f.gauge_thead);

            Console.WriteLine(f.ConvertGauges(agent_gauge));

            // Generate the candlestick tables
            Console.WriteLine(f.GetJSONFromTable(h.GetAgent_CandlestickALL_Stats(), "candlestick_agent_table", ""));
            Console.WriteLine(f.GetJSONFromTable(h.GetAgent_CandlestickOutdated_Stats(), "candlestick_agent_outdated_table", ""));

            // Generate the tables used in the agent line charts
            foreach (DataRow r in agent_list.Rows)
            {
                Console.WriteLine(f.GetJSONFromTable(h.GetAgent_Line_Stats(r[0].ToString()), f.GetAgentTableName((string)r[0]), f.agent_thead));
            }
            return(0);
        }
예제 #2
0
        static int Main(string[] args)
        {
            // This tool generates the javascript as seen in sample Web-UI/agent_trending_data.js
            // This requires quite a few SQL queries, so I'll probably start with this.

            if (args.Length > 0)
            {
                string arg = args[0].ToLower();
                if (arg == "-h" || arg == "--help")
                {
                    Console.WriteLine(help_msg);
                    return(1);
                }
                else if (arg == "-v" || arg == "--version")
                {
                    Console.WriteLine(version);
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }

            DataHandler h = new DataHandler();
            JSformatter f = new JSformatter();

            Console.WriteLine(@"
var bi_options = { title: 'Basic Inventory (Core)' };
var hw_options = { title: 'Hardware Inventory' };
var os_options = { title: 'OS Inventory' };
var sw_options = { title: 'Software Inventory' };
var ug_options = { title: 'User Group Inventory' };
");

            Console.WriteLine("var candlestick_all_options = {legend:'none', title:'Computers sending Inventory'};");
            Console.WriteLine("var candlestick_out_options = {legend:'none', title:'Inventory data older than 4 weeks'};");
            Console.WriteLine();

            // Generate the gauge tables
            string inv_gauge = f.GetJSONFromTable(h.GetInventory_Gauge_Stats(), "inv_gauge_table", f.gauge_thead);

            Console.WriteLine(f.ConvertGauges(inv_gauge));

            // Generate the candlestick tables
            Console.WriteLine(f.GetJSONFromTable(h.GetInventory_CandleALL_Stats(), "candlestick_all_table", ""));
            Console.WriteLine(f.GetJSONFromTable(h.GetInventory_CandleOutdated_Stats(), "candlestick_out_table", ""));

            // Generate the tables used in the inventory line charts
            foreach (DataRow r in h.GetInventory_List().Rows)
            {
                Console.WriteLine(f.GetJSONFromTable(h.GetInventory_Line_Stats((string)r[0]), f.GetInvTableName((string)r[0]), f.inv_thead));
            }

            return(0);
        }