zabcon 0.0.6 → 0.0.327

Sign up to get free protection for your applications and to get access to all the features.
data/libs/zabcon_core.rb CHANGED
@@ -20,65 +20,70 @@
20
20
 
21
21
  ##########################################
22
22
  # Subversion information
23
- # $Id: $
24
- # $Revision: 281 $
23
+ # $Id: zabcon_core.rb 325 2011-09-26 08:57:00Z nelsonab $
24
+ # $Revision: 325 $
25
25
  ##########################################
26
26
 
27
+ require 'libs/utility_items'
28
+ require 'libs/revision'
27
29
  require 'parseconfig'
28
30
  require 'ostruct'
29
31
  require 'rexml/document'
30
- require 'libs/zbxcliserver'
32
+ require 'libs/zabbix_server'
31
33
  require 'libs/printer'
32
- require 'libs/zdebug'
34
+ require 'zbxapi/zdebug'
33
35
  require 'libs/input'
34
36
  #require 'libs/defines'
35
37
  require 'libs/command_tree'
36
- require 'libs/argument_processor'
38
+ #require 'libs/argument_processor'
37
39
  require 'libs/command_help'
38
40
  require 'libs/zabcon_globals'
41
+ require 'libs/zabcon_commands'
42
+
39
43
 
40
44
 
41
45
  class ZabconCore
42
46
 
43
47
  include ZDebug
44
48
 
45
- def initialize()
46
- @env = EnvVars.instance # make it easier to call the global EnvVars singleton
47
49
 
50
+ def initialize()
48
51
  # This must be set first or the debug module will throw an error
49
- set_debug_level(@env["debug"])
52
+ set_debug_level(env["debug"])
50
53
 
51
- @env.register_notifier("debug",self.method(:set_debug_level))
52
- @env.register_notifier("api_debug",self.method(:set_debug_api_level))
54
+ env.register_notifier("debug",self.method(:set_debug_level))
55
+ env.register_notifier("api_debug",self.method(:set_debug_api_level))
53
56
 
54
- @server = nil
55
- @callbacks={}
56
57
  @printer=OutputPrinter.new
57
- @commands=nil
58
- @setvars={}
59
- debug(5,"Setting up help")
60
- @cmd_help=CommandHelp.new("english") # Setup help functions, determine default language to use
61
- debug(5,"Setting up ArgumentProcessor")
62
- @arg_processor=ArgumentProcessor.new # Need to instantiate for debug routines
63
-
64
- if !@env["server"].nil? and !@env["username"].nil? and !@env["password"].nil? then
65
- puts "Found valid login credentials, attempting login" if @env["echo"]
58
+ debug(5,:msg=>"Setting up help")
59
+ # @cmd_help=CommandHelp.new("english") # Setup help functions, determine default language to use
60
+ CommandHelp.setup("english")
61
+
62
+ #TODO Remove reference to ArgumentProcessor when new command objects in use
63
+ debug(5,:msg=>"Setting up ArgumentProcessor")
64
+ # @arg_processor=ArgumentProcessor.new # Need to instantiate for debug routines
65
+
66
+ if !env["server"].nil? and !env["username"].nil? and !env["password"].nil? then
67
+ puts "Found valid login credentials, attempting login" if env["echo"]
66
68
  begin
67
- do_login({:server=>@env["server"], :username=>@env["username"],:password=>@env["password"]})
69
+ ZabbixServer.instance.login
70
+
71
+ rescue ZbxAPI_ExceptionBadAuth => e
72
+ puts e.message
68
73
  rescue ZbxAPI_ExceptionLoginPermission
69
74
  puts "Error Invalid login or no API permissions."
70
75
  end
71
76
  end
72
77
 
73
- debug(5,"Setting up prompt")
78
+ debug(5,:msg=>"Setting up prompt")
74
79
  @debug_prompt=false
75
- if @env["have_tty"]
80
+ if env["have_tty"]
76
81
  prc=Proc.new do
77
82
  debug_part = @debug_prompt ? " #{debug_level}" : ""
78
- if @server.nil?
83
+ if !ZabbixServer.instance.connected?
79
84
  " #{debug_part}-> "
80
85
  else
81
- @server.login? ? " #{debug_part}+> " : " #{debug_part}-> "
86
+ ZabbixServer.instance.loggedin? ? " #{debug_part}+> " : " #{debug_part}-> "
82
87
  end
83
88
  end
84
89
  @input=Readline_Input.new
@@ -86,160 +91,117 @@ class ZabconCore
86
91
  else
87
92
  @input=STDIN_Input.new
88
93
  end
89
- debug(5,"Setup complete")
90
- end
91
94
 
92
- # Argument logged in is used to determine which set of commands to load. If loggedin is true then commands which
93
- # require a valid login are loaded
94
- def setupcommands(loggedin)
95
- debug(5,loggedin,"Starting setupcommands (loggedin)")
96
-
97
- @commands=Parser.new(@arg_processor.default)
98
-
99
- no_cmd=nil
100
- no_args=nil
101
- no_help=nil
102
- no_verify=nil
103
-
104
- login_required = lambda {
105
- debug(6,"Lambda 'login_required'")
106
- puts "Login required"
107
- }
108
-
109
- # parameters for insert: insert_path, command, commandproc, arguments=[], helpproc=nil, verify_func=nil, options
110
-
111
- # These commands do not require a valid login
112
- @commands.insert ["quit"], :exit
113
- @commands.insert ["exit"], :exit
114
- @commands.insert ["help"], :help,no_args,no_help,@arg_processor.help, :suppress_printer
115
-
116
- @commands.insert ["hisotry"], self.method(:do_history),no_args,no_help,no_verify,:suppress_printer
117
- @commands.insert ["info"], self.method(:do_info),no_args,no_help,no_verify,:suppress_printer
118
- @commands.insert ["load"], no_cmd,no_args,no_help,no_verify,:suppress_printer
119
- @commands.insert ["login"], self.method(:do_login),nil,nil,@arg_processor.method(:login), :suppress_printer
120
- @commands.insert ["load","config"], @env.method(:load_config),no_args,no_help,no_verify,:suppress_printer
121
- @commands.insert ["set","debug"], self.method(:set_debug),no_args,no_help,no_verify,:suppress_printer
122
- @commands.insert ["set","lines"], self.method(:set_lines),no_args,no_help,no_verify,:suppress_printer
123
- @commands.insert ["set","pause"], self.method(:set_pause),no_args,no_help,no_verify,:suppress_printer
124
- @commands.insert ["set","var"], self.method(:set_var), no_args, no_help, @arg_processor.method(:simple_processor),:suppress_printer
125
- @commands.insert ["set","env"], self.method(:set_env), no_args, no_help, @arg_processor.method(:simple_processor), :suppress_printer
126
- @commands.insert ["show","var"], self.method(:show_var), no_args, no_help, @arg_processor.default, :use_array_processor, :suppress_printer
127
- @commands.insert ["show","env"], self.method(:show_env), no_args, no_help, @arg_processor.default, :use_array_processor, :suppress_printer
128
- @commands.insert ["unset","var"], self.method(:unset_var), no_args, no_help, @arg_processor.default, :use_array_processor, :suppress_printer
129
-
130
-
131
- if loggedin then
132
- debug(5,"Inserting commands which require login")
133
- # This command tree is for a valid login
134
- @commands.insert ["get"], no_cmd, no_args, @cmd_help.method(:get)
135
- #Import commented out until fixed
136
- #@commands.insert ["import"], self.method(:do_import),no_args,@cmd_help.method(:import),@arg_processor.default,:not_empty, :use_array_processor, :num_args=>"==1"
137
-
138
- @commands.insert ["add","app"], @server.method(:addapp),no_args,no_help,no_verify
139
- @commands.insert ["add","app","id"], @server.method(:getappid),no_args,no_help,no_verify
140
- @commands.insert ["add","host"], @server.method(:addhost), no_args, @cmd_help.method(:add_host), @arg_processor.method(:add_host), :server => @server
141
- @commands.insert ["add","host","group"], @server.method(:addhostgroup),no_args,no_help,no_verify
142
- @commands.insert ["add","item"], @server.method(:additem), no_args, @cmd_help.method(:add_item), @arg_processor.method(:add_item)
143
- @commands.insert ["add","link"], @server.method(:addlink),no_args,no_help,no_verify
144
- @commands.insert ["add","link","trigger"], @server.method(:addlinktrigger),no_args,no_help,no_verify
145
- @commands.insert ["add","sysmap"], @server.method(:addsysmap),no_args,no_help,no_verify
146
- @commands.insert ["add","sysmap","element"], @server.method(:addelementtosysmap),no_args,no_help,no_verify
147
- @commands.insert ["add","trigger"], @server.method(:addtrigger),no_args,no_help,no_verify
148
- @commands.insert ["add","user"], @server.method(:adduser), no_args, @cmd_help.method(:add_user), @arg_processor.method(:add_user)
149
- @commands.insert ["add","user","media"], @server.method(:addusermedia),no_args,@cmd_help.method(:add_user_media),no_verify
150
-
151
- @commands.insert ["get","app"], @server.method(:getapp), no_args, no_help, @arg_processor.default_get
152
- @commands.insert ["get","host"], @server.method(:gethost), no_args, no_help, @arg_processor.default_get
153
- @commands.insert ["get","host","group"], @server.method(:gethostgroup), no_args, no_help, @arg_processor.default_get
154
- @commands.insert ["get","host","group","id"], @server.method(:gethostgroupid), no_args, no_help, @arg_processor.method(:get_group_id)
155
- @commands.insert ["get","item"], @server.method(:getitem),
156
- ['itemids','hostids','groupids', 'triggerids','applicationids','status','templated_items','editable','count','pattern','limit','order', 'show'],
157
- @cmd_help.method(:get_item), @arg_processor.default_get
158
- @commands.insert ["get","seid"], @server.method(:getseid), no_args, no_help, @arg_processor.default_get
159
- @commands.insert ["get","trigger"], @server.method(:gettrigger), no_args, no_help, @arg_processor.default_get
160
- @commands.insert ["get","user"], @server.method(:getuser),['show'], @cmd_help.method(:get_user), @arg_processor.method(:get_user)
161
-
162
- @commands.insert ["delete","user"], @server.method(:deleteuser), ['id'], @cmd_help.method(:delete_user), @arg_processor.method(:delete_user)
163
- @commands.insert ["delete","host"], @server.method(:deletehost), no_args, @cmd_help.method(:delete_host), @arg_processor.method(:delete_host)
164
- @commands.insert ["delete","item"], @server.method(:deleteitem), ['itemid'], @cmd_help.method(:delete_item), @arg_processor.default
165
-
166
- @commands.insert ["raw","api"], @server.method(:raw_api), no_args, @cmd_help.method(:raw_api), @arg_processor.method(:raw_api)
167
- @commands.insert ["raw","json"], @server.method(:raw_json), no_args, @cmd_help.method(:raw_json), @arg_processor.method(:raw_processor)
168
-
169
- @commands.insert ["update","user"], @server.method(:updateuser), no_args, no_help, no_verify
95
+ ###############################################################################
96
+ ###############################################################################
97
+ zabconcore=self
98
+ if @input.respond_to?(:history)
99
+ ZabconCommand.add_command "history" do
100
+ set_method do zabconcore.show_history end
101
+ set_help_tag :history
102
+ end
170
103
  else
171
- debug(5,"Inserting commands which do not require login")
172
- # This command tree is for no login
173
- @commands.insert ["add","app"], login_required,no_args,no_help
174
- @commands.insert ["add","app","id"], login_required,no_args,no_help
175
- @commands.insert ["add","host"], login_required, no_args, @cmd_help.method(:add_host)
176
- @commands.insert ["add","host","group"], login_required,no_args,no_help
177
- @commands.insert ["add","item"], login_required, no_args, no_help
178
- @commands.insert ["add","link"], login_required,no_args,no_help
179
- @commands.insert ["add","link","trigger"], login_required,no_args,no_help
180
- @commands.insert ["add","sysmap"], login_required,no_args,no_help
181
- @commands.insert ["add","sysmap","element"], login_required,no_args,no_help
182
- @commands.insert ["add","trigger"], login_required,no_args,no_help
183
- @commands.insert ["add","user"], login_required, no_args, @cmd_help.method(:add_user)
184
- @commands.insert ["add","user","media"], login_required,no_args,no_help
185
-
186
- @commands.insert ["get","app"], login_required, no_args, no_help
187
- @commands.insert ["get","host"], login_required, no_args, no_help
188
- @commands.insert ["get","host","group"], login_required, no_args, no_help
189
- @commands.insert ["get","host","group","id"], login_required, no_args, no_help
190
- @commands.insert ["get","item"], login_required, no_args, no_help
191
- @commands.insert ["get","seid"], login_required, no_args, no_help
192
- @commands.insert ["get","trigger"], login_required, no_args, no_help
193
- @commands.insert ["get","user"], login_required,no_args, @cmd_help.method(:get_user)
194
-
195
- @commands.insert ["delete","user"], login_required, no_args, @cmd_help.method(:delete_user)
196
- @commands.insert ["delete","host"], login_required, no_args, @cmd_help.method(:delete_host)
197
-
198
- @commands.insert ["update","user"], login_required, no_args, no_help
104
+ ZabconCommand.add_command "history" do
105
+ set_method do puts "History is not supported by your version of Ruby and ReadLine" end
106
+ set_help_tag :history
107
+ end
108
+ end
109
+ ###############################################################################
110
+ ###############################################################################
111
+
112
+ debug(5,:msg=>"Setting up custom commands")
113
+
114
+ if !env["custom_commands"].nil?
115
+ filename=nil
116
+ cmd_file=env["custom_commands"]
117
+ filename=File.exist?(cmd_file) && cmd_file
118
+ cmd_file=File::expand_path("~/#{env["custom_commands"]}")
119
+ filename=File.exist?(cmd_file) && cmd_file if filename.class!=String
120
+ if filename.class==String
121
+ puts "Loading custom commands from #{filename}" if env["echo"]
122
+ begin
123
+ load filename
124
+ rescue Exception=> e
125
+ puts "There was an error loading your custom commands"
126
+ p e
127
+ end
128
+ end
199
129
  end
130
+
131
+ debug(5,:msg=>"Setup complete")
200
132
  end
201
133
 
134
+ # #TODO The following method may need to be removed when new command object in use
135
+ # # Argument logged in is used to determine which set of commands to load. If loggedin is true then commands which
136
+ # # require a valid login are loaded
137
+ # def setupcommands(loggedin)
138
+ # debug(5,loggedin,"Starting setupcommands (loggedin)")
139
+ #
140
+ #
141
+ ## no_cmd=nil
142
+ ## no_args=nil
143
+ ## no_help=nil
144
+ ## no_verify=nil
145
+ #
146
+ # login_required = lambda {
147
+ # debug(6,"Lambda 'login_required'")
148
+ # puts "Login required"
149
+ # }
150
+ #
151
+ # # parameters for insert: insert_path, command, commandproc, arguments=[], helpproc=nil, verify_func=nil, options
152
+ #
153
+ # #Import commented out until fixed
154
+ # #@commands.insert ["import"], self.method(:do_import),no_args,@cmd_help.method(:import),@arg_processor.default,:not_empty, :use_array_processor, :num_args=>"==1"
155
+ #
156
+ # @commands.insert ["add","app","id"], @server.method(:getappid),no_args,no_help,no_verify
157
+ # @commands.insert ["add","link"], @server.method(:addlink),no_args,no_help,no_verify
158
+ # @commands.insert ["add","link","trigger"], @server.method(:addlinktrigger),no_args,no_help,no_verify
159
+ # @commands.insert ["add","sysmap"], @server.method(:addsysmap),no_args,no_help,no_verify
160
+ # @commands.insert ["add","sysmap","element"], @server.method(:addelementtosysmap),no_args,no_help,no_verify
161
+ # @commands.insert ["add","user","media"], @server.method(:addusermedia),no_args,@cmd_help.method(:add_user_media),no_verify
162
+ #
163
+ # @commands.insert ["get","host","group","id"], @server.method(:gethostgroupid), no_args, no_help, @arg_processor.method(:get_group_id)
164
+ # @commands.insert ["get","seid"], @server.method(:getseid), no_args, no_help, @arg_processor.default_get
165
+
202
166
  def start
203
- debug(5,"Entering main zabcon start routine")
204
- puts "Welcome to Zabcon." if @env["echo"]
205
- puts "Use the command 'help' to get help on commands" if @env["have_tty"] || @env["echo"]
167
+ debug(5,:msg=>"Entering main zabcon start routine")
168
+ puts "Welcome to Zabcon. Build Number: #{REVISION}" if env["echo"]
169
+ puts "Use the command 'help' to get help on commands" if env["have_tty"] || env["echo"]
206
170
 
207
- setupcommands(!@server.nil?) # If we don't have a valid server we're not logged in'
208
171
  begin
209
- while line=@input.get_line()
210
- line=@arg_processor.strip_comments(line) # use the argument processor's comment stripper'
211
- next if line.nil?
212
- next if line.strip.length==0 # don't bother parsing an empty line'
213
- debug(6, line, "Input from user")
214
-
215
- # this statement calls the command tree parser and sets up rhash
216
- # for later use and function calls
217
- rhash=@commands.parse(line, @setvars)
218
-
219
- debug(6, rhash, "Results from parse")
220
-
221
- next if rhash.nil?
222
- case rhash[:proc]
223
- when :exit
224
- break
225
- when :help
226
- @cmd_help.help(@commands,line)
227
- else
228
- if !rhash[:proc].nil?
229
- debug(4,rhash,"Calling function",250)
230
- results=rhash[:proc].call(rhash[:api_params])
231
- printing = rhash[:options].nil? ? true : rhash[:options][:suppress_printer].nil? ? true : false
232
- @printer.print(results,rhash[:show_params]) if !results.nil? if printing
233
- end
234
- end # case
235
-
236
- end # while
172
+ catch(:exit) do
173
+ while line=@input.get_line()
174
+ line=line.strip_comments
175
+ next if line.nil?
176
+ next if line.strip.length==0 # don't bother parsing an empty line'
177
+ debug(6, :var=>line, :msg=>"Input from user")
178
+
179
+ commands=ZabconExecuteContainer.new(line)
180
+ debug(8,:var=>commands,:msg=>"Commands tree")
181
+
182
+ commands.execute
183
+ @printer.print(commands.results,commands.show_params) if commands.print?
184
+
185
+ end # while
186
+ end #end catch
187
+ rescue CommandList::InvalidCommand => e
188
+ puts e.message
189
+ retry
190
+ rescue Command::ParameterError => e
191
+ puts e.message
192
+ retry
193
+ rescue ZabbixServer::ConnectionProblem => e
194
+ puts e.message
195
+ retry
237
196
  rescue ParseError => e #catch the base exception class
238
197
  e.show_message
239
198
  retry if e.retry?
240
199
  rescue ZbxAPI_ExceptionVersion => e
241
200
  puts e
242
201
  retry # We will allow for graceful recover from Version exceptions
202
+ rescue ZbxAPI_ExceptionBadAuth => e
203
+ puts e.message
204
+ retry
243
205
  rescue ZbxAPI_ExceptionLoginPermission
244
206
  puts "No login permissions"
245
207
  retry
@@ -255,7 +217,6 @@ class ZabconCore
255
217
  retry
256
218
  else
257
219
  e.show_message
258
- # ddputs "Error: #{e.message}"
259
220
  retry if e.retry?
260
221
  end
261
222
  rescue ZError => e
@@ -266,29 +227,37 @@ class ZabconCore
266
227
  puts "A fatal error occurred."
267
228
  end
268
229
  e.show_message
269
- # e.show_backtrace
270
230
  retry if e.retry?
271
231
  end #end of exception block
272
232
  end # def
273
233
 
274
234
  def getprompt
275
235
  debug_part = @debug_prompt ? " #{debug_level}" : ""
276
- if @server.nil?
277
- return " #{debug_part}-> "
278
- end
279
- return @server.login? ? " #{debug_part}+> " : " #{debug_part}-> "
280
- end
281
236
 
282
- def do_history(input)
283
- history = @input.history.to_a
284
- history.each_index do |index|
285
- puts "#{index}: #{history[index]}"
286
- end
237
+ return " #{debug_part}-> " if @server.nil?
238
+ @server.login? ? " #{debug_part}+> " : " #{debug_part}-> "
287
239
  end
288
240
 
289
- # set_debug is for the callback to set the debug level
290
- # todo
291
- # This command is now deprecated for "set env debug=n"
241
+ # def set_lines(input)
242
+ # @printer.sheight=input.keys[0].to_i
243
+ # end
244
+
245
+ # def set_pause(input)
246
+ # if input.nil? then
247
+ # puts "set pause requires either Off or On"
248
+ # return
249
+ # end
250
+ #
251
+ # if input.keys[0].upcase=="OFF"
252
+ # @printer.sheight=@printer.sheight.abs*(-1)
253
+ # elsif input.keys[0].upcase=="ON"
254
+ # @printer.sheight=@printer.sheight.abs
255
+ # else
256
+ # puts "set pause requires either Off or On"
257
+ # end
258
+ # @printer.sheight = 24 if @printer.sheight==0
259
+ # end
260
+
292
261
  def set_debug(input)
293
262
  if input["prompt"].nil? then
294
263
  puts "This command is deprecated, please use \"set env debug=n\""
@@ -303,146 +272,34 @@ class ZabconCore
303
272
  set_facility_debug_level(:api,value)
304
273
  end
305
274
 
306
- def set_lines(input)
307
- @printer.sheight=input.keys[0].to_i
308
- end
309
-
310
- def set_pause(input)
311
- if input.nil? then
312
- puts "set pause requires either Off or On"
313
- return
314
- end
315
-
316
- if input.keys[0].upcase=="OFF"
317
- @printer.sheight=@printer.sheight.abs*(-1)
318
- elsif input.keys[0].upcase=="ON"
319
- @printer.sheight=@printer.sheight.abs
320
- else
321
- puts "set pause requires either Off or On"
322
- end
323
- @printer.sheight = 24 if @printer.sheight==0
324
- end
325
-
326
- def set_var(input)
327
- debug(6,input)
328
- input.each {|key,val|
329
- GlobalVars.instance[key]=val
330
- puts "#{key} : #{val.inspect}"
331
- }
332
- end
333
-
334
- def show_var(input)
335
- if input.empty?
336
- if GlobalVars.instance.empty?
337
- puts "No variables defined"
338
- else
339
- GlobalVars.instance.each { |key,val|
340
- puts "#{key} : #{val.inspect}"
341
- }
342
- end
343
- else
344
- input.each { |item|
345
- if GlobalVars.instance[item].nil?
346
- puts "#{item} *** Not Defined ***"
347
- else
348
- puts "#{item} : #{GlobalVars.instance[item].inspect}"
349
- end
350
- }
351
- end
352
- end
353
-
354
- def unset_var(input)
355
- if input.empty?
356
- puts "No variables given to unset"
357
- else
358
- input.each {|item|
359
- if GlobalVars.instance[item].nil?
360
- puts "#{item} *** Not Defined ***"
361
- else
362
- GlobalVars.instance.delete(item)
363
- puts "#{item} Deleted"
364
- end
365
- }
366
- end
367
- end
368
-
369
- def set_env(input)
370
- input.each{|key,val|
371
- @env[key]=val
372
- puts "#{key} : #{val.inspect}"
373
- }
374
- end
375
-
376
- def show_env(input)
377
- if input.empty?
378
- if @env.empty?
379
- puts "No variables defined"
380
- else
381
- @env.each { |key,val|
382
- puts "#{key} : #{val.inspect}"
383
- }
384
- end
385
- else
386
- input.each { |item|
387
- if @env[item].nil?
388
- puts "#{item} *** Not Defined ***"
389
- else
390
- puts "#{item} : #{@env[item].inspect}"
391
- end
392
- }
393
- end
394
- end
395
-
396
- # Load a configuration stored in a file
397
- # many things can be passed in
398
- # 1) an OpenStruct list of command line parameters which will overload the parameters
399
- # stored in the file
400
- # 2) A Hash with a key :filename
401
- # 3) If nil or empty the class variable @conffile will be used
402
-
403
- def do_login(params)
404
- url = params[:server]
405
- username = params[:username]
406
- password = params[:password]
407
-
408
- begin
409
- @server = ZbxCliServer.new(url,username,password,debug_level)
410
- puts "#{url} connected" if @env["echo"]
411
- puts "API Version: #{@server.version}" if @env["echo"]
412
-
413
- setupcommands(true)
414
- return true
415
- rescue ZbxAPI_ExceptionBadAuth
416
- puts "Login error, incorrect login information"
417
- puts "Server: #{url} User: #{username} password: #{password}" # will need to remove password in later versions
418
- return false
419
- rescue ZbxAPI_ExceptionBadServerUrl
420
- puts "Login error, unable to connect to host or bad host name: '#{url}'"
421
- # rescue ZbxAPI_ExceptionConnectionRefused
422
- # puts "Server refused connection, is url correct?"
423
- end
424
- end
425
-
426
- def do_info(input)
427
- puts "Current settings"
428
- puts "Server"
429
- if @server.nil?
430
- puts "Not connected"
431
- else
432
- puts " Server Name: %s" % @server.server_url
433
- puts " Username: %-15s Password: %-12s" % [@server.user, Array.new(@server.password.length,'*')]
434
- end
435
- puts "Display"
436
- puts " Current screen length #{@env["sheight"]}"
437
- puts "Other"
438
- puts " Debug level %d" % @env["debug"]
439
- end
275
+ # def set_var(input)
276
+ # debug(6,input)
277
+ # input.each {|key,val|
278
+ # GlobalVars.instance[key]=val
279
+ # puts "#{key} : #{val.inspect}"
280
+ # }
281
+ # end
282
+
283
+ # def unset_var(input)
284
+ # if input.empty?
285
+ # puts "No variables given to unset"
286
+ # else
287
+ # input.each {|item|
288
+ # if GlobalVars.instance[item].nil?
289
+ # puts "#{item} *** Not Defined ***"
290
+ # else
291
+ # GlobalVars.instance.delete(item)
292
+ # puts "#{item} Deleted"
293
+ # end
294
+ # }
295
+ # end
296
+ # end
440
297
 
441
298
  #
442
299
  # Import config from an XML file:
443
300
  #
444
301
  def do_import(input)
445
- debug(5,input,"args")
302
+ debug(5,:var=>input,:msg=>"args")
446
303
 
447
304
  input=input[0]
448
305
 
@@ -725,5 +582,9 @@ class ZabconCore
725
582
 
726
583
  end # end do_import
727
584
 
585
+ ###############################################################################
586
+ ###############################################################################
587
+
588
+
728
589
  end #end class
729
590
 
@@ -18,8 +18,8 @@
18
18
 
19
19
  ##########################################
20
20
  # Subversion information
21
- # $Id: zabcon_exceptions.rb 272 2011-01-06 21:04:22Z nelsonab $
22
- # $Revision: 272 $
21
+ # $Id: zabcon_exceptions.rb 325 2011-09-26 08:57:00Z nelsonab $
22
+ # $Revision: 325 $
23
23
  ##########################################
24
24
 
25
25
  #------------------------------------------------------------------------------
@@ -30,8 +30,8 @@
30
30
  #
31
31
  #------------------------------------------------------------------------------
32
32
 
33
- require 'libs/zdebug'
34
- require 'libs/exceptions'
33
+ require 'zbxapi/zdebug'
34
+ require 'zbxapi/exceptions'
35
35
 
36
36
  #---------------------------------------------------------
37
37
  #These general exceptions are only used internally and are