Hovering the mouse of the state symbol shows the members and their states
Warning: On very large configurations (~2000 pools) this can be detrimental to the HTTPD process.
This is not a risk for the application delivery itself, but may cause the process to be restarted.`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/pool/list.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improvePoolList;
},
"addPartitionFilter": new function(){
this.name = "Partition filter";
this.description = `
Adds a free text partition filter to ease partition selection
`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/overview/welcome/introduction.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = startLTMLogFetcher;
}
}
for(let i in enhancementFunctions){
let f = enhancementFunctions[i];
if(f.applicable()){
f.enhance();
}
}
/**************************************************************************
* Modify the top frame
**************************************************************************/
String.prototype.hashCode = function(){
let hash = 0;
if (this.length == 0) return hash;
for (let i = 0; i < this.length; i++) {
let char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
function startLTMLogFetcher(){
//Check if the database contains anything
if(typeof(logDatabase) === "undefined"){
let rawData = localStorage.getItem("ltmLog") || "{\"content\":{},\"lastSynced\":null}";
logDatabase = JSON.parse(rawData);
//updateLTMLogStatistics(getLTMLogStatisticsSummary(logDatabase));
initiateLTMLogStatistics();
}
if(logDatabase.lastSynced){
let lastSynced = new Date(logDatabase.lastSynced);
let now = new Date();
let seconds = (now.getTime() - lastSynced.getTime()) / 1000;
}
let fetchLTMLog = function(){
$.ajax({
url: "https://" + window.location.host + "/tmui/Control/jspmap/tmui/system/log/list_ltm.jsp",
type: "GET",
success: function(response) {
$(response).find("table.list tbody tr").each(function(){
let message = {}
let row = $(this).find("td");
message.timeStamp = $(row[0]).text().trim();
message.logLevel = $(row[1]).text().trim();
message.host = $(row[2]).text().trim();
message.service = $(row[3]).text().trim();
message.statusCode = $(row[4]).text().trim();
message.logEvent = $(row[5]).text().trim();
let data = "";
for(let i in message){
data += message[i]
}
if(!(data in logDatabase)){
logDatabase.content[data] = message
}
logDatabase.lastSynced = new Date();
})
updateLTMLogStatistics(getLTMLogStatisticsSummary(logDatabase));
localStorage.setItem("ltmLog", JSON.stringify(logDatabase));
}
})
}
fetchLTMLog();
setInterval(fetchLTMLog, ltmLogCheckInterval*1000);
}
function initiateLTMLogStatistics(){
let topFrame = $(parent.top.document);
if(topFrame.find("div.ltmLogStats").length == 0){
let styleTag = $(``);
topFrame.find('html > head').append(styleTag);
let html = ``;
let parameterList = [];
for(let i in ltmLogPatterns){
if(parameterList.length == 2){
html += `
` + parameterList.join("") + `
`
parameterList = [];
}
parameterList.push(`
Loading...
`
);
}
if(parameterList.length != 0){
html += `
` + parameterList.join("") + `
`
}
topFrame.find("div#userinfo").last().after(html);
}
}
function updateLTMLogStatistics(summary){
let topFrame = $(parent.top.document);
if(topFrame.find("div.ltmLogStats").length != 0){
let i = 0
for(let stats in summary){
let statsSpan = topFrame.find("div#logStats" + stats + " span");
statsSpan.fadeOut(300);
statsSpan.html(summary[stats]);
statsSpan.fadeIn(300);
}
}
}
function getLTMLogStatisticsSummary(logDatabase){
let summary = {};
let events = logDatabase.content;
for(let f in ltmLogPatterns){
let logTest = ltmLogPatterns[f];
if(logTest.enabled){
summary[f] = 0;
}
}
for(let i in events){
let event = events[i];
for(let functionName in ltmLogPatterns){
let f = ltmLogPatterns[functionName];
if(f.isMatching(event)){
summary[functionName]++;
}
}
}
return(summary);
}
function isItChristmas(){
let d = new Date();
return d.getMonth() == 11;
}
function showChristmasOption(){
if($(parent.top.document).find("input#grinch").length == 0){
let partitionDiv = $(parent.top.document).find("div#partition");
partitionDiv.after(`
Merry Christmas! Which one are you?
`);
if(localStorage.getItem("tamperMonkey-snowActivated") === "true"){
letItSnow();
$(parent.top.document).find("input#santa").attr("checked", true);
} else {
$(parent.top.document).find("input#grinch").attr("checked", true);
}
$(parent.top.document).find("input.christmasButton").on("click", function(){
if($(this).val() === "santa"){
letItSnow();
localStorage.setItem("tamperMonkey-snowActivated", "true");
} else {
$(parent.top.document).find("#xmasdiv").remove();
$(parent.top.document).find("#santahat").remove();
localStorage.setItem("tamperMonkey-snowActivated", "false")
}
})
}
}
// This function handles the Christmas theme (santa hat on the F5 ball and snow)
function letItSnow(){
if(parent.top.document.getElementById("xmasdiv") === null){
let b = parent.top.document.getElementById("banner");
let logo = parent.top.document.getElementById("logo");
let image = $(logo).find("img");
let position = image.position();
let santacap = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAAA4CAYAAABE814IAAAACXBIWXMAAC4jAAAuIwF4pT92AAATUUlEQVRo3t1bCVhVVdeGywwXLlxEZBARBzTJnIfIAUUmZZA5Qs0wtayvPsv8slQUlVENHHEWUTDTTBP7888hhzTNNHNIEUQckMFQBBld/7v2PRdRIaHs68fzPOs55557OGfvd7/rXcO5aGg8gy3I2krHz1wZ7GZouM1ZSyvXWUOjxkVTkzy1tMhDJqPBOMa5O84y2YlhBgYLfZVK9yArK0ON53HzMTFxGaqnd7yfhgaF6uhQvKkp7bSyomN2dvSrvT2dgR1p3Zq+bNWK4vDdGD09FUBaWhc9jI1jfBUKp+cGjNEvOkX00dCoDNTWpm2Y8NV27aigQwe62b69OM6RLBfG5/i7a9gfBVgLzcwoAH8HICtcdHW3A5gpYE3oCCMjNz+lcugIudzVz9zcw9/SMsJLLk/0Uir3uBrJ97obGGz2khvNBCO9Qlq3Nvt/A8abzs5eveAaU4yN6QomnI/JZjk4UCbscgOm/i5XAo7/7kuwaZy+PvUFwwbAhsHc4WbD4W6eOPaC+ePzWG0telNXm8Kw98HnoTjvoq19zdPIaHGAhUXnfxSMyX4+ps56ejmTDQ3FxJgFfwREQ+AwgHlgzE3cYxuAGWtgwFoj7FWwZ4qhAcWZGNMyMwWtUprSanNTsV8OizaR07/09WgE3M9FJrsL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Cu5Rxeys2jx5k3Qjzrs2JJGwT27k7uBwS+vv/BC8/yHptEdO9oiMavISEmpfTPA73p+PHOaysvK6fRv5ykRucXZS5fE18VgEgPFLUoW01ip/cm/N5k6bSrxDwsn9Oo1tFnXMiOUypQRtraUe+FibS3DG3f49x47Cs0oU9V7FVW0bud20eOt26lnMD6dN5tcFQoaadlq4yM3Ly8pNSspvqvZnACZ1L+/Bfz+pC/E8PShwypQhPtU1epFaWkZbdr9NTLUJRTLQIAl3KmP27iO3hodTi4o6jz19XdO9fIyeeTm1WXlE0rvlJg0N5a8Zm/fCvVHxgB9fVoxfQblXsmhMuhHYWkpHbtwnhZ9kU6z1ySLBjb3QKLXrqDxwYE0wsqKfzF918fY+NNRDg5aT9y4/G5pFwCi3RxdJ9TaWtPbxOSDfhoaha4mxqL5/WZIEL03ZTJNnx9HUUuTaGZCLE0aE05eLS24IXTdQyaL9jcz66jxPG8h1lZ2w/X1x3vq6a0eoqFxCVYp+hxgz1CZjBvY1zxkWvMDW7Swftq9/g/AgFBTdyRnHAAAAABJRU5ErkJggg==";
$(logo).prepend("");
$(b).before("")
let canvas = parent.top.document.getElementById("xmassnow");
let w = b.offsetWidth
let h = b.offsetHeight
let ctx = canvas.getContext('2d'),
windowW = w,
windowH = h,
numFlakes = 200,
flakes = [];
function Flake(x, y) {
let maxWeight = 5,
maxSpeed = 0.5;
this.x = x;
this.y = y;
this.r = randomBetween(0, 1);
this.a = randomBetween(0, Math.PI);
this.aStep = 0.01;
this.weight = randomBetween(2, maxWeight);
this.alpha = (this.weight / maxWeight);
this.speed = (this.weight / maxWeight) * maxSpeed;
this.update = function() {
this.x += Math.cos(this.a) * this.r;
this.a += this.aStep;
this.y += this.speed;
}
}
function init() {
let i = numFlakes,
flake,
x,
y;
while (i--) {
x = randomBetween(0, windowW, true);
y = randomBetween(0, windowH, true);
flake = new Flake(x, y);
flakes.push(flake);
}
scaleCanvas();
loop();
}
function scaleCanvas() {
canvas.width = windowW;
canvas.height = windowH;
}
function loop() {
let i = flakes.length,
z,
dist,
flakeA,
flakeB;
// clear canvas
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, windowW, windowH);
ctx.restore();
// loop of hell
while (i--) {
flakeA = flakes[i];
flakeA.update();
/*for (z = 0; z < flakes.length; z++) {
flakeB = flakes[z];
if (flakeA !== flakeB && distanceBetween(flakeA, flakeB) < 150) {
ctx.beginPath();
ctx.moveTo(flakeA.x, flakeA.y);
ctx.lineTo(flakeB.x, flakeB.y);
ctx.strokeStyle = '#444444';
ctx.stroke();
ctx.closePath();
}
}*/
ctx.beginPath();
ctx.arc(flakeA.x, flakeA.y, flakeA.weight, 0, 2 * Math.PI, false);
ctx.fillStyle = 'rgba(255, 255, 255, ' + flakeA.alpha + ')';
ctx.fill();
if (flakeA.y >= windowH) {
flakeA.y = -flakeA.weight;
}
}
requestAnimationFrame(loop);
}
function randomBetween(min, max, round) {
let num = Math.random() * (max - min + 1) + min;
if (round) {
return Math.floor(num);
} else {
return num;
}
}
function distanceBetween(vector1, vector2) {
let dx = vector2.x - vector1.x,
dy = vector2.y - vector1.y;
return Math.sqrt(dx*dx + dy*dy);
}
init();
}
}
function addPartitionFilter(){
let partitionDiv = $(parent.top.document).find("div#partition");
// Add the filter input and the label
partitionDiv.prepend(" ")
partitionDiv.prepend("");
let partitionDropDown = partitionDiv.find("select#partition_control");
let partitonOptions = partitionDropDown.find("option");
let partitionFilterInput = partitionDiv.find("input#partitionFilter");
partitionFilterInput.on("keyup", function(e){
if(e.keyCode === 13){
triggerEvent("change", parent.top.document.querySelector("div#partition select#partition_control"))
return;
}
let searchValue = this.value;
// Set the local storage in order to re-populate the filter upon page reload
localStorage.setItem("tamperMonkey-PartitionFilter", searchValue);
let re = new RegExp(searchValue, "i");
partitonOptions.each(function(){
if($(this).val().match(re) || $(this).val() === "[All]"){
$(this).attr("ismatch", "true")
$(this).show();
} else {
$(this).attr("ismatch", "false")
$(this).hide();
}
});
let selectedOption = partitionDropDown.find("option:selected");
let selectedOptionValue = selectedOption.val() || ""
let matchedCount = partitionDropDown.find("option[ismatch='true']").length;
if(!selectedOptionValue.match(re) && matchedCount > 0){
selectedOption.removeAttr("selected");
partitionDropDown.find("option[ismatch='true']:eq(0)").attr("selected", "selected");
}
})
partitionFilterInput.val(localStorage.getItem("tamperMonkey-PartitionFilter") || "").trigger("keyup");
}
/**************************************************************************
* iRule improvements
**************************************************************************/
function improveiRuleProperties(){
// Show the data group lists used in an iRule
cacheDataGroupLists(function(dataGroupLists){
//This part prepares the iRule definition table for the data group lists (adds a third column)
$("table#general_table thead tr.tablehead td").attr("colspan", 3);
$("table#general_table tr").not("#definition_ace_row").each(function(){
$(this).find("td").eq(1).attr("colspan", 2);
});
$("tr#definition_ace_row").append("
").css({
"vertical-align": "top"
});
$("tr#definition_ace_row td.settings").css("width","80%");
//This command generates the data group lists (if any)
getDataGroupListsFromRule($("textarea#rule_definition").val());
//getDataGroupListsFromRuleOld($("textarea#rule_definition").val());
//Update the list on every key stroke
$(document).on("keyup", function(){
let iRuleContent = codeEditor.gSettings.editor.container.env.document.doc.$lines.join("\n");
getDataGroupListsFromRule(iRuleContent);
//getDataGroupListsFromRuleOld($("textarea#rule_definition").val());
});
});
}
// Caches a list of all the data group lists available in Common and the current partition (if any)
function cacheDataGroupLists(updateDGPage){
let DataGroupListLink = "https://" + window.location.host + "/tmui/Control/jspmap/tmui/locallb/datagroup/list.jsp";
// We want to get all data group lists in case there is a direct reference
let currentPartition = getCookie("F5_CURRENT_PARTITION");
replaceCookie("F5_CURRENT_PARTITION", "\"[All]\"");
//Request the iRule page to see if the instance exists or not
$.ajax({
url: DataGroupListLink,
type: "GET",
success: function(response) {
let dataGroupListLinks = $(response).find('table.list tbody#list_body tr td:nth-child(3) a');
for(let i = 0; i < dataGroupListLinks.length; i++){
let link = dataGroupListLinks[i].href;
let name = link.split("name=")[1];
tamperDataGroupLists.push(name);
}
replaceCookie("F5_CURRENT_PARTITION", currentPartition);
updateDGPage();
}
});
}
//Parses data group list html to get the key/value pairs for the hover information
function parseDataGroupValues(dg, showBalloon){
let dgLink = 'https://' + window.location.host + '/tmui/Control/jspmap/tmui/locallb/datagroup/properties.jsp?name=' + dg;
let html;
$.ajax({
url: dgLink,
type: "GET",
success: function(htmlresponse) {
let matches = htmlresponse.match(/";
}
}
$("select:visible").last().append(selectList);
$("input#bulkReplace").prop("disabled", false);
$("input#bulkEdit").prop("disabled", false);
$("input#update").prop("disabled", false);
})
$("input#bulkReplace").on("click", function(){
"use strict";
//First get the data
let importListArr = $("textarea.bulkcontent:visible").val().split("\n");
//Create an object from the array
let importObj = createDGListObject(importListArr);
//Remove current options
$("select:visible").last().find("option").remove();
let selectList = "";
for(let key in importObj){
let value = importObj[key];
let optionValue = value === "" ? key : (key + "\\x0a" + value);
let optionText = value === "" ? key : (key + " := " + value);
selectList += "";
}
$("select:visible").last().append(selectList);
$("input#bulkEdit").prop("disabled", false);
$("input#update").prop("disabled", false);
})
$("input#bulkEdit").on("click", function(){
let keyVals = []
$("select:visible").last().find("option").each(function(){
keyVals.push($(this).text().trim())
$(this).remove();
})
$("input#bulkEdit").prop("disabled", true);
$("input#update").prop("disabled", true);
$("textarea.bulkcontent:visible").val(keyVals.join("\n"));
})
$("input#bulkSelected").on("click", function(){
let keyVals = []
$("select:visible").last().find("option:selected").each(function(){
keyVals.push($(this).text().trim())
$(this).remove();
})
$("input#bulkReplace").prop("disabled", true);
$("input#bulkEdit").prop("disabled", true);
$("input#update").prop("disabled", true);
$("textarea.bulkcontent:visible").val(keyVals.join("\n"));
})
}
function improveDataGroupListProperties(){
$("input[name=string_input], input[name=string_pair_value], input#string_add_button").on("keyup change input focus click", function(){
let key = $("input[name=string_input]").val();
let value = $("input[name=string_pair_value]").val();
let currentList = [];
$('select#class_string_item option').each(function(){
currentList.push($(this).val());
})
if(key.length){
let listItem = "";
if(value === ""){
listItem = key;
} else {
listItem = key + "\\x0a" + value;
}
if(currentList.indexOf(listItem) === -1){
$("input#update").prop("disabled", true);
} else {
$("input#update").prop("disabled", false);
}
} else if(currentList.length && currentList.length === 0){
$("input#update").prop("disabled", true);
} else {
$("input#update").prop("disabled", false);
}
})
$("input#edit_string").on("click", function(){
$("input#update").prop("disabled", true);
})
}
function createDGListObject(lines){
let bulkImportObj = {}
//Creating object and ignoring duplicates
lines.map(function(line){
// break on first := if present
let lineArr = line.split(/\s*:=\s*(.*)/i)
let key = lineArr[0];
let value = lineArr[1] || "";
if(!(key in bulkImportObj)){
bulkImportObj[key] = value;
}
});
return bulkImportObj
}
/**************************************************************************
* Virtual server improvements
**************************************************************************/
function improveVirtualServerProperties(){
let css = `select.large { resize: both; }`;
addGlobalStyle(css);
// SSL Profile (client)
addDoubleClick("selectedclientsslprofiles", "availableclientsslprofiles_button");
addDoubleClick("availableclientsslprofiles", "selectedclientsslprofiles_button");
// SSL Profile (server)
addDoubleClick("selectedserversslprofiles", "availableserversslprofiles_button");
addDoubleClick("availableserversslprofiles", "selectedserversslprofiles_button");
// VLANs and Tunnels
addDoubleClick("selected_vlans", "available_vlans_button");
addDoubleClick("available_vlans", "selected_vlans_button");
}
function improveiRuleSelection(){
// Add double click feature
addDoubleClick("rule_references", "assigned_rules_button");
addDoubleClick("assigned_rules", "rule_references_button");
}
function improveVirtualServerResources(){
let selecteddefaultpool = $('input[name=default_pool_before]').val();
if(selecteddefaultpool != 'NO_SELECTION'){
$('input[name=default_pool_before]').after('')
}
}
/**************************************************************************
* Pool improvements
**************************************************************************/
function improvePoolList(){
addGlobalStyle('div.tamperpoolstatus{position:relative;}div.tamperpoolstatus table.list{position:relative;width:100%;border:1px solid #999 }div.tamperpoolstatus table.list tbody tr.color0{background:#deddd9}div.tamperpoolstatus table.list tbody tr.color0 td{border-bottom:1px solid #c4c2be}div.tamperpoolstatus table.list tbody tr.inner td,div.tamperpoolstatus table.list tbody tr.innerbold td{padding:3px 5px;border-bottom:none;white-space:nowrap}div.tamperpoolstatus table.list tbody tr.color1{background:#fff}div.tamperpoolstatus table.list tbody tr.color2{background:#f7f6f5}div.tamperpoolstatus table.list tbody tr.innerbold td{font-weight:700}div.tamperpoolstatus table.list tbody td{vertical-align:top;padding:6px 5px 4px;border-bottom:1px solid #ddd;white-space:nowrap}div.tamperpoolstatus table.list tbody td input{margin-top:0}div.tamperpoolstatus table.list tbody td img{padding-top:1px}div.tamperpoolstatus table.list div.customtooltip div,div.tamperpoolstatus table.list div.filter div{padding:3px 5px}div.tamperpoolstatus table.list tbody td.first{border-left:1px solid #999}div.tamperpoolstatus table.list tbody td.last{border-right:1px solid #999}div.tamperpoolstatus table.list tbody td.column1,div.tamperpoolstatus table.list tbody td.column2{border-left:1px solid #ddd}div.tamperpoolstatus table.list div.customtooltip,div.tamperpoolstatus table.list div.filter{position:absolute;z-index:1;margin-top:2px;border:1px solid #666;background:#deddd9}div.tamperpoolstatus table.list div.customtooltip div a.close{color:red;font-weight:700}div.tamperpoolstatus table.list div.filter div.current{margin:1px;padding:3px;border:1px solid #999;background:#eee}div.tamperpoolstatus table.list tbody tr.expanded td,div.tamperpoolstatus table.list tbody tr.notlast td{border-bottom:none!important}div.tamperpoolstatus table.list .expired{padding-left:17px;background:url(../images/status_certificate_expired.gif) left center no-repeat}div.tamperpoolstatus table.list .warning{padding-left:17px;background:url(../images/status_certificate_warning.gif) left center no-repeat}div.tamperpoolstatus table.list tbody tr.collapsible-parent td a{vertical-align:top}div.tamperpoolstatus table.list thead tr td div.collapsible-toggle.expanded{background:url(/xui/common/images/icon_toggle_all_minus.gif) no-repeat;width:15px;height:15px;display:inline-block;cursor:pointer;zoom:1}div.tamperpoolstatus table.list tbody tr.expanded td div.collapsible-toggle{background:url(/xui/common/images/icon_toggle_minus.gif) no-repeat;width:12px;height:12px;margin:0 auto;zoom:1}div.tamperpoolstatus table.list thead tr td div.collapsible-toggle.collapsed{background:url(/xui/common/images/icon_toggle_all_plus.gif) no-repeat;width:15px;height:15px;display:inline-block;cursor:pointer;zoom:1}div.tamperpoolstatus table.list tbody tr.collapsed td div.collapsible-toggle{background:url(/xui/common/images/icon_toggle_plus.gif) no-repeat;width:12px;height:12px;margin:0 auto;zoom:1}div.tamperpoolstatus table.list tbody tr.set-whitespace-normal td{white-space:normal}div.tamperpoolstatus table.list tbody.group_move_placeholder{display:table-row}div.tamperpoolstatus table.list tbody tr.handle td.first{width:15px;background:url(/tmui/tmui/skins/Default/images/icon_gripper.png) 50% no-repeat!important;cursor:url(/xui/common/images/openhand.cur),default}div.tamperpoolstatus thead tr.columnhead td div.reorder{width:16px;height:16px;background:url(/xui/common/images/cursor-openhand.png) center no-repeat}div.tamperpoolstatus table.list .highlight{background:#dbefff!important;cursor:url(/xui/common/images/openhand.cur),default}div.tamperpoolstatus table.list .highlight a{cursor:url(/xui/common/images/openhand.cur),default}div.tamperpoolstatus div.section{margin:10px 0}div.tamperpoolstatus thead tr.tablehead td{border-bottom:1px solid #999;vertical-align:bottom}div.tamperpoolstatus thead tr.tablehead div{padding-bottom:3px;white-space:nowrap}div.tamperpoolstatus thead tr.tablehead div.title{float:left;margin-top:.5em;color:#000;font-weight:700}div.tamperpoolstatus thead tr.tablehead div.advancedtoggle{float:left;margin:0 0 0 5px;color:#000}div.tamperpoolstatus thead tr.tablehead div.search{float:left}div.tamperpoolstatus thead tr.tablehead div.searchnofloat{clear:both;float:left}div.tamperpoolstatus thead tr.tablehead div.search input.search,div.tamperpoolstatus thead tr.tablehead div.searchnofloat input.search{width:240px}div.tamperpoolstatus thead tr.tablehead div.buttons{float:right}div.buttons input[type=button],div.tamperpoolstatus thead tr.tablehead div.buttons input[type=button],div.tamperpoolstatus thead tr.tablehead div.buttons input[type=submit]{padding:0 5px}div.tamperpoolstatus thead tr.tablehead div.buttons input.checkall{margin-right:9px}div.tamperpoolstatus thead tr.tablehead div.grouptitle{margin:0 3px 0 2px;padding:1px 10px;border:1px solid #999;border-bottom:none;background:#deddd9;text-align:center;font-weight:700}div.tamperpoolstatus thead tr.columnhead td{padding:5px;border-bottom:1px solid #999;border-top:1px solid #999;border-left:1px solid #999;background:url(../images/background_list_head.gif) #deddd9;white-space:nowrap}div.tamperpoolstatus thead tr.columnhead td.last{border-right:1px solid #999}div.tamperpoolstatus thead tr.columnhead td a{display:block;width:expression("1%");padding-top:1px;margin-top:-1px;color:#000}div.tamperpoolstatus thead tr.columnhead td a.filteroff{margin-top:0;padding-left:20px;background:url(../images/button_filter_off.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.filteron{margin-top:0;padding-left:20px;background:url(../images/button_filter_on.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.selectall{margin-top:0;width:15px;background:url(../images/button_select_all.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.selectall:hover{text-decoration:none}div.tamperpoolstatus thead tr.columnhead td a.sortoff{margin-top:0;padding-left:12px;background:url(../images/button_sort_off.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.sorton{margin-top:0;padding-left:12px;background:url(../images/button_sort_on.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.sortup{margin-top:0;padding-left:12px;background:url(../images/button_sort_up.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td a.sortdown{margin-top:0;padding-left:12px;background:url(../images/button_sort_down.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .greenflag,div.tamperpoolstatus thead tr.columnhead td .redflag,div.tamperpoolstatus thead tr.columnhead td .yellowflag{display:block;width:expression("1%");padding-top:1px;padding-left:20px}div.tamperpoolstatus thead tr.columnhead td .greenflag{background:url(../images/status_flag_green.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .yellowflag{background:url(../images/status_flag_yellow.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .redflag{background:url(../images/status_flag_red.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .activedevice,div.tamperpoolstatus thead tr.columnhead td .failsafefaultdevice,div.tamperpoolstatus thead tr.columnhead td .impaireddevice,div.tamperpoolstatus thead tr.columnhead td .maintenancedevice,div.tamperpoolstatus thead tr.columnhead td .offlinedevice,div.tamperpoolstatus thead tr.columnhead td .replacementdevice,div.tamperpoolstatus thead tr.columnhead td .standbydevice,div.tamperpoolstatus thead tr.columnhead td .unknowndevice,div.tamperpoolstatus thead tr.columnhead td .unreachabledevice{display:block;width:expression("1%");padding:2px 0 2px 27px}div.tamperpoolstatus thead tr.columnhead td .activedevice{background:url(../images/status_filter_device_active.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .standbydevice{background:url(../images/status_filter_device_standby.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .failsafefaultdevice{background:url(../images/status_filter_device_failsafe_fault.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .offlinedevice{background:url(../images/status_filter_device_offline.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .forcedofflinedevice{display:block;width:expression("1%");padding:2px 0 2px 27px;background:url(../images/status_filter_device_forcedoffline.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .unknowndevice{background:url(../images/status_filter_device_present_unknown.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .impaireddevice{background:url(../images/status_filter_device_impaired.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .maintenancedevice{background:url(../images/status_filter_device_maint.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .replacementdevice{background:url(../images/status_filter_device_replacement.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .unreachabledevice{background:url(../images/status_filter_device_unreachable.gif) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .available,div.tamperpoolstatus thead tr.columnhead td .offline,div.tamperpoolstatus thead tr.columnhead td .unavailable,div.tamperpoolstatus thead tr.columnhead td .unknown{display:block;width:expression("1%");padding-top:1px;padding-left:20px}div.tamperpoolstatus thead tr.columnhead td .available{background:url(../images/status_circle_green.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .unavailable{background:url(../images/status_triangle_yellow.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .offline{background:url(../images/status_diamond_red.png) left center no-repeat}div.tamperpoolstatus thead tr.columnhead td .unknown{background:url(../images/status_square_blue.png) left center no-repeat}div.tamperpoolstatus table.head td.wizardtext{padding-top:10px}div.tamperpoolstatus table.tablefoot{width:100%}div.tamperpoolstatus table.tablefoot td{vertical-align:top}div.tamperpoolstatus table.tablefoot div{padding:3px 0 20px}div.tamperpoolstatus table.tablefoot div.buttons{float:left}div.tamperpoolstatus table.tablefoot div.buttons input[type=button],div.tamperpoolstatus table.tablefoot div.buttons input[type=submit]{padding:0 5px}div.tamperpoolstatus table.tablefoot div.pagecontrols{float:right}');
let poolStatuses = {}
let oldMessage = $(parent.top.document).find("div#message div#messagetype div#messagetext").text();
// Check when the loading screen for pools has disappears and then show a member statuses.
let statusInterval = setInterval(function(){
if(!$(parent.top.document).find("div#message").is(":visible")){
$(parent.top.document).find("div#message div#messagetype div#messagetext").text("Loading member statuses...");
$(parent.top.document).find("div#message").show();
clearInterval(statusInterval);
}
} , 100);
$.ajax({
url: "https://" + window.location.host + "/tmui/Control/jspmap/tmui/locallb/pool/stats.jsp?SearchString=*&",
type: "GET",
success: function(response) {
$(response).find("tbody#list_body tr")
.filter(function() {
return this.id.match(/\/.+\//);
})
.each(function(){
let poolName = this.id.replace(/_member_row_[0-9]+$/i, "");
if(!(poolName in poolStatuses)){
poolStatuses[poolName] = {};
}
let memberName = $(this).find("td").eq(3).text().trim();
let statusIcon = $(this).find("td").eq(1).find("img").attr("src");
let title = $(this).find("td").eq(1).find("img").attr("title");
poolStatuses[poolName][memberName] = { "icon": statusIcon, "title": title };
});
$("tbody#list_body tr").each(function(){
let poolName = $(this).find("td").eq(2).find("a").attr("href").replace(/.+name=/i, "");
let existingIcons = [];
if(poolName in poolStatuses){
let memberStatuses = poolStatuses[poolName];
for(let memberStatus in memberStatuses){
if(existingIcons.indexOf(memberStatuses[memberStatus].icon) === -1){
existingIcons.push(memberStatuses[memberStatus].icon);
}
}
if(existingIcons.length > 1){
let html = "
";
for(let i = 0; i < existingIcons.length; i++){
let iconURL = existingIcons[i].replace(/\/.*_/i, "/tmui/tmui/skins/Default/images/status_circle_");
switch (i){
case 0:
html += ""
break;
case 1:
html += ""
break;
case 2:
html += ""
break;
case 3:
html += ""
break;
}
}
html += "
";
$(this).find("td").eq(1).html(html);
} else {
let html = ""
$(this).find("td").eq(1).html(html);
}
$(this).find("td").eq(1).find("div").on("mouseover", function(){
poolName = $(this).attr("data-poolname");
if(poolName in poolStatuses){
let table = "
Member
Status
";
memberStatuses = poolStatuses[poolName];
let i = 0;
for(let member in memberStatuses){
table += "
" + member + "
" + memberStatuses[member].title + "
";
i++;
}
table += "
";
$(this).balloon({ position: "right", css: { whitespace: "nowrap", boxShadow: null, opacity: "1", padding: "0px", border: "0px", background: "rgba(0, 0, 255,1)" }, minLifetime: 0, tipSize:0, showDuration: 0, hideDuration: 0, contents: table });
}
});
//For some reason I need to trigger this at least one ahead of time in order to get the popup to show on the first attempt
$(this).find("td").eq(1).find("div").trigger("mouseover");
$(this).find("td").eq(1).find("div").trigger("mouseout");
}
})
$(parent.top.document).find("div#message").fadeOut(function(){
$(parent.top.document).find("div#message div#messagetype div#messagetext").text(oldMessage);
});
}
})
}
function improvePoolProperties(){
// Increase the select box sizes
$("#monitor_rule").attr("size", MonitorCount);
$("#available_monitor_select").attr("size", MonitorCount);
// Add double click feature
addDoubleClick("monitor_rule", "available_monitor_select_button");
addDoubleClick("available_monitor_select", "monitor_rule_button");
}
function improvePoolCreation(){
// Increase the select box sizes
$("#monitor_rule").attr("size", MonitorCount);
$("#available_monitor_select").attr("size", MonitorCount);
// Add double click feature
addDoubleClick("monitor_rule", "available_monitor_select_button");
addDoubleClick("available_monitor_select", "monitor_rule_button");
// Set the default pool name suffix
$("#pool_name").find("input[name=name]").attr("value", DefaultPoolName);
// Set the default action on pool down value
$("#action_on_service_down").find("option[value=\"" + DefaultActionOnPoolDown + "\"]").attr("SELECTED", "");
// Set the default LB Method
$("#lb_mode").find("option[value=\"" + DefaultLBMethod + "\"]").attr("SELECTED", "");
// If configured, choose node as default when selecting pool members
if(ChooseNodeAsDefault){
if(majorVersion === "11"){
$("#member_address_radio_address").attr("unchecked","");
$("#member_address_radio_node").attr("checked","");
$("#member_address_radio_node").click();
} else if(["11", "12", "13", "14", "15"].indexOf(majorVersion) != -1){
$("tr#member_address_selection td input").eq(0).attr("unchecked", "");
$("tr#member_address_selection td input").eq(4).attr("checked", "");
$("tr#member_address_selection td input").eq(4).click();
}
}
}
function addHTTPMonitorSuffix(){
if($("select[name=mon_type]").find(":selected").text().trim() == "HTTP"){
let monitorname = $("input[name=monitor_name]").attr("value");
if($("input[name=monitor_name]").length && monitorname == "") {
$("input[name=monitor_name]").attr("value", HttpMonitorSuffix);
} else if ($("input[name=monitor_name]").length && !(endsWith(monitorname, HttpMonitorSuffix))) {
monitorname = monitorname + HttpMonitorSuffix;
$("input[name=monitor_name]").attr("value", monitorname);
}
}
}
// Adds monitor test strings to the pool member details
function improvePoolMemberProperties(){
if($("#member_address td").next().length && $("#member_port td").next().length){
// Add double click feature
addDoubleClick("monitor_rule", "available_monitor_select_button");
addDoubleClick("available_monitor_select", "monitor_rule_button");
//Add global style
let css = `a.monitortest { position: relative; display: inline; color:#000000;}
a.monitortest p { position: absolute; color: #000; top:-50px; left:-55px;
background: #f7f6f5; border: 1px solid #000; padding-left:5px; padding-right:5px;
padding-top:2px; padding-bottom:0px; height: 30px; text-align: center;
visibility: hidden; border-radius: 2px; font-size:12px; font-weight:bold; }
a:hover.monitortest p { visibility: visible; bottom: 30px; z-index: 999; }
.monitorcopybox { width:140px;font-weight:normal;font-size:10px;margin-bottom:1px;}
button.monitortestbutton { font-size:12px; }`;
addGlobalStyle(css);
let ip = $("#member_address td.settings").text().trim();
let port = $("#member_port td.settings").text().trim();
$('#general_table tbody tr td.settings').not('tr#member_health_monitors_status').each(function(){
$(this).attr("colspan", 2);
});
$('#health_monitor_table tbody tr').not(".monitorheaderrow").each(function(key,value){
let monitorurl = $(value).find('td a').attr("href");
$.ajax({
url: "https://" + window.location.host + monitorurl,
type: "GET",
ip: ip,
port: port,
success: function(response) {
"use strict";
let type = "";
let sendstring;
if($(response).find("#monitor_send_string").length){
sendstring = $(response).find("#monitor_send_string").text().trim();
type = $(response).find("#div_general_table tbody tr td:contains('Type')").next().text().trim();
} else if ($(response).find("#div_configuration_table table tbody tr td:contains('Send String')")) {
// Default monitors does not have the same page structure as the normal ones. Needs special treatment.
sendstring = $(response).find("#div_configuration_table table tbody tr").find("td:contains('Send String')").next().text().trim();
type = $(response).find("#general_table tbody tr").find("td:contains('Type')").next().text().trim();
}
if(type == "HTTP" || type == "HTTPS"){
let commands = getMonitorRequestParameters(sendstring, type, ip, port);
let html = "";
for(let c in commands.commands){
html += `
");
}
},
async: false
});
});
//Attach an onmouseover function which focuses and selects the text
if($('.monitortest').length){
$('.monitortest').mouseover(function(){
$(this).find("p input").focus();
$(this).find("p input").select();
let inputstring = $(this).find('p input').attr('value');
$(this).attr("href", "javascript:prompt('The command','" + inputstring.replace(/\'/g,"\\'") + "')");
});
}
//Remove the parent padding first
$('#health_monitor_table').parent().css('padding','0px');
//Add a row with headers
$('#health_monitor_table tbody tr:first').before('
Monitors
Monitor tests
');
//Make the headers bold
$('#health_monitor_table tbody tr.monitorheaderrow td').css({
'font-weight' : 'bold',
'border-right' : '1px solid #dddddd'
});
//Add padding
$('#health_monitor_table tr td').css({
'padding' : '5px'
});
$('#health_monitor_table tr td').not('.monitorheadercell').css({
'border-right' : '1px solid #dddddd',
'border-top' : '1px solid #dddddd',
});
$('#health_monitor_table tr td.monitortests').css('text-align','center');
}
}
function getMonitorRequestParameters(sendstring, type, ip, port){
"use strict";
let headers = [];
let protocol = "";
let commandObj = {
"commands": {
"HTTP": {
"title": "",
"command": ""
},
"Curl": {
"title": "",
"command": ""
},
"Netcat": {
"title": "",
"command": ""
}
},
"success": true
}
let sendstringarr = sendstring.split(" ");
let verb = sendstringarr[0];
let uri = sendstringarr[1].replace("\\r\\n", "");
if (/^HTTP[S]?$/.test(type)){
protocol = type.toLowerCase();
}
//So far we only support HTTP GET request
if( verb === "GET" || verb === "HEAD"){
//Parse for headers
let headersarr = sendstring.split('\\r\\n');
let i;
if(headersarr.length > 2){
for(i in headersarr){
let header = headersarr[i];
if(header.indexOf(":") >= 0){
if(header.split(":").length == 2){
headers.push(header);
}
}
}
}
let commandstring = 'curl -vvv';
if (verb === "HEAD"){
commandstring += " -I"
}
if(headers.length > 0){
for(i in headers){
let headerarr = headers[i].split(":");
let headername = headerarr[0].trim();
let headervalue = headerarr[1].trim();
headervalue = headervalue.replace(/\"/g,'\\"');
commandstring += ' --header "' + headername + ':' + headervalue + '"';
}
}
commandstring += ' ' + protocol + '://' + ip + ':' + port + uri
commandObj.commands.Curl.title = "Curl Command";
commandObj.commands.Curl.string = commandstring;
commandObj.commands.Netcat.title = "Netcat Command";
commandObj.commands.Netcat.string = "echo -ne \"" + sendstring + "\" | nc " + ip + " " + port;
commandObj.commands.HTTP.title = "HTTP Link";
commandObj.commands.HTTP.string = protocol + '://' + ip + ':' + port + uri;
} else {
commandObj.success = false;
}
return commandObj;
}
/**************************************************************************
* Client SSL Profile Improvements
**************************************************************************/
function improveClientSSLProfileCreation(){
if(defaultClientSSLParentProfile !== ""){
setTimeout(function(){
$('select#parent_profile_name').val(defaultClientSSLParentProfile);
$('select#parent_profile_name').trigger("change");
}, 1000);
}
$("input[name='certificate_name']").on("keyup", function(){
$("input[name='common_name']").val($(this).val().replace(/^star\./g, "*."));
});
setTimeout(function(){
$("select[name='issuer']").val("Certificate Authority");
$("select[name='issuer']").trigger("change");
}, 500);
}
function improveCertKeyChainSelection(){
$('input[name="cert_key_chain_override"]').on("click", matchCertAndKey);
$('input[name="add_modal_button"]').on("mouseup", function(){
setTimeout(function(){
let currentPartition = getCookie("F5_CURRENT_PARTITION");
let profileName = $("input[name='profile_name']").val();
if($("select#cert option[value='/" + currentPartition + "/" + profileName + ".crt']").length > 0){
$('select#cert').val("/" + currentPartition + "/" + profileName + ".crt");
$('select#key').val("/" + currentPartition + "/" + profileName + ".key");
} else if ($("select#cert option[value='/Common/" + profileName + ".crt']").length > 0){
$('select#cert').val("/Common/" + profileName + ".crt");
$('select#key').val("/Common/" + profileName + ".key");
}
$('select#chain').val(defaultChain)
}, 500);
});
}
function matchCertAndKey(){
$('select#chain').val(defaultChain)
$('select#cert').on("change", function(){
let certName = $(this).val();
let probableKeyName = certName.replace(/\.crt$/, ".key");
$('select#key').val(probableKeyName);
if(defaultChain !== ""){
$('select#chain').val(defaultChain)
}
});
}
/**************************************************************************
* SSL certificate creation improvements
**************************************************************************/
function addCSRDropDownMenu(){
//A certificate is being created and the default certificate signing setting has been enabled
let csrdropdown = '