Last active
August 29, 2015 14:13
-
-
Save FilBot3/bdec2f744b4aeedf5f44 to your computer and use it in GitHub Desktop.
Get Login Information for Zabbix (2.4?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.zabbix.com/documentation/1.8/api/getting_started | |
require 'net/http' | |
@params = { | |
"jsonrpc" => '2.0', | |
'method' => 'user.login', | |
'params' => { | |
'user' => 'Admin', | |
'password' => 'zabbix' | |
}, | |
'id' => 1 | |
}.to_json | |
def create_agent | |
uri = URI('http://zabbixserver:80/zabbix/api_jsonrpc.php') | |
http = Net::HTTP.new(uri.host, uri.port) | |
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json'}) | |
req.body = @params | |
res = http.request(req) | |
puts "repsonse #{res.body}" | |
rescue => e | |
puts "Failed: #{e}" | |
end | |
puts create_agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment