gnms 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gnms might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/LICENSE +459 -0
  2. data/README +29 -0
  3. data/bin/gnms +11 -0
  4. data/gnms.gemspec +70 -0
  5. data/lib/cmd_parse.rb +747 -0
  6. data/lib/config_global.rb +414 -0
  7. data/lib/contact.rb +171 -0
  8. data/lib/external/crypt/blowfish-tables.rb +190 -0
  9. data/lib/external/crypt/blowfish.rb +110 -0
  10. data/lib/external/crypt/cbc.rb +123 -0
  11. data/lib/external/crypt/stringxor.rb +27 -0
  12. data/lib/external/fog.rb +41 -0
  13. data/lib/external/jjmx.rb +45 -0
  14. data/lib/external/sms.rb +282 -0
  15. data/lib/external/xmpp4r-simple.rb +497 -0
  16. data/lib/format.rb +85 -0
  17. data/lib/gnms.rb +329 -0
  18. data/lib/gui/about_window.rb +177 -0
  19. data/lib/gui/adddelnode.rb +799 -0
  20. data/lib/gui/base_window.rb +789 -0
  21. data/lib/gui/canvas_map.rb +498 -0
  22. data/lib/gui/charts/gruff.rb +51 -0
  23. data/lib/gui/color_macro.rb +145 -0
  24. data/lib/gui/config_window.rb +2151 -0
  25. data/lib/gui/custom_plugin_window.rb +90 -0
  26. data/lib/gui/debug_window.rb +46 -0
  27. data/lib/gui/event_window.rb +469 -0
  28. data/lib/gui/find_node_window.rb +438 -0
  29. data/lib/gui/help_window.rb +47 -0
  30. data/lib/gui/ipcalculator.rb +147 -0
  31. data/lib/gui/jmx_ref_window.rb +309 -0
  32. data/lib/gui/link_view.rb +46 -0
  33. data/lib/gui/mib_browser.rb +585 -0
  34. data/lib/gui/node_host_property.rb +3712 -0
  35. data/lib/gui/node_host_view.rb +270 -0
  36. data/lib/gui/node_network_property.rb +1059 -0
  37. data/lib/gui/node_network_view.rb +186 -0
  38. data/lib/gui/node_view.rb +672 -0
  39. data/lib/gui/oid_ref_window.rb +288 -0
  40. data/lib/gui/snmptrap_ref_window.rb +288 -0
  41. data/lib/gui/sub/account_frame.rb +196 -0
  42. data/lib/gui/sub/contact_frame.rb +519 -0
  43. data/lib/gui/syslog_ref_window.rb +288 -0
  44. data/lib/gui/treenode_window.rb +320 -0
  45. data/lib/gui/update_window.rb +124 -0
  46. data/lib/gui/widgets.rb +169 -0
  47. data/lib/gui/wmi_ref_window.rb +286 -0
  48. data/lib/interface.rb +16 -0
  49. data/lib/ipcalc.rb +266 -0
  50. data/lib/link.rb +45 -0
  51. data/lib/main.rb +1091 -0
  52. data/lib/monitor/client/custom/custom_monitoring.rb +40 -0
  53. data/lib/monitor/client/jmx/jmx_attr_monitoring.rb +36 -0
  54. data/lib/monitor/client/jmx/jmx_monitoring.rb +83 -0
  55. data/lib/monitor/client/jmx/jmx_ref.rb +114 -0
  56. data/lib/monitor/client/snmp/mibs/SNMPv2-MIB.txt +854 -0
  57. data/lib/monitor/client/snmp/mibs/SNMPv2-SMI.txt +344 -0
  58. data/lib/monitor/client/snmp/oid_ref.rb +141 -0
  59. data/lib/monitor/client/snmp/snmp.rb +178 -0
  60. data/lib/monitor/client/snmp/snmp_monitoring.rb +58 -0
  61. data/lib/monitor/client/wmi/wmi.rb +139 -0
  62. data/lib/monitor/client/wmi/wmi_monitoring.rb +60 -0
  63. data/lib/monitor/client/wmi/wmi_ref.rb +141 -0
  64. data/lib/monitor/custom_plugin.rb +50 -0
  65. data/lib/monitor/server/msg_buffer.rb +39 -0
  66. data/lib/monitor/server/snmp/snmptrap_analyzer.rb +81 -0
  67. data/lib/monitor/server/snmp/snmptrap_capture.rb +26 -0
  68. data/lib/monitor/server/snmp/snmptrap_monitoring.rb +32 -0
  69. data/lib/monitor/server/snmp/snmptrap_ref.rb +135 -0
  70. data/lib/monitor/server/snmp/snmptrap_server.rb +50 -0
  71. data/lib/monitor/server/syslog/syslog_analyzer.rb +141 -0
  72. data/lib/monitor/server/syslog/syslog_capture.rb +28 -0
  73. data/lib/monitor/server/syslog/syslog_monitoring.rb +32 -0
  74. data/lib/monitor/server/syslog/syslog_ref.rb +136 -0
  75. data/lib/monitor/server/syslog/syslog_server.rb +43 -0
  76. data/lib/node.rb +1020 -0
  77. data/lib/node_db.rb +2668 -0
  78. data/lib/node_host.rb +215 -0
  79. data/lib/node_listener.rb +639 -0
  80. data/lib/node_network.rb +269 -0
  81. data/lib/node_property.rb +39 -0
  82. data/lib/notify/alarm.rb +247 -0
  83. data/lib/notify/irc_bot.rb +167 -0
  84. data/lib/notify/xmpp_bot.rb +107 -0
  85. data/lib/service.rb +36 -0
  86. data/lib/version.rb +8 -0
  87. data/pixmap/bg/map_bg.jpg +0 -0
  88. data/pixmap/bg/map_bg2.jpg +0 -0
  89. data/pixmap/logo.jpg +0 -0
  90. data/pixmap/logo_icon.png +0 -0
  91. data/pixmap/os/3com.png +0 -0
  92. data/pixmap/os/aix.gif +0 -0
  93. data/pixmap/os/amiga.png +0 -0
  94. data/pixmap/os/beos.png +0 -0
  95. data/pixmap/os/cisco.png +0 -0
  96. data/pixmap/os/freebsd.png +0 -0
  97. data/pixmap/os/hp.png +0 -0
  98. data/pixmap/os/hurd.gif +0 -0
  99. data/pixmap/os/irix.gif +0 -0
  100. data/pixmap/os/linux.png +0 -0
  101. data/pixmap/os/mac.png +0 -0
  102. data/pixmap/os/netbsd.gif +0 -0
  103. data/pixmap/os/netware.png +0 -0
  104. data/pixmap/os/openbsd.png +0 -0
  105. data/pixmap/os/os2warp.gif +0 -0
  106. data/pixmap/os/qnx.gif +0 -0
  107. data/pixmap/os/sco.gif +0 -0
  108. data/pixmap/os/sgi.xpm +111 -0
  109. data/pixmap/os/solaris.gif +0 -0
  110. data/pixmap/os/unix.gif +0 -0
  111. data/pixmap/os/unknown.png +0 -0
  112. data/pixmap/os/vms.xpm +345 -0
  113. data/pixmap/os/windows.png +0 -0
  114. data/pixmap/type/cloud.png +0 -0
  115. data/pixmap/type/device.png +0 -0
  116. data/pixmap/type/firewall.png +0 -0
  117. data/pixmap/type/gateway.png +0 -0
  118. data/pixmap/type/home.png +0 -0
  119. data/pixmap/type/host.png +0 -0
  120. data/pixmap/type/network.png +0 -0
  121. data/pixmap/type/printer.png +0 -0
  122. data/pixmap/type/router.png +0 -0
  123. data/pixmap/type/server.png +0 -0
  124. data/pixmap/type/switch.png +0 -0
  125. data/pixmap/type/vm.png +0 -0
  126. data/plugins/Defaultme.rb +7 -0
  127. data/plugins/DnsCheck.rb +46 -0
  128. data/plugins/FooMonitor.rb +26 -0
  129. data/plugins/HttpVirtualHostMonitor.rb +43 -0
  130. data/plugins/MysqlShowStatusMonitor.rb +64 -0
  131. data/plugins/PgsqlPercentConnectionMonitor.rb +72 -0
  132. data/plugins/SshCpuLoadMonitor.rb +85 -0
  133. data/plugins/SshDiskMonitor.rb +69 -0
  134. data/plugins/SshFgtAvExpiredMonitor.rb +75 -0
  135. data/plugins/SshPercentUsedRamMonitor.rb +74 -0
  136. data/plugins/TelnetCpuLoadMonitor.rb +69 -0
  137. data/plugins/example1.rb +15 -0
  138. data/plugins/example2.rb +7 -0
  139. data/sound/beep.wav +0 -0
  140. metadata +378 -0
@@ -0,0 +1,414 @@
1
+
2
+ #we can't load it anymore in sub gui contact_frame
3
+ $ldap_library_missing=false
4
+ begin
5
+ require 'ldap'
6
+ rescue LoadError
7
+ $log.error("You have to install ldap ruby library to be able to fill contact automatically")
8
+ $ldap_library_missing=true
9
+ end
10
+
11
+ require "#{GNMSLIB}"+'/gui/config_window'
12
+ begin
13
+ require 'yaml'
14
+ rescue LoadError
15
+ $log.fatal("You must install yaml module for ruby")
16
+ exit()
17
+ end
18
+ require 'yaml/store'
19
+
20
+ class ConfigGlobal
21
+
22
+ DEFAULT_MAIL_SERVER = "localhost"
23
+ DEFAULT_MAIL_SERVER_PORT = "25"
24
+ DEFAULT_SOUND_FILE = "Just beep"
25
+
26
+ attr_reader :window
27
+ attr_reader :default_width, :default_height, :default_map, :show_label, :noshow_fqdn, :show_tooltips, :confirm_delete, :confirm_quit, :log_level
28
+ attr_reader :read_community, :write_community, :snmp_version, :snmp_port, :snmp_timeout, :snmp_retry, :mail_server_addr, :mail_server_port, :sms_device, :im_login, :im_password, :irc_server, :irc_port, :irc_channel
29
+ attr_accessor :level
30
+ attr_reader :broadcast_ping_state, :broadcast_ping_delay, :mac_state, :mac_delay, :mac_lock, :mac_manufacturer, :syslog_mon, :syslog_port, :snmptrap_mon, :snmptrap_port, :snmptrap_community
31
+ attr_reader :node_resolving, :node_resolving_delay
32
+ attr_reader :port_mon, :port_mon_delay, :snmp_mon, :snmp_mon_delay, :wmi_mon, :wmi_mon_delay, :custom_mon, :custom_mon_delay, :jmx_mon, :jmx_mon_delay
33
+ attr_reader :ping_path, :nmap_path, :ssh_path, :telnet_path, :browser_path, :vncviewer_path, :rdesktop_path, :xterm_path, :nmblookup_path, :xprobe_path, :wmic_path
34
+ attr_accessor :image_path, :bg_type
35
+ attr_reader :rgb, :label_text, :label_bg
36
+ attr_reader :auto_save_map, :auto_save_map_value, :mail_server, :im_daemon, :irc_daemon
37
+ attr_accessor :pixmap_size
38
+ attr_accessor :host_label_view, :host_icon_view, :network_label_view, :network_icon_view, :map_display_view
39
+ attr_accessor :nmap_vers
40
+ attr_accessor :mail_by_level, :sound_file_path_by_level, :script_name_by_level, :sms_num_by_level, :im_dest_by_level
41
+
42
+ #
43
+ # save configuration to file as INF format, refresh general value
44
+ # warning: deprecated
45
+ #
46
+ def save_config()
47
+
48
+ fic_tmp=Tempfile.new(File.basename(GLOBAL_CONF_FILE))
49
+
50
+ line_idx=0
51
+ File.readlines(GLOBAL_CONF_FILE).each{|line|
52
+ if line_idx == 1
53
+ fic_tmp.puts("#{get_map_width()}")
54
+ fic_tmp.puts("#{get_map_height()}")
55
+ fic_tmp.puts("#{$map}")
56
+ fic_tmp.puts("#{$config.host_label_view}")
57
+ fic_tmp.puts("#{$config.host_icon_view}")
58
+ fic_tmp.puts("#{$config.network_label_view}")
59
+ fic_tmp.puts("#{$config.network_icon_view}")
60
+ fic_tmp.puts("#{$config.map_display_view}")
61
+ end
62
+ #we rewrite all exept GENERAL paragrapher
63
+ if (line_idx == 0) || (line_idx > 8)
64
+ fic_tmp.print line
65
+ end
66
+ line_idx+=1
67
+ }
68
+ fic_tmp.close
69
+ if File.stat(fic_tmp.path).size?
70
+ #all seems good
71
+ FileUtils.move(fic_tmp.path, GLOBAL_CONF_FILE)
72
+ end
73
+
74
+ end
75
+
76
+ def read_config_yaml()
77
+
78
+ if FileTest.exist?(GLOBAL_CONF_FILE)
79
+ if !File.readable?(GLOBAL_CONF_FILE) or !File.writable?(GLOBAL_CONF_FILE)
80
+ $log.fatal("Wrong permission on #{GLOBAL_CONF_FILE} need read-write access")
81
+ exit()
82
+ end
83
+ begin
84
+ db = YAML::load_file(GLOBAL_CONF_FILE)
85
+ rescue Exception => msg
86
+ $log.fatal("Error reading configuration file #{GLOBAL_CONF_FILE}")
87
+ exit()
88
+ end
89
+
90
+ @default_width = db["general"]["default_width"]
91
+ @default_height = db["general"]["default_height"]
92
+ @default_map = db["general"]["default_map"]
93
+ @host_label_view = db["general"]["host_label_view"]
94
+ @host_icon_view = db["general"]["host_icon_view"]
95
+ @network_label_view = db["general"]["network_label_view"]
96
+ @network_icon_view = db["general"]["network_icon_view"]
97
+ @map_display_view = db["general"]["map_display_view"]
98
+ @show_label = db["general"]["show_label"]
99
+ @noshow_fqdn = db["general"]["noshow_fqdn"]
100
+ @show_tooltips = db["general"]["show_tooltips"]
101
+ @confirm_delete = db["general"]["confirm_delete"]
102
+ @confirm_quit = db["general"]["confirm_quit"]
103
+ @auto_save_map = db["general"]["auto_save_map"]
104
+ @auto_save_map_value = db["general"]["auto_save_map_value"]
105
+ @log_level = db["general"]["log_level"]
106
+ @mail_server = db["general"]["mail_server"]
107
+ @mail_server_addr = db["general"]["mail_server_addr"]
108
+ @mail_server_port = db["general"]["mail_server_port"]
109
+ @sms_device = db["general"]["sms_device"]
110
+ @im_daemon = db["general"]["im_daemon"]
111
+ @im_login = db["general"]["im_login"]
112
+ @im_password = blowfish_decode(Base64.decode64(db["general"]["im_password"]))
113
+ @irc_daemon = db["general"]["irc_daemon"]
114
+ @irc_server = db["general"]["irc_server"]
115
+ @irc_port = db["general"]["irc_port"]
116
+ @irc_channel = db["general"]["irc_channel"]
117
+
118
+ @read_community = db["snmp"]["read_community"]
119
+ @write_community = db["snmp"]["write_community"]
120
+ @snmp_version = db["snmp"]["snmp_version"]
121
+ @snmp_port = db["snmp"]["snmp_port"]
122
+ @snmp_timeout = db["snmp"]["snmp_timeout"]
123
+ @snmp_retry = db["snmp"]["snmp_retry"]
124
+
125
+ @level = db["notification"]["level"]
126
+ $level_alert_type = db["notification"]["level_alert_type"]
127
+ @mail_by_level = db["notification"]["mail"]
128
+ @sound_file_path_by_level = db["notification"]["sound_file_path"]
129
+ @script_name_by_level = db["notification"]["script_name"]
130
+ @sms_num_by_level = db["notification"]["sms_num"]
131
+ @im_dest_by_level = db["notification"]["im_dest"]
132
+
133
+ @broadcast_ping_state = db["scan"]["broadcast_ping"]["state"]
134
+ @broadcast_ping_delay = db["scan"]["broadcast_ping"]["delay"]
135
+ @mac_state = db["scan"]["mac"]["state"]
136
+ @mac_delay = db["scan"]["mac"]["delay"]
137
+ @mac_lock = db["scan"]["mac"]["lock"]
138
+ @mac_manufacturer = db["scan"]["mac"]["manufacturer"]
139
+ @node_resolving = db["scan"]["node_resolving"]["state"]
140
+ @node_resolving_delay = db["scan"]["node_resolving"]["delay"]
141
+ @port_mon = db["scan"]["port"]["state"]
142
+ @port_mon_delay = db["scan"]["port"]["delay"]
143
+ @snmp_mon = db["scan"]["snmp"]["state"]
144
+ @snmp_mon_delay = db["scan"]["snmp"]["delay"]
145
+ @wmi_mon = db["scan"]["wmi"]["state"]
146
+ @wmi_mon_delay = db["scan"]["wmi"]["delay"]
147
+ @custom_mon = db["scan"]["custom"]["state"]
148
+ @custom_mon_delay = db["scan"]["custom"]["delay"]
149
+ @jmx_mon = db["scan"]["jmx"]["state"]
150
+ @jmx_mon_delay = db["scan"]["jmx"]["delay"]
151
+ @syslog_mon = db["scan"]["syslog"]["state"]
152
+ @syslog_port = db["scan"]["syslog"]["port"]
153
+ @snmptrap_mon = db["scan"]["snmptrap"]["state"]
154
+ @snmptrap_port = db["scan"]["snmptrap"]["port"]
155
+ @snmptrap_community = db["scan"]["snmptrap"]["community"]
156
+
157
+ @ping_path = db["path"]["ping"]
158
+ @nmap_path = db["path"]["nmap"]
159
+ @ssh_path = db["path"]["ssh"]
160
+ @telnet_path = db["path"]["telnet"]
161
+ @browser_path = db["path"]["browser"]
162
+ @vncviewer_path = db["path"]["vncviewer"]
163
+ @rdesktop_path = db["path"]["rdesktop"]
164
+ @xterm_path = db["path"]["terminal"]
165
+ @nmblookup_path = db["path"]["nmblookup"]
166
+ @xprobe_path = db["path"]["xprobe"]
167
+ @wmic_path = db["path"]["wmic"]
168
+
169
+ @pixmap_size = db["colors"]["pixmap_size"]
170
+ @bg_type = db["colors"]["bg_type"]
171
+ @label_text = db["colors"]["label_text"]
172
+ @label_bg = db["colors"]["label_bg"]
173
+ @rgb = db["colors"]["rgb"]
174
+ @image_path = db["colors"]["image_path"]
175
+ else
176
+ init_config_var()
177
+ end
178
+ end
179
+
180
+ #
181
+ # save configuration to file as YAML format
182
+ #
183
+ def write_config_yaml()
184
+
185
+ fic_tmp=Tempfile.new(File.basename(GLOBAL_CONF_FILE))
186
+
187
+ general = {
188
+ 'default_width' => @default_width.to_i,
189
+ 'default_height' => @default_height.to_i,
190
+ 'default_map' => @default_map,
191
+ 'host_label_view' => @host_label_view,
192
+ 'host_icon_view' => @host_icon_view,
193
+ 'network_label_view' => @network_label_view,
194
+ 'network_icon_view' => @network_icon_view,
195
+ 'map_display_view' => @map_display_view,
196
+ 'show_label' => @show_label,
197
+ 'noshow_fqdn' => @noshow_fqdn,
198
+ 'show_tooltips' => @show_tooltips,
199
+ 'confirm_delete' => @confirm_delete,
200
+ 'confirm_quit' => @confirm_quit,
201
+ 'auto_save_map' => @auto_save_map,
202
+ 'auto_save_map_value' => @auto_save_map_value.to_i,
203
+ 'log_level' => @log_level,
204
+ 'mail_server' => @mail_server,
205
+ 'mail_server_addr' => @mail_server_addr,
206
+ 'mail_server_port' => @mail_server_port,
207
+ 'sms_device' => @sms_device,
208
+ 'im_daemon' => @im_daemon,
209
+ 'im_login' => @im_login,
210
+ 'im_password' => Base64.encode64(blowfish_encode(@im_password)),
211
+ 'irc_daemon' => @irc_daemon,
212
+ 'irc_server' => @irc_server,
213
+ 'irc_port' => @irc_port,
214
+ 'irc_channel' => @irc_channel
215
+ }
216
+ snmp = {
217
+ 'read_community' => @read_community,
218
+ 'write_community' => @write_community,
219
+ 'snmp_version' => @snmp_version,
220
+ 'snmp_port' => @snmp_port.to_i,
221
+ 'snmp_timeout' => @snmp_timeout.to_i,
222
+ 'snmp_retry' => @snmp_retry.to_i
223
+ }
224
+
225
+ notification = {
226
+ 'level' => @level,
227
+ 'level_alert_type' => $level_alert_type,
228
+ 'mail' => @mail_by_level,
229
+ 'sound_file_path' => @sound_file_path_by_level,
230
+ 'script_name' => @script_name_by_level,
231
+ 'sms_num' => @sms_num_by_level,
232
+ 'im_dest' => @im_dest_by_level
233
+ }
234
+
235
+ scan = {
236
+ 'broadcast_ping' => {
237
+ 'state' => @broadcast_ping_state,
238
+ 'delay' => @broadcast_ping_delay.to_i,
239
+ },
240
+ 'mac' => {
241
+ 'state' => @mac_state,
242
+ 'delay' => @mac_delay.to_i,
243
+ 'lock' => @mac_lock,
244
+ 'manufacturer' => {
245
+ 'state' => @mac_manufacturer
246
+ }
247
+ },
248
+ 'node_resolving' => {
249
+ 'state' => @node_resolving,
250
+ 'delay' => @node_resolving_delay.to_i
251
+ },
252
+ 'port' => {
253
+ 'state' => @port_mon,
254
+ 'delay' => @port_mon_delay.to_i
255
+ },
256
+ 'snmp' => {
257
+ 'state' => @snmp_mon,
258
+ 'delay' => @snmp_mon_delay.to_i
259
+ },
260
+ 'wmi' => {
261
+ 'state' => @wmi_mon,
262
+ 'delay' => @wmi_mon_delay.to_i
263
+ },
264
+
265
+ 'custom' => {
266
+ 'state' => @custom_mon,
267
+ 'delay' => @custom_mon_delay.to_i
268
+ },
269
+ 'jmx' => {
270
+ 'state' => @jmx_mon,
271
+ 'delay' => @jmx_mon_delay.to_i
272
+ },
273
+
274
+ 'syslog' => {
275
+ 'state' => @syslog_mon,
276
+ 'port' => @syslog_port.to_i
277
+ },
278
+ 'snmptrap' => {
279
+ 'state' => @snmptrap_mon,
280
+ 'port' => @snmptrap_port.to_i,
281
+ 'community' => @snmptrap_community
282
+ }
283
+ }
284
+
285
+ path = {
286
+ 'ping' => @ping_path,
287
+ 'nmap' => @nmap_path,
288
+ 'ssh' => @ssh_path,
289
+ 'telnet' => @telnet_path,
290
+ 'browser' => @browser_path,
291
+ 'vncviewer' => @vncviewer_path,
292
+ 'rdesktop' => @rdesktop_path,
293
+ 'terminal' => @xterm_path,
294
+ 'nmblookup' => @nmblookup_path,
295
+ 'xprobe' => @xprobe_path,
296
+ 'wmic' => @wmic_path
297
+ }
298
+
299
+ #keys = {}
300
+
301
+ colors = {
302
+ 'pixmap_size' => @pixmap_size,
303
+ 'bg_type' => @bg_type,
304
+ 'label_text' => @label_text,
305
+ 'label_bg' => @label_bg,
306
+ 'rgb' => @rgb,
307
+ 'image_path' => @image_path
308
+ }
309
+
310
+ YAML::dump(general)
311
+ YAML::dump(snmp)
312
+ YAML::dump(notification)
313
+ YAML::dump(scan)
314
+ YAML::dump(path)
315
+ #YAML::dump(keys)
316
+ YAML::dump(colors)
317
+
318
+ db = YAML::Store.new(fic_tmp.path)
319
+ db.transaction{
320
+ db['general'] = general
321
+ db['snmp'] = snmp
322
+ db['notification'] = notification
323
+ db['scan'] = scan
324
+ db['path'] = path
325
+ # db['keys'] = keys
326
+ db['colors'] = colors
327
+ }
328
+ if File.stat(fic_tmp.path).size?
329
+ FileUtils.move(fic_tmp.path, GLOBAL_CONF_FILE)
330
+ end
331
+ end
332
+
333
+ def init_config_var()
334
+ @host_label_view="dns_name"
335
+ @host_icon_view="type"
336
+ @network_label_view="ip"
337
+ @network_icon_view="type"
338
+ @map_display_view="User defined"
339
+ #map is set in mail
340
+ @show_label=true
341
+ @noshow_fqdn=false
342
+ @show_tooltips=false
343
+ @confirm_delete=true
344
+ @confirm_quit=true
345
+ @auto_save_map=false
346
+ @auto_save_map_value=60
347
+ @log_level="Info"
348
+ @pixmap_size=35
349
+ @bg_type="color"
350
+ #black
351
+ @label_text = [0, 0, 0]
352
+ #grey
353
+ @label_bg = [48251, 45824, 45824]
354
+ @rgb=[48251, 45824, 45824]
355
+ @mail_server=false
356
+ @im_daemon=false
357
+ @irc_daemon=false
358
+ end
359
+
360
+ def show()
361
+ @window.show()
362
+ end
363
+
364
+ def init_hash_conf_by_level(h)
365
+ for l in $LEVEL
366
+ h[l]= nil
367
+ end
368
+ end
369
+
370
+ def initialize ()
371
+ @label_text = [0, 0, 0]
372
+ grey = [48251, 45824, 45824]
373
+ @label_bg = grey
374
+ @rgb = grey
375
+ @image_path = "#{PIXMAP_PATH}/bg"
376
+ @bg_type = "color"
377
+ #set this for the first time we launch gnms
378
+ @port_mon_delay = "60"
379
+ @snmp_mon_delay = "60"
380
+ @wmi_mon_delay = "60"
381
+ @custom_mon_delay = "60"
382
+ @jmx_mon_delay = "60"
383
+ @broadcast_ping_delay = "300"
384
+ @node_resolving_delay = "120"
385
+ @mac_delay = "60"
386
+ @syslog_port="514"
387
+ @snmptrap_port="162"
388
+ @snmptrap_comunity="public"
389
+ @mail_server_addr="localhost"
390
+ @mail_server_port=25
391
+
392
+ #store mail recipient for each severity level
393
+ @mail_by_level = Hash.new
394
+ init_hash_conf_by_level(@mail_by_level)
395
+ #store sound path if one for each severity level
396
+ @sound_file_path_by_level = Hash.new
397
+ init_hash_conf_by_level(@sound_file_path_by_level)
398
+ @sms_num_by_level = Hash.new
399
+ init_hash_conf_by_level(@sms_num_by_level)
400
+ @im_dest_by_level = Hash.new
401
+ init_hash_conf_by_level(@im_dest_by_level)
402
+ @script_name_by_level = Hash.new
403
+ init_hash_conf_by_level(@script_name_by_level)
404
+
405
+ begin
406
+ @window=ConfigWindow.new(self)
407
+ rescue Exception => msg
408
+ raise msg
409
+ end
410
+
411
+ end
412
+
413
+
414
+ end
@@ -0,0 +1,171 @@
1
+ class Contact
2
+ attr_accessor :firstname, :lastname, :email, :phone, :mobile, :im, :pager, :title, :organization, :location, :note, :nb_use
3
+
4
+ #
5
+ # add a contact
6
+ #
7
+ def Contact::add_contact(firstname, lastname, email, phone, mobile, im, pager, title, organization, location, note)
8
+ if $contact["#{firstname}|#{lastname}"] == nil
9
+ $contact["#{firstname}|#{lastname}"] = Contact.new(firstname, lastname, email, phone, mobile, im, pager, title, organization, location, note)
10
+ return true
11
+ end
12
+ return false
13
+ end
14
+
15
+
16
+ #
17
+ # delete a contact
18
+ # return true is entry delete otherwise false
19
+ #
20
+ def Contact::del_contact(firstname, lastname)
21
+ if !Contact::used?(firstname,lastname)
22
+ $contact.delete("#{firstname}|#{lastname}")
23
+ return true
24
+ end
25
+ return false
26
+ end
27
+
28
+ #
29
+ # return contact's title
30
+ #
31
+ def Contact::get_contact_title(firstname, lastname)
32
+ if Contact::contact_exist?(firstname, lastname)
33
+ return $contact["#{firstname}|#{lastname}"].title
34
+ end
35
+ end
36
+
37
+ #
38
+ # return contact's organization
39
+ #
40
+ def Contact::get_contact_organization(firstname, lastname)
41
+ if Contact::contact_exist?(firstname, lastname)
42
+ return $contact["#{firstname}|#{lastname}"].organization
43
+ end
44
+ end
45
+
46
+ #
47
+ # return contact's email
48
+ #
49
+ def Contact::get_contact_email(firstname, lastname)
50
+ if Contact::contact_exist?(firstname, lastname)
51
+ return $contact["#{firstname}|#{lastname}"].email
52
+ end
53
+ end
54
+
55
+ #
56
+ # return contact's mobile
57
+ #
58
+ def Contact::get_contact_mobile(firstname, lastname)
59
+ if Contact::contact_exist?(firstname, lastname)
60
+ return $contact["#{firstname}|#{lastname}"].mobile
61
+ end
62
+ end
63
+
64
+ #
65
+ # return contact's im
66
+ #
67
+ def Contact::get_contact_im(firstname, lastname)
68
+ if Contact::contact_exist?(firstname, lastname)
69
+ return $contact["#{firstname}|#{lastname}"].im
70
+ end
71
+ end
72
+
73
+ #
74
+ # return a table of all contact
75
+ #
76
+ def get_contact_name()
77
+ name_t=[]
78
+ $contact.each_key {|name|
79
+ name_t.push name
80
+ }
81
+ return name_t
82
+ end
83
+
84
+ def Contact::set_title(firstname, lastname, title)
85
+ $contact["#{firstname}|#{lastname}"].title=title
86
+ end
87
+
88
+ def Contact::set_organization(firstname, lastname, organization)
89
+ $contact["#{firstname}|#{lastname}"].organization=organization
90
+ end
91
+
92
+
93
+ def Contact::set_email(firstname, lastname, email)
94
+ $contact["#{firstname}|#{lastname}"].email=email
95
+ end
96
+
97
+ def Contact::set_phone(firstname, lastname, phone)
98
+ $contact["#{firstname}|#{lastname}"].phone=phone
99
+ end
100
+
101
+ def Contact::set_mobile(firstname, lastname, mobile)
102
+ $contact["#{firstname}|#{lastname}"].mobile=mobile
103
+ end
104
+
105
+ def Contact::set_pager(firstname, lastname, pager)
106
+ $contact["#{firstname}|#{lastname}"].pager=pager
107
+ end
108
+
109
+ def Contact::set_im(firstname, lastname, im)
110
+ $contact["#{firstname}|#{lastname}"].im=im
111
+ end
112
+
113
+ def Contact::set_location(firstname, lastname, location)
114
+ $contact["#{firstname}|#{lastname}"].location=location
115
+ end
116
+
117
+ def Contact::set_note(firstname, lastname, note)
118
+ $contact["#{firstname}|#{lastname}"].note=note
119
+ end
120
+
121
+ #
122
+ # check if a contact is defined
123
+ #
124
+ def Contact::contact_exist?(firstname, lastname)
125
+ return $contact["#{firstname}|#{lastname}"] != nil
126
+ end
127
+
128
+ #
129
+ # return number of contact
130
+ #
131
+ def Contact::contact_nb_entry()
132
+ return $contact.size
133
+ end
134
+
135
+ ###############################################################
136
+
137
+ def initialize (fname, lname, email, phone, mobile, im, pager, title=nil, organization=nil, location=nil, note=nil)
138
+ #fnamelname have to be uniq
139
+ @firstname=fname
140
+ @lastname=lname
141
+ @email=email
142
+ @phone=phone
143
+ @mobile=mobile
144
+ @im=im
145
+ @pager=pager
146
+ @title=title
147
+ @organization=organization
148
+ @location=location
149
+ @note=note
150
+ @nb_use=0
151
+ end
152
+
153
+ def Contact::add_use(firstname, lastname)
154
+ $contact["#{firstname}|#{lastname}"].nb_use+=1
155
+ Contact::used?(firstname, lastname)
156
+ end
157
+
158
+ def Contact::del_use(firstname, lastname)
159
+ $contact["#{firstname}|#{lastname}"].nb_use-=1
160
+ Contact::used?(firstname, lastname)
161
+ end
162
+
163
+ def Contact::used?(firstname, lastname)
164
+ return $contact["#{firstname}|#{lastname}"].nb_use>0
165
+ end
166
+
167
+ def to_str()
168
+ print "Contact: ", @firstname, " ", @lastname, " ", @email, " ", @phone, " ", @mobile, " ", @im, " ", @pager, " ", @title, " ", @organization, " ", @location, " ", @note,"\n"
169
+ end
170
+
171
+ end #class