Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Jul 15, 2024
1 parent 19e1019 commit 9851b54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugins/zabbix/conf/zabbix.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '127.0.0.1';
$DB['PORT'] = '{$ZABBIX_PORT}';
$DB['PORT'] = '{$ZABBIX_DB_PORT}';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = '{$ZABBIX_PASS}';
$DB['PASSWORD'] = '{$ZABBIX_DB_PASS}';

// Schema name. Used for PostgreSQL.
$DB['SCHEMA'] = '';
Expand Down
4 changes: 2 additions & 2 deletions plugins/zabbix/conf/zabbix_server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ LogFileSize=1
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=127.0.0.1
DBPort={$ZABBIX_PORT}
DBPort={$ZABBIX_DB_PORT}
DBName=zabbix
DBUser=zabbix
DBPassword={$ZABBIX_PASS}
DBPassword={$ZABBIX_DB_PASS}
ListenPort=10051
15 changes: 8 additions & 7 deletions plugins/zabbix/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def contentReplace(content):
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$ZABBIX_ROOT}', '/usr/share/zabbix')
content = content.replace('{$ZABBIX_PORT}', '18888')

psdb = pSqliteDb('databases')
db_pass = psdb.where('name = ?', ('zabbix',)).getField('password')
content = content.replace('{$ZABBIX_DB_PORT}', getMySQLPort())
content = content.replace('{$ZABBIX_DB_PASS}', db_pass)
return content


Expand Down Expand Up @@ -189,8 +194,7 @@ def zabbixImportMySQLData():
# php配置
if not os.path.exists(php_dst_path):
content = mw.readFile(php_src_tpl)
content = content.replace('{$ZABBIX_PORT}', getMySQLPort())
content = content.replace('{$ZABBIX_PASS}', db_pass)
content = contentReplace(content)
mw.writeFile(php_dst_path, content)

return True
Expand All @@ -209,12 +213,9 @@ def initZsConf():
zs_src_tpl = getPluginDir()+'/conf/zabbix_server.conf'
zs_dst_path = zabbixServerConf()

psdb = pSqliteDb('databases')
db_pass = psdb.where('name = ?', ('zabbix',)).getField('password')
# nginx配置
# zabbix_server配置
content = mw.readFile(zs_src_tpl)
content = content.replace('{$ZABBIX_PORT}', getMySQLPort())
content = content.replace('{$ZABBIX_PASS}', db_pass)
content = contentReplace(content)
mw.writeFile(zs_dst_path, content)

def initDreplace():
Expand Down

0 comments on commit 9851b54

Please sign in to comment.