1.请求端
from django.shortcuts import render,redirect
def home(request): """ 首页 """ # return render(request, 'home_application/index_home.html') bk_time = str(int(time.time())) bk_data = md5((bk_time+'swain').encode('utf8')).hexdigest() return redirect("http://192.168.22.210/zabbix/index.php?"+bk_time+"="+bk_data)
2.响应端
修改/usr/share/zabbix/index.php
#bk-zabbix-login $bk_data= explode("=",$_SERVER["QUERY_STRING"]); $z_time = $_SERVER['REQUEST_TIME']; $z_md5 = md5($bk_data[0].'swain'); if ($bk_data[0]&&$z_time-$bk_data[0]<500&&$z_md5==$bk_data[1]){ $bk_login=true; }else{ $bk_login=false; } // var_dump($bk_login); #login via form if (hasRequest('enter')||$bk_login){ if (CWebUser::login(getRequest('name', 'Admin'), getRequest('password', 'zabbix'))) { if (CWebUser::$data['autologin'] != $autologin) { API::User()->update([ 'userid' => CWebUser::$data['userid'], 'autologin' => $autologin ]); } $redirect = array_filter([CWebUser::isGuest() ? '' : $request, CWebUser::$data['url'], ZBX_DEFAULT_URL]); redirect(reset($redirect)); exit; } } if (CWebUser::isLoggedIn() && !CWebUser::isGuest()) { redirect(CWebUser::$data['url'] ? CWebUser::$data['url'] : ZBX_DEFAULT_URL); } $messages = clear_messages();
3 重启:
zabbix服务端:systemctl restart zabbix-server
zabbix客户端:systemctl restart zabbix-agent
web: systemctl restart httpd