Ejemplo n.º 1
0
        public IAMDbUpdate(String server, String dbName, String username, String password)
        {
            scripts = UpdateScriptRepository.GetScriptsBySqlProviderName("System.Data.SqlClient");

            if ((scripts == null) || (scripts.Count <IUpdateScript>() == 0))
            {
                return;
            }

            foreach (IUpdateScript s in scripts)
            {
                if ((Int64)s.Serial > updateSerial)
                {
                    updateSerial = (Int64)s.Serial;
                }
            }

            this.db = new IAMDatabase(server, dbName, username, password);

            //Verifica se a base de dados está atualizada
            try
            {
                this.serial = db.ExecuteScalar <Int64>("select isnull(max([version]),0) from [db_ver]");
            }
            catch
            {
                this.serial = 0;
            }
        }
Ejemplo n.º 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);

            //HostingEnvironment.

            ConnectionStringSettings cs = IAM.GlobalDefs.IAMDatabase.GetWebConnectionStringSettings();
            DbBase db = DbBase.InstanceFromConfig(cs);

            new AutomaticUpdater().Run(db, UpdateScriptRepository.GetScriptsBySqlProviderName(cs.ProviderName));
        }
Ejemplo n.º 3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);

            ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["CASDatabase"];
            DbBase db = DbBase.InstanceFromConfig(cs);

            new AutomaticUpdater().Run(db, UpdateScriptRepository.GetScriptsBySqlProviderName(cs));
            new ServiceSynchronizer().Run(db, Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data/config"));
            //Application["plugins"] = CASPlugins.GetPlugins2(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data/config"), Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data/plugins"));
        }
Ejemplo n.º 4
0
        public void Start()
        {
            if (Uris.Count == 0)
            {
                throw new Exception("Listagem de URLs está vazia");
            }

            LoadTestDatabase db = null;

            try
            {
                if (this.ConnectionString == null)
                {
                    throw new Exception("ConnectionStrings is null");
                }

                db = new LoadTestDatabase(this.ConnectionString);

                new AutomaticUpdater().Run(db, UpdateScriptRepository.GetScriptsBySqlProviderName(this.ConnectionString));
            }
            catch (Exception ex)
            {
                throw new Exception("Erro on load/update database", ex);
            }

            try
            {
                this.TestName = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                db            = new LoadTestDatabase(this.ConnectionString);
                //db.CreateDatabase(this.TestName);
            }
            catch (Exception ex)
            {
                throw new Exception("Falha ao conectar a base de dados: " + ex.Message);
            }

            dStart = DateTime.Now;

            //Verifica a limitação de utilização free
            if (this.VirtualUsers > 5000)
            {
                db.insertMessages(this.TestName, "0. Licenciamento safetrend.com.br", "A versão free deste aplicativo permite no máximo 5000 VU/SBU");
                this.VirtualUsers = 5000;
            }


            JavaScriptSerializer ser = new JavaScriptSerializer();

            if (this.ZabbixMonitors != null)
            {
                foreach (ZabbixConfig zbxHost in this.ZabbixMonitors)
                {
                    //Realiza teste de conex'ao em cada um dos zabbix listados
                    try
                    {
                        using (Zabbix zbx = new Zabbix(zbxHost.Host, zbxHost.Port))
                        {
                            StringBuilder hostInfo = new StringBuilder();

                            String hostname = zbx.GetItem("system.hostname");

                            hostInfo.AppendLine("<strong>Config name:</strong>&nbsp;" + zbxHost.Name);
                            hostInfo.AppendLine("<strong>Config ip:</strong>&nbsp;" + zbxHost.Host + ":" + zbxHost.Port);
                            hostInfo.AppendLine("<strong>Hostname:</strong>&nbsp;" + hostname);

                            String memory = zbx.GetItem("vm.memory.size[total]");
                            try
                            {
                                Double m = Double.Parse(memory);
                                ;

                                hostInfo.AppendLine("<strong>Memória total:</strong>&nbsp;" + FileResources.formatData(m, ChartDataType.Bytes));
                            }
                            catch { }

                            String cpus = zbx.GetItem("system.cpu.discovery");
                            try
                            {
                                Dictionary <String, Object[]> values = ser.Deserialize <Dictionary <String, Object[]> >(cpus);
                                //List<Dictionary<String, String>> values = ser.Deserialize<List<Dictionary<String, String>>>(cpus);
                                hostInfo.AppendLine("<strong>Quantidade de vCPU:</strong>&nbsp;" + values["data"].Length);
                            }
                            catch { }


                            String disk = zbx.GetItem("vfs.fs.discovery");
                            try
                            {
                                Dictionary <String, Object[]> values = ser.Deserialize <Dictionary <String, Object[]> >(disk);
                                //List<Dictionary<String, String>> values = ser.Deserialize<List<Dictionary<String, String>>>(cpus);
                                Int32 cnt = 1;
                                foreach (Object o in values["data"])
                                {
                                    String name = "";
                                    String type = "";

                                    if (o is Dictionary <String, Object> )
                                    {
                                        Dictionary <String, Object> tO = (Dictionary <String, Object>)o;

                                        name = tO["{#FSNAME}"].ToString();
                                        type = tO["{#FSTYPE}"].ToString();

                                        if (!String.IsNullOrEmpty(name))
                                        {
                                            switch (type.ToLower())
                                            {
                                            case "rootfs":
                                            case "sysfs":
                                            case "proc":
                                            case "devtmpfs":
                                            case "devpts":
                                            case "tmpfs":
                                            case "fusectl":
                                            case "debugfs":
                                            case "securityfs":
                                            case "pstore":
                                            case "cgroup":
                                            case "rpc_pipefs":
                                            case "unknown":
                                            case "usbfs":
                                            case "binfmt_misc":
                                            case "autofs":
                                                break;

                                            default:
                                                hostInfo.AppendLine("<strong>Disco " + cnt + ":</strong>&nbsp;" + name + " --> " + type);
                                                cnt++;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            catch { }

                            String netIfs = zbx.GetItem("net.if.discovery");
                            try
                            {
                                List <String> exclusionList = new List <string>();
                                exclusionList.Add("Bluetooth");
                                exclusionList.Add("TAP-Windows");
                                exclusionList.Add("WFP");
                                exclusionList.Add("QoS");
                                exclusionList.Add("Diebold");
                                exclusionList.Add("Microsoft Kernel Debug");
                                exclusionList.Add("WAN Miniport");
                                exclusionList.Add("Loopback");
                                exclusionList.Add("Wi-Fi Direct Virtual");
                                exclusionList.Add("Filter Driver");
                                exclusionList.Add("Pseudo-Interface");

                                Dictionary <String, Object[]> values = ser.Deserialize <Dictionary <String, Object[]> >(netIfs);
                                Int32 cnt = 1;
                                foreach (Object o in values["data"])
                                {
                                    String ifName = "";

                                    if (o is Dictionary <String, Object> )
                                    {
                                        Dictionary <String, Object> tO = (Dictionary <String, Object>)o;

                                        ifName = tO["{#IFNAME}"].ToString();

                                        if (!String.IsNullOrEmpty(ifName))
                                        {
                                            Boolean insert = true;

                                            foreach (String e in exclusionList)
                                            {
                                                if (ifName.IndexOf(e, StringComparison.CurrentCultureIgnoreCase) >= 0)
                                                {
                                                    insert = false;
                                                }
                                            }

                                            if (insert)
                                            {
                                                hostInfo.AppendLine("<strong>Interface de rede " + cnt + ":</strong>&nbsp;" + ifName);
                                                cnt++;
                                            }
                                        }
                                    }
                                }
                            }
                            catch { }

                            db.insertMessages(this.TestName, "1. Zabbix Monitor", hostInfo.ToString());
                        }
                    }
                    catch
                    {
                        db.insertMessages(this.TestName, "0. Zabbix Monitor", "Erro ao resgatar informação do Host Zabbix " + zbxHost.Name + " (" + zbxHost.Host + ":" + zbxHost.Port + ")");
                    }
                }
            }


            //Antes de iniciar o stress test realiza a análise de conteúdo
            this.ContentAnalizer();

            if (this.SleepTime < 0)
            {
                this.SleepTime = 0;
            }

            Int16 factor = 300;

            if (this.Type == ClientType.VU)
            {
                factor = (Int16)(factor * 2);
            }

            if (this.VirtualUsers < 0)
            {
                this.VirtualUsers = 1;
            }

            //Inicia servi;co de monitoramento e SNMP Trap
            using (TestEnvironment tmp = (TestEnvironment)this.Clone())
            {
                StartApplication("ZabbixGet.exe", tmp);
                StartApplication("snmptrapreceiver.exe", tmp);
            }


            using (TestEnvironment tmp = (TestEnvironment)this.Clone())
            {
                Int16 r = this.VirtualUsers;
                if (r > factor)
                {
                    r = factor;
                }
                tmp.VirtualUsers = r;
                FileInfo tFile = new FileInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

                tmp.SaveToFile(tFile.FullName);


                Console.WriteLine("Para iniciar mais conexões utilize o comando abaixo, cada cliente iniciará {0} usuários virtuais", tmp.VirtualUsers);
                Console.WriteLine("\"{0}\\{1}\" \"{2}\"", Environment.CurrentDirectory, "client.exe", tFile.FullName);
                Console.WriteLine("");
            }


            Int16 restConn = this.VirtualUsers;

            while (restConn > factor)
            {
                using (TestEnvironment tmp = (TestEnvironment)this.Clone())
                {
                    tmp.VirtualUsers = factor;
                    StartApplication("client.exe", tmp);
                    restConn -= factor;
                }
            }

            if (restConn > 0)
            {
                using (TestEnvironment tmp = (TestEnvironment)this.Clone())
                {
                    tmp.VirtualUsers = restConn;
                    StartApplication("client.exe", tmp);
                }
            }
        }