Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device.
Atlassian cookies and tracking notice, (opens new window)
Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
🔍 Discover Our Product Documentation

Barracuda Load Balancer
Results will update as you type.
  • What's New in the Barracuda Load Balancer
  • Deployment Options
  • Getting Started
  • Services
  • Traffic Management
  • Global Server Load Balancing
  • Networking
  • Certificate Management
  • Monitoring
  • Maintenance
  • Tools and Add-Ins
  • APIs
    • Automation API Guide
      • API Descriptions
      • Sample Program - Changing Real Server Status to Maintenance Mode
      • Sample Program - Multiple Functions
  • Barracuda Load Balancer Hardware
  • Downloads

    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Sample Program - Changing Real Server Status to Maintenance Mode
    Published Jan 08

    Sample Program - Changing Real Server Status to Maintenance Mode

    Jan 08, 2026
    Subscribe

    This program changes the status for a list of Real Servers to maintenance mode. It performs the following functions:

    • For each IP address in a list, it sets the status of the Real Server to maintenance. The Barracuda Load Balancer will not direct any new client connections or requests to a Real Server in maintenance mode;

    • It displays the Real Server state to confirm that the state has changed.

    Edit the IP addresses – 10.5.126.63 should be the WAN IP address of your Barracuda Load Balancer, 192.168.132.214 is the VIP address of an existing Service, and 15.15.15.11 and 15.15.15.12 are the IP addresses of the Real Servers to be put into maintenance mode. You can put more Real Servers in the $server_ips list, just be sure to separate them by a comma (,). Change the password to the API password for the Barracuda Load Balancer.

    You can also modify this program to disable the Real Servers or make them active again by changing the value of the $action parameter to disable or enable.

    To run maint.pl, at a command prompt type:
    perl maint.pl

    maint.pl

    #!/usr/bin/perl

    use strict;
    use warnings;

    use XML::RPC;
    use LWP::UserAgent;

    # Service parameters
    my $service_ip = '192.168.132.214' ;
    my $service_protocol = 'TCP' ;
    my $service_port = '80' ;

    # Server parameters
    my $server_ips = '15.15.15.11,15.15.15.12' ;
    my $server_port = '80' ;

    my $method_change = "server.change_state" ;
    my $action = 'maintenance' ; #disable/enable/maintenance
    my $service_id = "$service_ip:$service_port:$service_protocol" ;
    my @server_ip = split(",",$server_ips);
    my $service_show = 'status/state' ;
    my $result;

    # Create the XML::RPC object
    my $ua = LWP::UserAgent->new ;
    $ua->timeout( 60 );
    my $xmlrpc = XML::RPC->new (
                'https://10.5.126.63/cgi-mod/api.cgi?password=admin',
                'lwp_useragent' => $ua );

    #Change Real Server status for the IP addresses in the list
    #to maintenance mode

    my $disable_parameters = {
                               vip => $service_id,
                               port => $server_port,
                               action => $action };

    foreach my $ip (@server_ip){
        $disable_parameters->{'ip'} = $ip;
        print "Setting status for server $ip to $action.\n";
        $result = $xmlrpc->call($method_change, $disable_parameters );
          print "$result->{'msg'}\n";

        #Show the Real Server state now
        $result = $xmlrpc->call( 'service.show',
                                 { vip => $service_id,
                                   port => $server_port,
                                   ip => $ip,
                                   show => $service_show
                                 }
                               );
        my $instance_id = "$ip" . ":" . "$server_port";
        print
      "Server status: $result->{$service_id}{$instance_id}{'state'}\n";
    }

        

    Related Articles
    • Automation API Guide

    • API Descriptions

    • Sample Program - Multiple Functions


    We value your feedback.
    If you have questions, suggestions, or feedback on our documentation, contact the Campus Product Documentation team.
    For general product inquiries or technical support, please contact the global Barracuda Support team.

    {"serverDuration": 10, "requestCorrelationId": "307accc6eaaf4509947779af8b4a6af0"}