diff --git a/plugins/zabbix/ico.svg b/plugins/zabbix/ico.svg
new file mode 100644
index 000000000..9425964a3
--- /dev/null
+++ b/plugins/zabbix/ico.svg
@@ -0,0 +1 @@
+
diff --git a/plugins/zabbix/index.py b/plugins/zabbix/index.py
index 1d5fd5840..92c609609 100755
--- a/plugins/zabbix/index.py
+++ b/plugins/zabbix/index.py
@@ -72,26 +72,6 @@ def checkArgs(data, ck=[]):
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
-def configTpl():
- path = getPluginDir() + '/tpl'
- pathFile = os.listdir(path)
- tmp = []
- for one in pathFile:
- file = path + '/' + one
- tmp.append(file)
- return mw.getJson(tmp)
-
-
-def readConfigTpl():
- args = getArgs()
- data = checkArgs(args, ['file'])
- if not data[0]:
- return data[1]
-
- content = mw.readFile(args['file'])
- content = contentReplace(content)
- return mw.returnJson(True, 'ok', content)
-
def getPidFile():
file = getConf()
content = mw.readFile(file)
@@ -329,7 +309,5 @@ if __name__ == "__main__":
print(zabbixServerConf())
elif func == 'run_log':
print(runLog())
- elif func == 'config_tpl':
- print(configTpl())
else:
print('error')
diff --git a/plugins/zabbix/install.sh b/plugins/zabbix/install.sh
index 64cd79a26..b95a44b86 100755
--- a/plugins/zabbix/install.sh
+++ b/plugins/zabbix/install.sh
@@ -2,11 +2,10 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
-# https://www.mongodb.com/try/download/community
+# https://www.zabbix.com
-# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
-# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
-# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
+# cd /www/server/mdserver-web/plugins/zabbix && /bin/bash install.sh install 7.0
+# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/zabbix/index.py start
diff --git a/plugins/zabbix_agent/conf/zabbix_server.conf b/plugins/zabbix_agent/conf/zabbix_server.conf
new file mode 100644
index 000000000..5ce358714
--- /dev/null
+++ b/plugins/zabbix_agent/conf/zabbix_server.conf
@@ -0,0 +1,10 @@
+LogFile=/var/log/zabbix/zabbix_server.log
+LogFileSize=1
+PidFile=/run/zabbix/zabbix_server.pid
+SocketDir=/run/zabbix
+DBHost=127.0.0.1
+DBPort={$ZABBIX_DB_PORT}
+DBName=zabbix
+DBUser=zabbix
+DBPassword={$ZABBIX_DB_PASS}
+ListenPort=10051
diff --git a/plugins/zabbix_agent/ico.png b/plugins/zabbix_agent/ico.png
new file mode 100644
index 000000000..01024eb07
Binary files /dev/null and b/plugins/zabbix_agent/ico.png differ
diff --git a/plugins/zabbix_agent/ico.svg b/plugins/zabbix_agent/ico.svg
new file mode 100644
index 000000000..9425964a3
--- /dev/null
+++ b/plugins/zabbix_agent/ico.svg
@@ -0,0 +1 @@
+
diff --git a/plugins/zabbix_agent/index.html b/plugins/zabbix_agent/index.html
new file mode 100755
index 000000000..d52ef99d2
--- /dev/null
+++ b/plugins/zabbix_agent/index.html
@@ -0,0 +1,30 @@
+
+
+
+
\ No newline at end of file
diff --git a/plugins/zabbix_agent/index.py b/plugins/zabbix_agent/index.py
new file mode 100755
index 000000000..5947aefd9
--- /dev/null
+++ b/plugins/zabbix_agent/index.py
@@ -0,0 +1,217 @@
+# coding:utf-8
+
+import sys
+import io
+import os
+import time
+import re
+
+sys.path.append(os.getcwd() + "/class/core")
+import mw
+
+app_debug = False
+if mw.isAppleSystem():
+ app_debug = True
+
+
+def getPluginName():
+ return 'zabbix_agent'
+
+
+def getPluginDir():
+ return mw.getPluginDir() + '/' + getPluginName()
+
+
+def getServerDir():
+ return mw.getServerDir() + '/' + getPluginName()
+
+
+def getInitDFile():
+ current_os = mw.getOs()
+ if current_os == 'darwin':
+ return '/tmp/' + getPluginName()
+ return '/etc/init.d/' + getPluginName()
+
+
+def getInitDTpl():
+ path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
+ return path
+
+
+def getArgs():
+ args = sys.argv[3:]
+ tmp = {}
+ args_len = len(args)
+
+ if args_len == 1:
+ t = args[0].strip('{').strip('}')
+ if t.strip() == '':
+ tmp = []
+ else:
+ t = t.split(':')
+ tmp[t[0]] = t[1]
+ tmp[t[0]] = t[1]
+ elif args_len > 1:
+ for i in range(len(args)):
+ t = args[i].split(':')
+ tmp[t[0]] = t[1]
+ return tmp
+
+def checkArgs(data, ck=[]):
+ for i in range(len(ck)):
+ if not ck[i] in data:
+ return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
+ return (True, mw.returnJson(True, 'ok'))
+
+def getPidFile():
+ file = getConf()
+ content = mw.readFile(file)
+ rep = 'pidfile\s*(.*)'
+ tmp = re.search(rep, content)
+ return tmp.groups()[0].strip()
+
+def status():
+ cmd = "ps aux|grep zabbix-agent |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
+ data = mw.execShell(cmd)
+ if data[0] == '':
+ return 'stop'
+ return 'start'
+
+def contentReplace(content):
+ service_path = mw.getServerDir()
+ content = content.replace('{$ROOT_PATH}', mw.getRootDir())
+ content = content.replace('{$SERVER_PATH}', service_path)
+ return content
+
+def zabbixAgentConf():
+ return '/etc/zabbix/zabbix_server.conf'
+
+
+def initOpConf():
+ nginx_src_tpl = getPluginDir()+'/conf/zabbix.nginx.conf'
+ nginx_dst_vhost = zabbixNginxConf()
+
+ # nginx配置
+ if not os.path.exists(nginx_dst_vhost):
+ content = mw.readFile(nginx_src_tpl)
+ content = contentReplace(content)
+ mw.writeFile(nginx_dst_vhost, content)
+
+def initZsConf():
+ zs_src_tpl = getPluginDir()+'/conf/zabbix_server.conf'
+ zs_dst_path = zabbixServerConf()
+
+ # zabbix_server配置
+ content = mw.readFile(zs_src_tpl)
+ content = contentReplace(content)
+ mw.writeFile(zs_dst_path, content)
+
+def initDreplace():
+
+ # initZsConf()
+ return True
+
+
+def zOp(method):
+
+ initDreplace()
+
+ data = mw.execShell('systemctl ' + method + ' zabbix-agent')
+ if data[1] == '':
+ return 'ok'
+ return data[1]
+
+
+def start():
+ return zOp('start')
+
+
+def stop():
+ val = zOp('stop')
+ return val
+
+def restart():
+ status = zOp('restart')
+ return status
+
+def reload():
+ return zOp('reload')
+
+def initdStatus():
+ current_os = mw.getOs()
+ if current_os == 'darwin':
+ return "Apple Computer does not support"
+
+ shell_cmd = 'systemctl status zabbix-agent | grep loaded | grep "enabled;"'
+ data = mw.execShell(shell_cmd)
+ if data[0] == '':
+ return 'fail'
+ return 'ok'
+
+
+def initdInstall():
+ current_os = mw.getOs()
+ if current_os == 'darwin':
+ return "Apple Computer does not support"
+
+ mw.execShell('systemctl enable zabbix-agent')
+ return 'ok'
+
+
+def initdUinstall():
+ current_os = mw.getOs()
+ if current_os == 'darwin':
+ return "Apple Computer does not support"
+
+ mw.execShell('systemctl disable zabbix-agent')
+ return 'ok'
+
+
+def installPreInspection():
+ openresty_dir = mw.getServerDir() + "/openresty"
+ if not os.path.exists(openresty_dir):
+ return '需要安装Openresty插件'
+
+ mysql_dir = mw.getServerDir() + "/mysql"
+ if not os.path.exists(mysql_dir):
+ return '需要安装MySQL插件,至少8.0!'
+
+ return 'ok'
+
+
+def uninstallPreInspection():
+ return 'ok'
+
+
+if __name__ == "__main__":
+ func = sys.argv[1]
+ if func == 'status':
+ print(status())
+ elif func == 'start':
+ print(start())
+ elif func == 'stop':
+ print(stop())
+ elif func == 'restart':
+ print(restart())
+ elif func == 'reload':
+ print(reload())
+ elif func == 'initd_status':
+ print(initdStatus())
+ elif func == 'initd_install':
+ print(initdInstall())
+ elif func == 'initd_uninstall':
+ print(initdUinstall())
+ elif func == 'install_pre_inspection':
+ print(installPreInspection())
+ elif func == 'uninstall_pre_inspection':
+ print(uninstallPreInspection())
+ elif func == 'conf':
+ print(zabbixNginxConf())
+ elif func == 'php_conf':
+ print(zabbixPhpConf())
+ elif func == 'zabbix_server_conf':
+ print(zabbixServerConf())
+ elif func == 'run_log':
+ print(runLog())
+ else:
+ print('error')
diff --git a/plugins/zabbix_agent/info.json b/plugins/zabbix_agent/info.json
new file mode 100755
index 000000000..f721b8359
--- /dev/null
+++ b/plugins/zabbix_agent/info.json
@@ -0,0 +1,18 @@
+{
+ "sort": 7,
+ "ps": "Zabbix被控服务器[开发中]",
+ "name": "zabbix_agent",
+ "title": "Zabbix Agent",
+ "shell": "install.sh",
+ "versions":["7.0"],
+ "updates":["7.0"],
+ "tip": "soft",
+ "checks": "server/zabbix_agent",
+ "path": "server/zabbix_agent",
+ "display": 1,
+ "author": "midoks",
+ "date": "2022-07-14",
+ "home": "https://www.zabbix.com",
+ "type": 0,
+ "pid": "5"
+}
diff --git a/plugins/zabbix_agent/install.sh b/plugins/zabbix_agent/install.sh
new file mode 100755
index 000000000..d666cbc08
--- /dev/null
+++ b/plugins/zabbix_agent/install.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
+export PATH
+
+# https://www.zabbix.com
+
+# cd /www/server/mdserver-web/plugins/zabbix_agent && /bin/bash install.sh install 7.0
+# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/zabbix_agent/index.py start
+
+
+curPath=`pwd`
+rootPath=$(dirname "$curPath")
+rootPath=$(dirname "$rootPath")
+serverPath=$(dirname "$rootPath")
+
+install_tmp=${rootPath}/tmp/mw_install.pl
+VERSION=$2
+
+sysName=`uname`
+echo "use system: ${sysName}"
+
+OSNAME=`bash ${rootPath}/scripts/getos.sh`
+
+if [ "" == "$OSNAME" ];then
+ OSNAME=`cat ${rootPath}/data/osname.pl`
+fi
+
+if [ "macos" == "$OSNAME" ];then
+ echo "不支持Macox"
+ exit
+fi
+
+if [ -f ${rootPath}/bin/activate ];then
+ source ${rootPath}/bin/activate
+fi
+
+Install_App()
+{
+ echo '正在安装脚本文件...'
+ mkdir -p $serverPath/source/zabbix_agent
+ shell_file=${curPath}/versions/${VERSION}/${OSNAME}.sh
+
+ if [ -f $shell_file ];then
+ bash -x $shell_file install
+ else
+ echo '不支持...'
+ exit 1
+ fi
+
+ if [ "$?" == "0" ];then
+ mkdir -p $serverPath/zabbix_agent
+ echo "${VERSION}" > $serverPath/zabbix_agent/version.pl
+
+ #初始化
+ cd ${rootPath} && python3 ${rootPath}/plugins/zabbix_agent/index.py start
+ cd ${rootPath} && python3 ${rootPath}/plugins/zabbix_agent/index.py initd_install
+ fi
+
+ echo 'Zabbix安装完成'
+}
+
+Uninstall_App()
+{
+ cd ${rootPath} && python3 ${rootPath}/plugins/zabbix_agent/index.py stop
+ cd ${rootPath} && python3 ${rootPath}/plugins/zabbix_agent/index.py initd_uninstall
+
+ rm -rf $serverPath/zabbix_agent
+ rm -rf $serverPath/source/zabbix_agent
+ echo 'Zabbix卸载完成'
+}
+
+action=$1
+if [ "${1}" == 'install' ];then
+ Install_App
+else
+ Uninstall_App
+fi
diff --git a/plugins/zabbix_agent/js/zabbix.js b/plugins/zabbix_agent/js/zabbix.js
new file mode 100755
index 000000000..312a8f9fc
--- /dev/null
+++ b/plugins/zabbix_agent/js/zabbix.js
@@ -0,0 +1,64 @@
+function zabbixPost(method, version, args,callback){
+ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
+
+ var req_data = {};
+ req_data['name'] = 'zabbix';
+ req_data['func'] = method;
+ req_data['version'] = version;
+
+ if (typeof(args) == 'string'){
+ req_data['args'] = JSON.stringify(toArrayObject(args));
+ } else {
+ req_data['args'] = JSON.stringify(args);
+ }
+
+ $.post('/plugins/run', req_data, function(data) {
+ layer.close(loadT);
+ if (!data.status){
+ //错误展示10S
+ layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']});
+ return;
+ }
+
+ if(typeof(callback) == 'function'){
+ callback(data);
+ }
+ },'json');
+}
+
+function zabbixPostCallbak(method, version, args,callback){
+ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
+
+ var req_data = {};
+ req_data['name'] = 'zabbix';
+ req_data['func'] = method;
+ args['version'] = version;
+
+ if (typeof(args) == 'string'){
+ req_data['args'] = JSON.stringify(toArrayObject(args));
+ } else {
+ req_data['args'] = JSON.stringify(args);
+ }
+
+ $.post('/plugins/callback', req_data, function(data) {
+ layer.close(loadT);
+ if (!data.status){
+ layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
+ return;
+ }
+
+ if(typeof(callback) == 'function'){
+ callback(data);
+ }
+ },'json');
+}
+
+
+function zabbixReadme(){
+ var readme = '';
+ readme += '- 默认配置OpenResty端口:18888
';
+ readme += '
';
+
+ $('.soft-man-con').html(readme);
+}
+
diff --git a/plugins/zabbix_agent/versions/7.0/debian.sh b/plugins/zabbix_agent/versions/7.0/debian.sh
new file mode 100644
index 000000000..628559a79
--- /dev/null
+++ b/plugins/zabbix_agent/versions/7.0/debian.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+export PATH
+
+curPath=`pwd`
+rootPath=$(dirname "$curPath")
+rootPath=$(dirname "$rootPath")
+serverPath=$(dirname "$rootPath")
+sourcePath=${serverPath}/source
+sysName=`uname`
+install_tmp=${rootPath}/tmp/mw_install.pl
+
+SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
+
+Install_App()
+{
+ mkdir -p $serverPath/source/zabbix
+
+ ZABBIX_NAME=zabbix-release_7.0-2+debian12_all.deb
+ echo "wget -O $serverPath/source/zabbix/${ZABBIX_NAME} https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/${ZABBIX_NAME}"
+ if [ ! -f $serverPath/source/zabbix/${ZABBIX_NAME} ];then
+ wget -O $serverPath/source/zabbix/${ZABBIX_NAME} https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/${ZABBIX_NAME}
+ fi
+
+ cd $serverPath/source/zabbix && dpkg -i zabbix-release_7.0-2+debian12_all.deb
+ apt update -y
+
+ apt install -y zabbix-agent
+}
+
+Uninstall_App()
+{
+ echo "卸载成功"
+}
+
+action=${1}
+if [ "${1}" == 'install' ];then
+ Install_App
+else
+ Uninstall_App
+fi