The following code uses Stingray's Control API to list all the running virtual servers on a cluster. The code is written in Ruby.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/ruby require 'http-access2' require 'soap/rpc/driver' # Fix these for your admin server, password etc url = 'https://10.100.1.31:9090/soap' user = 'admin' pass = 'admin' client.add_method( 'getVirtualServerNames' ) client.add_method( 'getEnabled' , 'names' ) client.options[ 'protocol.http.ssl_config.verify_mode' ] = OpenSSL: SSL::VERIFY_NONE client.options[ 'protocol.http.basic_auth' ] << [ url, user, pass ] vservers = client.getVirtualServerNames enabled = client.getEnabled( vservers ) vservers. length . times do |i| if enabled puts vservers end end |
Run the Ruby script as follows:
$ listVS.rb
Main website
Mail servers
Test site
As well as Ruby 1.8, you will need to install the http-access2 and openssl Ruby packages in order for the HTTPS Basic Authentication used by Stingray's SOAP server to functions correctly.