Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Last active August 29, 2015 14:13
Show Gist options
  • Save FilBot3/bdec2f744b4aeedf5f44 to your computer and use it in GitHub Desktop.
Save FilBot3/bdec2f744b4aeedf5f44 to your computer and use it in GitHub Desktop.
Get Login Information for Zabbix (2.4?)
# 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