Pool Member Status HTML5 Page
Problem this snippet solves:
This allows a publicly accessible status page of Pools and Pool Members. No cron job is needed.
How to install:
If you only have one pool, you will probably have ...
Updated Sep 20, 2022
Version 2.0LoyalSoldier
Altostratus
Joined September 14, 2020
LoyalSoldier
Altostratus
Joined September 14, 2020
Maneesh_72711
Apr 19, 2017Cirrostratus
when HTTP_REQUEST { IP Block. Allow specific users/groups to access the status page. if { [IP::addr [IP::client_addr] equals 10.0.0.0/8 ] } { if { [HTTP::uri] eq "/json" } { set response "{ \"PoolDet\": ["
foreach { selectedpool } [class get test] {
set thispool [getfield $selectedpool " " 1]
if { [catch {
if { [active_members $thispool] < 1 } {
Pool Status for pools with no active members
append response "{\"PoolName\": \"$thispool\","
append response "\"PoolStatus\":\"Inactive\"},"
} else {
Pool Status
append response "{"
append response "\"PoolName\": \"$thispool\","
append response "\"PoolStatus\":\"Active\","
append response "\"PoolMemberDet\": \["
Pool Member Status Section
foreach { pmem } [members -list $thispool] {
append response "{\"PoolMember\": \"$pmem\","
set nodestatus "[LB::status pool $thispool member [getfield $pmem " " 1] [getfield $pmem " " 2]]"
if {$nodestatus == "up"} {
append response "\"PoolMemberStatus\": \"Up\""
} elseif {$nodestatus == "down"} {
append response "\"PoolMemberStatus\": \"Down\""
} elseif {$nodestatus == "session_disabled"} {
append response "\"PoolMemberStatus\": \"Disabled\""
} else {
append response "\"PoolMemberStatus\": \"$nodestatus\""
}
set nodestatus null
append response "},"
}
append response "{ \"PoolMember\": \"filler\", \"PoolMemberStatus\": \"filler\" }\]},"
}
} errmsg ] } {
append response "\"PoolNameError\": \"$thispool: ERROR: Invalid pool name\""
}
}
append response "{"
append response "\"PoolName\": \"filler\","
append response "\"PoolStatus\":\"filler\""
append response "}\]}"
End Pool Member Status Section
HTTP::respond 200 content $response "Content-Type" "application/json"
}
} }