action / bt-source /panel /config /crontab.json
GGSheng's picture
feat: deploy Gemma 4 to hf space
020c337 verified
[
{
"script_id": 99,
"type_id": 6,
"is_baota": 1,
"name": "端口检测",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport socket\narg = sys.argv[-1]\nip,port = arg.split(':')\ntry:\n s = socket.socket()\n s.settimeout(0.15)\n s.connect((ip,int(port)))\n s.close()\nexcept:\n print('closed')\n sys.exit(1)\n\nprint('open')",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "输出说明:closed=端口已关闭,open=端口处理打开状态",
"create_time": 1668247589,
"is_args": 1,
"args_title": "检测目标",
"args_ps": "如:127.0.0.1:443"
},
{
"script_id": 98,
"type_id": 1,
"is_baota": 1,
"name": "获取PHP服务状态",
"status": 1,
"author": "堡塔",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含stopped则表示已停止(需要输入版本号)",
"create_time": 1668245068,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 97,
"type_id": 3,
"is_baota": 1,
"name": "发送飞书通知",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nmsg = sys.argv[-1]\nres = public.push_msg('feishu',{'msg':msg})\nif 'status' in res and res['status']:\n print(\"done\")\nelse:\n print(res)",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "需要在【面板设置】- 【告警通知】- 【告警设置】中配置好飞书机器人才能成功发送",
"create_time": 1668244213,
"is_args": 1,
"args_title": "通知内容",
"args_ps": "支持文本、Markdown格式"
},
{
"script_id": 96,
"type_id": 3,
"is_baota": 1,
"name": "发送企业微信通知",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nmsg = sys.argv[-1]\nres = public.push_msg('weixin',{'msg':msg})\nif 'status' in res and res['status']:\n print(\"done\")\nelse:\n print(res)",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "需要在【面板设置】- 【告警通知】- 【告警设置】中配置好企业微信机器人才能成功发送",
"create_time": 1668244123,
"is_args": 1,
"args_title": "通知内容",
"args_ps": "支持字符串、Markdown格式"
},
{
"script_id": 95,
"type_id": 3,
"is_baota": 1,
"name": "发送钉钉通知",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nmsg = sys.argv[-1]\nres = public.push_msg('dingding',{'msg':msg})\nif 'status' in res and res['status']:\n print(\"done\")\nelse:\n print(res)",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "需要在【面板设置】- 【告警通知】- 【告警设置】中配置好钉钉机器人才能成功发送",
"create_time": 1668243763,
"is_args": 1,
"args_title": "通知内容",
"args_ps": "支持文本、Markdown格式"
},
{
"script_id": 94,
"type_id": 3,
"is_baota": 1,
"name": "发送邮件通知",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nmsg = sys.argv[-1]\nres = public.push_msg('mail',{'title':\"【宝塔任务编排】\" + msg[:10],'msg':msg})\nif 'status' in res and res['status']:\n print(\"done\")\nelse:\n print(res)",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "需要在【面板设置】- 【告警通知】- 【告警设置】中配置好【邮箱】及【收件者邮件】才能成功发送",
"create_time": 1668243392,
"is_args": 1,
"args_title": "通知内容",
"args_ps": "支持文本、HTML格式"
},
{
"script_id": 93,
"type_id": 3,
"is_baota": 1,
"name": "发送公众号通知",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nmsg = sys.argv[-1]\nres = public.push_msg('wx_account',{'msg':msg})\nif 'status' in res and res['status']:\n print(\"done\")\nelse:\n print(res)",
"version": "1.0",
"return_type": "string",
"script_type": "python",
"ps": "需要在【面板设置】- 【告警通知】- 【告警设置】中完成微信绑定才能成功发送",
"create_time": 1668243176,
"is_args": 1,
"args_title": "通知内容",
"args_ps": "支持文本、Markdown格式"
},
{
"script_id": 92,
"type_id": 5,
"is_baota": 1,
"name": "获取指定网站描述",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@author hwliang(hwl@bt.cn)\n#@print string\nimport sys\nimport requests\nimport re\n\nsys.stdout.reconfigure(encoding='utf-8')\nsys.stderr.reconfigure(encoding='utf-8')\n\nurl = sys.argv[-1]\ntry:\n res = requests.get(url,timeout=30)\n res.encoding = res.apparent_encoding\nexcept Exception as ex:\n print(ex)\n sys.exit(1)\ndescription = re.findall(r\"<meta\\s+name=\\\"description\\\"\\s+content=\\\"(.{0,1024})\\\"\\s?\\/?>\", res.text)\nif description:\n print(description[0])\nelse:\n print('无')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "如果结果为空或者未获取到,则输出\"空\"",
"create_time": 1668242334,
"is_args": 1,
"args_title": "URL地址",
"args_ps": "请填写URL地址,如:https://www.bt.cn"
},
{
"script_id": 91,
"type_id": 5,
"is_baota": 1,
"name": "获取指定网站关键词",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@author hwliang(hwl@bt.cn)\n#@print string\nimport sys\nimport requests\nimport re\n\nsys.stdout.reconfigure(encoding='utf-8')\nsys.stderr.reconfigure(encoding='utf-8')\n\nurl = sys.argv[-1]\ntry:\n res = requests.get(url,timeout=30)\n res.encoding = res.apparent_encoding\nexcept Exception as ex:\n print(ex)\n sys.exit(1)\nkeywords = re.findall(r\"<meta\\s+name=\\\"keywords\\\"\\s+content=\\\"(.{0,1024})\\\"\\s*\\/?>\", res.text)\nif keywords:\n print(keywords[0])\nelse:\n print('无')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "如果结果为空或者未获取到,则输出\"空\"",
"create_time": 1668242220,
"is_args": 1,
"args_title": "URL地址",
"args_ps": "请填写URL地址,如:https://www.bt.cn"
},
{
"script_id": 90,
"type_id": 5,
"is_baota": 1,
"name": "获取指定网站标题",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@author hwliang(hwl@bt.cn)\n#@print string\nimport sys\nimport requests\nimport re\n\nsys.stdout.reconfigure(encoding='utf-8')\nsys.stderr.reconfigure(encoding='utf-8')\n\nurl = sys.argv[-1]\ntry:\n res = requests.get(url,timeout=30)\n res.encoding = res.apparent_encoding\nexcept Exception as ex:\n print(ex)\n sys.exit(1)\ntitle = re.findall(r\"<title>[\\s]*(.{0,1024})\\s*<\\/title>\", res.text)\nif title:\n print(title[0])\nelse:\n print('无')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "如果结果为空或者未获取到,则输出\"空\"",
"create_time": 1668242092,
"is_args": 1,
"args_title": "URL地址",
"args_ps": "请填写URL地址,如:https://www.bt.cn"
},
{
"script_id": 89,
"type_id": 5,
"is_baota": 1,
"name": "获取指定URL地址的响应状态",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取指定URL地址的响应内容\n#@author hwliang(hwl@bt.cn)\n#@print string\nimport sys\nimport requests\n\nsys.stdout.reconfigure(encoding='utf-8')\nsys.stderr.reconfigure(encoding='utf-8')\n\nurl = sys.argv[-1]\ntry:\n res = requests.get(url,timeout=30)\n res.encoding = res.apparent_encoding\nexcept Exception as ex:\n print(ex)\n sys.exit(1)\nprint(res.status_code)",
"version": "1.1",
"return_type": "int",
"script_type": "python",
"ps": "获取指定URL地址的响应状态",
"create_time": 1668241817,
"is_args": 1,
"args_title": "URL地址",
"args_ps": "请填写URL地址,如:https://www.bt.cn"
},
{
"script_id": 88,
"type_id": 5,
"is_baota": 1,
"name": "获取指定URL地址的响应内容",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取指定URL地址的响应内容\n#@author hwliang(hwl@bt.cn)\n#@print string\nimport sys\nimport requests\n\nsys.stdout.reconfigure(encoding='utf-8')\nsys.stderr.reconfigure(encoding='utf-8')\n\nurl = sys.argv[-1]\ntry:\n res = requests.get(url,timeout=30)\n res.encoding = res.apparent_encoding\nexcept Exception as ex:\n print(ex)\n sys.exit(1)\nprint(res.text)",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "获取指定URL地址的响应内容",
"create_time": 1668241548,
"is_args": 1,
"args_title": "URL地址",
"args_ps": "请填写URL地址,如:https://www.bt.cn"
},
{
"script_id": 87,
"type_id": 4,
"is_baota": 1,
"name": "获取指定分区的磁盘可用容量",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取/www分区的磁盘可用容量(单位GB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nimport sys\ndev_path = sys.argv[-1]\ndisk_usage = psutil.disk_usage(dev_path)\nfree_size = disk_usage.free / 1024 / 1024 / 1024\nprint(\"{:.2f}\".format(free_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(GB)",
"create_time": 1668241167,
"is_args": 1,
"args_title": "分区路径",
"args_ps": "请填写分区挂载路径,如:/www"
},
{
"script_id": 86,
"type_id": 2,
"is_baota": 1,
"name": "获取PHP的内存占用",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n# PHP版本\nphp_version=sys.argv[-1]\nphp_version = php_version.replace('.','')\n# 进程名称(必需)\nprocess_name = 'php-fpm'\n# 进程绝对路径,可为None\nbin_file=None\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# 获取进程PID\ncmd_line = 'php-fpm: master process (/www/server/php/{}/etc/php-fpm.conf)'.format(php_version)\npid = public.get_process_pid(process_name,bin_file,cmd_line)\nif not pid:\n print(\"错误:获取进程PID失败: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# 检查是否为有效PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \nused_total_bytes = 0\n# 获取内存信息\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\n used_total_bytes += mem_info.uss\nexcept:\n print(0)\n sys.exit(1)\n \nfor mpid in psutil.pids():\n try:\n process = psutil.Process(mpid)\n if process.name() != process_name: continue\n if process.ppid() != pid: continue\n mem_info = process.memory_full_info()\n used_total_bytes += mem_info.uss\n except:\n pass\n \n# 单位转换\nmem_used_size = used_total_bytes / 1024 / 1024\n\n# 输出\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668240991,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 85,
"type_id": 2,
"is_baota": 1,
"name": "获取PHP的CPU使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取指定进程CPU使用率\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\nimport threading\n# PHP版本\nphp_version=sys.argv[-1]\nphp_version = php_version.replace('.','')\n\n# 进程名称(必需)\nprocess_name = 'php-fpm'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/php/{}/sbin/php-fpm\".format(php_version)\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\ncpu_count = psutil.cpu_count()\ncpu_percent = 0.00\ndef get_percent(process):\n global cpu_count,cpu_percent\n c = process.cpu_percent(1) / cpu_count\n cpu_percent += c\n \n\n\n# 获取CPU使用率\npid_thread_dict = {}\nfor pid in psutil.pids():\n try:\n process = psutil.Process(pid)\n if process.name() != process_name: continue\n if bin_file and process.exe() != bin_file: continue\n pid_thread_dict[pid] = threading.Thread(target=get_percent,args=(process,))\n pid_thread_dict[pid].start()\n except:\n continue\n\nfor pid in pid_thread_dict.keys():\n pid_thread_dict[pid].join()\n\n# 输出\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(%)",
"create_time": 1668240881,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 84,
"type_id": 1,
"is_baota": 1,
"name": "启动PHP服务",
"status": 1,
"author": "堡塔",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功(需要输入版本号)",
"create_time": 1668240713,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 83,
"type_id": 1,
"is_baota": 1,
"name": "停止PHP服务",
"status": 1,
"author": "堡塔",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version stop",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功(需要输入版本号)",
"create_time": 1668240680,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 82,
"type_id": 1,
"is_baota": 1,
"name": "重载PHP配置文件",
"status": 1,
"author": "堡塔",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功(需要输入版本号)",
"create_time": 1668240627,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请填写PHP版本,如:8.1"
},
{
"script_id": 81,
"type_id": 1,
"is_baota": 1,
"name": "重启PHP服务",
"status": 1,
"author": "堡塔",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功(需要输入版本号)",
"create_time": 1668240442,
"is_args": 1,
"args_title": "PHP版本",
"args_ps": "请输入PHP版本,如8.1"
},
{
"script_id": 79,
"type_id": 4,
"is_baota": 1,
"name": "获取网络收包数",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取网络收包数(个/秒)\n#@author hwliang(hwl@bt.cn)\n#@print int\nimport psutil\nimport time\nold_netio = psutil.net_io_counters()\ntime.sleep(1)\nnew_netio = psutil.net_io_counters()\npackets_recv = (new_netio.packets_recv - old_netio.packets_recv)\n\nprint(packets_recv)",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "单位(个/秒)",
"create_time": 1668220545,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 78,
"type_id": 4,
"is_baota": 1,
"name": "获取网络发包数",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取网络发包数(个/秒)\n#@author hwliang(hwl@bt.cn)\n#@print int\nimport psutil\nimport time\nold_netio = psutil.net_io_counters()\ntime.sleep(1)\nnew_netio = psutil.net_io_counters()\npackets_sent = (new_netio.packets_sent - old_netio.packets_sent)\n\nprint(packets_sent)",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "单位(个/秒)",
"create_time": 1668220488,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 77,
"type_id": 4,
"is_baota": 1,
"name": "获取网络下行速度",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取下行流量大小(单位KB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nimport time\nold_netio = psutil.net_io_counters()\ntime.sleep(1)\nnew_netio = psutil.net_io_counters()\nbytes_recv = (new_netio.bytes_recv - old_netio.bytes_recv) / 1024\n\nprint(\"{:.2f}\".format(bytes_recv))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(KB/秒)",
"create_time": 1668220379,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 76,
"type_id": 4,
"is_baota": 1,
"name": "获取网络上行速度",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取上行流量大小(单位KB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nimport time\nold_netio = psutil.net_io_counters()\ntime.sleep(1)\nnew_netio = psutil.net_io_counters()\nbytes_sent = (new_netio.bytes_sent - old_netio.bytes_sent) / 1024\n\nprint(\"{:.2f}\".format(bytes_sent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(KB/秒)",
"create_time": 1668220318,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 75,
"type_id": 4,
"is_baota": 1,
"name": "获取内存使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取内存使用率\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nvirtual_memory = psutil.virtual_memory()\nmemory_percent = 100 * ((virtual_memory.total - (virtual_memory.free + virtual_memory.buffers + virtual_memory.cached)) / virtual_memory.total )\nprint(\"{:.2f}\".format(memory_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(%)",
"create_time": 1668219497,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 74,
"type_id": 4,
"is_baota": 1,
"name": "获取已用内存大小",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取已用内存大小(单位MB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nvirtual_memory = psutil.virtual_memory()\nused_size = (virtual_memory.total - (virtual_memory.free + virtual_memory.buffers + virtual_memory.cached)) / 1024 / 1024\nprint(\"{:.2f}\".format(used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668219428,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 73,
"type_id": 4,
"is_baota": 1,
"name": "获取可用内存大小",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取可用内存大小(单位MB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nvirtual_memory = psutil.virtual_memory()\nfree_size = (virtual_memory.free + virtual_memory.buffers + virtual_memory.cached) / 1024 / 1024\nprint(\"{:.2f}\".format(free_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668219298,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 72,
"type_id": 4,
"is_baota": 1,
"name": "获取已使用的swap大小",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取已使用的swap大小(单位MB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nswap_memory = psutil.swap_memory()\nswap_used = swap_memory.used / 1024 / 1024\nprint(\"{:.2f}\".format(swap_used))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668219039,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 71,
"type_id": 4,
"is_baota": 1,
"name": "获取/www分区的磁盘可用容量",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取/www分区的磁盘可用容量(单位GB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\ndisk_usage = psutil.disk_usage('/www')\nfree_size = disk_usage.free / 1024 / 1024 / 1024\nprint(\"{:.2f}\".format(free_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(GB)",
"create_time": 1668218898,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 70,
"type_id": 4,
"is_baota": 1,
"name": "获取根分区(/)的磁盘可用容量",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取根分区(/)的磁盘可用容量(单位GB)\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\ndisk_usage = psutil.disk_usage('/')\nfree_size = disk_usage.free / 1024 / 1024 / 1024\nprint(\"{:.2f}\".format(free_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(GB)",
"create_time": 1668218820,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 69,
"type_id": 4,
"is_baota": 1,
"name": "获取网络连接数",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取网络连接数\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\nprint(len(psutil.net_connections()))",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "获取网络连接数",
"create_time": 1668218591,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 68,
"type_id": 4,
"is_baota": 1,
"name": "获取CPU使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取CPU使用率\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport psutil\ncpu_count = psutil.cpu_count()\ncpu_percent = psutil.cpu_percent(1) / cpu_count\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "获取每秒CPU使用率(%)",
"create_time": 1668218234,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 67,
"type_id": 4,
"is_baota": 1,
"name": "获取系统进程数量",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取系统进程数量\n#@author hwliang(hwl@bt.cn)\n#@print int\nimport psutil\npids = psutil.pids()\nprint(len(pids))",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "获取正在运行的进程数量(个)",
"create_time": 1668218094,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 66,
"type_id": 4,
"is_baota": 1,
"name": "获取最近15分钟平均负载",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取系统最近1分钟平均负载\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[2])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load average,系统最近15分钟平均负载",
"create_time": 1668217975,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 65,
"type_id": 4,
"is_baota": 1,
"name": "获取最近5分钟平均负载",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取系统最近1分钟平均负载\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[1])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load average,系统最近5分钟平均负载",
"create_time": 1668217953,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 64,
"type_id": 4,
"is_baota": 1,
"name": "获取最近1分钟平均负载",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取系统最近1分钟平均负载\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[0])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load average,系统最近1分钟平均负载",
"create_time": 1668217869,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 60,
"type_id": 2,
"is_baota": 1,
"name": "获取Apache的CPU使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\n#@name 获取指定进程CPU使用率\n#@author hwliang(hwl@bt.cn)\n#@print float\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\nimport threading\n\n# 进程名称(必需)\nprocess_name = 'httpd'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/apache/bin/httpd\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\ncpu_count = psutil.cpu_count()\ncpu_percent = 0.00\ndef get_percent(process):\n global cpu_count,cpu_percent\n c = process.cpu_percent(1) / cpu_count\n cpu_percent += c\n \n\n\n# 获取CPU使用率\npid_thread_dict = {}\nfor pid in psutil.pids():\n try:\n process = psutil.Process(pid)\n if process.name() != process_name: continue\n if bin_file and process.exe() != bin_file: continue\n pid_thread_dict[pid] = threading.Thread(target=get_percent,args=(process,))\n pid_thread_dict[pid].start()\n except:\n continue\n\nfor pid in pid_thread_dict.keys():\n pid_thread_dict[pid].join()\n\n# 输出\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(%)",
"create_time": 1668157345,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 59,
"type_id": 2,
"is_baota": 1,
"name": "获取Nginx的CPU使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\nimport threading\n\n# 进程名称(必需)\nprocess_name = 'nginx'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/nginx/sbin/nginx\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\ncpu_count = psutil.cpu_count()\ncpu_percent = 0.00\ndef get_percent(process):\n global cpu_count,cpu_percent\n c = process.cpu_percent(1) / cpu_count\n cpu_percent += c\n \n\n\n# 获取CPU使用率\npid_thread_dict = {}\nfor pid in psutil.pids():\n try:\n process = psutil.Process(pid)\n if process.name() != process_name: continue\n if bin_file and process.exe() != bin_file: continue\n pid_thread_dict[pid] = threading.Thread(target=get_percent,args=(process,))\n pid_thread_dict[pid].start()\n except:\n continue\n\nfor pid in pid_thread_dict.keys():\n pid_thread_dict[pid].join()\n\n# 输出\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(%)",
"create_time": 1668156750,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 58,
"type_id": 2,
"is_baota": 1,
"name": "获取MySQL的CPU使用率",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\nimport threading\n\n# 进程名称(必需)\nprocess_name = 'mysqld'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/mysql/bin/mysqld\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\ncpu_count = psutil.cpu_count()\ncpu_percent = 0.00\ndef get_percent(process):\n global cpu_count,cpu_percent\n c = process.cpu_percent(1) / cpu_count\n cpu_percent += c\n\n\n# 获取CPU使用率\npid_thread_dict = {}\nfor pid in psutil.pids():\n try:\n process = psutil.Process(pid)\n if process.name() != process_name: continue\n if bin_file and process.exe() != bin_file: continue\n pid_thread_dict[pid] = threading.Thread(target=get_percent,args=(process,))\n pid_thread_dict[pid].start()\n except:\n continue\n\nfor pid in pid_thread_dict.keys():\n pid_thread_dict[pid].join()\n\n# 输出\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "仅mysqld进程,单位(%)",
"create_time": 1668155455,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 54,
"type_id": 2,
"is_baota": 1,
"name": "获取Apache内存占用",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# 进程名称(必需)\nprocess_name = 'httpd'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/apache/bin/httpd\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# 获取进程PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"错误:获取进程PID失败: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# 检查是否为有效PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# 获取内存信息\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# 单位转换\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# 输出\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668150591,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 53,
"type_id": 2,
"is_baota": 1,
"name": "获取Nginx内存占用",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# 进程名称(必需)\nprocess_name = 'nginx'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/nginx/sbin/nginx\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# 获取进程PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"错误:获取进程PID失败: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# 检查是否为有效PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# 获取内存信息\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# 单位转换\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# 输出\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "单位(MB)",
"create_time": 1668150492,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 52,
"type_id": 2,
"is_baota": 1,
"name": "获取MySQL内存占用",
"status": 1,
"author": "堡塔",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# 进程名称(必需)\nprocess_name = 'mysqld'\n# 进程绝对路径,可为None\nbin_file=\"/www/server/mysql/bin/mysqld\"\n\n# 如果bin_file不为None,且指定路径不存在\nif bin_file and not os.path.exists(bin_file):\n print(\"错误:指定进程路径不存在: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# 获取进程PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"错误:获取进程PID失败: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# 检查是否为有效PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# 获取内存信息\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# 单位转换\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# 输出\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "仅mysqld进程,单位(MB)",
"create_time": 1668149446,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 49,
"type_id": 1,
"is_baota": 1,
"name": "启动Nginx",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/nginx start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功",
"create_time": 1668044622,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 48,
"type_id": 1,
"is_baota": 1,
"name": "启动MySQL",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/mysqld start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含Starting则表示成功",
"create_time": 1668044553,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 44,
"type_id": 1,
"is_baota": 1,
"name": "重载Nginx",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/nginx reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功",
"create_time": 1668044290,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 43,
"type_id": 1,
"is_baota": 1,
"name": "重载MySQL",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/mysqld reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含Reloading则表示成功",
"create_time": 1668044127,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 39,
"type_id": 1,
"is_baota": 1,
"name": "获取Nginx状态",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/nginx status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含stopped则表示已停止",
"create_time": 1668043943,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 38,
"type_id": 1,
"is_baota": 1,
"name": "获取MySQL状态",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/mysqld status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含dead则表示已停止",
"create_time": 1668043876,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 19,
"type_id": 1,
"is_baota": 1,
"name": "重启MySQL",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/mysqld restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功",
"create_time": 1667983888,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 18,
"type_id": 1,
"is_baota": 1,
"name": "重启Nginx",
"status": 1,
"author": "堡塔",
"script": "/etc/init.d/nginx restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "如果输出包含done则表示成功",
"create_time": 1667983870,
"is_args": 0,
"args_title": null,
"args_ps": null
}
]