日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python install zabbix.4.0

發布時間:2025/3/8 python 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python install zabbix.4.0 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.安裝?MySQLdb?模塊; #!/bin/bash #this?is?rpm?python?Environment?depends?on function?depends_rpm(){ yum?clean?all? yum?-y?install?gcc*?python-devel?python-pip?mariadb?mariadb-devel?mariadb-server if?[?$??-eq?0?]thenpip?install?MySQL-python==1.2.5????? elseecho?"Environmental?initialization?failure"?? fi } depends_rpm


2.python?安裝zabbix4.0?腳本; #!/bin/evn?python? import?subprocess import?os import?shutil import?urllib2 import?MySQLdb def?Doanload_zabbix_rpm():print("downloading?with?zabbix-3.5.1")url?=?"http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm"f?=?urllib2.urlopen(url)?data?=?f.read()??path?=?"/usr/local/src/zabbix-release-3.5-1.el7.noarch.rpm"with?open("path",?"wb")?as?code:code.write(data)???os.system('rpm?-vih?"path"') def?Zabbix_Package_install():subprocess.call("yum?-y?install?zabbix-get?zabbix-sender?zabbix-web?zabbix-agent?zabbix-web-mysql?zabbix-server-mysql?",shell=True)os.system('systemctl?restart?mariadb.service')os.system('mysqladmin?-u?root?password?mysqladmin') try:subprocess.check_call("yum?-y?install?zabbix-get?zabbix-sender?zabbix-web?zabbix-agent?zabbix-web-mysql?zabbix-server-mysql?",shell=True) except?subprocess.CalledProcessError?as?err:print("install?rpm?Error?check?command?or?network") def?Zabbix_createDB():conn?=?MySQLdb.connect(host='localhost',port=3306,user='root',passwd='mysqladmin',)?cursor?=?conn.cursor()cursor.execute('CREATE?DATABASE?IF?NOT?EXISTS?zabbix?character?set?utf8?collate?utf8_bin;')sql?=?"""grant?all?on?zabbix.*?to?'zabbix'@'localhost'?identified?by?'123456';flush?privileges;"""os.system('/usr/bin/zcat?/usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz?|mysql?-uzabbix?-p123456?zabbix')??????? try:cursor.execute(sql)print("zabbix?database?create?successful")? except:print("zabbix?db?grant?successful") def?Create_config():flist={'LogFile':?'/var/log/zabbix/zabbix_server.log','LogFileSize':0,'PidFile':'/var/run/zabbix/zabbix_server.pid','DBName':'zabbix','DBUser':'zabbix','DBPassword':123456,'DBSocket':'/var/lib/mysql/mysql.sock','SNMPTrapperFile':'/var/log/snmptrap/snmptrap.log','Timeout':4,'AlertScriptsPath':'/usr/lib/zabbix/alertscripts','ExternalScripts':'/usr/lib/zabbix/externalscripts','LogSlowQueries':'3000'?}?????confdir?=?"/etc/zabbix"if?os.path.exists(confdir)?==?True:???????f?=?open("/etc/zabbix/zabbix_server.conf",?"wb")???os.chdir(confdir)shutil.copyfile("zabbix_server.conf","zabbix_server.conf.bak")print("backup?zabbix?config?file?sucessful")for?k,v?in?flist.items():flist[k]='='+str(v)??????????????f.write(k+flist[k]+'\n')??????????????????????????????????????print("zabbix-server?config?edit?sucessful")f.close()?os.system("sed?-i?'/timezone/c?php_value?date.timezone?Asia/Shanghai'?/etc/httpd/conf.d/zabbix.conf")??????????????????????????????else:print("zabbix?configuser?not?exsits")?def?Service_manager():serlist?=?[?"systemctl?enable?httpd.service","systemctl?enable?zabbix-server.service","systemctl?enable?zabbix-agent.service","systemctl?enable?mariadb.service","systemctl?restart?httpd.service","systemctl?restart?zabbix-server.service","systemctl?restart?zabbix-agent","systemctl?stop?firewalld","setenforce?0"?]???????for?x?in?serlist:os.system(x)?????????print("service?add?and?start?success")???????????????? def?access_zabbix():address=("You?can?access?http://$ServerIP/zabbix?to?configure?your?web?ZABBIX","database_user:zabbix","password:123456","webui-user:Admin","webui-Password:zabbix")for?i?in?address:print(i)?return?i?????????? Doanload_zabbix_rpm() Zabbix_Package_install() Zabbix_createDB() Create_config() Service_manager() web=access_zabbix() print(web)


轉載于:https://blog.51cto.com/breaklinux/2065435

總結

以上是生活随笔為你收集整理的python install zabbix.4.0的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。