diff --git a/src/manager/om/script/gs_checkos b/src/manager/om/script/gs_checkos index 0cf1e70e1..0851a5964 100644 --- a/src/manager/om/script/gs_checkos +++ b/src/manager/om/script/gs_checkos @@ -89,11 +89,12 @@ g_OSCheckOpts = { 'B5': ['Setting items', '[ Set network card configuration value ]', 'Normal', 'OK', 'OK'], 'B6': ['Setting items', '[ Set THP service ]', 'Normal', 'OK', 'OK'], - 'B7': ['Setting items', '[ Set RemoveIPC value ]', 'Normal', 'OK', 'OK']} + 'B7': ['Setting items', '[ Set RemoveIPC value ]', 'Normal', 'OK', 'OK'], + 'B8': ['Setting items', '[ Set Session Process ]', 'Normal', 'OK', 'OK']} DEFAULT_INTERVAL = 60 CHECK_ITEMNUMLIST = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14'] -SET_ITEMNUMLIST = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7'] +SET_ITEMNUMLIST = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8'] LOG_DIR = "/tmp/gs_checkos" Local_CheckOs = "" Local_Check = "" @@ -123,6 +124,7 @@ ACTION_SET_FILESYSTEM_CONFIGURE = "Set_FileSystem_Configure" ACTION_SET_NETWORK_CONFIGURE = "Set_Network_Configure" ACTION_SET_THP_SERVICE = "Set_THP_Service" ACTION_SET_REMOVEIPC_VALUE = "Set_RemoveIPC_Value" +ACTION_SET_SESSION_PROCESS = "Set_Session_Process" ACTION_SET_BLOCKDEV_CONFIGURE = "Set_BlockDev_Configure" ACTION_SET_LOGICAL_BLOCK = "Set_Logical_Block" ACTION_SET_IO_CONFIGURE = "Set_IO_Configure" @@ -220,6 +222,7 @@ Item number description: 'B5':[ Set network card configuration value ] 'B6':[ Set THP service ] 'B7':[Set RemoveIPC value] + 'B8':[Set Session Process] """ print(usage.__doc__) @@ -477,6 +480,8 @@ def doSetOS(itemNumber): setTHPService() elif (itemNumber == 'B7'): setRemoveIPCValue() + elif (itemNumber == 'B8'): + setSessionProcess() def checkOSVersion(): @@ -1044,6 +1049,50 @@ def getSetRemoveIPCValue(action_item, flag_str, flag_error, success_mesg, g_OSCheckOpts[item_num][2] = '%s' % warning_level g_OSCheckOpts[item_num][3] = "\n %s" % str(e) +def getSetSessionProcess(action_item, flag_str, flag_error, success_mesg, + item_num, warning_level, configFile="", command=""): + """ + get the print information that is from setting session process + """ + try: + if command == "": + command = Local_CheckOs + + if (configFile != ""): + cmd = "%s -t %s -X '%s' -l '%s'"\ + % (command, action_item, configFile, g_opts.localLog) + else: + cmd = "%s -t %s -l '%s'" % (command, action_item, g_opts.localLog) + (status, output, outputMap) = getCmdOutput(cmd) + message = "" + parRes = "" + for node in list(status.keys()): + if (status[node] != DefaultValue.SUCCESS): + g_logger.logExit("[%s]: \n" % node + + ErrorCode.GAUSS_516["GAUSS_51632"] % cmd + + " Error: \n%s" % outputMap[node].strip()) + + if (outputMap[node].find(flag_error) >= 0): + parRes += "[%s]\n%s\n" % (node, outputMap[node]) + + if (outputMap[node].find(flag_str) >= 0): + message += " [%s]\n%s\n" % (node, outputMap[node]) + + if (parRes != ""): + raise Exception("%s" % parRes) + + if (g_OSCheckOpts[item_num][2] != warning_level): + if (message != ""): + g_OSCheckOpts[item_num][3] = "\n%s %s" % ( + message, success_mesg) + else: + g_OSCheckOpts[item_num][3] = "\n %s" % success_mesg + + except Exception as e: + g_logger.debug(str(e)) + g_OSCheckOpts[item_num][2] = '%s' % warning_level + g_OSCheckOpts[item_num][3] = "\n %s" % str(e) + def getSetOSPrintInfo(action_item, flag_str, flag_error, success_mesg, item_num, warning_level, configFile="", command=""): @@ -1138,9 +1187,18 @@ def setRemoveIPCValue(): """ g_logger.debug("Setting RemoveIPC value.") getSetRemoveIPCValue(ACTION_SET_REMOVEIPC_VALUE, "Set", "Failed", "Setting sysctl \ - parameter values succeed.", "B1", "Abnormal", g_opts.confFile, Local_CheckOs) + parameter values succeed.", "B7", "Abnormal", g_opts.confFile, Local_CheckOs) g_logger.debug("Sucessfully setted RemoveIPC value.") +def setSessionProcess(): + """ + Setting Session Process + """ + g_logger.debug("Setting Session Process.") + getSetSessionProcess(ACTION_SET_SESSION_PROCESS, "Set", "Failed", "Setting sysctl \ + parameter values succeed.", "B8", "Abnormal", g_opts.confFile, Local_CheckOs) + g_logger.debug("Sucessfully Setted Session Process.") + def setIOConfigure(): """ Setting IO scheduler value diff --git a/src/manager/om/script/gs_collector b/src/manager/om/script/gs_collector index c93dd11d7..58c8a737a 100644 --- a/src/manager/om/script/gs_collector +++ b/src/manager/om/script/gs_collector @@ -129,12 +129,12 @@ General options: COLLECT_INFO_MAP { "System" : "HardWareInfo,RunTimeInfo", - "Database" : "pg_catalog.pg_stat_activity,dbe_perf.wait_events", - "Log" : "Coordinator,DataNode,Gtm,ClusterManager,FFDC,AWRReport", - "XLog": "Coordinator,DataNode", - "Config" : "Coordinator,DataNode,Gtm", - "Gstack" : "Coordinator,DataNode,Gtm", - "CoreDump": "gaussdb,gs_gtm,gs_rewind,cm_server,cm_agent,gs_ctl" + "Database" : "pg_locks,pg_stat_activity,pg_thread_wait_status", + "Log" : "DataNode,ClusterManager", + "XLog": "DataNode", + "Config" : "DataNode", + "Gstack" : "DataNode", + "CoreDump": "gaussdb,GaussMaster,gs_ctl" "Trace": "Dump" "Plan": "*" # Any database name or character "*" } diff --git a/src/manager/om/script/gspylib/common/ErrorCode.py b/src/manager/om/script/gspylib/common/ErrorCode.py index 517ee97c9..3a7564ad1 100644 --- a/src/manager/om/script/gspylib/common/ErrorCode.py +++ b/src/manager/om/script/gspylib/common/ErrorCode.py @@ -349,7 +349,8 @@ class ErrorCode(): GAUSS_510 = { 'GAUSS_51000': "[GAUSS-51000] : THP services must be shut down.", 'GAUSS_51001': "[GAUSS-51001] : Failed to obtain THP service.", - 'GAUSS_51002': "[GAUSS-51002] : Failed to close THP service." + 'GAUSS_51002': "[GAUSS-51002] : Failed to close THP service.", + 'GAUSS_51003': "[GAUSS-51003] : Failed to set session process." } ########################################################################### diff --git a/src/manager/om/script/local/LocalCheckOS.py b/src/manager/om/script/local/LocalCheckOS.py index c855ea0f2..d44b4974c 100644 --- a/src/manager/om/script/local/LocalCheckOS.py +++ b/src/manager/om/script/local/LocalCheckOS.py @@ -63,6 +63,7 @@ ACTION_CHECK_THP_SERVICE = "Check_THP_Service" ACTION_SET_BLOCKDEV_CONFIGURE = "Set_BlockDev_Configure" ACTION_SET_IO_CONFIGURE = "Set_IO_Configure" ACTION_SET_REMOVEIPC_VALUE = "Set_RemoveIPC_Value" +ACTION_SET_SESSION_PROCESS = "Set_Session_Process" ACTION_SET_NETWORK_CONFIGURE = "Set_Network_Configure" ACTION_SET_THP_SERVICE = "Set_THP_Service" ACTION_SET_LOGICAL_BLOCK = "Set_Logical_Block" @@ -840,7 +841,6 @@ def disRemoveIPC(): " cannot be all no") g_logger.debug("Successfully change RemoveIPC to no.") - def disableRemoveIPCLog(cmd): """ function : disable remove IPCLog @@ -856,6 +856,38 @@ def disableRemoveIPCLog(cmd): return output + +def CheckSessionProcess(): + """ + function : Set User Session Process Control + input : NA + output : NA + """ + g_logger.debug("Setting User Session Process Control.") + etcFile = "/etc/pam.d/sshd" + if os.path.exists(etcFile): + set_cmd = "sed -i '/.*session\+.*pam_limits\.so/d' /etc/pam.d/sshd;" \ + "echo 'session required pam_limits.so' >> " \ + "/etc/pam.d/sshd; " + setSeesionProcess(set_cmd) + g_logger.debug("Successfully Set Session Process.") + +def setSeesionProcess(cmd): + """ + function : Set User Session Process Control + input : cmd + output : NA + """ + (status, output) = subprocess.getstatusoutput(cmd) + if status != 0: + g_logger.debug("Failed to set session process. Commands" + " for set session process: %s." % cmd) + g_logger.logExit(ErrorCode.GAUSS_510["GAUSS_51003"] + + " Error: \n%s" % output) + return output + + + def disTHPServer(): """ function : close THP Server @@ -2170,6 +2202,7 @@ def checkParameter(): and g_opts.action != ACTION_SET_NETWORK_CONFIGURE and g_opts.action != ACTION_SET_IO_CONFIGURE and g_opts.action != ACTION_SET_REMOVEIPC_VALUE + and g_opts.action != ACTION_SET_SESSION_PROCESS and g_opts.action != ACTION_SET_THP_SERVICE and g_opts.action != ACTION_SET_LOGICAL_BLOCK and g_opts.action != ACTION_SET_IO_REQUEST @@ -2219,6 +2252,7 @@ def doLocalCheck(): ACTION_CHECK_TIME_CONSISTENCY: CheckNtp, ACTION_CHECK_FIREWALL_SERVICE: CheckFirewallServer, ACTION_SET_REMOVEIPC_VALUE: disRemoveIPC, + ACTION_SET_SESSION_PROCESS: CheckSessionProcess, ACTION_CHECK_THP_SERVICE: CheckTHPServer, ACTION_SET_THP_SERVICE: disTHPServer} function_keys = list(function_dict.keys())