Files
yakpanel-core/config/crontab.json
2026-04-07 02:04:22 +05:30

768 lines
36 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[
{
"script_id": 99,
"type_id": 6,
"is_baota": 1,
"name": "Port Detection",
"status": 1,
"author": "yakpanel",
"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": "Output description: closed=port closed, open=port processing open status",
"create_time": 1668247589,
"is_args": 1,
"args_title": "Detection target",
"args_ps": "For example:127.0.0.1:443"
},
{
"script_id": 98,
"type_id": 1,
"is_baota": 1,
"name": "Get PHP Service Status",
"status": 1,
"author": "yakpanel",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains' stopped ', it means it has stopped (you need to enter the version number)",
"create_time": 1668245068,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 94,
"type_id": 3,
"is_baota": 1,
"name": "Send Email Notification",
"status": 1,
"author": "yakpanel",
"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':\"【yakpanel task arrangement】\" + 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": "You need to configure the [Email] and [Recipient Email] in the [Panel Settings] - [Alarm Notifications] - [Alarm Settings] to successfully send",
"create_time": 1668243392,
"is_args": 1,
"args_title": "Notification content",
"args_ps": "Supports text and HTML formats"
},
{
"script_id": 92,
"type_id": 5,
"is_baota": 1,
"name": "Get The Specified Website Description",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@author hwliang(hwl@yakpanel.com)\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('empty')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "If the result is empty or not obtained, output 'empty'",
"create_time": 1668242334,
"is_args": 1,
"args_title": "URL address",
"args_ps": "Please fill in the URL address, such as: https://yakpanel.com"
},
{
"script_id": 91,
"type_id": 5,
"is_baota": 1,
"name": "Retrieve Specified Website Keywords",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@author hwliang(hwl@yakpanel.com)\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('empty')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "If the result is empty or not obtained, output 'empty'",
"create_time": 1668242334,
"is_args": 1,
"args_title": "URL address",
"args_ps": "Please fill in the URL address, such as: https://yakpanel.com"
},
{
"script_id": 90,
"type_id": 5,
"is_baota": 1,
"name": "Get The Specified Website Title",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@author hwliang(hwl@yakpanel.com)\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('empty')",
"version": "1.1",
"return_type": "string",
"script_type": "python",
"ps": "If the result is empty or not obtained, output 'empty'",
"create_time": 1668242092,
"is_args": 1,
"args_title": "URL address",
"args_ps": "Please fill in the URL address, such as: https://yakpanel.com"
},
{
"script_id": 89,
"type_id": 5,
"is_baota": 1,
"name": "Retrieve The Response Status Of The Specified URL Address",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the response content of the specified URL address\n#@author hwliang(hwl@yakpanel.com)\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": "Retrieve the response status of the specified URL address",
"create_time": 1668241817,
"is_args": 1,
"args_title": "URL address",
"args_ps": "Please fill in the URL address, such as: https://yakpanel.com"
},
{
"script_id": 88,
"type_id": 5,
"is_baota": 1,
"name": "Retrieve The Response Content Of The Specified URL Address",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the response content of the specified URL address\n#@author hwliang(hwl@yakpanel.com)\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": "Retrieve the response content of the specified URL address",
"create_time": 1668241548,
"is_args": 1,
"args_title": "URL address",
"args_ps": "Please fill in the URL address, such as: https://yakpanel.com"
},
{
"script_id": 87,
"type_id": 4,
"is_baota": 1,
"name": "Get The Available Disk Capacity Of The Specified Partition",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the available disk capacity (in GB) of the/ww partition\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (GB)",
"create_time": 1668241167,
"is_args": 1,
"args_title": "Partition path",
"args_ps": "Please fill in the partition mounting path, such as:/www"
},
{
"script_id": 86,
"type_id": 2,
"is_baota": 1,
"name": "Get The Memory Usage Of PHP",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n# PHP Version\nphp_version=sys.argv[-1]\nphp_version = php_version.replace('.','')\n# Process name (required)\nprocess_name = 'php-fpm'\n# Process absolute path, can be None\nbin_file=None\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist:{}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# Get process 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(\"Error: Failed to retrieve process PID: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# Check if it is a valid PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \nused_total_bytes = 0\n# Retrieve memory information\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# unit conversion\nmem_used_size = used_total_bytes / 1024 / 1024\n\n# output\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Unit (MB)",
"create_time": 1668240991,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 85,
"type_id": 2,
"is_baota": 1,
"name": "Get The CPU Usage Of PHP",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the CPU usage of the specified process\n#@author hwliang(hwl@yakpanel.com)\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 Version\nphp_version=sys.argv[-1]\nphp_version = php_version.replace('.','')\n\n# Process name (required)\nprocess_name = 'php-fpm'\n# Process absolute path, can be None\nbin_file=\"/www/server/php/{}/sbin/php-fpm\".format(php_version)\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".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# Get CPU usage rate\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": "Unit (%)",
"create_time": 1668240881,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 84,
"type_id": 1,
"is_baota": 1,
"name": "Start PHP Service",
"status": 1,
"author": "yakpanel",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success (version number needs to be entered)",
"create_time": 1668240713,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 83,
"type_id": 1,
"is_baota": 1,
"name": "Stop PHP Service",
"status": 1,
"author": "yakpanel",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version stop",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success (version number needs to be entered)",
"create_time": 1668240680,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 82,
"type_id": 1,
"is_baota": 1,
"name": "Overloading PHP Configuration Files",
"status": 1,
"author": "yakpanel",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success (version number needs to be entered)",
"create_time": 1668240627,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 81,
"type_id": 1,
"is_baota": 1,
"name": "Restart PHP Service",
"status": 1,
"author": "yakpanel",
"script": "php_version=\"${1/./}\"\n/etc/init.d/php-fpm-$php_version restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success (version number needs to be entered)",
"create_time": 1668240442,
"is_args": 1,
"args_title": "PHP Version",
"args_ps": "Please fill in the PHP version, such as 8.1"
},
{
"script_id": 79,
"type_id": 4,
"is_baota": 1,
"name": "Get The Number Of Network Packets Received",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the number of network packets received(pcs/s)\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (pcs/s)",
"create_time": 1668220545,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 78,
"type_id": 4,
"is_baota": 1,
"name": "Obtain The Number Of Network Packets Sent",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Obtain the number of network packets sent(pcs/s)\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (pcs/s)",
"create_time": 1668220488,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 77,
"type_id": 4,
"is_baota": 1,
"name": "Obtain Network Downlink Speed",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Obtain network downlink speed(KB/second)\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (KB/second)",
"create_time": 1668220379,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 76,
"type_id": 4,
"is_baota": 1,
"name": "Obtain Network Uplink Speed",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Obtain the size of upstream traffic(KB/s)\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (KB/s)",
"create_time": 1668220318,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 75,
"type_id": 4,
"is_baota": 1,
"name": "Get Memory Usage Rate",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get memory usage rate\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (%)",
"create_time": 1668219497,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 74,
"type_id": 4,
"is_baota": 1,
"name": "Retrieve The Size Of Used Memory",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the size of used memoryUnit MB\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (MB)",
"create_time": 1668219428,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 73,
"type_id": 4,
"is_baota": 1,
"name": "Get Available Memory Size",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get available memory sizeUnit MB\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (MB)",
"create_time": 1668219298,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 72,
"type_id": 4,
"is_baota": 1,
"name": "Get The Size Of The Used Swap",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the size of the used swapUnit MB\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (MB)",
"create_time": 1668219039,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 71,
"type_id": 4,
"is_baota": 1,
"name": "Retrieve The Available Disk Capacity Of The/ww Partition",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the available disk capacity of the/ww partitionUnit GB\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (GB)",
"create_time": 1668218898,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 70,
"type_id": 4,
"is_baota": 1,
"name": "Retrieve The Available Disk Capacity Of The Root Partition (/)",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Retrieve the available disk capacity of the root partition (/)Unit GB\n#@author hwliang(hwl@yakpanel.com)\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": "Unit (GB)",
"create_time": 1668218820,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 69,
"type_id": 4,
"is_baota": 1,
"name": "Get The Number Of Network Connections",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the number of network connections\n#@author hwliang(hwl@yakpanel.com)\n#@print float\nimport psutil\nprint(len(psutil.net_connections()))",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "Get the number of network connections",
"create_time": 1668218591,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 68,
"type_id": 4,
"is_baota": 1,
"name": "Get CPU Usage Rate",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get CPU usage rate\n#@author hwliang(hwl@yakpanel.com)\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": "Get CPU usage rate per second(%)",
"create_time": 1668218234,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 67,
"type_id": 4,
"is_baota": 1,
"name": "Get The Number Of System Processes",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the number of system processes\n#@author hwliang(hwl@yakpanel.com)\n#@print int\nimport psutil\npids = psutil.pids()\nprint(len(pids))",
"version": "1.0",
"return_type": "int",
"script_type": "python",
"ps": "Get the number of running processes (units)",
"create_time": 1668218094,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 66,
"type_id": 4,
"is_baota": 1,
"name": "Obtain The Average Load Over The Past 15 Minutes",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Obtain the average load over the past 15 minutes\n#@author hwliang(hwl@yakpanel.com)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[2])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load averageThe average load of the system in the past 15 minutes",
"create_time": 1668217975,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 65,
"type_id": 4,
"is_baota": 1,
"name": "Get The Average Load Over The Past 5 Minutes",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the average load over the past 5 minutes\n#@author hwliang(hwl@yakpanel.com)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[1])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load averageThe average load of the system in the past 5 minutes",
"create_time": 1668217953,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 64,
"type_id": 4,
"is_baota": 1,
"name": "Get The Average Load In The Last Minute",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the average load in the last minute\n#@author hwliang(hwl@yakpanel.com)\n#@print float\nimport os\nload_average = os.getloadavg()\nprint(load_average[0])",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "load averageThe average load of the system in the past minute",
"create_time": 1668217869,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 60,
"type_id": 2,
"is_baota": 1,
"name": "Get The CPU Usage Of Apache",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\n#@name Get the CPU usage of the specified process\n#@author hwliang(hwl@yakpanel.com)\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# Process name (required)\nprocess_name = 'httpd'\n# Process absolute path, can be None\nbin_file=\"/www/server/apache/bin/httpd\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".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# Get CPU usage rate\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": "Unit (%)",
"create_time": 1668157345,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 59,
"type_id": 2,
"is_baota": 1,
"name": "Get The CPU Usage Of Nginx",
"status": 1,
"author": "yakpanel",
"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# Process name (required)\nprocess_name = 'nginx'\n# Process absolute path, can be None\nbin_file=\"/www/server/nginx/sbin/nginx\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".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# Get CPU usage rate\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# output\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Unit (%)",
"create_time": 1668156750,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 58,
"type_id": 2,
"is_baota": 1,
"name": "Get The CPU Usage Of MySQL",
"status": 1,
"author": "yakpanel",
"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# Process name (required)\nprocess_name = 'mysqld'\n# Process absolute path, can be None\nbin_file=\"/www/server/mysql/bin/mysqld\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".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# Get CPU usage rate\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# output\nprint(\"{:.2f}\".format(cpu_percent))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Only mysqld processUnit (%)",
"create_time": 1668155455,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 54,
"type_id": 2,
"is_baota": 1,
"name": "Get Apache Memory Usage",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# Process name (required)\nprocess_name = 'httpd'\n# Process absolute path, can be None\nbin_file=\"/www/server/apache/bin/httpd\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# Get process PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"Error: Failed to retrieve process PID: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# Check if it is a valid PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# Retrieve memory information\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# unit conversion\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# output\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Unit (MB)",
"create_time": 1668150591,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 53,
"type_id": 2,
"is_baota": 1,
"name": "Get Nginx Memory Usage",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# Process name (required)\nprocess_name = 'nginx'\n# Process absolute path, can be None\nbin_file=\"/www/server/nginx/sbin/nginx\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# Get process PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"Error: Failed to retrieve process PID: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# Check if it is a valid PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# Retrieve memory information\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# unit conversion\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# output\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Unit (MB)",
"create_time": 1668150492,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 52,
"type_id": 2,
"is_baota": 1,
"name": "Get MySQL Memory Usage",
"status": 1,
"author": "yakpanel",
"script": "#coding: utf-8\nimport os\nimport sys\nos.chdir('/www/server/panel')\nsys.path.insert(0,'class/')\nimport public\nimport psutil\n\n# Process name (required)\nprocess_name = 'mysqld'\n# Process absolute path, can be None\nbin_file=\"/www/server/mysql/bin/mysqld\"\n\n# If binFILE is not None and the specified path does not exist\nif bin_file and not os.path.exists(bin_file):\n print(\"Error: The specified process path does not exist: {}\".format(bin_file))\n print(0)\n sys.exit(1)\n\n# Get process PID\npid = public.get_process_pid(process_name,bin_file)\nif not pid:\n print(\"Error: Failed to retrieve process PID: {}\".format(process_name))\n print(0)\n sys.exit(1)\n\n# Check if it is a valid PID\nif not public.pid_exists(pid):\n print(0)\n sys.exit(1)\n \n# Retrieve memory information\ntry:\n process = psutil.Process(pid)\n mem_info = process.memory_full_info()\nexcept:\n print(0)\n sys.exit(1)\n \n# unit conversion\nmem_used_size = mem_info.uss / 1024 / 1024\n\n# output\nprint(\"{:.2f}\".format(mem_used_size))",
"version": "1.0",
"return_type": "float",
"script_type": "python",
"ps": "Only mysqld processUnit (MB)",
"create_time": 1668149446,
"is_args": 0,
"args_title": "",
"args_ps": ""
},
{
"script_id": 49,
"type_id": 1,
"is_baota": 1,
"name": "Start Nginx",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/nginx start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success",
"create_time": 1668044622,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 48,
"type_id": 1,
"is_baota": 1,
"name": "Start MySQL",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/mysqld start",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains Starting, it indicates success",
"create_time": 1668044553,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 44,
"type_id": 1,
"is_baota": 1,
"name": "Reload Nginx",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/nginx reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success",
"create_time": 1668044290,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 43,
"type_id": 1,
"is_baota": 1,
"name": "Reload MySQL",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/mysqld reload",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains Reloading, it indicates success",
"create_time": 1668044127,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 39,
"type_id": 1,
"is_baota": 1,
"name": "Get Nginx Status",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/nginx status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains' stopped ', it means it has stopped",
"create_time": 1668043943,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 38,
"type_id": 1,
"is_baota": 1,
"name": "Get MySQL Status",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/mysqld status",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains' dead ', it means it has stopped",
"create_time": 1668043876,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 19,
"type_id": 1,
"is_baota": 1,
"name": "Restart MySQL",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/mysqld restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success",
"create_time": 1667983888,
"is_args": 0,
"args_title": null,
"args_ps": null
},
{
"script_id": 18,
"type_id": 1,
"is_baota": 1,
"name": "Restart Nginx",
"status": 1,
"author": "yakpanel",
"script": "/etc/init.d/nginx restart",
"version": "1.0",
"return_type": "string",
"script_type": "bash",
"ps": "If the output contains done, it indicates success",
"create_time": 1667983870,
"is_args": 0,
"args_title": null,
"args_ps": null
}
]