Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the MonitoringServer class
        /// </summary>
        /// <param name="port">The port used by the server to listen.</param>
        /// <param name="host">The host used to publish the service.</param>
        /// <param name="serverUserName">A username for basic authentication.</param>
        /// <param name="serverPassword">A password for basic authentication.</param>
        public MonitoringServer(int port, string host, string serverUserName, string serverPassword)
        {
            this.hostName   = host;
            this.serverPort = port;
            this.username   = serverUserName;
            this.password   = serverPassword;

            if (instance == null)
            {
                instance = this;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the MonitoringServer class
        /// </summary>
        /// <param name="port">The port used by the server to listen.</param>
        /// <param name="host">The host used to publish the service.</param>
        /// <param name="serverUserName">A username for basic authentication.</param>
        /// <param name="serverPassword">A password for basic authentication.</param>
        public MonitoringServer(int port, string host, string serverUserName, string serverPassword)
        {
            this.hostName = host;
            this.serverPort = port;
            this.username = serverUserName;
            this.password = serverPassword;

            if (instance == null)
            {
                instance = this;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts the HTTP server used for monitoring.
 /// </summary>
 /// <param name="host">The host that publishes the monitoring server.</param>
 /// <param name="port">The port on which the server will listen.</param>
 /// <param name="auth">The user and password used for basic http authentication.</param>
 private void StartHttpServer(string host, int port, string[] auth)
 {
     // TODO: vladi: port this again, this will most likely not work
     this.httpMonitoringServer = new MonitoringServer(port, host, auth[0], auth[1]);
     this.httpMonitoringServer.HealthzRequested += new EventHandler<HealthzRequestEventArgs>(this.HttpMonitoringServer_HealthzRequested);
     this.httpMonitoringServer.VarzRequested += new EventHandler<VarzRequestEventArgs>(this.HttpMonitoringServer_VarzRequested);
     this.httpMonitoringServer.Start();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Starts the HTTP server used for healthz and varz.
        /// </summary>
        private void StartHttpServer()
        {
            MonitoringServer = new MonitoringServer(this.Port, this.Host, this.Authentication[0], this.Authentication[1]);

            MonitoringServer.VarzRequested += delegate(object sender, VarzRequestEventArgs response)
            {
                try
                {
                    this.VarzLock.EnterWriteLock();
                    response.VarzMessage = JsonConvertibleObject.SerializeToJson(this.Varz);
                }
                finally
                {
                    this.VarzLock.ExitWriteLock();
                }
            };

            MonitoringServer.HealthzRequested += delegate(object sender, HealthzRequestEventArgs response)
            {
                response.HealthzMessage = this.Healthz;
            };

            MonitoringServer.Start();
        }