Fortinet white logo
Fortinet white logo

Script Reference Guide

Set persistence table entry

Set persistence table entry

You can set the entry to the persistence table and the real server will be assigned after lookup.

Set the entry to the persistence table:
when RULE_INIT {
    env={}
    PROXY:init_stick_tbl_timeout(1000)
}
when PERSISTENCE {
    debug("PERSIST \n");
    t={};
    t["operation"] = "get_valid_server";
    ret_tbl = HTTP: persist(t);
    if(ret_tbl) then
        for srv, state in pairs(ret_tbl) do
            debug("server %s status %s\n", srv, state);   
        end
    end
    t={};
    t["operation"] = "save_tbl";
    t["hash_value"]= "hash_str";
    t["srv_name"]= "rsrv_70";
    ret = HTTP: persist(t)
    if ret then
        debug("save table success\n");
    else
        debug("save table failed\n");
    end
    t={};
    t["operation"] = "dump_tbl";
    t["index"] = 0;
    t["count"] = 500;
    ret_tbl = HTTP: persist(t)
    if(ret_tbl) then
        for k, cnt in pairs(ret_tbl) do
            debug(" hash %s srv_name %s\n", k, cnt)
        end
    end
    t={};
    t["hash_value"]= "hash_str";
    ret = HTTP:lookup_tbl(t);
    if ret then
        debug("LOOKUP success\n");
    else
        debug("LOOKUP fail\n");
    end
}

Set persistence table entry

Set persistence table entry

You can set the entry to the persistence table and the real server will be assigned after lookup.

Set the entry to the persistence table:
when RULE_INIT {
    env={}
    PROXY:init_stick_tbl_timeout(1000)
}
when PERSISTENCE {
    debug("PERSIST \n");
    t={};
    t["operation"] = "get_valid_server";
    ret_tbl = HTTP: persist(t);
    if(ret_tbl) then
        for srv, state in pairs(ret_tbl) do
            debug("server %s status %s\n", srv, state);   
        end
    end
    t={};
    t["operation"] = "save_tbl";
    t["hash_value"]= "hash_str";
    t["srv_name"]= "rsrv_70";
    ret = HTTP: persist(t)
    if ret then
        debug("save table success\n");
    else
        debug("save table failed\n");
    end
    t={};
    t["operation"] = "dump_tbl";
    t["index"] = 0;
    t["count"] = 500;
    ret_tbl = HTTP: persist(t)
    if(ret_tbl) then
        for k, cnt in pairs(ret_tbl) do
            debug(" hash %s srv_name %s\n", k, cnt)
        end
    end
    t={};
    t["hash_value"]= "hash_str";
    ret = HTTP:lookup_tbl(t);
    if ret then
        debug("LOOKUP success\n");
    else
        debug("LOOKUP fail\n");
    end
}