zabbixapi 0.5.0b3 → 0.5.0b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +0 -1
 - data/lib/zabbixapi.rb +30 -49
 - data/lib/zabbixapi/applications.rb +29 -9
 - data/lib/zabbixapi/client.rb +3 -3
 - data/lib/zabbixapi/graphs.rb +13 -9
 - data/lib/zabbixapi/hostgroups.rb +45 -12
 - data/lib/zabbixapi/hosts.rb +28 -11
 - data/lib/zabbixapi/items.rb +30 -12
 - data/lib/zabbixapi/mediatypes.rb +87 -15
 - data/lib/zabbixapi/screens.rb +59 -9
 - data/lib/zabbixapi/templates.rb +61 -9
 - data/lib/zabbixapi/triggers.rb +32 -9
 - data/lib/zabbixapi/usergroups.rb +89 -8
 - data/lib/zabbixapi/users.rb +42 -7
 - data/lib/zabbixapi/version.rb +1 -1
 - data/spec/localhost.rb +75 -102
 - data/spec/run.rb +75 -102
 - metadata +2 -3
 - data/lib/zabbixapi/basic.rb +0 -109
 
    
        data/lib/zabbixapi/screens.rb
    CHANGED
    
    | 
         @@ -1,13 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ZabbixApi
         
     | 
| 
       2 
     | 
    
         
            -
              class Screens 
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
                def api_method_name
         
     | 
| 
       5 
     | 
    
         
            -
                  "screen"
         
     | 
| 
       6 
     | 
    
         
            -
                end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                def api_identify
         
     | 
| 
       9 
     | 
    
         
            -
                  "name"
         
     | 
| 
       10 
     | 
    
         
            -
                end
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Screens
         
     | 
| 
       11 
3 
     | 
    
         | 
| 
       12 
4 
     | 
    
         
             
                # extracted from frontends/php/include/defines.inc.php
         
     | 
| 
       13 
5 
     | 
    
         
             
                #SCREEN_RESOURCE_GRAPH => 0,
         
     | 
| 
         @@ -28,6 +20,41 @@ class ZabbixApi 
     | 
|
| 
       28 
20 
     | 
    
         
             
                #SCREEN_RESOURCE_SYSTEM_STATUS => 15,
         
     | 
| 
       29 
21 
     | 
    
         
             
                #SCREEN_RESOURCE_HOST_TRIGGERS => 16
         
     | 
| 
       30 
22 
     | 
    
         | 
| 
      
 23 
     | 
    
         
            +
                def initialize(client)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @client = client
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @screen_default_options = {
         
     | 
| 
      
 26 
     | 
    
         
            +
                    :vsize => 3
         
     | 
| 
      
 27 
     | 
    
         
            +
                  }
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                # Create screen
         
     | 
| 
      
 31 
     | 
    
         
            +
                #
         
     | 
| 
      
 32 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 33 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "Screen name", hsize (rows) and vsize (columns) and array :screenitems => []
         
     | 
| 
      
 34 
     | 
    
         
            +
                #   screenitems contains :resourcetype (0 - graph), :resourcetypeid (id item) and :x and :y position
         
     | 
| 
      
 35 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 36 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 37 
     | 
    
         
            +
                def create(data)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  result = @client.api_request(:method => "screen.create", :params => data)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  result ? result['screenids'][0].to_i : nil
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                # Create screen
         
     | 
| 
      
 43 
     | 
    
         
            +
                # Synonym create
         
     | 
| 
      
 44 
     | 
    
         
            +
                def add(data)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  create(data)
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                # Update screen
         
     | 
| 
      
 49 
     | 
    
         
            +
                #
         
     | 
| 
      
 50 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 51 
     | 
    
         
            +
                #   - +data+ -> Hash with :screenid => [ "screenid" ]
         
     | 
| 
      
 52 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 53 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 54 
     | 
    
         
            +
                def update(data)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  result = @client.api_request(:method => "screen.update", :params => data)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  result ? result['screenids'][0].to_i : nil      
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
       31 
58 
     | 
    
         | 
| 
       32 
59 
     | 
    
         
             
                # Return info about screen
         
     | 
| 
       33 
60 
     | 
    
         
             
                # 
         
     | 
| 
         @@ -40,6 +67,29 @@ class ZabbixApi 
     | 
|
| 
       40 
67 
     | 
    
         
             
                  result.empty? ? [] : result
         
     | 
| 
       41 
68 
     | 
    
         
             
                end
         
     | 
| 
       42 
69 
     | 
    
         | 
| 
      
 70 
     | 
    
         
            +
                # Return screenid
         
     | 
| 
      
 71 
     | 
    
         
            +
                # 
         
     | 
| 
      
 72 
     | 
    
         
            +
                # * *Args*    : 
         
     | 
| 
      
 73 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "Screen name"
         
     | 
| 
      
 74 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 75 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 76 
     | 
    
         
            +
                def get_id(data)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  result = get_full_data(data)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  screenid = nil
         
     | 
| 
      
 79 
     | 
    
         
            +
                  result.each { |screen| screenid = screen['screenid'].to_i if screen['name'] == data[:name] }
         
     | 
| 
      
 80 
     | 
    
         
            +
                  screenid
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                # Delete screen
         
     | 
| 
      
 84 
     | 
    
         
            +
                #
         
     | 
| 
      
 85 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 86 
     | 
    
         
            +
                #   - +data+ -> Hash with :params => [screenid]
         
     | 
| 
      
 87 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 88 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 89 
     | 
    
         
            +
                def delete(data)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  result = @client.api_request(:method => "screen.delete", :params => data)
         
     | 
| 
      
 91 
     | 
    
         
            +
                  result.empty? ? nil : result['screenids'][0].to_i
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
       43 
93 
     | 
    
         | 
| 
       44 
94 
     | 
    
         
             
                # Create screen all graphs for host
         
     | 
| 
       45 
95 
     | 
    
         
             
                #
         
     | 
    
        data/lib/zabbixapi/templates.rb
    CHANGED
    
    | 
         @@ -1,22 +1,50 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ZabbixApi
         
     | 
| 
       2 
     | 
    
         
            -
              class Templates 
     | 
| 
      
 2 
     | 
    
         
            +
              class Templates
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
                def  
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(client)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @client = client
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                # Create template
         
     | 
| 
      
 9 
     | 
    
         
            +
                #
         
     | 
| 
      
 10 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 11 
     | 
    
         
            +
                #   - +data+ -> Hash with :host => "Template_Name" and :groups => array with hostgroup ids
         
     | 
| 
      
 12 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 13 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 14 
     | 
    
         
            +
                def create(data)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  result = @client.api_request(:method => "template.create", :params => [data])
         
     | 
| 
      
 16 
     | 
    
         
            +
                  result.empty? ? nil : result['templateids'][0].to_i
         
     | 
| 
       10 
17 
     | 
    
         
             
                end
         
     | 
| 
       11 
18 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                # Add template
         
     | 
| 
      
 20 
     | 
    
         
            +
                # Synonym create
         
     | 
| 
      
 21 
     | 
    
         
            +
                def add(data)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  create(data)
         
     | 
| 
       14 
23 
     | 
    
         
             
                end
         
     | 
| 
       15 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
                # Delete template
         
     | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 28 
     | 
    
         
            +
                #   - +data+ -> Hash with :host => "Template_Name"
         
     | 
| 
      
 29 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 30 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
       16 
31 
     | 
    
         
             
                def delete(data)
         
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
      
 32 
     | 
    
         
            +
                  result = @client.api_request(:method => "template.delete", :params => [:templateid => data])
         
     | 
| 
      
 33 
     | 
    
         
            +
                  result.empty? ? nil : result['templateids'][0].to_i
         
     | 
| 
       18 
34 
     | 
    
         
             
                end
         
     | 
| 
       19 
35 
     | 
    
         | 
| 
      
 36 
     | 
    
         
            +
                # Destroy template
         
     | 
| 
      
 37 
     | 
    
         
            +
                # Synonym delete
         
     | 
| 
      
 38 
     | 
    
         
            +
                def destroy(data)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  delete(data)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                # Return templateids linked with host 
         
     | 
| 
      
 43 
     | 
    
         
            +
                # 
         
     | 
| 
      
 44 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 45 
     | 
    
         
            +
                #   - +data+ -> Hash with :hostids => [hostid]
         
     | 
| 
      
 46 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 47 
     | 
    
         
            +
                #   - Array with templateids
         
     | 
| 
       20 
48 
     | 
    
         
             
                def get_ids_by_host(data)
         
     | 
| 
       21 
49 
     | 
    
         
             
                  result = []
         
     | 
| 
       22 
50 
     | 
    
         
             
                  @client.api_request(:method => "template.get", :params => data).each do |tmpl|
         
     | 
| 
         @@ -24,7 +52,19 @@ class ZabbixApi 
     | 
|
| 
       24 
52 
     | 
    
         
             
                  end
         
     | 
| 
       25 
53 
     | 
    
         
             
                  result
         
     | 
| 
       26 
54 
     | 
    
         
             
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                # Return templateid
         
     | 
| 
      
 57 
     | 
    
         
            +
                # 
         
     | 
| 
      
 58 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 59 
     | 
    
         
            +
                #   - +data+ -> Hash with :host => "Template_Name" and :groups => array with hostgroup ids
         
     | 
| 
      
 60 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 61 
     | 
    
         
            +
                #   - Integer
         
     | 
| 
      
 62 
     | 
    
         
            +
                def get_or_create(data)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  unless templateid = get_id(:host => data[:host])
         
     | 
| 
      
 64 
     | 
    
         
            +
                    templateid = create(data)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  templateid
         
     | 
| 
      
 67 
     | 
    
         
            +
                end   
         
     | 
| 
       28 
68 
     | 
    
         | 
| 
       29 
69 
     | 
    
         
             
                # Analog Zabbix api call massUpdate
         
     | 
| 
       30 
70 
     | 
    
         
             
                # 
         
     | 
| 
         @@ -115,5 +155,17 @@ class ZabbixApi 
     | 
|
| 
       115 
155 
     | 
    
         
             
                  end
         
     | 
| 
       116 
156 
     | 
    
         
             
                end
         
     | 
| 
       117 
157 
     | 
    
         | 
| 
      
 158 
     | 
    
         
            +
                # Return info about template
         
     | 
| 
      
 159 
     | 
    
         
            +
                # 
         
     | 
| 
      
 160 
     | 
    
         
            +
                # * *Args*    : 
         
     | 
| 
      
 161 
     | 
    
         
            +
                #   - +data+ -> Hash with :host => "Template name"
         
     | 
| 
      
 162 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 163 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 164 
     | 
    
         
            +
                def get_id(data)
         
     | 
| 
      
 165 
     | 
    
         
            +
                  templateid = nil
         
     | 
| 
      
 166 
     | 
    
         
            +
                  get_full_data(data).each { |template| templateid = template['templateid'].to_i if template['host'] == data[:host] }
         
     | 
| 
      
 167 
     | 
    
         
            +
                  templateid
         
     | 
| 
      
 168 
     | 
    
         
            +
                end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
       118 
170 
     | 
    
         
             
              end
         
     | 
| 
       119 
171 
     | 
    
         
             
            end
         
     | 
    
        data/lib/zabbixapi/triggers.rb
    CHANGED
    
    | 
         @@ -1,24 +1,47 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ZabbixApi
         
     | 
| 
       2 
     | 
    
         
            -
              class Triggers 
     | 
| 
      
 2 
     | 
    
         
            +
              class Triggers
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
                def  
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(client)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @client = client
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                def  
     | 
| 
       9 
     | 
    
         
            -
                  " 
     | 
| 
      
 8 
     | 
    
         
            +
                def create(data)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  result = @client.api_request(:method => "trigger.create", :params => [data])
         
     | 
| 
      
 10 
     | 
    
         
            +
                  result.empty? ? nil : result['triggerids'][0].to_i
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def add(data)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  create(data)
         
     | 
| 
       10 
15 
     | 
    
         
             
                end
         
     | 
| 
       11 
16 
     | 
    
         | 
| 
       12 
17 
     | 
    
         
             
                def delete(data)
         
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
      
 18 
     | 
    
         
            +
                  result = @client.api_request(:method => "trigger.delete", :params => [data])
         
     | 
| 
      
 19 
     | 
    
         
            +
                  result.empty? ? nil : result['triggerids'][0].to_i
         
     | 
| 
       14 
20 
     | 
    
         
             
                end
         
     | 
| 
       15 
21 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                def  
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
      
 22 
     | 
    
         
            +
                def destroy(data)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  delete(data)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def update(data)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  result = @client.api_request(:method => "trigger.update", :params => data)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  result.empty? ? nil : result['triggerids'][0].to_i
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def create_or_update(data)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  triggerid = get_id(:description => data[:description], :templateid => data[:templateid])
         
     | 
| 
      
 33 
     | 
    
         
            +
                  triggerid ? update(data.merge(:triggerid => triggerid)) : create(data)
         
     | 
| 
       18 
34 
     | 
    
         
             
                end
         
     | 
| 
       19 
35 
     | 
    
         | 
| 
       20 
36 
     | 
    
         
             
                def get_full_data(data)
         
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 37 
     | 
    
         
            +
                  @client.api_request(:method => "trigger.get", :params => {:filter => data, :output => "extend"})
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                def get_id(data)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  result = get_full_data(data)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  triggerid = nil
         
     | 
| 
      
 43 
     | 
    
         
            +
                  result.each { |template| triggerid = template['triggerid'].to_i if template['name'] == data[:name] }
         
     | 
| 
      
 44 
     | 
    
         
            +
                  triggerid
         
     | 
| 
       22 
45 
     | 
    
         
             
                end
         
     | 
| 
       23 
46 
     | 
    
         | 
| 
       24 
47 
     | 
    
         
             
              end
         
     | 
    
        data/lib/zabbixapi/usergroups.rb
    CHANGED
    
    | 
         @@ -1,22 +1,97 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ZabbixApi
         
     | 
| 
       2 
     | 
    
         
            -
              class Usergroups 
     | 
| 
      
 2 
     | 
    
         
            +
              class Usergroups
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
                def  
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(client)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @client = client
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                # Create UserGroup
         
     | 
| 
      
 9 
     | 
    
         
            +
                #
         
     | 
| 
      
 10 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 11 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "UserGroup"
         
     | 
| 
      
 12 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 13 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 14 
     | 
    
         
            +
                def create(data)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  result = @client.api_request(:method => "usergroup.create", :params => data)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  result ? result['usrgrpids'][0].to_i : nil
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                # Add UserGroup
         
     | 
| 
      
 20 
     | 
    
         
            +
                # Synonym create
         
     | 
| 
      
 21 
     | 
    
         
            +
                def add(data)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  create(data)
         
     | 
| 
       10 
23 
     | 
    
         
             
                end
         
     | 
| 
       11 
24 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                # Delete UserGroup
         
     | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 28 
     | 
    
         
            +
                #   - +data+ -> Array with usrgrpids
         
     | 
| 
      
 29 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 30 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
      
 31 
     | 
    
         
            +
                def delete(data)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  result = @client.api_request(:method => "usergroup.delete", :params => data)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  result ? result['usrgrpids'][0].to_i : nil
         
     | 
| 
       14 
34 
     | 
    
         
             
                end
         
     | 
| 
       15 
35 
     | 
    
         | 
| 
      
 36 
     | 
    
         
            +
                # Destroy UserGroup
         
     | 
| 
      
 37 
     | 
    
         
            +
                # Synonym delete
         
     | 
| 
      
 38 
     | 
    
         
            +
                def destroy(data)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  delete(data)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                # Get UserGroup info
         
     | 
| 
      
 43 
     | 
    
         
            +
                #
         
     | 
| 
      
 44 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 45 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "UserGroup"
         
     | 
| 
      
 46 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 47 
     | 
    
         
            +
                #   - Nil or Integer
         
     | 
| 
       16 
48 
     | 
    
         
             
                def get_full_data(data)
         
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
      
 49 
     | 
    
         
            +
                  @client.api_request(
         
     | 
| 
      
 50 
     | 
    
         
            +
                    :method => "usergroup.get", 
         
     | 
| 
      
 51 
     | 
    
         
            +
                    :params => {
         
     | 
| 
      
 52 
     | 
    
         
            +
                      :filter => [data[:name]],
         
     | 
| 
      
 53 
     | 
    
         
            +
                      :output => "extend"
         
     | 
| 
      
 54 
     | 
    
         
            +
                      }
         
     | 
| 
      
 55 
     | 
    
         
            +
                    )
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def get(data)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  get_full_data(data)
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                # Return usrgrpid
         
     | 
| 
      
 63 
     | 
    
         
            +
                # 
         
     | 
| 
      
 64 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 65 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "UserGroup"
         
     | 
| 
      
 66 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 67 
     | 
    
         
            +
                #   - Nil or Integer 
         
     | 
| 
      
 68 
     | 
    
         
            +
                def get_id(data)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  result = get_full_data(data)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  usrgrpid = nil
         
     | 
| 
      
 71 
     | 
    
         
            +
                  result.each { |usr| usrgrpid = usr['usrgrpid'].to_i if usr['name'] == data[:name] }
         
     | 
| 
      
 72 
     | 
    
         
            +
                  usrgrpid
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                # Return usrgrpid
         
     | 
| 
      
 76 
     | 
    
         
            +
                # 
         
     | 
| 
      
 77 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 78 
     | 
    
         
            +
                #   - +data+ -> Hash with :name => "UserGroup"
         
     | 
| 
      
 79 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 80 
     | 
    
         
            +
                #   - Integer
         
     | 
| 
      
 81 
     | 
    
         
            +
                def get_or_create(data)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  usrgrpid = get_id(data)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  if usrgrpid.nil?
         
     | 
| 
      
 84 
     | 
    
         
            +
                    usrgrpid = create(data)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                  usrgrpid
         
     | 
| 
       18 
87 
     | 
    
         
             
                end
         
     | 
| 
       19 
88 
     | 
    
         | 
| 
      
 89 
     | 
    
         
            +
                # Set permission for usrgrp on some hostgroup
         
     | 
| 
      
 90 
     | 
    
         
            +
                # 
         
     | 
| 
      
 91 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 92 
     | 
    
         
            +
                #   - +data+ -> Hash with :usrgrpids => id, :hostgroupids => [], :permission => 2,3 (read and read write)
         
     | 
| 
      
 93 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 94 
     | 
    
         
            +
                #   - Integer
         
     | 
| 
       20 
95 
     | 
    
         
             
                def set_perms(data)
         
     | 
| 
       21 
96 
     | 
    
         
             
                  permission = data[:permission] || 2 
         
     | 
| 
       22 
97 
     | 
    
         
             
                  result = @client.api_request(
         
     | 
| 
         @@ -29,6 +104,12 @@ class ZabbixApi 
     | 
|
| 
       29 
104 
     | 
    
         
             
                  result ? result['usrgrpids'][0].to_i : nil
         
     | 
| 
       30 
105 
     | 
    
         
             
                end
         
     | 
| 
       31 
106 
     | 
    
         | 
| 
      
 107 
     | 
    
         
            +
                # Update usergroup, add user
         
     | 
| 
      
 108 
     | 
    
         
            +
                # 
         
     | 
| 
      
 109 
     | 
    
         
            +
                # * *Args*    :
         
     | 
| 
      
 110 
     | 
    
         
            +
                #   - +data+ -> Hash with :usrgrpids => id, :userids => []
         
     | 
| 
      
 111 
     | 
    
         
            +
                # * *Returns* :
         
     | 
| 
      
 112 
     | 
    
         
            +
                #   - Integer
         
     | 
| 
       32 
113 
     | 
    
         
             
                def add_user(data)
         
     | 
| 
       33 
114 
     | 
    
         
             
                  result = @client.api_request(
         
     | 
| 
       34 
115 
     | 
    
         
             
                    :method => "usergroup.massAdd", 
         
     | 
    
        data/lib/zabbixapi/users.rb
    CHANGED
    
    | 
         @@ -1,20 +1,43 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class ZabbixApi
         
     | 
| 
       2 
     | 
    
         
            -
              class Users 
     | 
| 
      
 2 
     | 
    
         
            +
              class Users
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
                def  
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(client)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @client = client
         
     | 
| 
       6 
6 
     | 
    
         
             
                end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                def  
     | 
| 
       9 
     | 
    
         
            -
                  " 
     | 
| 
      
 8 
     | 
    
         
            +
                def create(data)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  result = @client.api_request(:method => "user.create", :params => data)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  result ? result['userids'][0].to_i : nil
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def add(data)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  create(data)
         
     | 
| 
       10 
15 
     | 
    
         
             
                end
         
     | 
| 
       11 
16 
     | 
    
         | 
| 
       12 
17 
     | 
    
         
             
                def delete(data)
         
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
      
 18 
     | 
    
         
            +
                  result = @client.api_request(:method => "user.delete", :params => [:userid => data])
         
     | 
| 
      
 19 
     | 
    
         
            +
                  result ? result['userids'][0].to_i : nil
         
     | 
| 
       14 
20 
     | 
    
         
             
                end
         
     | 
| 
       15 
21 
     | 
    
         | 
| 
       16 
22 
     | 
    
         
             
                def get_full_data(data)
         
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
      
 23 
     | 
    
         
            +
                  @client.api_request(
         
     | 
| 
      
 24 
     | 
    
         
            +
                    :method => "user.get", 
         
     | 
| 
      
 25 
     | 
    
         
            +
                    :params => {
         
     | 
| 
      
 26 
     | 
    
         
            +
                      :filter => {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        :name => data[:name]
         
     | 
| 
      
 28 
     | 
    
         
            +
                      },
         
     | 
| 
      
 29 
     | 
    
         
            +
                      :output => "extend"
         
     | 
| 
      
 30 
     | 
    
         
            +
                      }
         
     | 
| 
      
 31 
     | 
    
         
            +
                    )
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                def get(data)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  get_full_data(data)
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                def create_or_update(data)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  userid = get_id(:name => data[:name])
         
     | 
| 
      
 40 
     | 
    
         
            +
                  userid ? update(data.merge(:userid => userid)) : create(data)
         
     | 
| 
       18 
41 
     | 
    
         
             
                end
         
     | 
| 
       19 
42 
     | 
    
         | 
| 
       20 
43 
     | 
    
         
             
                def add_medias(data)
         
     | 
| 
         @@ -28,5 +51,17 @@ class ZabbixApi 
     | 
|
| 
       28 
51 
     | 
    
         
             
                  result ? result['userids'][0].to_i : nil
         
     | 
| 
       29 
52 
     | 
    
         
             
                end
         
     | 
| 
       30 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
                def get_id(data)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  result = get_full_data(data)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  userid = nil
         
     | 
| 
      
 57 
     | 
    
         
            +
                  result.each { |usr| userid = usr['userid'].to_i if usr['name'] == data[:name] }
         
     | 
| 
      
 58 
     | 
    
         
            +
                  userid
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                def update(data)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  result = @client.api_request(:method => "user.update", :params => data)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  result ? result['userids'][0].to_i : nil
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
       31 
66 
     | 
    
         
             
              end
         
     | 
| 
       32 
67 
     | 
    
         
             
            end
         
     | 
    
        data/lib/zabbixapi/version.rb
    CHANGED
    
    
    
        data/spec/localhost.rb
    CHANGED
    
    | 
         @@ -36,12 +36,11 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
              it "HOSTGROUP: Create" do
         
     | 
| 
       39 
     | 
    
         
            -
                 
     | 
| 
       40 
     | 
    
         
            -
                $hostgroup_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 39 
     | 
    
         
            +
                zbx.hostgroups.create(:name => hostgroup).should be_kind_of(Integer)
         
     | 
| 
       41 
40 
     | 
    
         
             
              end
         
     | 
| 
       42 
41 
     | 
    
         | 
| 
       43 
42 
     | 
    
         
             
              it "HOSTGROUP: Find" do
         
     | 
| 
       44 
     | 
    
         
            -
                zbx.hostgroups.get_id(:name => hostgroup).should  
     | 
| 
      
 43 
     | 
    
         
            +
                zbx.hostgroups.get_id(:name => hostgroup).should be_kind_of(Integer)
         
     | 
| 
       45 
44 
     | 
    
         
             
              end
         
     | 
| 
       46 
45 
     | 
    
         | 
| 
       47 
46 
     | 
    
         
             
              it "HOSTGROUP: Find unknown" do
         
     | 
| 
         @@ -49,61 +48,59 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       49 
48 
     | 
    
         
             
              end
         
     | 
| 
       50 
49 
     | 
    
         | 
| 
       51 
50 
     | 
    
         
             
              it "HOSTGROUP: Create or get" do
         
     | 
| 
       52 
     | 
    
         
            -
                zbx.hostgroups.get_or_create(:name => hostgroup).should  
     | 
| 
      
 51 
     | 
    
         
            +
                zbx.hostgroups.get_or_create(:name => hostgroup).should be_kind_of(Integer)
         
     | 
| 
       53 
52 
     | 
    
         
             
              end
         
     | 
| 
       54 
53 
     | 
    
         | 
| 
       55 
54 
     | 
    
         
             
              it "HOSTGROUP: Get all" do
         
     | 
| 
       56 
     | 
    
         
            -
                zbx.hostgroups.all.should  
     | 
| 
      
 55 
     | 
    
         
            +
                zbx.hostgroups.all.should be_kind_of(Hash)
         
     | 
| 
       57 
56 
     | 
    
         
             
              end
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
       59 
58 
     | 
    
         
             
              it "TEMPLATE: Create" do
         
     | 
| 
       60 
     | 
    
         
            -
                 
     | 
| 
      
 59 
     | 
    
         
            +
                zbx.templates.create(
         
     | 
| 
       61 
60 
     | 
    
         
             
                  :host => template,
         
     | 
| 
       62 
61 
     | 
    
         
             
                  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
         
     | 
| 
       63 
     | 
    
         
            -
                )
         
     | 
| 
       64 
     | 
    
         
            -
                $template_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 62 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       65 
63 
     | 
    
         
             
              end
         
     | 
| 
       66 
64 
     | 
    
         | 
| 
       67 
65 
     | 
    
         
             
              it "TEMPLATE: Get get or create" do
         
     | 
| 
       68 
66 
     | 
    
         
             
                zbx.templates.get_or_create(
         
     | 
| 
       69 
67 
     | 
    
         
             
                  :host => template,
         
     | 
| 
       70 
68 
     | 
    
         
             
                  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
         
     | 
| 
       71 
     | 
    
         
            -
                ).should  
     | 
| 
      
 69 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              it "TEMPLATE: Check full data" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                zbx.templates.get_full_data(:host => template)[0]['host'].should be_kind_of(String)
         
     | 
| 
       72 
74 
     | 
    
         
             
              end
         
     | 
| 
       73 
75 
     | 
    
         | 
| 
       74 
76 
     | 
    
         
             
              it "TEMPLATE: Find" do
         
     | 
| 
       75 
     | 
    
         
            -
                zbx.templates.get_id(:host => template).should  
     | 
| 
      
 77 
     | 
    
         
            +
                zbx.templates.get_id(:host => template).should be_kind_of(Integer)
         
     | 
| 
       76 
78 
     | 
    
         
             
              end
         
     | 
| 
       77 
79 
     | 
    
         | 
| 
       78 
80 
     | 
    
         
             
              it "TEMPLATE: Find unknown" do
         
     | 
| 
       79 
81 
     | 
    
         
             
                zbx.templates.get_id(:host => "#{template}_____").should be_kind_of(NilClass)
         
     | 
| 
       80 
82 
     | 
    
         
             
              end
         
     | 
| 
       81 
83 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
              it "TEMPLATE: Get all" do
         
     | 
| 
       83 
     | 
    
         
            -
                zbx.templates.all.should include(template => $template_id_real.to_s)
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
84 
     | 
    
         
             
              it "APPLICATION: Create" do
         
     | 
| 
       87 
     | 
    
         
            -
                 
     | 
| 
      
 85 
     | 
    
         
            +
                zbx.applications.create(
         
     | 
| 
       88 
86 
     | 
    
         
             
                  :name => application,
         
     | 
| 
       89 
87 
     | 
    
         
             
                  :hostid => zbx.templates.get_id(:host => template)
         
     | 
| 
       90 
88 
     | 
    
         
             
                )
         
     | 
| 
       91 
     | 
    
         
            -
                $application_id_real.should be_kind_of(Integer)
         
     | 
| 
       92 
     | 
    
         
            -
              end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
              it "APPLICATION: Get all" do
         
     | 
| 
       95 
     | 
    
         
            -
                zbx.applications.all.should include(application => $application_id_real.to_s)
         
     | 
| 
       96 
89 
     | 
    
         
             
              end
         
     | 
| 
       97 
90 
     | 
    
         | 
| 
       98 
91 
     | 
    
         
             
              it "APPLICATION: Get or create" do
         
     | 
| 
       99 
92 
     | 
    
         
             
                zbx.applications.get_or_create(
         
     | 
| 
       100 
93 
     | 
    
         
             
                  :name => application,
         
     | 
| 
       101 
94 
     | 
    
         
             
                  :hostid => zbx.templates.get_id(:host => template)
         
     | 
| 
       102 
     | 
    
         
            -
                ) 
     | 
| 
      
 95 
     | 
    
         
            +
                )
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              it "APPLICATION: Full info check" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                zbx.applications.get_full_data(:name => application)[0]['applicationid'].should be_kind_of(String)
         
     | 
| 
       103 
100 
     | 
    
         
             
              end
         
     | 
| 
       104 
101 
     | 
    
         | 
| 
       105 
102 
     | 
    
         
             
              it "APPLICATION: Find" do
         
     | 
| 
       106 
     | 
    
         
            -
                zbx.applications.get_id(:name => application).should  
     | 
| 
      
 103 
     | 
    
         
            +
                zbx.applications.get_id(:name => application).should be_kind_of(Integer)
         
     | 
| 
       107 
104 
     | 
    
         
             
              end
         
     | 
| 
       108 
105 
     | 
    
         | 
| 
       109 
106 
     | 
    
         
             
              it "APPLICATION: Find unknown" do
         
     | 
| 
         @@ -111,28 +108,27 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       111 
108 
     | 
    
         
             
              end
         
     | 
| 
       112 
109 
     | 
    
         | 
| 
       113 
110 
     | 
    
         
             
              it "ITEM: Create" do
         
     | 
| 
       114 
     | 
    
         
            -
                 
     | 
| 
      
 111 
     | 
    
         
            +
                zbx.items.create(
         
     | 
| 
       115 
112 
     | 
    
         
             
                  :description => item,
         
     | 
| 
       116 
113 
     | 
    
         
             
                  :key_ => "proc.num[aaa]",
         
     | 
| 
       117 
114 
     | 
    
         
             
                  :hostid => zbx.templates.get_id(:host => template),
         
     | 
| 
       118 
115 
     | 
    
         
             
                  :applications => [zbx.applications.get_id(:name => application)]
         
     | 
| 
       119 
     | 
    
         
            -
                )
         
     | 
| 
       120 
     | 
    
         
            -
                $item_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 116 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       121 
117 
     | 
    
         
             
              end
         
     | 
| 
       122 
118 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
              it "ITEM:  
     | 
| 
       124 
     | 
    
         
            -
                zbx.items. 
     | 
| 
      
 119 
     | 
    
         
            +
              it "ITEM: Full info check" do
         
     | 
| 
      
 120 
     | 
    
         
            +
                zbx.items.get_full_data(:description => item)[0]['itemid'].should be_kind_of(String)
         
     | 
| 
       125 
121 
     | 
    
         
             
              end
         
     | 
| 
       126 
122 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
              it "ITEM:  
     | 
| 
       128 
     | 
    
         
            -
                zbx.items. 
     | 
| 
      
 123 
     | 
    
         
            +
              it "ITEM: Find" do
         
     | 
| 
      
 124 
     | 
    
         
            +
                zbx.items.get_id(:description => item).should be_kind_of(Integer)
         
     | 
| 
       129 
125 
     | 
    
         
             
              end
         
     | 
| 
       130 
126 
     | 
    
         | 
| 
       131 
127 
     | 
    
         
             
              it "ITEM: Update" do
         
     | 
| 
       132 
128 
     | 
    
         
             
                zbx.items.update(
         
     | 
| 
       133 
129 
     | 
    
         
             
                  :itemid => zbx.items.get_id(:description => item),
         
     | 
| 
       134 
130 
     | 
    
         
             
                  :status => 0
         
     | 
| 
       135 
     | 
    
         
            -
                ).should  
     | 
| 
      
 131 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       136 
132 
     | 
    
         
             
              end
         
     | 
| 
       137 
133 
     | 
    
         | 
| 
       138 
134 
     | 
    
         
             
              it "ITEM: Create or update" do
         
     | 
| 
         @@ -142,20 +138,19 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       142 
138 
     | 
    
         
             
                  :type => 6,
         
     | 
| 
       143 
139 
     | 
    
         
             
                  :hostid => zbx.templates.get_id(:host => template),
         
     | 
| 
       144 
140 
     | 
    
         
             
                  :applications => [zbx.applications.get_id(:name => application)]
         
     | 
| 
       145 
     | 
    
         
            -
                ).should  
     | 
| 
      
 141 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       146 
142 
     | 
    
         
             
              end
         
     | 
| 
       147 
143 
     | 
    
         | 
| 
       148 
144 
     | 
    
         
             
              it "ITEM: Get unknown" do
         
     | 
| 
       149 
     | 
    
         
            -
                zbx.items.get_id(:description => "#{item}_____") 
     | 
| 
      
 145 
     | 
    
         
            +
                zbx.items.get_id(:description => "#{item}_____")
         
     | 
| 
       150 
146 
     | 
    
         
             
              end
         
     | 
| 
       151 
147 
     | 
    
         | 
| 
       152 
148 
     | 
    
         
             
              it "HOST: Create" do
         
     | 
| 
       153 
     | 
    
         
            -
                 
     | 
| 
      
 149 
     | 
    
         
            +
                zbx.hosts.create(
         
     | 
| 
       154 
150 
     | 
    
         
             
                  :host => host,
         
     | 
| 
       155 
151 
     | 
    
         
             
                  :ip => "10.20.48.88",
         
     | 
| 
       156 
152 
     | 
    
         
             
                  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
         
     | 
| 
       157 
     | 
    
         
            -
                )
         
     | 
| 
       158 
     | 
    
         
            -
                $host_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 153 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       159 
154 
     | 
    
         
             
              end
         
     | 
| 
       160 
155 
     | 
    
         | 
| 
       161 
156 
     | 
    
         
             
              it "HOST: Update or create" do
         
     | 
| 
         @@ -163,7 +158,7 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       163 
158 
     | 
    
         
             
                  :host => host,
         
     | 
| 
       164 
159 
     | 
    
         
             
                  :ip => "10.20.48.89",
         
     | 
| 
       165 
160 
     | 
    
         
             
                  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
         
     | 
| 
       166 
     | 
    
         
            -
                ).should  
     | 
| 
      
 161 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       167 
162 
     | 
    
         
             
              end
         
     | 
| 
       168 
163 
     | 
    
         | 
| 
       169 
164 
     | 
    
         
             
              it "HOST: Find unknown" do
         
     | 
| 
         @@ -171,18 +166,20 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       171 
166 
     | 
    
         
             
              end
         
     | 
| 
       172 
167 
     | 
    
         | 
| 
       173 
168 
     | 
    
         
             
              it "HOST: Find" do
         
     | 
| 
       174 
     | 
    
         
            -
                zbx.hosts.get_id(:host => host).should  
     | 
| 
      
 169 
     | 
    
         
            +
                zbx.hosts.get_id(:host => host).should be_kind_of(Integer)
         
     | 
| 
       175 
170 
     | 
    
         
             
              end
         
     | 
| 
       176 
171 
     | 
    
         | 
| 
       177 
172 
     | 
    
         
             
              it "HOST: Update" do
         
     | 
| 
       178 
173 
     | 
    
         
             
                zbx.hosts.update(
         
     | 
| 
       179 
174 
     | 
    
         
             
                  :hostid => zbx.hosts.get_id(:host => host),
         
     | 
| 
       180 
175 
     | 
    
         
             
                  :status => 0
         
     | 
| 
       181 
     | 
    
         
            -
                ) 
     | 
| 
      
 176 
     | 
    
         
            +
                )
         
     | 
| 
       182 
177 
     | 
    
         
             
              end
         
     | 
| 
       183 
178 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
              it " 
     | 
| 
       185 
     | 
    
         
            -
                zbx. 
     | 
| 
      
 179 
     | 
    
         
            +
              it "TEMPLATE: Get all templates linked with host" do
         
     | 
| 
      
 180 
     | 
    
         
            +
                zbx.templates.get_ids_by_host(
         
     | 
| 
      
 181 
     | 
    
         
            +
                  :hostids => [zbx.hosts.get_id(:host => host)]
         
     | 
| 
      
 182 
     | 
    
         
            +
                ).should be_kind_of(Array)
         
     | 
| 
       186 
183 
     | 
    
         
             
              end
         
     | 
| 
       187 
184 
     | 
    
         | 
| 
       188 
185 
     | 
    
         
             
              it "TEMPLATE: Linked hosts with templates" do
         
     | 
| 
         @@ -199,18 +196,12 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       199 
196 
     | 
    
         
             
                ).should be_kind_of(TrueClass)
         
     | 
| 
       200 
197 
     | 
    
         
             
              end
         
     | 
| 
       201 
198 
     | 
    
         | 
| 
       202 
     | 
    
         
            -
              it "TEMPLATE: Get all templates linked with host" do
         
     | 
| 
       203 
     | 
    
         
            -
                zbx.templates.get_ids_by_host(
         
     | 
| 
       204 
     | 
    
         
            -
                  :hostids => [zbx.hosts.get_id(:host => host)]
         
     | 
| 
       205 
     | 
    
         
            -
                ).should include($template_id_real.to_s)
         
     | 
| 
       206 
     | 
    
         
            -
              end
         
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
199 
     | 
    
         
             
              it "TEMPLATE: Get all" do 
         
     | 
| 
       209 
     | 
    
         
            -
                zbx.templates.all.should  
     | 
| 
      
 200 
     | 
    
         
            +
                zbx.templates.all.should be_kind_of(Hash)
         
     | 
| 
       210 
201 
     | 
    
         
             
              end
         
     | 
| 
       211 
202 
     | 
    
         | 
| 
       212 
203 
     | 
    
         
             
              it "TRIGGER: Create" do
         
     | 
| 
       213 
     | 
    
         
            -
                 
     | 
| 
      
 204 
     | 
    
         
            +
                zbx.triggers.create(
         
     | 
| 
       214 
205 
     | 
    
         
             
                  :description => trigger,
         
     | 
| 
       215 
206 
     | 
    
         
             
                  :expression => "{#{template}:proc.num[aaa].last(0)}<1",
         
     | 
| 
       216 
207 
     | 
    
         
             
                  :comments => "Bla-bla is faulty (disaster)",
         
     | 
| 
         @@ -218,22 +209,13 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       218 
209 
     | 
    
         
             
                  :status     => 0,
         
     | 
| 
       219 
210 
     | 
    
         
             
                  :templateid => 0,
         
     | 
| 
       220 
211 
     | 
    
         
             
                  :type => 0
         
     | 
| 
       221 
     | 
    
         
            -
                )
         
     | 
| 
       222 
     | 
    
         
            -
                $trigger_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 212 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       223 
213 
     | 
    
         
             
              end
         
     | 
| 
       224 
214 
     | 
    
         | 
| 
       225 
215 
     | 
    
         
             
              it "TRIGGER: Find" do
         
     | 
| 
       226 
216 
     | 
    
         
             
                zbx.triggers.get_id(:description => trigger).should be_kind_of(Integer)
         
     | 
| 
       227 
217 
     | 
    
         
             
              end
         
     | 
| 
       228 
218 
     | 
    
         | 
| 
       229 
     | 
    
         
            -
              it "TRIGGER: Find unknown" do
         
     | 
| 
       230 
     | 
    
         
            -
                zbx.triggers.get_id(:description => "#{trigger}____").should be_kind_of(NilClass)
         
     | 
| 
       231 
     | 
    
         
            -
              end
         
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
              it "TRIGGER: Get all" do
         
     | 
| 
       234 
     | 
    
         
            -
                zbx.triggers.all.should be_kind_of(Hash)
         
     | 
| 
       235 
     | 
    
         
            -
              end
         
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
219 
     | 
    
         
             
              it "GRAPH: Create" do 
         
     | 
| 
       238 
220 
     | 
    
         
             
                gitems = {
         
     | 
| 
       239 
221 
     | 
    
         
             
                    :itemid => zbx.items.get_id(:description => item), 
         
     | 
| 
         @@ -241,14 +223,13 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       241 
223 
     | 
    
         
             
                    :type => "0",
         
     | 
| 
       242 
224 
     | 
    
         
             
                    :periods_cnt => "5"
         
     | 
| 
       243 
225 
     | 
    
         
             
                }
         
     | 
| 
       244 
     | 
    
         
            -
                 
     | 
| 
      
 226 
     | 
    
         
            +
                zbx.graphs.create(
         
     | 
| 
       245 
227 
     | 
    
         
             
                  :gitems => [gitems],
         
     | 
| 
       246 
228 
     | 
    
         
             
                  :show_triggers => "0",
         
     | 
| 
       247 
229 
     | 
    
         
             
                  :name => graph,
         
     | 
| 
       248 
230 
     | 
    
         
             
                  :width => "900",
         
     | 
| 
       249 
231 
     | 
    
         
             
                  :height => "200"
         
     | 
| 
       250 
     | 
    
         
            -
                )
         
     | 
| 
       251 
     | 
    
         
            -
                $graph_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 232 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       252 
233 
     | 
    
         
             
              end
         
     | 
| 
       253 
234 
     | 
    
         | 
| 
       254 
235 
     | 
    
         
             
              it "GRAPH: Create or get" do 
         
     | 
| 
         @@ -264,25 +245,21 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       264 
245 
     | 
    
         
             
                  :name => graph,
         
     | 
| 
       265 
246 
     | 
    
         
             
                  :width => "900",
         
     | 
| 
       266 
247 
     | 
    
         
             
                  :height => "200"
         
     | 
| 
       267 
     | 
    
         
            -
                ).should  
     | 
| 
      
 248 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       268 
249 
     | 
    
         
             
              end
         
     | 
| 
       269 
250 
     | 
    
         | 
| 
       270 
251 
     | 
    
         
             
              it "GRAPH: Find gititems" do
         
     | 
| 
       271 
     | 
    
         
            -
                zbx.graphs.get_items( zbx.graphs.get_id(:name => graph) ) 
     | 
| 
      
 252 
     | 
    
         
            +
                zbx.graphs.get_items( zbx.graphs.get_id(:name => graph) )
         
     | 
| 
       272 
253 
     | 
    
         
             
              end
         
     | 
| 
       273 
254 
     | 
    
         | 
| 
       274 
255 
     | 
    
         
             
              it "GRAPH: Find" do
         
     | 
| 
       275 
     | 
    
         
            -
                zbx.graphs.get_id( :name => graph ).should  
     | 
| 
      
 256 
     | 
    
         
            +
                zbx.graphs.get_id( :name => graph ).should be_kind_of(Integer)
         
     | 
| 
       276 
257 
     | 
    
         
             
              end
         
     | 
| 
       277 
258 
     | 
    
         | 
| 
       278 
259 
     | 
    
         
             
              it "GRAPH: get_ids_by_host" do
         
     | 
| 
       279 
260 
     | 
    
         
             
                zbx.graphs.get_ids_by_host( :host => host ).should be_kind_of(Array)
         
     | 
| 
       280 
261 
     | 
    
         
             
              end
         
     | 
| 
       281 
262 
     | 
    
         | 
| 
       282 
     | 
    
         
            -
              it "GRAPH: Get all" do
         
     | 
| 
       283 
     | 
    
         
            -
                zbx.graphs.all.should include(graph => $graph_id_real.to_s)
         
     | 
| 
       284 
     | 
    
         
            -
              end
         
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
263 
     | 
    
         
             
              it "GRAPH: Update" do
         
     | 
| 
       287 
264 
     | 
    
         
             
                zbx.graphs.update(
         
     | 
| 
       288 
265 
     | 
    
         
             
                  :graphid => zbx.graphs.get_id(
         
     | 
| 
         @@ -290,7 +267,7 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       290 
267 
     | 
    
         
             
                    :hostid => zbx.hosts.get_id(:host => host)
         
     | 
| 
       291 
268 
     | 
    
         
             
                  ), 
         
     | 
| 
       292 
269 
     | 
    
         
             
                  :ymax_type => 1
         
     | 
| 
       293 
     | 
    
         
            -
                ).should  
     | 
| 
      
 270 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       294 
271 
     | 
    
         
             
              end
         
     | 
| 
       295 
272 
     | 
    
         | 
| 
       296 
273 
     | 
    
         
             
              it "GRAPH: Create or Update" do
         
     | 
| 
         @@ -306,15 +283,14 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       306 
283 
     | 
    
         
             
                :name => graph,
         
     | 
| 
       307 
284 
     | 
    
         
             
                :width => "900",
         
     | 
| 
       308 
285 
     | 
    
         
             
                :height => "200"
         
     | 
| 
       309 
     | 
    
         
            -
              ).should  
     | 
| 
      
 286 
     | 
    
         
            +
              ).should be_kind_of(Integer)
         
     | 
| 
       310 
287 
     | 
    
         
             
              end
         
     | 
| 
       311 
288 
     | 
    
         | 
| 
       312 
289 
     | 
    
         
             
              it "SCREEN: Get or create for host" do
         
     | 
| 
       313 
     | 
    
         
            -
                 
     | 
| 
      
 290 
     | 
    
         
            +
                zbx.screens.get_or_create_for_host(
         
     | 
| 
       314 
291 
     | 
    
         
             
                  :host => host,
         
     | 
| 
       315 
292 
     | 
    
         
             
                  :graphids => zbx.graphs.get_ids_by_host(:host => host)
         
     | 
| 
       316 
     | 
    
         
            -
                )
         
     | 
| 
       317 
     | 
    
         
            -
                $screen_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 293 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       318 
294 
     | 
    
         
             
              end
         
     | 
| 
       319 
295 
     | 
    
         | 
| 
       320 
296 
     | 
    
         
             
              it "TEMPLATE: Unlink hosts from templates" do
         
     | 
| 
         @@ -324,14 +300,10 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       324 
300 
     | 
    
         
             
                ).should be_kind_of(TrueClass)
         
     | 
| 
       325 
301 
     | 
    
         
             
              end
         
     | 
| 
       326 
302 
     | 
    
         | 
| 
       327 
     | 
    
         
            -
              it "SCREEN: Get all" do
         
     | 
| 
       328 
     | 
    
         
            -
                zbx.screens.all.should be_kind_of(Hash)
         
     | 
| 
       329 
     | 
    
         
            -
              end
         
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
303 
     | 
    
         
             
              it "SCREEN: Delete" do
         
     | 
| 
       332 
304 
     | 
    
         
             
                zbx.screens.delete(
         
     | 
| 
       333 
305 
     | 
    
         
             
                  [zbx.screens.get_id(:name => "#{host}_graphs")]
         
     | 
| 
       334 
     | 
    
         
            -
                ).should  
     | 
| 
      
 306 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       335 
307 
     | 
    
         
             
              end
         
     | 
| 
       336 
308 
     | 
    
         | 
| 
       337 
309 
     | 
    
         
             
              it "GRAPH: Delete" do
         
     | 
| 
         @@ -343,37 +315,36 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       343 
315 
     | 
    
         
             
              end
         
     | 
| 
       344 
316 
     | 
    
         | 
| 
       345 
317 
     | 
    
         
             
              it "HOST: Delete" do
         
     | 
| 
       346 
     | 
    
         
            -
                zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should  
     | 
| 
      
 318 
     | 
    
         
            +
                zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should be_kind_of(Integer)
         
     | 
| 
       347 
319 
     | 
    
         
             
              end
         
     | 
| 
       348 
320 
     | 
    
         | 
| 
       349 
321 
     | 
    
         
             
              it "ITEM: Delete" do
         
     | 
| 
       350 
322 
     | 
    
         
             
                zbx.items.delete(
         
     | 
| 
       351 
323 
     | 
    
         
             
                  zbx.items.get_id(:description => item)
         
     | 
| 
       352 
     | 
    
         
            -
                ).should  
     | 
| 
      
 324 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       353 
325 
     | 
    
         
             
              end
         
     | 
| 
       354 
326 
     | 
    
         | 
| 
       355 
327 
     | 
    
         
             
              it "APPLICATION: Delete" do
         
     | 
| 
       356 
     | 
    
         
            -
                zbx.applications.delete( zbx.applications.get_id(:name => application) ) 
     | 
| 
      
 328 
     | 
    
         
            +
                zbx.applications.delete( zbx.applications.get_id(:name => application) )
         
     | 
| 
       357 
329 
     | 
    
         
             
              end
         
     | 
| 
       358 
330 
     | 
    
         | 
| 
       359 
331 
     | 
    
         
             
              it "TEMPLATE: Delete" do
         
     | 
| 
       360 
     | 
    
         
            -
                zbx.templates.delete(zbx.templates.get_id(:host => template)) 
     | 
| 
      
 332 
     | 
    
         
            +
                zbx.templates.delete(zbx.templates.get_id(:host => template))
         
     | 
| 
       361 
333 
     | 
    
         
             
              end
         
     | 
| 
       362 
334 
     | 
    
         | 
| 
       363 
335 
     | 
    
         
             
              it "HOSTGROUP: Delete" do
         
     | 
| 
       364 
336 
     | 
    
         
             
                zbx.hostgroups.delete(
         
     | 
| 
       365 
337 
     | 
    
         
             
                  zbx.hostgroups.get_id(:name => hostgroup)
         
     | 
| 
       366 
     | 
    
         
            -
                ).should  
     | 
| 
      
 338 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       367 
339 
     | 
    
         
             
              end
         
     | 
| 
       368 
340 
     | 
    
         | 
| 
       369 
341 
     | 
    
         
             
              it "USER: Create" do
         
     | 
| 
       370 
     | 
    
         
            -
                 
     | 
| 
      
 342 
     | 
    
         
            +
                zbx.users.create(
         
     | 
| 
       371 
343 
     | 
    
         
             
                  :alias => "Test #{user}",
         
     | 
| 
       372 
344 
     | 
    
         
             
                  :name => user,
         
     | 
| 
       373 
345 
     | 
    
         
             
                  :surname => user,
         
     | 
| 
       374 
346 
     | 
    
         
             
                  :passwd => user
         
     | 
| 
       375 
     | 
    
         
            -
                )
         
     | 
| 
       376 
     | 
    
         
            -
                $user_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 347 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       377 
348 
     | 
    
         
             
              end
         
     | 
| 
       378 
349 
     | 
    
         | 
| 
       379 
350 
     | 
    
         
             
              it "USER: Create or update" do
         
     | 
| 
         @@ -382,31 +353,34 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       382 
353 
     | 
    
         
             
                  :name => user,
         
     | 
| 
       383 
354 
     | 
    
         
             
                  :surname => user,
         
     | 
| 
       384 
355 
     | 
    
         
             
                  :passwd => user
         
     | 
| 
       385 
     | 
    
         
            -
                ).should  
     | 
| 
      
 356 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
      
 357 
     | 
    
         
            +
              end
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
              it "USER: Find" do
         
     | 
| 
      
 360 
     | 
    
         
            +
                zbx.users.get_full_data(:name => user)[0]['name'].should be_kind_of(String)
         
     | 
| 
       386 
361 
     | 
    
         
             
              end
         
     | 
| 
       387 
362 
     | 
    
         | 
| 
       388 
363 
     | 
    
         
             
              it "USER: Update" do
         
     | 
| 
       389 
     | 
    
         
            -
                zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should  
     | 
| 
      
 364 
     | 
    
         
            +
                zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should be_kind_of(Integer)
         
     | 
| 
       390 
365 
     | 
    
         
             
              end
         
     | 
| 
       391 
366 
     | 
    
         | 
| 
       392 
367 
     | 
    
         
             
              it "USER: Find unknown" do
         
     | 
| 
       393 
     | 
    
         
            -
                zbx.users.get_id(:name => "#{user}_____") 
     | 
| 
      
 368 
     | 
    
         
            +
                zbx.users.get_id(:name => "#{user}_____")
         
     | 
| 
       394 
369 
     | 
    
         
             
              end
         
     | 
| 
       395 
370 
     | 
    
         | 
| 
       396 
371 
     | 
    
         
             
              it "USERGROUPS: Create" do
         
     | 
| 
       397 
     | 
    
         
            -
                 
     | 
| 
       398 
     | 
    
         
            -
                $usergrp_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 372 
     | 
    
         
            +
                zbx.usergroups.create(:name => usergroup).should be_kind_of(Integer)
         
     | 
| 
       399 
373 
     | 
    
         
             
              end
         
     | 
| 
       400 
374 
     | 
    
         | 
| 
       401 
375 
     | 
    
         
             
              it "USERGROUPS: Create or update" do
         
     | 
| 
       402 
     | 
    
         
            -
                zbx.usergroups.get_or_create(:name => usergroup).should  
     | 
| 
      
 376 
     | 
    
         
            +
                zbx.usergroups.get_or_create(:name => usergroup).should be_kind_of(Integer)
         
     | 
| 
       403 
377 
     | 
    
         
             
              end
         
     | 
| 
       404 
378 
     | 
    
         | 
| 
       405 
379 
     | 
    
         
             
              it "USERGROUPS: Add user" do
         
     | 
| 
       406 
380 
     | 
    
         
             
                zbx.usergroups.add_user(
         
     | 
| 
       407 
381 
     | 
    
         
             
                    :usrgrpids => [zbx.usergroups.get_id(:name => usergroup)],
         
     | 
| 
       408 
382 
     | 
    
         
             
                    :userids => [zbx.users.get_id(:name => user2)]
         
     | 
| 
       409 
     | 
    
         
            -
                ).should  
     | 
| 
      
 383 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       410 
384 
     | 
    
         
             
              end
         
     | 
| 
       411 
385 
     | 
    
         | 
| 
       412 
386 
     | 
    
         
             
              it "USERGROUPS: Set UserGroup read & write perm" do
         
     | 
| 
         @@ -414,24 +388,23 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       414 
388 
     | 
    
         
             
                  :usrgrpid => zbx.usergroups.get_or_create(:name => usergroup).to_s,
         
     | 
| 
       415 
389 
     | 
    
         
             
                  :hostgroupids => zbx.hostgroups.all.values,
         
     | 
| 
       416 
390 
     | 
    
         
             
                  :permission => 3
         
     | 
| 
       417 
     | 
    
         
            -
                ).should  
     | 
| 
      
 391 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       418 
392 
     | 
    
         
             
              end
         
     | 
| 
       419 
393 
     | 
    
         | 
| 
       420 
394 
     | 
    
         
             
              it "MEDIATYPE: Create" do
         
     | 
| 
       421 
     | 
    
         
            -
                 
     | 
| 
      
 395 
     | 
    
         
            +
                zbx.mediatypes.create(
         
     | 
| 
       422 
396 
     | 
    
         
             
                  :description => mediatype,
         
     | 
| 
       423 
397 
     | 
    
         
             
                  :type => 0,
         
     | 
| 
       424 
398 
     | 
    
         
             
                  :smtp_server => "127.0.0.1",
         
     | 
| 
       425 
399 
     | 
    
         
             
                  :smtp_email => "zabbix@test.com"
         
     | 
| 
       426 
     | 
    
         
            -
                )
         
     | 
| 
       427 
     | 
    
         
            -
                $meditype_id_real.should be_kind_of(Integer)
         
     | 
| 
      
 400 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       428 
401 
     | 
    
         
             
              end
         
     | 
| 
       429 
402 
     | 
    
         | 
| 
       430 
403 
     | 
    
         
             
              it "MEDIATYPE: Update or create" do
         
     | 
| 
       431 
404 
     | 
    
         
             
                zbx.mediatypes.create_or_update(
         
     | 
| 
       432 
405 
     | 
    
         
             
                  :description => mediatype,
         
     | 
| 
       433 
406 
     | 
    
         
             
                  :smtp_email => "zabbix2@test.com"
         
     | 
| 
       434 
     | 
    
         
            -
                ).should  
     | 
| 
      
 407 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       435 
408 
     | 
    
         
             
              end
         
     | 
| 
       436 
409 
     | 
    
         | 
| 
       437 
410 
     | 
    
         
             
              it "USER: Add mediatype" do
         
     | 
| 
         @@ -446,21 +419,21 @@ describe ZabbixApi, "test_api" do 
     | 
|
| 
       446 
419 
     | 
    
         
             
                      :severity => "56"
         
     | 
| 
       447 
420 
     | 
    
         
             
                    }
         
     | 
| 
       448 
421 
     | 
    
         
             
                  ]
         
     | 
| 
       449 
     | 
    
         
            -
                ).should  
     | 
| 
      
 422 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       450 
423 
     | 
    
         
             
              end
         
     | 
| 
       451 
424 
     | 
    
         | 
| 
       452 
425 
     | 
    
         
             
              it "MEDIATYPE: Delete" do
         
     | 
| 
       453 
426 
     | 
    
         
             
                zbx.mediatypes.delete(
         
     | 
| 
       454 
427 
     | 
    
         
             
                  zbx.mediatypes.get_id(:description => mediatype)
         
     | 
| 
       455 
     | 
    
         
            -
                ).should  
     | 
| 
      
 428 
     | 
    
         
            +
                ).should be_kind_of(Integer)
         
     | 
| 
       456 
429 
     | 
    
         
             
              end
         
     | 
| 
       457 
430 
     | 
    
         | 
| 
       458 
431 
     | 
    
         
             
              it "USER: Delete" do
         
     | 
| 
       459 
     | 
    
         
            -
                zbx.users.delete(zbx.users.get_id(:name => user2)).should  
     | 
| 
      
 432 
     | 
    
         
            +
                zbx.users.delete(zbx.users.get_id(:name => user2)).should be_kind_of(Integer)
         
     | 
| 
       460 
433 
     | 
    
         
             
              end
         
     | 
| 
       461 
434 
     | 
    
         | 
| 
       462 
435 
     | 
    
         
             
              it "USERGROUPS: Delete" do
         
     | 
| 
       463 
     | 
    
         
            -
                zbx.usergroups.delete([zbx.usergroups.get_id(:name => usergroup)]).should  
     | 
| 
      
 436 
     | 
    
         
            +
                zbx.usergroups.delete([zbx.usergroups.get_id(:name => usergroup)]).should be_kind_of(Integer)
         
     | 
| 
       464 
437 
     | 
    
         
             
              end
         
     | 
| 
       465 
438 
     | 
    
         | 
| 
       466 
439 
     | 
    
         
             
              it "QUERY" do
         
     |