Installs and configures Zabbix agent and server with PostgreSQL and Nginx. Provides LWRP for creating and modifying Zabbix objects.
- Ubuntu
- apt
- build-essential
- lvm
- nginx
- postgresql_lwrp
- php-fpm
node['zabbix']['version']
- Defaults to2.4
.node['zabbix']['api-version']
- Defaults to2.4.4
.
node['zabbix']['agent']['include']
- Defaults to/opt/zabbix/etc
.node['zabbix']['agent']['scripts']
- Defaults to/opt/zabbix/scripts
.node['zabbix']['agent']['templates']
- Defaults to/opt/zabbix/templates
.node['zabbix']['agent']['loglevel']
- Defaults to3
.node['zabbix']['agent']['remotecmds']
- Defaults to0
.node['zabbix']['agent']['timeout']
- Defaults to3
.node['zabbix']['agent']['listen_ip']
- Defaults to0.0.0.0
.node['zabbix']['agent']['enable_remote_commands']
- Defaults to0
.node['zabbix']['agent']['serverhost']
- Defaults tonode['ipaddress']
.node['zabbix']['agent']['user_params']
- Defaults to{ ... }
.
node['zabbix']['server']['database']['filesystem']
- Defaults toext4
.node['zabbix']['server']['database']['lvm_group']
- Defaults toshared
.node['zabbix']['server']['database']['lvm_volume']
- Defaults to/dev/sda3
.node['zabbix']['server']['database']['partition_size']
- Defaults to10G
.node['zabbix']['server']['database']['cluster']
- Defaults tomain
.node['zabbix']['server']['database']['databag']
- Defaults tozabbix
.node['zabbix']['server']['database']['locale']
- Defaults toen_US.utf8
.node['zabbix']['server']['database']['mount_point']
- Defaults to/var/lib/postgresql
.node['zabbix']['server']['database']['network']
- Defaults to127.0.0.0/8
.node['zabbix']['server']['database']['version']
- Defaults to9.4
.node['zabbix']['server']['database']['configuration']['listen_addresses']
- Defaults to127.0.0.1
.node['zabbix']['server']['database']['configuration']['port']
- Defaults to5432
.node['zabbix']['server']['database']['configuration']['max_connections']
- Defaults to300
.node['zabbix']['server']['database']['configuration']['shared_buffers']
- Defaults to128MB
.node['zabbix']['server']['database']['configuration']['maintenance_work_mem']
- Defaults to128MB
.node['zabbix']['server']['database']['configuration']['work_mem']
- Defaults to8MB
.node['zabbix']['server']['database']['configuration']['effective_cache_size']
- Defaults to2GB
.node['zabbix']['server']['database']['configuration']['log_min_duration_statement']
- Defaults to1000
.node['zabbix']['server']['database']['configuration']['archive_mode']
- Defaults toon
.node['zabbix']['server']['database']['configuration']['archive_command']
- Defaults toexit 0
.
node['zabbix']['server']['service']
- Defaults tozabbix-server
.node['zabbix']['server']['credentials']['databag']
- Defaults tozabbix
.node['zabbix']['server']['config']['listenip']
- Defaults to0.0.0.0
.node['zabbix']['server']['config']['debuglevel']
- Defaults to3
.node['zabbix']['server']['config']['workers']
- Defaults to{ ... }
.node['zabbix']['server']['config']['hk']
- Defaults to{ ... }
.node['zabbix']['server']['config']['cache']
- Defaults to{ ... }
.node['zabbix']['server']['config']['timeouts']
- Defaults to{ ... }
.node['zabbix']['server']['config']['global']
- Defaults to{ ... }
.node['zabbix']['server']['config']['alerts']
- Defaults to{ ... }
.
node['zabbix']['server']['web']['server_name']
- Defaults tolocalhost
.node['zabbix']['server']['web']['listen']
- Defaults to127.0.0.1
.node['zabbix']['server']['web']['port']
- Defaults to9200
.node['zabbix']['server']['web']['max_requests']
- Defaults to500
.node['zabbix']['server']['web']['max_children']
- Defaults to5
.node['zabbix']['server']['web']['min_spare_servers']
- Defaults to1
.node['zabbix']['server']['web']['max_spare_servers']
- Defaults to3
.node['zabbix']['server']['web']['process_manager']
- Defaults todynamic
.node['zabbix']['server']['web']['configuration']['php_admin_value[date.timezone]']
- Defaults toUTC
.node['zabbix']['server']['web']['configuration']['php_admin_flag[display_errors]']
- Defaults tofalse
.node['zabbix']['server']['web']['configuration']['php_admin_value[error_reporting]']
- Defaults toE_ALL & ~E_DEPRECATED
.node['zabbix']['server']['web']['configuration']['php_admin_value[error_log]']
- Defaults to/var/log/zabbix-php-error.log
.node['zabbix']['server']['web']['configuration']['php_admin_value[max_execution_time]']
- Defaults to600
.node['zabbix']['server']['web']['configuration']['php_admin_value[max_input_time]']
- Defaults to300
.node['zabbix']['server']['web']['configuration']['php_admin_value[memory_limit]']
- Defaults to128M
.node['zabbix']['server']['web']['configuration']['php_admin_value[post_max_size]']
- Defaults to32M
.node['zabbix']['server']['web']['configuration']['php_admin_flag[register_globals]']
- Defaults totrue
.
- zabbix_lwrp::agent - Installs and configures Zabbix agent.
- zabbix_lwrp::connect - Connects to Zabbix API to sync configuration.
- zabbix_lwrp::default - Installs and configures Zabbix official repository and agent.
- zabbix_lwrp::database - Installs and configures Zabbix database.
- zabbix_lwrp::host - Creates host via Zabbix API.
- zabbix_lwrp::partition - Configures LVM for Zabbix database.
- zabbix_lwrp::repository - Installs Zabbix official repository.
- zabbix_lwrp::server - Installs and configures Zabbix server.
- zabbix_lwrp::web - Installs and configures Zabbix frontend.
Data bag zabbix
must contains the following items:
- admin (with Zabbix admin password)
- databases
- users
databases
and users
items related to the postgresql database (see postgresql_lwrp cookbook)
For examples see fixture data bag test/fixtures/databags/zabbix/
This cookbooks provides next resources:
- zabbix_action
- zabbix_application
- zabbix_connect
- zabbix_database
- zabbix_graph
- zabbix_host
- zabbix_media_type
- zabbix_screen
- zabbix_template
- zabbix_user_group
- zabbix_user_macro
Creates zabbix action with operations, conditions and messages.
Action | Description |
---|---|
sync | Default action. Sync action description with one's in zabbix server |
Attribute | Description | Default |
---|---|---|
name | Name attribute. Name of the action (required) | |
event_source | Source of event for action, now only :trigger allowed | :triggers |
escalation_time | Delay between escalation steps | 60 |
enabled | Is action enabled? | true |
message_subject | Subject of action message | |
message_body | Body of action message | true |
send_recovery_message | Send recovery message when conditions of action become false | false |
recovery_message_subject | Subject of recovery message | |
recovery_message_body | Body of recovery message | |
operation | Add an operation to action, see below. It's possible to add more then one operation | |
condition | Add an condition to action, see below. It's possible to add more the one condition |
Attributes for operation.
Attribute | Description | Default |
---|---|---|
type | Type of operation, can be :message or :command | :message |
escalation_time | Time to escalate to next step | |
start | Start step, when this operation take place | |
stop | Last step, when this operation take place | |
user_groups | Zabbix user group names that'll receive message | |
message | Message description, see below | Use default actin message if empty |
Attributes for conditions.
Attribute | Description | Default |
---|---|---|
type | Type of condition, can be one of :trigger, :trigger_value, :trigger_serverity, :host_group, :maintenance | |
operator | Operator for condition, can be one of :equal, :not_equal, :like, :not_like, :in, :gte, :lte, :not_in | |
value | Value for condition. |
It also possible to use short form of condition, like:
condition :trigger, :equal, '42th trigger name'
Attributes for message.
Attribute | Description | Default |
---|---|---|
use_default_message | Use default message from action | |
subject | Message subject | |
message | Message body | |
media_type | Name of media type to use | By default all media types are used |
zabbix_action 'Test action' do
action :sync
event_source :triggers
operation do
user_groups 'Test group'
message do
use_default_message false
subject 'Test {TRIGGER.SEVERITY}: {HOSTNAME1} {TRIGGER.STATUS}: {TRIGGER.NAME}'
message "Trigger: {TRIGGER.NAME}\n"\
"Trigger status: {TRIGGER.STATUS}\n" \
"Trigger severity: {TRIGGER.SEVERITY}\n" \
"\n" \
"Item values:\n" \
'{ITEM.NAME1} ({HOSTNAME1}:{TRIGGER.KEY1}): {ITEM.VALUE1}'
media_type 'sms'
end
end
condition :trigger_severity, :gte, :high
condition :host_group, :equal, 'Main'
condition :maintenance, :not_in, :maintenance
end
Creates application, items and triggers. You should think about items and triggers like nested resources inside zabbix_application lwrp.
Action | Description |
---|---|
sync | Default action. Sync application description with one's in zabbix server |
Attribute | Description | Default |
---|---|---|
name | Name attribute. Name of the application (required) | |
item | Add an item to application, see below. It's possible to add more then one item | |
trigger | Add an trigger to application, see below. It's possible to add more the one trigger |
Create/update zabbix item
Attribute | Description | Default |
---|---|---|
key | Name attribute. Zabbix key for an item, should be unique. | |
type | Type of zabbix check, possible values :zabbix, :trapper, :active, :calculated | |
name | Descriptive name of zabbix check, shown in web-interface | |
frequency | How often zabbix checks this item in seconds | 60 |
history | How many days store item's history | 7 days |
multiplier | Set a multiplier for item | 0 |
trends | How many days store item's trends (archived history) | 365 |
units | Set a unit for item | |
value_type | Type of gathered value, possible values :float, :character, :log_line, :unsigned_int, :text | :unsigned_int |
Attribute | Description | Default |
---|
zabbix_application "Test application" do
action :sync
item 'vfs.fs.size[/var/log,free]' do
type :active
name 'Free disk space on /var/log'
frequency 600
value_type :unsigned_int
end
trigger "Number #{node.fqdn} of free inodes on log < 10%" do
expression "{#{node.fqdn}:vfs.fs.size[/var/log,free].last(0)}>0"
severity :high
end
end
zabbix_connect 'default' do
action :make
apiurl 'http://localhost/api_jsonrpc.php'
databag 'zabbix'
end
zabbix_database db_name do
db_user db_user
db_pass db_pass
db_host db_host
db_port db_port
action :create
end
zabbix_graph 'Test Graph' do
action :create
width 640
height 480
graph_items [:key => 'vfs.fs.size[/var/log,free]', :color => '111111']
end
zabbix_host node['fqdn'] do
action :create
host_group 'Hosts'
use_ip true
ip_address node['ipaddress']
end
zabbix_media_type 'sms' do
action :create
type :sms
modem '/dev/modem'
end
zabbix_screen 'Test Screen' do
action :sync
screen_item 'Test Graph' do
resource_type :graph
end
end
Action | Description |
---|---|
add | Default action. Add a template to node |
import | Import templates from xml file to zabbix server |
Attribute | Description | Default |
---|---|---|
path | Name attribute. Path to file for :import or name of template for :add action (required) | |
host_name | Name of host new template to add | FQDN of current node |
zabbix_template '/opt/zabbix/templates/zbx_templates_linux.xml' do
action :import
end
zabbix_template 'Linux_Template'
action :add
end
Action | Description |
---|---|
create | Default action. Create a new zabbix user group |
Attribute | Description | Default |
---|---|---|
name | Name attribute. Name of new zabbix user group (required) |
zabbix_user_group 'Test group' do
action :create
end
zabbix_user_macro 'Test_macro' do
action :create
value 'foobar'
end
To install Zabbix agent just include zabbix_lwrp
default recipe into your node's run_list
:
{
"name":"my_node",
"run_list": [
"recipe[zabbix_lwrp]"
]
}
This recipe should be included before all usage of LWRP, because connection to zabbix server is established here.
To install Zabbix server include the following recipes:
{
"name":"my_node",
"run_list": [
"recipe[zabbix_lwrp::default]",
"recipe[zabbix_lwrp::database]",
"recipe[zabbix_lwrp::server]",
"recipe[zabbix_lwrp::web]"
]
}
For examples of LWRP see fixture cookbook in tests/fixtures/cookbooks
.
Maintainer:: LLC Express 42 (cookbooks@express42.com)
License:: MIT