zbxapi 0.1.1 → 0.1.291
Sign up to get free protection for your applications and to get access to all the features.
- data/libs/api_exceptions.rb +4 -0
- data/libs/exceptions.rb +5 -3
- data/libs/zdebug.rb +2 -2
- data/zbxapi.rb +15 -601
- metadata +4 -4
data/libs/api_exceptions.rb
CHANGED
@@ -97,6 +97,10 @@ end
|
|
97
97
|
#------------------------------------------------------------------------------
|
98
98
|
|
99
99
|
class ZbxAPI_ExceptionLoginPermission < ZError
|
100
|
+
def initialize(message=nil, params=nil)
|
101
|
+
super(message, params)
|
102
|
+
@local_msg="This is also a general Zabbix API error number (Your error may not be a login error).\nTell the Zabbix devs to honor section 5.1 of the JSON-RPC 2.0 Spec."
|
103
|
+
end
|
100
104
|
end
|
101
105
|
|
102
106
|
#------------------------------------------------------------------------------
|
data/libs/exceptions.rb
CHANGED
@@ -34,14 +34,12 @@ class ZError < RuntimeError
|
|
34
34
|
|
35
35
|
include ZDebug
|
36
36
|
|
37
|
-
|
37
|
+
attr_accessor :help_func, :message, :retry
|
38
38
|
|
39
39
|
# list of valid params
|
40
40
|
# :help_func, the help function with more information for the exception
|
41
41
|
# : retry, is the exception eligable for retry?
|
42
42
|
def initialize(message=nil, params=nil)
|
43
|
-
debug(2,self.class,"Exception raised")
|
44
|
-
debug(2,params,"params")
|
45
43
|
raise "Exception not called correctly" if params.class!=Hash if !params.nil?
|
46
44
|
params={} if params.nil?
|
47
45
|
@help_func=params[:help_func]
|
@@ -117,3 +115,7 @@ class ParseError < ZError
|
|
117
115
|
@local_msg="Parse Error"
|
118
116
|
end
|
119
117
|
end
|
118
|
+
|
119
|
+
class ReturnError < ZError
|
120
|
+
|
121
|
+
end
|
data/libs/zdebug.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
|
18
18
|
##########################################
|
19
19
|
# Subversion information
|
20
|
-
# $Id: zdebug.rb
|
21
|
-
# $Revision:
|
20
|
+
# $Id: zdebug.rb 281 2011-04-06 18:10:16Z nelsonab $
|
21
|
+
# $Revision: 281 $
|
22
22
|
##########################################
|
23
23
|
|
24
24
|
module ZDebug
|
data/zbxapi.rb
CHANGED
@@ -19,11 +19,13 @@
|
|
19
19
|
#--
|
20
20
|
##########################################
|
21
21
|
# Subversion information
|
22
|
-
# $Id: zbxapi.rb
|
23
|
-
# $Revision:
|
22
|
+
# $Id: zbxapi.rb 290 2011-07-08 04:58:15Z nelsonab $
|
23
|
+
# $Revision: 290 $
|
24
24
|
##########################################
|
25
25
|
#++
|
26
26
|
|
27
|
+
#TODO Create class to capture resultant data
|
28
|
+
|
27
29
|
#setup our search path or libraries
|
28
30
|
$: << File.expand_path(File.join(File.dirname(__FILE__), '.'))
|
29
31
|
|
@@ -35,6 +37,16 @@ require 'net/https'
|
|
35
37
|
require 'rubygems'
|
36
38
|
require 'json'
|
37
39
|
|
40
|
+
require "api_classes/application"
|
41
|
+
require "api_classes/history"
|
42
|
+
require "api_classes/host"
|
43
|
+
require "api_classes/host_group"
|
44
|
+
require "api_classes/item"
|
45
|
+
require "api_classes/sysmap"
|
46
|
+
require "api_classes/trigger"
|
47
|
+
require "api_classes/user"
|
48
|
+
require "api_classes/user_group"
|
49
|
+
|
38
50
|
|
39
51
|
|
40
52
|
#------------------------------------------------------------------------------
|
@@ -267,6 +279,7 @@ class ZabbixAPI
|
|
267
279
|
|
268
280
|
# check return code and throw exception for error checking
|
269
281
|
resp = JSON.parse(response.body) #parse the JSON Object so we can use it
|
282
|
+
raise
|
270
283
|
if !resp["error"].nil?
|
271
284
|
errcode=resp["error"]["code"].to_i
|
272
285
|
case errcode
|
@@ -299,605 +312,6 @@ class ZabbixAPI
|
|
299
312
|
end
|
300
313
|
end
|
301
314
|
|
302
|
-
# Class: Zbx_API_Sub
|
303
|
-
# Wrapper class to ensure all class calls goes to the parent object not the
|
304
|
-
# currently instantiated object.
|
305
|
-
# Also ensures class specific variable sanity for global functions
|
306
|
-
class ZbxAPI_Sub < ZabbixAPI #:nodoc: all
|
307
|
-
attr_accessor :parent
|
308
|
-
|
309
|
-
def initialize(parent)
|
310
|
-
@parent=parent
|
311
|
-
end
|
312
|
-
|
313
|
-
def checkauth
|
314
|
-
@parent.checkauth
|
315
|
-
end
|
316
|
-
|
317
|
-
def checkversion(major,minor,options=nil)
|
318
|
-
@parent.checkversion(major,minor,options)
|
319
|
-
end
|
320
|
-
|
321
|
-
def do_request(req)
|
322
|
-
return @parent.do_request(req)
|
323
|
-
end
|
324
|
-
|
325
|
-
def json_obj(method, param)
|
326
|
-
return @parent.json_obj(method, param)
|
327
|
-
end
|
328
|
-
|
329
|
-
def debug(level,param="",message=nil)
|
330
|
-
@parent.debug(level,param,message)
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
# Class ZbxAPI_User
|
335
|
-
#
|
336
|
-
# Class encapsulating User functions
|
337
|
-
#
|
338
|
-
# API Function Status
|
339
|
-
# [get] Implemented, need error checking
|
340
|
-
# [authenticate] Will not implement here, belongs in ZabbixAPI main class
|
341
|
-
# [checkauth] Will not implement here, belongs in ZabbixAPI main class
|
342
|
-
# [getid] Implemented
|
343
|
-
# [create] Implemented, need to test more to find fewest items
|
344
|
-
# needed, input value testing needed
|
345
|
-
# [update]
|
346
|
-
#
|
347
|
-
# [addmedia]
|
348
|
-
#
|
349
|
-
# [deletemedia]
|
350
|
-
#
|
351
|
-
# [updatemedia]
|
352
|
-
# [delete] Implemented, checking of input values needed
|
353
|
-
#
|
354
|
-
# All functions expect a hash of options to add.
|
355
|
-
# If multiple users need to be manipulated it must be broken out into different calls
|
356
|
-
|
357
|
-
class ZbxAPI_User < ZbxAPI_Sub
|
358
|
-
def get(options={})
|
359
|
-
checkauth
|
360
|
-
checkversion(1,1)
|
361
|
-
|
362
|
-
obj=do_request(json_obj('user.get',options))
|
363
|
-
return obj['result']
|
364
|
-
end
|
365
|
-
|
366
|
-
def getid(username)
|
367
|
-
raise ZbxAPI_ExceptionArgumentError, "String argument expected" if username.class != String
|
368
|
-
|
369
|
-
checkauth
|
370
|
-
checkversion(1,1)
|
371
|
-
|
372
|
-
obj=do_request(json_obj('user.getid',{'alias'=>username}))
|
373
|
-
return obj['result']
|
374
|
-
end
|
375
|
-
|
376
|
-
def create(options)
|
377
|
-
checkauth
|
378
|
-
checkversion(1,1)
|
379
|
-
|
380
|
-
#Check input parameters
|
381
|
-
|
382
|
-
raise ZbxAPI_ParameterError, "Missing 'name' argument", "User.create" if options["name"].nil?
|
383
|
-
raise ZbxAPI_ParameterError, "Missing 'alias' argument", "User.create" if options["alias"].nil?
|
384
|
-
raise ZbxAPI_ParameterError, "Missing 'passwd' argument", "User.create" if options["passwd"].nil?
|
385
|
-
|
386
|
-
obj=do_request(json_obj('user.create',options))
|
387
|
-
return obj['result']
|
388
|
-
end
|
389
|
-
|
390
|
-
# Alias function name for code written to work against 1.0 API
|
391
|
-
# may be removed in future versions
|
392
|
-
|
393
|
-
def add(options)
|
394
|
-
puts "WARNING API Function User.add is deprecated and will be removed in the future without further warning"
|
395
|
-
create(options)
|
396
|
-
end
|
397
|
-
|
398
|
-
def delete(userid)
|
399
|
-
checkauth
|
400
|
-
checkversion(1,1)
|
401
|
-
|
402
|
-
obj=do_request(json_obj('user.delete',[userid]))
|
403
|
-
return obj['result']
|
404
|
-
end
|
405
|
-
|
406
|
-
def update(options)
|
407
|
-
checkauth
|
408
|
-
checkversion(1,1)
|
409
|
-
|
410
|
-
obj=do_request(json_obj('user.update',options))
|
411
|
-
return obj['result']
|
412
|
-
end
|
413
|
-
|
414
|
-
# addmedia expects a hash of the following variables
|
415
|
-
# userid, mediatypeid, sendto, severity, active, period
|
416
|
-
def addmedia(options)
|
417
|
-
debug(8, "User.addmedia Start")
|
418
|
-
checkauth
|
419
|
-
checkversion(1,1)
|
420
|
-
|
421
|
-
# p options
|
422
|
-
|
423
|
-
raise ZbxAPI_ParameterError, "Missing 'userid' argument", "User.addmedia" if options["userid"].nil?
|
424
|
-
raise ZbxAPI_ParameterError, "Missing 'mediatypeid' argument", "User.addmedia" if options["mediatypeid"].nil?
|
425
|
-
raise ZbxAPI_ParameterError, "Missing 'severity' argument", "User.addmedia" if options["severity"].nil?
|
426
|
-
raise ZbxAPI_ParameterError, "Missing 'active' argument", "User.addmedia" if options["active"].nil?
|
427
|
-
raise ZbxAPI_ParameterError, "Missing 'period' argument", "User.addmedia" if options["period"].nil?
|
428
|
-
|
429
|
-
args = {}
|
430
|
-
args["userid"]=options["userid"]
|
431
|
-
args["medias"]={}
|
432
|
-
args["medias"]["mediatypeid"]=options["mediatypeid"]
|
433
|
-
args["medias"]["sendto"]=options["sendto"]
|
434
|
-
args["medias"]["severity"]=options["severity"]
|
435
|
-
args["medias"]["active"]=options["active"]
|
436
|
-
args["medias"]["period"]=options["period"]
|
437
|
-
|
438
|
-
# p args
|
439
|
-
|
440
|
-
obj=do_request(json_obj('user.addMedia',args))
|
441
|
-
return obj['result']
|
442
|
-
end
|
443
|
-
end
|
444
|
-
|
445
|
-
#******************************************************************************
|
446
|
-
#
|
447
|
-
# Class ZbxAPI_Host
|
448
|
-
#
|
449
|
-
# Class encapsulating Host and template functions
|
450
|
-
#
|
451
|
-
# API Function Status
|
452
|
-
# get Basic function implemented
|
453
|
-
# getid
|
454
|
-
# create Basic function implemented 20091020
|
455
|
-
# update
|
456
|
-
# massupdate
|
457
|
-
# delete Implimented
|
458
|
-
#
|
459
|
-
# template.create implemented as host.create_template
|
460
|
-
# template.get implemented as host.get_template
|
461
|
-
# template.delete implemented as host.delete_template
|
462
|
-
#
|
463
|
-
#******************************************************************************
|
464
|
-
|
465
|
-
class ZbxAPI_Host < ZbxAPI_Sub
|
466
|
-
def get(options={})
|
467
|
-
checkauth
|
468
|
-
checkversion(1,1)
|
469
|
-
|
470
|
-
obj=do_request(json_obj('host.get',options))
|
471
|
-
obj['result']
|
472
|
-
end
|
473
|
-
|
474
|
-
def get_template(options={})
|
475
|
-
checkauth
|
476
|
-
checkversion(1,3)
|
477
|
-
|
478
|
-
obj=do_request(json_obj('template.get',options))
|
479
|
-
obj['result']
|
480
|
-
end
|
481
|
-
|
482
|
-
def create(options={})
|
483
|
-
checkauth
|
484
|
-
checkversion(1,1)
|
485
|
-
|
486
|
-
obj=do_request(json_obj('host.create',options))
|
487
|
-
obj['result']
|
488
|
-
end
|
489
|
-
|
490
|
-
def create_template(options={})
|
491
|
-
checkauth
|
492
|
-
checkversion(1,3)
|
493
|
-
|
494
|
-
obj=do_request(json_obj('template.create',options))
|
495
|
-
obj['result']
|
496
|
-
end
|
497
|
-
|
498
|
-
# http://www.zabbix.com/documentation/1.8/api/objects/host#hostdelete
|
499
|
-
#Accepts a single host id or an array of host id's to be deleted
|
500
|
-
def delete(ids)
|
501
|
-
checkauth
|
502
|
-
checkversion(1,3)
|
503
|
-
|
504
|
-
obj=do_request(json_obj('host.delete',delete_helper("hostid",ids)))
|
505
|
-
obj['result']
|
506
|
-
end
|
507
|
-
|
508
|
-
def delete_template(ids)
|
509
|
-
checkauth
|
510
|
-
checkversion(1,3)
|
511
|
-
|
512
|
-
obj=do_request(json_obj('template.delete',delete_helper("templateid",ids)))
|
513
|
-
obj['result']
|
514
|
-
end
|
515
|
-
|
516
|
-
private
|
517
|
-
|
518
|
-
def delete_helper(id_type,ids)
|
519
|
-
if ids.class==Fixnum
|
520
|
-
ids=[ids]
|
521
|
-
elsif ids.class==Array
|
522
|
-
ids=ids
|
523
|
-
else
|
524
|
-
raise ZbxAPI_ParameterError, "ids parameter must be number or array"
|
525
|
-
end
|
526
|
-
|
527
|
-
ids.map do |id|
|
528
|
-
{id_type=>id}
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
end
|
533
|
-
|
534
|
-
#******************************************************************************
|
535
|
-
#
|
536
|
-
# Class ZbxAPI_Item
|
537
|
-
#
|
538
|
-
# Class encapsulating Item functions
|
539
|
-
#
|
540
|
-
# API Function Status
|
541
|
-
# get Basic Function working
|
542
|
-
# getid Function implemented
|
543
|
-
# create Function implemented
|
544
|
-
# update
|
545
|
-
# delete Function implemented - need to add type checking to input
|
546
|
-
#
|
547
|
-
#******************************************************************************
|
548
|
-
|
549
|
-
class ZbxAPI_Item < ZbxAPI_Sub
|
550
|
-
def get(options={})
|
551
|
-
checkauth
|
552
|
-
checkversion(1,1)
|
553
|
-
|
554
|
-
obj=do_request(json_obj('item.get',options))
|
555
|
-
return obj['result']
|
556
|
-
end
|
557
|
-
|
558
|
-
def getid(options)
|
559
|
-
checkauth
|
560
|
-
checkversion(1,1)
|
561
|
-
|
562
|
-
obj=do_request(json_obj('item.getid', options))
|
563
|
-
return obj['result']
|
564
|
-
end
|
565
|
-
|
566
|
-
def create(options)
|
567
|
-
debug(8,options)
|
568
|
-
checkauth
|
569
|
-
checkversion(1,1)
|
570
|
-
|
571
|
-
obj=do_request(json_obj('item.create', options))
|
572
|
-
return obj['result']
|
573
|
-
end
|
574
|
-
|
575
|
-
# Alias function for code written against 1.0 API
|
576
|
-
def add(options)
|
577
|
-
puts "WARNING API Function Item.add is deprecated and will be removed in the future without further warning"
|
578
|
-
create(options)
|
579
|
-
end
|
580
|
-
|
581
|
-
def delete(ids)
|
582
|
-
checkauth
|
583
|
-
checkversion(1,1)
|
584
|
-
|
585
|
-
obj=do_request(json_obj('item.delete', ids))
|
586
|
-
return obj['result']
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
#******************************************************************************
|
591
|
-
#
|
592
|
-
# Class ZbxAPI_UserGroup
|
593
|
-
#
|
594
|
-
# Class encapsulating User Group functions
|
595
|
-
#
|
596
|
-
# API Function Status
|
597
|
-
# get Basic function implemented
|
598
|
-
# getid
|
599
|
-
# create
|
600
|
-
# update
|
601
|
-
# updaterights
|
602
|
-
# addrights
|
603
|
-
# addusers
|
604
|
-
# removeusers
|
605
|
-
# delete
|
606
|
-
#
|
607
|
-
#******************************************************************************
|
608
|
-
|
609
|
-
class ZbxAPI_UserGroup < ZbxAPI_Sub
|
610
|
-
def get(options={})
|
611
|
-
checkauth
|
612
|
-
checkversion(1,1)
|
613
|
-
|
614
|
-
obj=do_request(json_obj('usergroup.get',options))
|
615
|
-
return obj['result']
|
616
|
-
end
|
617
|
-
end
|
618
|
-
|
619
|
-
#******************************************************************************
|
620
|
-
#
|
621
|
-
# Class ZbxAPI_HostGroup
|
622
|
-
#
|
623
|
-
# Class encapsulating User Group functions
|
624
|
-
#
|
625
|
-
# API Function Status
|
626
|
-
# get Basic function implemented
|
627
|
-
# getid
|
628
|
-
# create
|
629
|
-
# update
|
630
|
-
# delete
|
631
|
-
# addhosts
|
632
|
-
# removehost
|
633
|
-
# addgroupstohost
|
634
|
-
# updategroupstohost
|
635
|
-
#
|
636
|
-
#******************************************************************************
|
637
|
-
|
638
|
-
class ZbxAPI_HostGroup < ZbxAPI_Sub
|
639
|
-
def create(options={})
|
640
|
-
debug(8, "HostGroup.create Start")
|
641
|
-
checkauth
|
642
|
-
checkversion(1,1)
|
643
|
-
|
644
|
-
obj=do_request(json_obj('hostgroup.create',options))
|
645
|
-
return obj['result']
|
646
|
-
end
|
647
|
-
|
648
|
-
# alias function for code written against 1.0 API
|
649
|
-
def add(options={})
|
650
|
-
puts "WARNING API Function HostGroup.add is deprecated and will be removed in the future without further warning"
|
651
|
-
create(options)
|
652
|
-
end
|
653
|
-
|
654
|
-
def get(options={})
|
655
|
-
debug(8, "HostGroup.get Start")
|
656
|
-
checkauth
|
657
|
-
checkversion(1,1)
|
658
|
-
|
659
|
-
obj=do_request(json_obj('hostgroup.get',options))
|
660
|
-
return obj['result']
|
661
|
-
end
|
662
|
-
|
663
|
-
def getId(name)
|
664
|
-
puts "WARNING API Function HostGroup.getId is deprecated and will be removed in the future without further warning"
|
665
|
-
getObjects(name)
|
666
|
-
end
|
667
|
-
|
668
|
-
def getObjects(name)
|
669
|
-
debug(8, "HostGroup.getId Start")
|
670
|
-
checkauth
|
671
|
-
checkversion(1,1)
|
672
|
-
|
673
|
-
begin
|
674
|
-
if name.class==String
|
675
|
-
do_request(json_obj('hostgroup.getObjects',{"name"=>name}))['result']
|
676
|
-
elsif name.class==Array
|
677
|
-
valid = name.map {|item| item.class==String ? nil : false} # create a validation array of nils or false
|
678
|
-
valid.compact! # remove nils
|
679
|
-
raise ZbxAPI_ParameterError, "Expected a string or an array of strings" if !valid.empty?
|
680
|
-
|
681
|
-
results=[]
|
682
|
-
name.each do |item|
|
683
|
-
response=do_request(json_obj('hostgroup.getObjects',{"name"=>item}))
|
684
|
-
response['result'].each {|result| results << result } # Just in case the server returns an array
|
685
|
-
end
|
686
|
-
results
|
687
|
-
else
|
688
|
-
raise ZbxAPI_ParameterError, "Expected a string or an array of strings"
|
689
|
-
end
|
690
|
-
rescue ZbxAPI_GeneralError => e
|
691
|
-
if e.message["code"]==-32602
|
692
|
-
return 0
|
693
|
-
else
|
694
|
-
raise e
|
695
|
-
end
|
696
|
-
end
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
#******************************************************************************
|
701
|
-
|
702
|
-
#
|
703
|
-
# Class ZbxAPI_Application
|
704
|
-
#
|
705
|
-
# Class encapsulating application functions
|
706
|
-
#
|
707
|
-
# API Function Status
|
708
|
-
# get Not implemented
|
709
|
-
# getById Implemented
|
710
|
-
# getId Not implemented
|
711
|
-
# create Not implemented
|
712
|
-
# update Not implemented
|
713
|
-
# delete Not implemented
|
714
|
-
#
|
715
|
-
#******************************************************************************
|
716
|
-
|
717
|
-
|
718
|
-
class ZbxAPI_Application < ZbxAPI_Sub
|
719
|
-
def get(options={})
|
720
|
-
debug(8, "Application.get Start")
|
721
|
-
checkauth
|
722
|
-
checkversion(1,1)
|
723
|
-
|
724
|
-
obj=do_request(json_obj('application.get',options))
|
725
|
-
return obj['result']
|
726
|
-
end
|
727
|
-
|
728
|
-
def create(options={})
|
729
|
-
debug(8, "Application.create Start")
|
730
|
-
checkauth
|
731
|
-
checkversion(1,1)
|
732
|
-
|
733
|
-
obj=do_request(json_obj('application.create',options))
|
734
|
-
return obj['result']
|
735
|
-
end
|
736
|
-
|
737
|
-
# Alias function for code written against 1.0 API
|
738
|
-
def add(options={})
|
739
|
-
puts "WARNING API Function Application.add is deprecated and will be removed in the future without further warning"
|
740
|
-
create(options)
|
741
|
-
end
|
742
|
-
|
743
|
-
def getid(options={})
|
744
|
-
debug(8, "Application.getid Start")
|
745
|
-
checkauth
|
746
|
-
checkversion(1,1)
|
747
|
-
|
748
|
-
begin
|
749
|
-
obj=do_request(json_obj('application.getid',options))
|
750
|
-
rescue ZbxAPI_GeneralError => e
|
751
|
-
if e.message["code"]==-32400
|
752
|
-
return 0
|
753
|
-
else
|
754
|
-
raise e
|
755
|
-
end
|
756
|
-
end
|
757
|
-
return obj['result']
|
758
|
-
end
|
759
|
-
end
|
760
|
-
|
761
|
-
#******************************************************************************
|
762
|
-
#
|
763
|
-
# Class ZbxAPI_Trigger
|
764
|
-
#
|
765
|
-
# Class encapsulating trigger functions
|
766
|
-
#
|
767
|
-
# get Implemented
|
768
|
-
# getById Not implemented
|
769
|
-
# getId Not implemented
|
770
|
-
# create Implemented
|
771
|
-
# update Not implemented
|
772
|
-
# delete Not implemented
|
773
|
-
# addDependency Not implemented
|
774
|
-
#
|
775
|
-
#******************************************************************************
|
776
|
-
|
777
|
-
|
778
|
-
class ZbxAPI_Trigger < ZbxAPI_Sub
|
779
|
-
def get(options={})
|
780
|
-
debug(8, "Trigger.get Start")
|
781
|
-
checkauth
|
782
|
-
checkversion(1,1)
|
783
|
-
|
784
|
-
obj=do_request(json_obj('trigger.get',options))
|
785
|
-
return obj['result']
|
786
|
-
end
|
787
|
-
|
788
|
-
# Function name changed to reflect 1.1 API changes
|
789
|
-
def create(options={})
|
790
|
-
debug(8, "Trigger.create Start")
|
791
|
-
checkauth
|
792
|
-
checkversion(1,1)
|
793
|
-
|
794
|
-
obj=do_request(json_obj('trigger.create',options))
|
795
|
-
return obj['result']
|
796
|
-
end
|
797
|
-
|
798
|
-
# Alias function for code written against 1.0 api
|
799
|
-
def add(options={})
|
800
|
-
puts "WARNING API Function Trigger.add is deprecated and will be removed in the future without further warning"
|
801
|
-
create(options)
|
802
|
-
end
|
803
|
-
end
|
804
|
-
|
805
|
-
#******************************************************************************
|
806
|
-
#
|
807
|
-
# Class ZbxAPI_Sysmap
|
808
|
-
#
|
809
|
-
# Class encapsulating sysmap functions
|
810
|
-
#
|
811
|
-
# get Not implemented
|
812
|
-
# cr eate Basic implementation
|
813
|
-
#
|
814
|
-
#******************************************************************************
|
815
|
-
|
816
|
-
class ZbxAPI_Sysmap < ZbxAPI_Sub
|
817
|
-
def create(options={})
|
818
|
-
debug(8, "Sysmap.create Start")
|
819
|
-
checkauth
|
820
|
-
checkversion(1,1)
|
821
|
-
|
822
|
-
obj=do_request(json_obj('map.create',options))
|
823
|
-
return obj['result']
|
824
|
-
end
|
825
|
-
|
826
|
-
# Alias function for code written against 1.0 API
|
827
|
-
def add(options={})
|
828
|
-
puts "WARNING API Function Sysmap.add is deprecated and will be removed in the future without further warning"
|
829
|
-
create(options)
|
830
|
-
end
|
831
|
-
|
832
|
-
def addelement(options={})
|
833
|
-
debug(8, "Sysmap.addelement Start")
|
834
|
-
checkauth
|
835
|
-
checkversion(1,1)
|
836
|
-
|
837
|
-
obj=do_request(json_obj('map.addelement',options))
|
838
|
-
return obj['result']
|
839
|
-
end
|
840
|
-
|
841
|
-
def addlink(options={})
|
842
|
-
debug(8, "Sysmap.addlink Start")
|
843
|
-
checkauth
|
844
|
-
checkversion(1,1)
|
845
|
-
|
846
|
-
obj=do_request(json_obj('map.addlink',options))
|
847
|
-
return obj['result']
|
848
|
-
end
|
849
|
-
|
850
|
-
def getseid(options={})
|
851
|
-
debug(8, "Sysmap.getseid Start")
|
852
|
-
checkauth
|
853
|
-
checkversion(1,1)
|
854
|
-
|
855
|
-
obj=do_request(json_obj('map.getseid',options))
|
856
|
-
return obj['result']
|
857
|
-
end
|
858
|
-
|
859
|
-
def addlinktrigger(options={})
|
860
|
-
debug(8, "Sysmap.addlinktrigger Start")
|
861
|
-
checkauth
|
862
|
-
checkversion(1,1)
|
863
|
-
|
864
|
-
obj=do_request(json_obj('map.addlinktrigger',options))
|
865
|
-
return obj['result']
|
866
|
-
end
|
867
|
-
end
|
868
|
-
|
869
|
-
#******************************************************************************
|
870
|
-
#
|
871
|
-
# Class ZbxAPI_History
|
872
|
-
#
|
873
|
-
# Class encapsulating history functions
|
874
|
-
#
|
875
|
-
# get
|
876
|
-
#
|
877
|
-
#******************************************************************************
|
878
|
-
|
879
|
-
class ZbxAPI_History
|
880
|
-
|
881
|
-
def initialize(server)
|
882
|
-
@server=server
|
883
|
-
end
|
884
|
-
|
885
|
-
#Get the history for an item.
|
886
|
-
# itemids is a required option
|
887
|
-
# example: get({"itemids"=>12345})
|
888
|
-
def get(options)
|
889
|
-
@server.checkauth
|
890
|
-
@server.checkversion(1,3)
|
891
|
-
|
892
|
-
raise ZbxAPI_ParameterError, "Missing 'itemid'", "History.get" if options["itemids"].nil?
|
893
|
-
|
894
|
-
p obj=@server.raw_api("history.get",options)
|
895
|
-
return obj['result']
|
896
|
-
end
|
897
|
-
|
898
|
-
end
|
899
|
-
|
900
|
-
|
901
315
|
#******************************************************************************
|
902
316
|
|
903
317
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zbxapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 605
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 291
|
10
|
+
version: 0.1.291
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- A. Nelson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-08 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|