Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Zabbix 3.2 support #55

Merged
merged 4 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source :rubygems
source 'https://rubygems.org'

gem "rspec"
gem "rake"
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
diff-lcs (1.1.3)
json (1.6.1)
Expand All @@ -20,3 +20,6 @@ DEPENDENCIES
json
rake
rspec

BUNDLED WITH
1.11.2
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,17 @@ zbx.triggers.create(
:priority => 5,
:status => 0,
:templateid => 0,
:type => 0
:type => 0,
:tags => [
{
:tag => "process",
:value => "aaa"
},
{
:tag => "error",
:value => ""
}
]
)
```

Expand All @@ -275,6 +285,64 @@ triggers = zbx.query(
)
```

### Create action based on trigger
```ruby
zbx.actions.create(
:name => "trigger action",
:eventsource => '0', # event source is a triggerid
:status => '0', # action is enabled
:esc_period => '120', # how long each step should take
:def_shortdata => "Email header",
:def_longdata => "Email content",
:maintenance_mode => '1',
:filter => {
:evaltype => '1', # perform 'and' between the conditions
:conditions => [
{
:conditiontype => '3', # trigger name
:operator => '2', # like
:value => 'pattern' # the pattern
},
{
:conditiontype => '4', # trigger severity
:operator => '5', # >=
:value => '3' # average
}
]
},
:operations => [
{
:operationtype => '0', # send message
:opmessage_grp => [ # who the message will be sent to
{
:usrgrpid => '2'
}
],
:opmessage => {
:default_msg => '0', # use default message
:mediatypeid => '1' # email id
}
}
],
:recovery_operations => [
{
:operationtype => '11', # send recovery message
:opmessage_grp => [ # who the message will be sent to
{
:usrgrpid => '2'
}
],
:opmessage => {
:default_msg => '0', # use default message
:mediatypeid => '1' # email id
}
}
]
)
# In Zabbix 3.2 and higher actions now have a maintenance_mode property which pauses notifications during host maintenance
# A separate action condition for Maintenance status = not in “maintenance” is no longer needed
```

### Create user
```ruby
zbx.users.create(
Expand Down
20 changes: 15 additions & 5 deletions spec/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:esc_period => '120', # how long each step should take
:def_shortdata => "Email header",
:def_longdata => "Email content",
:maintenance_mode => '1',
:filter => {
:evaltype => '1', # perform 'and' between the conditions
:conditions => [
Expand All @@ -21,11 +22,6 @@
:operator => '2', # like
:value => 'pattern' # the pattern
},
{
:conditiontype => '5', # trigger value
:operator => '0', # equal
:value => '1' # 'on'
},
{
:conditiontype => '4', # trigger severity
:operator => '5', # >=
Expand All @@ -46,6 +42,20 @@
:mediatypeid => '1' # email id
}
}
],
:recovery_operations => [
{
:operationtype => '11', # send recovery message
:opmessage_grp => [ # who the message will be sent to
{
:usrgrpid => @usergroupid
}
],
:opmessage => {
:default_msg => '0', # use default message
:mediatypeid => '1' # email id
}
}
]
}
end
Expand Down
28 changes: 24 additions & 4 deletions spec/trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@
:expression => "{#{@template}:#{@proc}.last(0)}<1",
:comments => "Bla-bla is faulty (disaster)",
:priority => 5,
:status => 0,
:type => 0
:status => 0,
:type => 0,
:tags => [
{
:tag => "proc",
:value => "#{@proc}"
},
{
:tag => "error",
:value => ""
}
]
)
expect(triggerid).to be_kind_of(Integer)
end
Expand All @@ -54,8 +64,18 @@
:expression => "{#{@template}:#{@proc}.last(0)}<1",
:comments => "Bla-bla is faulty (disaster)",
:priority => 5,
:status => 0,
:type => 0
:status => 0,
:type => 0,
:tags => [
{
:tag => "proc",
:value => "#{@proc}"
},
{
:tag => "error",
:value => ""
}
]
)
end

Expand Down