express42 / zabbix_lwrp Goto Github PK
View Code? Open in Web Editor NEWExpress 42 zabbix cookbook
License: MIT License
Express 42 zabbix cookbook
License: MIT License
Добавление нового хоста в zabbix_lwrp сделано так, что при вызове рецепта сначала добавляются атрибуты этого хоста https://github.com/express42/zabbix_lwrp/blob/master/providers/host.rb. И во время выполнения рецепта connect по fqdn ноды из zabbix_api возвращает host_id и interface_id, после пытается записать их в атрибуты соответствующей ноды: https://github.com/express42/zabbix_lwrp/blob/master/providers/connect.rb#L132. Но рецепт connect выполняется только на ноде, где установлен zabbix server, а в chef одна нода не имеет прав на изменения атрибутов другой ноды. И из-за этой особенности, при обращении к атрибуту node['zabbix']['hosts'][fqdn]['host_id'] (https://github.com/express42/zabbix_lwrp/blob/master/providers/connect.rb#L303) возвращается пустое значение, что приводит к некорректной отработке ресурса zabbix_screen.
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/compat_resource/libraries/autoload.rb
================================================================================
LoadError
---------
cannot load such file -- /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/compat_resource/gemspec
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/compat_resource/libraries/autoload.rb:15:in `require_relative'
/tmp/kitchen/cache/cookbooks/compat_resource/libraries/autoload.rb:15:in `<top (required)>'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/compat_resource/libraries/autoload.rb:
8: cookbook_version = $1
9:
10: if CompatResource::VERSION != cookbook_version
11: raise "compat_resource gem version #{CompatResource::VERSION} was loaded as a gem before compat_resource cookbook version #{cookbook_version} was loaded. To remedy this, either update the cookbook to the gem version, update the gem to the cookbook version, or uninstall / stop loading the gem so early."
12: end
13: else
14: # The gem is not already activated, so activate the cookbook.
15>> require_relative '../files/lib/compat_resource/gemspec'
16: CompatResource::GEMSPEC.activate
17: end
18:
19: require 'compat_resource'
20:
compat_resource is not compabile with Chef11.
Dependency graph: zabbix_lwrp -> build-essential -> mingw -> compat_resource
Upon these tests don't work (namely a part with creation of zabbix'es resources).
zabbix_lwrp::connect recipe is running before delayed actions (in which is registered nginx and php-fpm reload commands) and in the log it is possible to observe hardly noticeable line:
WARN: Couldn't connect to zabbix server, all zabbix provider are non-working.HTTP Error: 404 on http://localhost/api_jsonrpc.php.
One of the ideas was moving zabbix_lwrp::connect also to delayed action (since they are started on - to an order):
--- test/fixtures/cookbooks/zabbix_lwrp_test/recipes/zabbix30.rb.orig 2017-05-17 10:24:54.000000000 +0400
+++ test/fixtures/cookbooks/zabbix_lwrp_test/recipes/zabbix30.rb 2017-05-19 16:31:13.690878402 +0400
@@ -100,4 +100,16 @@
host_name 'Test_snmp_host'
end
-include_recipe 'zabbix_lwrp::connect'
+#include_recipe 'zabbix_lwrp::connect'
+
+include_recipe 'build-essential'
+
+zabbix_connect 'default' do
+ action :nothing
+ apiurl 'http://localhost/api_jsonrpc.php'
+ databag 'zabbix'
+end
+
+log "zabbix_connect[default] delayed run" do
+ notifies :make, "zabbix_connect[default]", :delayed
+end
However this trick wasn't successful.
As we see zabbix_connect[default] is running after all other delayed actions, but for some reason does nothing, except as installs dependences. The problem is covered in this piece of a code. 'Search' finds nothing since chef updates data of a node only after completion of work of chef_run. Also it turns out that the test has worked it it is necessary to start twice.
Pleasant news is that KITCHEN_TEST and CI environment variables was added in test kitchen v1.11. Therefore we can precisely know that there is a testing.
For a solution simple patch is offered:
--- providers/connect.rb.orig 2017-05-19 15:01:40.000000000 +0400
+++ providers/connect.rb 2017-05-19 16:48:30.600887092 +0400
@@ -381,7 +381,7 @@
# rubocop:disable Style/AccessorMethodName
def get_hosts
- if Chef::Config[:solo]
+ if Chef::Config[:solo] or ENV['TEST_KITCHEN']
yield node
else
search(:node, 'hosts:*').each do |host|
Now tests will correctly work from the first:
Greetings!
When I user resource "zabbix_connect", to import my zabbix template on my zabbix server - it use default user_name "Admin". I have no ideas how to change in to my own. Take me some advice to do that. Tx
Because of hosts.create_or_update
RuntimeError: Server answer API error:
{
"code": -32602,
"message": "Invalid params.",
"data": "Interface is linked to item \"Ping to the server (TCP)\" on \"chef01.fl\"."
}
on request:
{
"method": "host.update",
"params": [
{
"host": "chef01.fl",
"interfaces": [
{
"type": 1,
"main": 1,
"ip": "192.168.15.8",
"dns": "",
"port": 10050,
"useip": 1
}
],
"groups": [
{
"groupid": 8
}
],
"hostid": 10138
}
],
"id": 36242,
"jsonrpc": "2.0",
"auth": "572a806e07790f5d9ba83c047567093c"
}
Hi. It seems there is a problem with overriding already existed action via zabbix_action. Could you please take a look? Thank you.
The RHEL7 3.4 package has no /etc/zabbix/alert.d
directory but it does have /usr/lib/zabbix/alertscripts
. Does any package use the former location or is this just your preference? You may want to create the directory if it won't exist.
P.S. Expect a small mountain of pull requests next week. 😉
The database provider is logging credentials:
https://github.com/express42/zabbix_lwrp/blob/master/providers/database.rb#L62
In the interest of security the log entry should either be removed or sanitized
Hi, looks like there is a bug with creating custom conditions via zabbix_action resource.
I've added the following conditions, but nothing changes:
condition :trigger_value, :equal, :problem
condition :maintenance, :not_in, :maintenance
I've attached image with the problem.
Checked in the latest cookbook with Zabbix server 2.4.5 and zabbixapi 2.4.2.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.