<commit_before>#!/usr/bin/env ruby

require 'rubygems'
require "zabbixapi"

require "zabbix_conf/version"


HOST = 'zb00.cec.mltn.local'
URL  = "http://#{HOST}/zabbix/api_jsonrpc.php"

puts URL


$zbx = ZabbixApi.connect(
  :url => URL,
  :user => 'admin',
  :password => '<PASSWORD>'
)


# Gets or Creates a Hostgroup
# Params:
# +name+:: hostname to be created and/or retrieved
def get_or_create_hostgroup( name )
    hostgroup = $zbx.hostgroups.get_id(:name => name)
    unless hostgroup
        hostgroup = $zbx.hostgroups.create(:name => name)
    end
    hostgroup
end

hostgroup_name = 'testGroup2'
puts get_or_create_hostgroup(hostgroup_name)

# test = zbx.hostgroups.get_id(:name => "hostgroup")
# puts test.inspect
# hostg = zbx.hostgroups.create(:name => 'testGroup')
# puts hostg.inspect

# module ZabbixConf
#   # Your code goes here...
# end<commit_msg>found built in zabbixapi function hostgroups.get_or_create<commit_after>#!/usr/bin/env ruby

require 'rubygems'
require "zabbixapi"

require "zabbix_conf/version"

# sync global stdout
STDOUT.sync = true


HOST = 'zb00.cec.mltn.local'
URL  = "http://#{HOST}/zabbix/api_jsonrpc.php"
print "Connecting to #{URL}"
$zbx = ZabbixApi.connect(
  :url => URL,
  :user => 'admin',
  :password => '<PASSWORD>'
)
puts "...connected"

hostgroup_name = 'testGroup'
puts $zbx.hostgroups.get_or_create(:name => hostgroup_name)


# module ZabbixConf
#   # Your code goes here...
# end
{'fraction_non_alphanumeric': 0.1456445993031359, 'fraction_numerical': 0.003484320557491289, 'mean_word_length': 4.279411764705882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6229643', 'n_tokens_mistral': 557, 'n_tokens_neox': 542, 'n_words': 117}