Tech Tips  
Home   Company   Solutions   Products   Sales   Services   Support
  How to change server weight based on server conditions

When a server's CPU usage changes, memory usage changes, or other condition changes, it is preferable to have the incoming traffic also adapte the change. WebMux firmware version 6.4.x supports this need by deploying custom health check code. The custom health check code now can reply not only "OK" and "NOT OK" for start or stop traffic, but also can reply weight increase or decrease, or only stop new incoming traffic. Please refer to the appendix in the user manual.

On Microsoft Windows © servers, there are a few parameters that called "WMI" interface for application to query the server status. Parameters like: GetCPUInfo, GetDiskInfo, GetOSInfo, LoadPercentage, DiskUsage, PhysicalMemoryUsage:1.5, VirtualMemoryUsage:2.0 are examples that custom CGI code can query. Custom health checking code can query WMI and notify WebMux for weight changes or stopping traffic. The following sample WMI code is witten by Dave Roth for how to inquiry the WMI interface on a Windows system. According to, user is responsible for any result from using the script or modification of the script.

# List all the available WMI properties for a various WMI Class on a
# remote or local box
# Version 1.0
# Tested on W2K and AS630 (with clients using W2K and NT4)

# Dumps a lot of information similar to the WMI SDK Utility, WBEMDUMP
#    If you were to run the command
#      WBEMDUMP /M2 \\COMPUTER\root\CIMV2 Win32_Classname
#      *Where:
#         -COMPUTER is a valid computer, and
#         -Win32_Classname is a valid calss name

# Valid Classnames can be found in the WMI SDK
# Class names can also found at:
# url=/library/en-us/wmisdk/r_32hard1_3d4j.asp
#      *Last checked the above URL on 2002/03/22
# Download the WMI Software Development Kit from:
# URL=/code/sample.asp?url=/msdn-files/027/001/566/msdncompositedoc.xml
#      *Last checked the above URL on 2002/03/22
# Here's a list of a few Helpful classes to get you started.
# Win32_ComputerSystem
# Win32_Processor
# Win32_TapeDrive
# Win32_TimeZone

# Last note.  If a class has a property that your computer doesn't show
# a value for, it isn't necessarily a problem with the script, OLE or
# WMI, but that the property isn't/wasn't populated in WMI for some
# reason

use Win32;
use Win32::OLE qw (in);


# syntax:
# perl computername Win32_TapeDrive
#  *Note: This may not return any information due
#            to the system you are querying not having a tape drive!
#  *Where the following command should return information (and for
#           both systems)
# perl computername Win32_ComputerSystem computername2
#      Win32_Processor
#  *And lastly, the asterisk can be used when looking for local
#       computer information
# perl * Win32_ComputerSystem computername2
#      Win32_Processor

foreach $item (@ARGV) {
  if ($x == 1) {
    if ($item eq "*") {
      $name = Win32::NodeName();    
    } else {
      $name = $item;
  } elsif ($x == 2) {
sub WMI {
  my $Computername = $_[0];
  my $Win32_Class = $_[1];
  my $Class = "WinMgmts://$Computername";
  my $Wmi = Win32::OLE->GetObject ($Class);
  print "$Computername ($Win32_Class)-> ";
  if ($Wmi) {
    my $Computers = $Wmi->ExecQuery("SELECT * FROM $Win32_Class");
    if (scalar(in($Computers)) lt "1") {
      print "\n    Check the computer and class name.\n";
      print   "    No information was found on the specified class!\n";
      return 0;
    print "$Computername\n";
    foreach my $pc (in ($Computers)) {
  } else {
    print "Unable to talk to WMI (Maybe I should ping this box \
         instead of assuming it is alive? :)   )\n";

sub properties {
  my $node = $_[0];
  foreach my $object (in $node->{Properties_}) {
    if (ref($object->{Value}) eq "ARRAY") {
      print "  $object->{Name} = { ";
      foreach my $value (in($object->{Value}) ) {
        print "$value ";
      print "}\n";
    } else {
      print "  $object->{Name} = $object->{Value}\n";
  print "----------------------------------\n";
------------------------- Script Page. 
Copyright ©1996 - 2005 Roth Consulting.

Contact us   Jobs   Press   Privacy   Terms of use
Copyright © 1987- CAI Networks, Inc. Copyright © 1998-2000 Red Hill Networks, Inc. All rights reserved.