<commit_before>Puppet::Type.type(:zabbix_item).provide(:ruby) do
  desc "zabbix item provider"
  confine :feature => :zabbixapi
  
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../../lib/ruby/")
  require "zabbix"

  def exists?
    extend Zabbix
     host_id = zbx.hosts.get({:name => resource[:host]})[0]['hostid']
     existing = zbx.query(
      :method => "item.get",
      :params => {
        :filter => {
          :name => resource[:name],
          :key_ => resource[:key],
          :hostid => [host_id]<commit_msg>fix grabbing hosts for tpl items as done for triggers in bd796fc<commit_after>Puppet::Type.type(:zabbix_item).provide(:ruby) do
  desc "zabbix item provider"
  confine :feature => :zabbixapi
  
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../../lib/ruby/")
  require "zabbix"

  def exists?
    extend Zabbix

     if not resource[:template].nil? then
       host_id = zbx.templates.get_id({:host => resource[:template]})
     else
       host_id = zbx.hosts.get({:name => resource[:host]})[0]['hostid']
     end
     existing = zbx.query(
      :method => "item.get",
      :params => {
        :filter => {
          :name => resource[:name],
          :key_ => resource[:key],
          :hostid => [host_id]
{'fraction_non_alphanumeric': 0.1819632881085395, 'fraction_numerical': 0.0039904229848363925, 'mean_word_length': 2.72106824925816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '4809634', 'n_tokens_mistral': 443, 'n_tokens_neox': 422, 'n_words': 81}