Wierd.. Attached the C# 'program' i used as an agent for a small
test(compile it with csc.exe).. maybe something is wrong with my test
implementation.?
When i press ` (the key besides the 1) it sends 0% and in the haproxy
stats the server is shown as "drain".
When i then press 9 for 90% is stays in drain, only when i press 0 for
100% the server comes back up again.
Maybe someone can take a look?
*My HAProxy version:*
HA-Proxy version 1.5-dev21-6b07bf7 +2013/12/17
Copyright 2000-2013 Willy Tarreau <w...@1wt.eu>
Build options :
TARGET = freebsd
CPU = generic
CC = cc
CFLAGS = -O2 -pipe -fno-strict-aliasing -DFREEBSD_PORTS
OPTIONS = USE_GETADDRINFO=1 USE_ZLIB=1 USE_OPENSSL=1 USE_STATIC_PCRE=1
*The backend using the check:*
backend SSSSS_tcp
mode tcp
balance static-rr
timeout connect 30000
timeout server 30000
retries 3
fullconn 3333
server asd 192.168.0.40:82 check inter 2000 agent-check
agent-inter 2000 agent-port 2123 weight 100
Malcolm Turnbull schreef op 11-1-2014 20:30:
Sorry only just got around to looking at this and updating my blog entry:
Yes the important bit missing was "agent-check"....
But my testing with Dev21 seems to bring the servers back fine with
any percentage reading i.e. 10% 75% etc. Please let me know if anyone
else is having an issue, thanks.
server Win2008R2 192.168.64.50:3389 weight 100 check agent-check
agent-port 3333 inter 2000 rise 2 fall 3 minconn 0 maxconn 0
on-marked-down shutdown-sessions
On 27 December 2013 22:44, PiBa-NL <piba.nl....@gmail.com> wrote:
Simon Drake schreef op 27-12-2013 17:07:
Would it be possible to post an example showing the correct haproxy config
to use with the agent-check.
By the way I saw the mailing list post recently about the changes to the
agent-check, using state and percentage, and I think that the right way to
go.
For me this config works:
server MyServer 192.168.0.40:80 check inter 5000 agent-check
agent-inter 3333 agent-port 2123 weight 32
I've tried a few small tests with it, and while bringing a server to 'down'
or 'drain' seemed to work, i was missing the 'up' keyword, only "100%" seems
to bring a server back alive. So if your monitoring 100-%CPUusage and
sending that 1on1 back to the agent on a server with 99% cpu capacity
available wont come back up..
//
// HAProxy agent check test program
//
// compile with:
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /out:"haproxy_agent_service.exe" "haproxy_agent_service.cs"
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
class healthchecker{
public static void Main(){
Console.WriteLine("Starting");
bool running = true;
TcpListener server=null;
try
{
Int32 port = 2123;
IPAddress localAddr = IPAddress.Parse("0.0.0.0");
server = new TcpListener(localAddr, port);
// Start listening for client requests.
server.Start();
// Buffer for reading data
Byte[] bytes = new Byte[256];
String data = null;
string message = "55%\n";
// Enter the listening loop.
while(running)
{
Console.Write("Waiting for a connection... ");
// Perform a blocking call to accept requests.
// You could also user server.AcceptSocket() here.
TcpClient client = null;
try{
using(client = server.AcceptTcpClient()){
Console.WriteLine("Connected!");
ConsoleKeyInfo cki;
while (Console.KeyAvailable)
{
cki = Console.ReadKey();
Console.WriteLine("Key PRESSED: {0}", cki.Key);
if (cki.Key == ConsoleKey.D)
message = "drain\n";
if (cki.Key == ConsoleKey.S)
message = "stopped\n";
if (cki.Key == ConsoleKey.U)
message = "up\n";
if (cki.Key == ConsoleKey.Oem3)
message = "0%\n";
if (cki.Key == ConsoleKey.D1)
message = "10%\n";
if (cki.Key == ConsoleKey.D2)
message = "20%\n";
if (cki.Key == ConsoleKey.D3)
message = "30%\n";
if (cki.Key == ConsoleKey.D4)
message = "40%\n";
if (cki.Key == ConsoleKey.D5)
message = "50%\n";
if (cki.Key == ConsoleKey.D6)
message = "60%\n";
if (cki.Key == ConsoleKey.D7)
message = "70%\n";
if (cki.Key == ConsoleKey.D8)
message = "80%\n";
if (cki.Key == ConsoleKey.D9)
message = "90%\n";
if (cki.Key == ConsoleKey.D0)
message = "100%\n";
if (cki.Key == ConsoleKey.Q)
running = false;
}
data = null;
// Get a stream object for reading and writing
NetworkStream stream = client.GetStream();
int i;
ASCIIEncoding uniEncoding = new ASCIIEncoding();
stream.Write(uniEncoding.GetBytes(message), 0, message.Length);
stream.Flush();
Console.WriteLine("Wrote {0} bytes: {1}", message.Length, message);
// Shutdown and end connection
client.Close();
}
} catch (SocketException e){
Console.WriteLine("Err: {0}", e);
}
}
}
catch(SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
finally
{
// Stop listening for new clients.
server.Stop();
}
Console.WriteLine("\nHit enter to continue...");
Console.Read();
}
}