Skip to content
Snippets Groups Projects

lb-test

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by meskio

    Simple test of the lb doing load balancing for bandwith.

    agent.go 937 B
    package main
    
    import (
            "log"
            "os"
            "time"
    
            "git.autistici.org/ale/lb/agent"
            "git.autistici.org/ale/lb/contrib/bwmon"
            "git.autistici.org/ale/lb/proto"
            "google.golang.org/grpc"
    )
    
    func usage() {
            log.Printf("%s agent-name device balancer-address", os.Args[0])
    }
    
    func main() {
            if len(os.Args) < 4 {
                    usage()
                    return
            }
    
            dialer, err := lbagent.NewGRPCDialer(os.Args[3], grpc.WithInsecure())
            if err != nil {
                    log.Fatal(err)
            }
    
            agent := lbagent.New(os.Args[1], nil, dialer)
            agent.RegisterUtilization("bandwidth", lbpb.Utilization_COUNTER, bwmon.GetBandwidthUtilization(os.Args[2], bwmon.TX))
            agent.SetUpdateInterval(time.Second)
            agent.SetReady(true)
    
            agent.Start()
            defer agent.Stop()
    
            for {
                    time.Sleep(time.Hour)
            }
    }
    server.go 1.16 KiB
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment