zabbix集成onealert报错:验证失败,重新输入
一、执行操作
[root@host-10-101-16-202 bin]# bash install.sh ecae1026-34dd-a447-8f31-c9add7b20fd2
./log.sh: line 6: /usr/local/zabbix/share/zabbix/alertscripts/oneitsm/bin/oneitsm.conf: No such file or directory
start to create config file...
Zabbix管理地址: http://10.101.16.202/php/index.php
Zabbix管理员账号: Admin
Zabbix管理员密码: zhangjunchao
start to auth by zabbix admin user and password...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
106 1904 0 1904 0 125 24321 1596 --:--:-- --:--:-- --:--:-- 22807
认证失败,请重新输入.
二、验证失败记录
[root@salt-master bin]# bash -x install.sh ecae1026-34dd-a447-8f31-c9add7b20fd2
+ source ./log.sh
++ '[' -z '' ']'
++++ dirname install.sh
+++ cd .
+++ pwd
++ DIR=/usr/lib/zabbix/alertscripts/oneitsm/bin
++ source /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf
+++ current_path=/usr/lib/zabbix/alertscripts/oneitsm/bin
+++ base_path=/usr/lib/zabbix/alertscripts/oneitsm
+++ agentVersion=1130
+++ AppKey=ecae1026-34dd-a447-8f31-c9add7b20fd2
+++ dirname install.sh
++ cd .
++ pwd
+ export current_path=/usr/lib/zabbix/alertscripts/oneitsm/bin
+ current_path=/usr/lib/zabbix/alertscripts/oneitsm/bin
+ export config_flie=/usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf
+ config_flie=/usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf
+++ pwd
++ dirname /usr/lib/zabbix/alertscripts/oneitsm/bin
+ export base_path=/usr/lib/zabbix/alertscripts/oneitsm
+ base_path=/usr/lib/zabbix/alertscripts/oneitsm
+ export 'green=\e[0;32m'
+ green='\e[0;32m'
+ export 'red=\e[0;31m'
+ red='\e[0;31m'
+ export 'endColor=\e[0m'
+ endColor='\e[0m'
+ agentVersion=1130
++ log INFO Install 'start to install oneitsm...'
++ path=/usr/lib/zabbix/alertscripts/oneitsm
++ log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log
+++ date '+%Y-%m-%d %H:%M:%S'
++ time='2018-05-23 16:34:29'
++ echo 2018-05-23 16:34:29 INFO '[Install]:' 'start to install oneitsm...'
+++ date +%Y-%m
++ bak_log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05
++ '[' '!' -f /usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05 ']'
+ chown -R zabbix:zabbix ../../oneitsm
+ chmod 755 -R ../../oneitsm
+ echo 'start to create config file...'
start to create config file...
+ '[' -f /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf ']'
+ rm -f /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf
+ touch oneitsm.conf
+ echo current_path=/usr/lib/zabbix/alertscripts/oneitsm/bin
+ echo base_path=/usr/lib/zabbix/alertscripts/oneitsm
+ echo agentVersion=1130
+ AppKey=ecae1026-34dd-a447-8f31-c9add7b20fd2
+ '[' -z ecae1026-34dd-a447-8f31-c9add7b20fd2 ']'
+ echo AppKey=ecae1026-34dd-a447-8f31-c9add7b20fd2
++ log INFO Install 'Write Appkey=ecae1026-34dd-a447-8f31-c9add7b20fd2 into oneitsm.conf'
++ path=/usr/lib/zabbix/alertscripts/oneitsm
++ log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log
+++ date '+%Y-%m-%d %H:%M:%S'
++ time='2018-05-23 16:34:29'
++ echo 2018-05-23 16:34:29 INFO '[Install]:' 'Write Appkey=ecae1026-34dd-a447-8f31-c9add7b20fd2 into oneitsm.conf'
+++ date +%Y-%m
++ bak_log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05
++ '[' '!' -f /usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05 ']'
+ i=1
+ (( 1 == 1 ))
+ read -p 'Zabbix管理地址: ' zabbix_host
Zabbix管理地址: http://39.108.217.12/php/index.php
++ curl -I -m 10 -o /dev/null -s -w '%{http_code}' http://39.18.17.12/php/index.php
+ check_host_response=200
+ '[' '!' 200 -eq 200 -a '!' 200 -eq 301 ']'
+ echo zabbix_host=http://39.108.217.12/php/index.php
+ zabbix_url=http://39.108.217.12/php/index.php/api_jsonrpc.php
+ echo zabbix_url=http://39.108.217.12/php/index.php/api_jsonrpc.php
+ i=0
+ (( 0 == 1 ))
+ j=1
+ (( 1 == 1 ))
+ read -p 'Zabbix管理员账号: ' zabbix_admin_user
Zabbix管理员账号: Admin
+ read -s -p 'Zabbix管理员密码: ' zabbix_admin_password
Zabbix管理员密码: ++ log INFO Install 'start to Auth by user and password...'
++ path=/usr/lib/zabbix/alertscripts/oneitsm
++ log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log
+++ date '+%Y-%m-%d %H:%M:%S'
++ time='2018-05-23 16:35:06'
++ echo 2018-05-23 16:35:06 INFO '[Install]:' 'start to Auth by user and password...'
+++ date +%Y-%m
++ bak_log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05
++ '[' '!' -f /usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05 ']'
+ echo -e '\nstart to auth by zabbix admin user and password...'
start to auth by zabbix admin user and password...
++ cat
+ auth_body=' {
"jsonrpc": "2.0",
"method":"user.login",
"id":"1",
"params": {
"user":"Admin",
"password":"zabbix"
}
}'
++ curl -H Content-Type:application/json -X POST -d ' {
"jsonrpc": "2.0",
"method":"user.login",
"id":"1",
"params": {
"user":"Admin",
"password":"zabbix"
}
}' http://39.108.217.12/php/index.php/api_jsonrpc.php
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2029 0 1904 100 125 30216 1983 --:--:-- --:--:-- --:--:-- 30709
+ auth_response='<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" />
<title>Warning [refreshed every 30 sec.]</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
<meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
</head>
<body><div class="article"><div class="msg-bad msg-global">Access denied<div class="msg-details"><ul class="msg-details-border"><li>You are logged in as "guest". You have no permissions to access this page.</li><li>If you think this message is wrong, please consult your administrators about getting the necessary permissions.</li></ul></div><div class="msg-buttons"><button type="button" id="login" name="login" onclick="javascript: document.location = "index.php?request=api_jsonrpc.php";">Login</button><button type="button" id="back" name="back" onclick="javascript: document.location = "zabbix.php?action=dashboard.view"">Go to dashboard</button></div></div></div><script type="text/javascript">
setTimeout('\''document.location.reload();'\'', 30000);
</script></body></html>'
++ log INFO Install 'auth response:<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" />
<title>Warning [refreshed every 30 sec.]</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
<meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
</head>
<body><div class="article"><div class="msg-bad msg-global">Access denied<div class="msg-details"><ul class="msg-details-border"><li>You are logged in as "guest". You have no permissions to access this page.</li><li>If you think this message is wrong, please consult your administrators about getting the necessary permissions.</li></ul></div><div class="msg-buttons"><button type="button" id="login" name="login" onclick="javascript: document.location = "index.php?request=api_jsonrpc.php";">Login</button><button type="button" id="back" name="back" onclick="javascript: document.location = "zabbix.php?action=dashboard.view"">Go to dashboard</button></div></div></div><script type="text/javascript">
setTimeout('\''document.location.reload();'\'', 30000);
</script></body></html>'
++ path=/usr/lib/zabbix/alertscripts/oneitsm
++ log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log
+++ date '+%Y-%m-%d %H:%M:%S'
++ time='2018-05-23 16:35:06'
++ echo 2018-05-23 16:35:06 INFO '[Install]:' 'auth response:<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" />
<title>Warning [refreshed every 30 sec.]</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
<meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
</head>
<body><div class="article"><div class="msg-bad msg-global">Access denied<div class="msg-details"><ul class="msg-details-border"><li>You are logged in as "guest". You have no permissions to access this page.</li><li>If you think this message is wrong, please consult your administrators about getting the necessary permissions.</li></ul></div><div class="msg-buttons"><button type="button" id="login" name="login" onclick="javascript: document.location = "index.php?request=api_jsonrpc.php";">Login</button><button type="button" id="back" name="back" onclick="javascript: document.location = "zabbix.php?action=dashboard.view"">Go to dashboard</button></div></div></div><script type="text/javascript">
setTimeout('\''document.location.reload();'\'', 30000);
</script></body></html>'
+++ date +%Y-%m
++ bak_log=/usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05
++ '[' '!' -f /usr/lib/zabbix/alertscripts/oneitsm/logs/oneitsm.log_2018-05 ']'
++ parse_json '<!DOCTYPE' 'html>' '<html>' '<head>' '<meta' 'http-equiv="X-UA-Compatible"' 'content="IE=Edge"/>' '<meta' 'charset="utf-8"' '/>' '<meta' 'name="viewport"' 'content="width=device-width,' 'initial-scale=1">' '<meta' 'name="Author"' 'content="Zabbix' 'SIA"' '/>' '<title>Warning' '[refreshed' every 30 'sec.]</title>' '<link' 'rel="icon"' 'href="favicon.ico">' '<link' 'rel="apple-touch-icon-precomposed"' 'sizes="76x76"' 'href="img/apple-touch-icon-76x76-precomposed.png">' '<link' 'rel="apple-touch-icon-precomposed"' 'sizes="120x120"' 'href="img/apple-touch-icon-120x120-precomposed.png">' '<link' 'rel="apple-touch-icon-precomposed"' 'sizes="152x152"' 'href="img/apple-touch-icon-152x152-precomposed.png">' '<link' 'rel="apple-touch-icon-precomposed"' 'sizes="180x180"' 'href="img/apple-touch-icon-180x180-precomposed.png">' '<link' 'rel="icon"' 'sizes="192x192"' 'href="img/touch-icon-192x192.png">' '<meta' 'name="msapplication-TileImage"' 'content="img/ms-tile-144x144.png">' '<meta' 'name="msapplication-TileColor"' 'content="#d40000">' '<meta' 'name="msapplication-config"' 'content="none"/>' '<link' 'rel="stylesheet"' 'type="text/css"' 'href="styles/blue-theme.css"' '/>' '</head>' '<body><div' 'class="article"><div' 'class="msg-bad' 'msg-global">Access' 'denied<div' 'class="msg-details"><ul' 'class="msg-details-border"><li>You' are logged in as '"guest".' You have no permissions to access this 'page.</li><li>If' you think this message is wrong, please consult your administrators about getting the necessary 'permissions.</li></ul></div><div' 'class="msg-buttons"><button' 'type="button"' 'id="login"' 'name="login"' 'onclick="javascript:' document.location = '"index.php?request=api_jsonrpc.php";">Login</button><button' 'type="button"' 'id="back"' 'name="back"' 'onclick="javascript:' document.location = '"zabbix.php?action=dashboard.view"">Go' to 'dashboard</button></div></div></div><script' 'type="text/javascript">' 'setTimeout('\''document.location.reload();'\'',' '30000);' '</script></body></html>' result
++ [[ <!DOCTYPE =~ html> ]]
++ echo error
+ auth=error
+ '[' error = error ']'
+ echo -e '\e[0;31m认证失败,请重新输入.\e[0m'
认证失败,请重新输入.
+ (( 1 == 1 ))
+ read -p 'Zabbix管理员账号: ' zabbix_admin_user
Zabbix管理员账号:
三、失败分析:
onealert验证zabbix密码时是调用了http://39.108.217.12/php/index.php/api_jsonrpc.php这个文件,但是这个文件他不在index.php下面,所以这里要求输入的zabbix管理地址是有误的!
实际正确的zabbix管理地址为: http://39.108.217.12/php/api_jsonrpc.php
这是第一个问题,解决了这个之后,发现还是不行,但是这个时候我们测试http://39.108.217.12/php,发现nginx403报错,403错误是服务器拒绝访问,也就是说nginx对php目录没有访问权限。
经过测试发现:http://39.108.217.12/index.php是可以访问的,这个时候我把php目录下的所有文件全部拷贝至nginx的根目录下面
[root@host-10-101-16-202 html]# chown root:root /usr/local/nginx/html -R
[root@host-10-101-16-202 html]# chown 755 /usr/local/nginx/html -R
四、解决完之后验证:
[root@host-10-101-16-202 bin]# bash install.sh ecae1026-34dd-a447-8f31-c9add7b20fd2
start to create config file...
Zabbix管理地址: http://10.101.16.202
Zabbix管理员账号: Admin
Zabbix管理员密码: zhangjunchao
start to auth by zabbix admin user and password...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 70 0 70 0 131 1147 2146 --:--:-- --:--:-- --:--:-- 0
auth success!
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 41 0 41 0 68 1021 1694 --:--:-- --:--:-- --:--:-- 0
start to create mediatype...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 56 0 56 0 300 948 5082 --:--:-- --:--:-- --:--:-- 0
create media type success!
start to create user group...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 54 0 54 0 160 903 2676 --:--:-- --:--:-- --:--:-- 0
create user group success!
start to create user in zabbix...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 51 0 51 0 572 821 9213 --:--:-- --:--:-- --:--:-- 0
create user success!
start to create action...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2013 0 51 103 1962 879 33836 --:--:-- --:--:-- --:--:-- 34421
create action success!
安装成功.
至此问题解决!!!