<commit_before>#include "common/mysql_helper.js"


var DESCRIPTION="This advisor reads the value of wsrep_sst_method and and notifies you"
" if wsrep_sst_xtrabackup-v2 is not installed, which is a recommended SST method for all Galera variants.";
var WARNING_THRESHOLD=4;


function main()
{
    var hosts     = cluster::galeraNodes();
    var advisorMap = {};
    var sst_method = "";
    var alarmMessage;
    for (idx = 0; idx < hosts.size(); idx++)
    {
        host        = hosts[idx];
        map         = host.toMap();
        gStatus     = map["galera"]["galerastatus"];

        print("   ");
        print(host);
        print("==========================");

        if (gStatus!="Primary")
        {
            print("Is not Primary, continuing.");
            continue;
        }
        var msg ="";
        var justification = "";
        var advice = new CmonAdvice();
        var raiseAlarm = false;
        advice.setTitle("Wsrep SST method");
        advice.setHost(host);
        var value = host.sqlSystemVariable("WSREP_SST_METHOD").toString();
        if (value.isError() || value == "")
        {
            msg = "Not enough data to calculate";
            advice.setSeverity(Ok);
            advice.setJustification(msg);
            advice.setAdvice(msg);
            advisorMap[idx]= advice;
            continue;
        }

        if (value.toString() !="xtrabackup-v2" &&
            value.toString() !="mariabackup")
        {
            retval = host.system("test -f /usr/bin/wsrep_sst_xtrabackup-v2");
            reply = retval["success"];
            if (reply)
            {
                raiseAlarm = true;
                msg="Use wsrep_sst_method=xtrabackup-v2 or mariabackup"
                " (for newer version of MariaDb) instead.";
                advice.setSeverity(Warning);
            }
            else
            {
                msg="/usr/bin/wsrep_sst_xtrabackup-v2 does not exist,"
                " so keep the current setting.";
                advice.setSeverity(Ok);
            }
            justification = "Current wsrep_sst_method=" + value;
            advice.setJustification(justification);

        }
        else
        {
            if (sst_method == "") {
                sst_method = value;
            }
            if (sst_method != value) {
                raiseAlarm = true;
                msg="The wsrep_sst_method is not the same throughout the cluster "
		    "and this could lead to incompatible state transfers";
                justification = "Current wsrep_sst_method=" + value;
                advice.setJustification(justification);
                advice.setSeverity(Warning); 
            }
            else {
                msg="Using wsrep_sst_method=" + value + ", so it is good.";
                advice.setSeverity(Ok);
                justification = "Current wsrep_sst_method=" + value;
                advice.setJustification(justification);
                host.clearAlarm(MySqlAdvisor);
            }
        }
        if (raiseAlarm)
        {
            alarmMessage = justification + "\n" + msg;
            host.raiseAlarm(MySqlAdvisor, Warning, alarmMessage);
        }
        advice.setAdvice(msg);
        advisorMap[idx]= advice;
        print(advice.toString("%E"));
    }
    return advisorMap;
}


<commit_msg>Added a check to see if the MariaDB Backup package has been installed<commit_after>#include "common/mysql_helper.js"


var DESCRIPTION="This advisor reads the value of wsrep_sst_method and and notifies you"
" if wsrep_sst_xtrabackup-v2 is not installed, which is a recommended SST method for all Galera variants.";
var WARNING_THRESHOLD=4;


function main()
{
    var hosts     = cluster::galeraNodes();
    var advisorMap = {};
    var sst_method = "";
    var alarmMessage;
    for (idx = 0; idx < hosts.size(); idx++)
    {
        host        = hosts[idx];
        map         = host.toMap();
        gStatus     = map["galera"]["galerastatus"];

        print("   ");
        print(host);
        print("==========================");

        if (gStatus!="Primary")
        {
            print("Is not Primary, continuing.");
            continue;
        }
        var msg ="";
        var justification = "";
        var advice = new CmonAdvice();
        var raiseAlarm = false;
        advice.setTitle("Wsrep SST method");
        advice.setHost(host);
        var value = host.sqlSystemVariable("WSREP_SST_METHOD").toString();
        if (value.isError() || value == "")
        {
            msg = "Not enough data to calculate";
            advice.setSeverity(Ok);
            advice.setJustification(msg);
            advice.setAdvice(msg);
            advisorMap[idx]= advice;
            continue;
        }

        if (value.toString() !="xtrabackup-v2" &&
            value.toString() !="mariabackup")
        {
            retval = host.system("test -f /usr/bin/wsrep_sst_xtrabackup-v2");
            reply = retval["success"];
            if (reply)
            {
                raiseAlarm = true;
                msg="Use wsrep_sst_method=xtrabackup-v2 or mariabackup"
                " (for newer version of MariaDb) instead.";
                advice.setSeverity(Warning);
            }
            else
            {
                msg="/usr/bin/wsrep_sst_xtrabackup-v2 does not exist,"
                " so keep the current setting.";
                advice.setSeverity(Ok);
            }
            justification = "Current wsrep_sst_method=" + value;
            advice.setJustification(justification);
        }
        else
        {
            if (sst_method == "") {
                sst_method = value;
            }
            if (sst_method != value) {
                raiseAlarm = true;
                msg="The wsrep_sst_method is not the same throughout the cluster "
                "and this could lead to incompatible state transfers.";
                justification = "Current wsrep_sst_method=" + value;
                advice.setJustification(justification);
                advice.setSeverity(Warning); 
            }
            else {
                if (value == "mariabackup") {
                    retval = host.system("test -f /usr/bin/mariabackup");
                    reply = retval["success"];
                    if (!reply)
                    {
                        raiseAlarm = true;
                        msg="The wsrep_sst_method is set to mariabackup but "
                        "/usr/bin/mariabackup does not exist. "
                        "Please install the MariaDB Backup package.";
                        justification = "Current wsrep_sst_method=" + value;
                        advice.setJustification(justification);
                        advice.setSeverity(Warning);
                    }
                }
            }
            if (!raiseAlarm) {
                msg="Using wsrep_sst_method=" + value + ", so it is good.";
                advice.setSeverity(Ok);
                justification = "Current wsrep_sst_method=" + value;
                advice.setJustification(justification);
                host.clearAlarm(MySqlAdvisor);
            }
        }
        if (raiseAlarm)
        {
            alarmMessage = justification + "\n" + msg;
            host.raiseAlarm(MySqlAdvisor, Warning, alarmMessage);
        }
        advice.setAdvice(msg);
        advisorMap[idx]= advice;
        print(advice.toString("%E"));
    }
    return advisorMap;
}



{'fraction_non_alphanumeric': 0.11212080716290258, 'fraction_numerical': 0.0018709073900841909, 'mean_word_length': 1.570937822054277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1064718', 'n_tokens_mistral': 2134, 'n_tokens_neox': 2046, 'n_words': 454}