如何获取集群中所有节点的license有效期

pnodeRun(getLicenseExpiration)只能得到数据节点、计算节点的license有效期,控制节点、代理节点的怎么获取呢?

请先 登录 后评论

1 个回答

wale

下面函数通过rpc(getControllerAlias(), getClusterPerf{true})得到agent和controller的相关信息,然后通过xdb连接节点后remoteRun得到license有效期。注意1.30.19和2.00.7之前的版本,getClusterPerf不能返回高可用集群中follower控制节点的信息,需要另外手工获取非领导控制节点的license信息。

/* *
*  @ brief  Get the expiration date of the license on all nodes in the cluster.
*  @ param NULL
*  @ return a table containing expiration date of the license on each node
*  @ sample usage  getAllLicenses()
*/


def getAllLicenses(){
    t = select node as nodeAlias,value as endDate from pnodeRun(getLicenseExpiration)
    nodes = exec name, host, port from rpc(getControllerAlias(), getClusterPerf{true}) where not mode in [0, 4]
    for(i in 0..(size(nodes)-1)){
        try{
            conn = xdb(nodes[`host][i], nodes[`port][i])
            t1 = remoteRun(
                conn, "table( getNodeAlias() as node ,getLicenseExpiration() as date)")
            t.append!(t1)
        } catch(ex){
            print(ex)
            writeLog(ex)
        }
    }
    return t
}

请先 登录 后评论