def uptime(): try: hostUtil = HostUtil() message = hostUtil.get_uptime_stat() except Exception, e: message = "error get uptime, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def getUname(): try: hostUtil = HostUtil() message = hostUtil.uname() except Exception, e: message = "error get uname, Ex:%s" % str(e) return Response.make_json_response(message, success=False, code=-1)
def execCommand(): try: hostUtil = HostUtil() message = hostUtil.exec_command(request.values.get("cmd")) except Exception, e: message = "error get sys process list, cmd(%s) Ex:%s" % ( request.values.get("cmd"), str(e)) return Response.make_json_response(message, success=False, code=-1)
def getProcessList(): try: hostUtil = HostUtil() message = hostUtil.processList() except Exception, e: message = "error get sys process list, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def memInfo(): try: hostUtil = HostUtil() message = hostUtil.get_memory_stat() except Exception, e: message = "error get mem info, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def diskPathDu(): try: hostUtil = HostUtil() message = hostUtil.get_path_du(request.args.get("path")) except Exception, e: message = "error get disk device stat, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def diskUsage(): try: hostUtil = HostUtil() message = hostUtil.disk_usage(request.args.get("mountpoint")) except Exception, e: message = "error get disk device stat, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def diskPartitions(): try: hostUtil = HostUtil() message = hostUtil.disk_partitions() except Exception, e: message = "error get disk partitions, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def loadavg(): try: hostUtil = HostUtil() message = hostUtil.get_load_stat() except Exception, e: message = "error get cpu loadavg, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)
def networkInfo(ifname): try: hostUtil = HostUtil() message = hostUtil.networkinfo(ifname) except Exception, e: message = "error get network %s info, Ex:%s" % (ifname, str(e)) return Response.make_json_response(message, success=False, code=-1)
def networkList(): try: hostUtil = HostUtil() message = hostUtil.network_list() except Exception, e: message = "error get network list, Ex:%s" % str(e) return Response.make_json_response(message, success=False, code=-1)