Diagnóstico de aplicaciones. System Health.

20 views
Skip to first unread message

Kiquenet

unread,
Apr 19, 2018, 6:24:11 PM4/19/18
to AltNet-Hispano
Qué tal?

En muchas ocasiones, en el desarrollo, puedes trabajar con muchos servidores (por ejemplo, aplicaciones web desplegadas en muchos servidores IIS) o muchos workstations (una aplicación Windowforms desplegada con ClickOnce en muchos equipos), y puede necesitarse validar la configuración del equipo, tener una utilidad de diagnóstico puede ser muy útil, para determinar si la configuración del equipo es correcta, y puede minimizar el tiempo de troubleshooting.

La idea viene de un dead project, que estaba en Codeplex:

Y para ASP.NET una referencia de Omar Al Zabir


Podemos fijarnos en el instalador de Sql Server 2008 R2 installer que hace lo siguiente: SQL Server Setup valida que la configuración del equipo está completa antes de iniciar la instalación). Lástima no liberen código del instalador, se aprenderían técnicas.


Por ejemplo, dada una configuración app.config (o web.config)

  <connectionStrings>
    <add name="ConnectionStrings.SqlServer"
         connectionString="Data Source="
         providerName="SqlClient"/>
    <add name="ConnectionStrings.SqlServer.Navision"
           connectionString="Data Source=NAVISION\SQL2014;"
           providerName="SqlClient"/>
  </connectionStrings>
 
  <appSettings>

    <add key="ModoPruebas" value="S" />
    <add key="IntegracionEAI.RutaLogs" value="\\sql-pre\logs\Log.IntegracionEAI"/>
    <add key="RutaFicheros.Envios" value="\\sql-pre\logs\Envios"/>
    <add key="RutaFicheros.Descargas" value="\\sql-pre\logs\Descargas\"/>
  </appSettings>

  <system.diagnostics>
    <trace autoflush="true" indentsize="4"/>
    <sources>
      <source name="System.Net">
        <listeners>
          <add name="System.Net"/>
        </listeners>
      </source>
      <source name="System.Net.Cache">
        <listeners>
          <add name="System.Net"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add
       name="System.Net"
       type="System.Diagnostics.TextWriterTraceListener"
       initializeData="C:\Company\Logs\Project\System.Net.trace.log"
       traceOutputOptions = "ProcessId, DateTime" />
    </sharedListeners>
    <switches>
      <!--  MSDN: 4 verbose Information, Information 3, Warning 2, Error 1, -->
      <add name="System.Net" value="Verbose" />
      <add name="System.Net.Cache" value="Verbose" />
    </switches>
  </system.diagnostics>

  
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IServiceSendSMSD">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://xxxxxxxxxxxx:444/WebServiceSendSMSD/ServiceSendSMSD.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceSendSMSD"
          contract="xxxxx.IServiceSendSMSD" name="BasicHttpBinding_IServiceSendSMSD" />
    </client>
  </system.serviceModel>
 
 
</configuration>


Podría hacerse algo así, comprobar las conexiones, las rutas físicas, etc
También poder acceder programáticamente a  sharedListeners de diagnostics y comprobar el valor de sharedListeners. O modificar las direcciónes de los endpoints, programáticamente .


 public static partial class Comprobaciones
    {

        public static bool TestConexionSQL()
        {
            try
            {
                using (var con = new System.Data.SqlClient.SqlConnection(CONEXION_SQL))
                {
                    con.Open();
                    con.Close();
                }
                return true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error Test: " + ex.Message);
                return false;
            }
        }

        public static bool TestPaths()
        {
            bool allPathOK = true;
            foreach (string key in ConfigurationManager.AppSettings.AllKeys)
            {
                string value = ConfigurationManager.AppSettings[key];

                if (value.StartsWith(@"\\"))
                {
                    if (!Directory.Exists(value) && !File.Exists(value))
                    {
                        Trace.WriteLine("Invalid path: " + key + "=" + value);
                        allPathOK = false;
                    }
                }
                // value = "../"    FullPath ...
                if (value.StartsWith(@"C:\") || value.StartsWith(@"D:\"))
                {
                    if (!Directory.Exists(value) && !File.Exists(value))
                    {
                        Trace.WriteLine("Invalid path: " + key + "=" + value);
                        allPathOK = false;
                    }
                }
            }
            if (allPathOK)
                return true;
            return false;
        }



Otras opciones más avanzadas:


Tenéis alguna experiencia?

Gracias de antemano.

Vicenç Garcia

unread,
Apr 19, 2018, 7:00:18 PM4/19/18
to altnet-...@googlegroups.com
Hola buenas,

mi actual cliente es una tienda de ropa en UK. Nosotros nos encargamos de desplegar un software de terceros (junto con algunas cosas nuestras) a las cajas de las tiendas (Windows XP embedded). Como ves todo muy a la última XD

Aquí en la casa utilizan un software llamado Landesk que permite desplegar scripts, control remoto y mil cosas más, incluso desplegar imágenes usando PXE. El agente de Landesk provee al servidor de información de la máquina, basicamente cosas que puede pillar de los performance counters. Una pequeña extensión que tiene y per permite la personalización es informar de valores en el registro de windows y esto es en lo que estamos trabajando para utilizar. Tenemos una scheduled task cada noche que calcula versiones de todo lo que tenemos instalado y actualiza unas claves en una carpeta propia en el registro de windows. Después le decimos a Landesk que lea de allí y así podemos recuperar y saber qué hay instalado. Manual, cutrecillo y de hace veinte años pero funciona :-)

Nunca lo he utilizado, pero también tienes serverspec: https://serverspec.org/

Salut!

--
Has recibido este mensaje porque estás suscrito al grupo "AltNet-Hispano" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a altnet-hispano+unsubscribe@googlegroups.com.
Para publicar en este grupo, envía un correo electrónico a altnet-hispano@googlegroups.com.
Visita este grupo en https://groups.google.com/group/altnet-hispano.
Para acceder a más opciones, visita https://groups.google.com/d/optout.



--

Carlos Admirador

unread,
May 3, 2018, 12:06:31 PM5/3/18
to AltNet-Hispano

Este código puede reutilizarse para diagnóstico del entorno. También es una versión "dump" del entorno cuando ocurre una excepción, y recopilar toda la información relevante.


Unless all you build are HelloWorld applications which never get deployed anywhere you almost certainly have come across cases where either you or your support team have had to figure out:

  • What is causing that OutOfMemory exception?
  • Why is there such a performance degradation after the last release?
  • Why is the DLL I have referenced not doing what it is supposed to?
  • What system is my app running in?
  • What arguments the app has started with?
  • What version of JSON.NET is the app using?
  • ...

Kiquenet

unread,
Dec 2, 2025, 3:25:23 PM (9 days ago) Dec 2
to AltNet-Hispano
LanDesk ??  
Reply all
Reply to author
Forward
0 new messages