Need help with zabbix_sender recipe


#1

I am working on creating a cookbook that will send the chef run status into zabbix with zabbix_sender. When I run knife cookbook upload for my cookbook I am receiving the following syntax error. It appears that it’s telling me that there is an unexpected break, but I can’t figure out what is wrong with my code below. Any help would be greatly appreciated.

syntax error, unexpected ‘\n’, expecting :: or ‘[’ or ‘.’

1 #!/usr/bin/ruby
2 chef_gem 'zabbix_sender’
3
4 require 'zabbix_sender’
5
6 module
7 class RunStatus < Chef::Handler
8 def zabbix
9 sender = ZabbixSender.new(zabbix_host: ‘’, port: 10051)
10 if success?
11 sender.post(‘host’, ‘key’, ‘1’)
12 else
13 if failed?
14 sender.post(‘host’, ‘key’, ‘0’)
15 end
16 end
17 end
18 end
19


#2

This is because you have the module keyword with no module name.

You can see that this doesn’t work:

module
end

To get the exact same error message, you need to put something inside, e.g., this will cause the same error:

module
  class Foo
  end
end

#3

Thanks for the input. I went ahead and updated the Module and ran kitchen converge but am getting an error “cannot load such file – zabbix_sender”

1: #!/usr/bin/ruby
2>> require ‘zabbix_sender’
3:
4: module ChefClient
5: module RunStatus
6: def zabbix
7: sender = ZabbixSender.new(zabbix_host:’’, port: 10051)
8: if success?
9: sender.post(‘host’, ‘key’, ‘1’)
10: elsif failed?
11: sender.post(‘host’, ‘key’, ‘0’)