您的位置:首页 > 其它

zabbix 添加主机成功失败判断

2016-05-03 14:08 519 查看
zabbix 成功添加后:

$VAR1 = bless( {
'version' => 0,
'content' => {
'jsonrpc' => '2.0',
'id' => 1,
'result' => {
'hostids' => [
'10228'
]
}
},
'jsontext' => '{"jsonrpc":"2.0","result":{"hostids":["10228"]},"id":1}',
'is_success' => 1
}, 'JSON::RPC::ReturnObject' );
----------------------
HASH(0x2857fd0)

zabbix 添加是失败的情况:

$VAR1 = bless( {
'version' => 0,
'content' => {
'jsonrpc' => '2.0',
'error' => {
'data' => 'Host with the same name "zjtest9-app" already exists.',
'message' => 'Invalid params.',
'code' => -32602
},
'id' => 1
},
'jsontext' => '{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Host with the same name \\"zjtest9-app\\" already exists."},"id":1}',
'is_success' => 0
}, 'JSON::RPC::ReturnObject' );

通过判断:
die "host.get failed\n" unless $response->content->{error}->{data};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: