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.
- data/LICENSE +459 -0
- data/README +29 -0
- data/bin/gnms +11 -0
- data/gnms.gemspec +70 -0
- data/lib/cmd_parse.rb +747 -0
- data/lib/config_global.rb +414 -0
- data/lib/contact.rb +171 -0
- data/lib/external/crypt/blowfish-tables.rb +190 -0
- data/lib/external/crypt/blowfish.rb +110 -0
- data/lib/external/crypt/cbc.rb +123 -0
- data/lib/external/crypt/stringxor.rb +27 -0
- data/lib/external/fog.rb +41 -0
- data/lib/external/jjmx.rb +45 -0
- data/lib/external/sms.rb +282 -0
- data/lib/external/xmpp4r-simple.rb +497 -0
- data/lib/format.rb +85 -0
- data/lib/gnms.rb +329 -0
- data/lib/gui/about_window.rb +177 -0
- data/lib/gui/adddelnode.rb +799 -0
- data/lib/gui/base_window.rb +789 -0
- data/lib/gui/canvas_map.rb +498 -0
- data/lib/gui/charts/gruff.rb +51 -0
- data/lib/gui/color_macro.rb +145 -0
- data/lib/gui/config_window.rb +2151 -0
- data/lib/gui/custom_plugin_window.rb +90 -0
- data/lib/gui/debug_window.rb +46 -0
- data/lib/gui/event_window.rb +469 -0
- data/lib/gui/find_node_window.rb +438 -0
- data/lib/gui/help_window.rb +47 -0
- data/lib/gui/ipcalculator.rb +147 -0
- data/lib/gui/jmx_ref_window.rb +309 -0
- data/lib/gui/link_view.rb +46 -0
- data/lib/gui/mib_browser.rb +585 -0
- data/lib/gui/node_host_property.rb +3712 -0
- data/lib/gui/node_host_view.rb +270 -0
- data/lib/gui/node_network_property.rb +1059 -0
- data/lib/gui/node_network_view.rb +186 -0
- data/lib/gui/node_view.rb +672 -0
- data/lib/gui/oid_ref_window.rb +288 -0
- data/lib/gui/snmptrap_ref_window.rb +288 -0
- data/lib/gui/sub/account_frame.rb +196 -0
- data/lib/gui/sub/contact_frame.rb +519 -0
- data/lib/gui/syslog_ref_window.rb +288 -0
- data/lib/gui/treenode_window.rb +320 -0
- data/lib/gui/update_window.rb +124 -0
- data/lib/gui/widgets.rb +169 -0
- data/lib/gui/wmi_ref_window.rb +286 -0
- data/lib/interface.rb +16 -0
- data/lib/ipcalc.rb +266 -0
- data/lib/link.rb +45 -0
- data/lib/main.rb +1091 -0
- data/lib/monitor/client/custom/custom_monitoring.rb +40 -0
- data/lib/monitor/client/jmx/jmx_attr_monitoring.rb +36 -0
- data/lib/monitor/client/jmx/jmx_monitoring.rb +83 -0
- data/lib/monitor/client/jmx/jmx_ref.rb +114 -0
- data/lib/monitor/client/snmp/mibs/SNMPv2-MIB.txt +854 -0
- data/lib/monitor/client/snmp/mibs/SNMPv2-SMI.txt +344 -0
- data/lib/monitor/client/snmp/oid_ref.rb +141 -0
- data/lib/monitor/client/snmp/snmp.rb +178 -0
- data/lib/monitor/client/snmp/snmp_monitoring.rb +58 -0
- data/lib/monitor/client/wmi/wmi.rb +139 -0
- data/lib/monitor/client/wmi/wmi_monitoring.rb +60 -0
- data/lib/monitor/client/wmi/wmi_ref.rb +141 -0
- data/lib/monitor/custom_plugin.rb +50 -0
- data/lib/monitor/server/msg_buffer.rb +39 -0
- data/lib/monitor/server/snmp/snmptrap_analyzer.rb +81 -0
- data/lib/monitor/server/snmp/snmptrap_capture.rb +26 -0
- data/lib/monitor/server/snmp/snmptrap_monitoring.rb +32 -0
- data/lib/monitor/server/snmp/snmptrap_ref.rb +135 -0
- data/lib/monitor/server/snmp/snmptrap_server.rb +50 -0
- data/lib/monitor/server/syslog/syslog_analyzer.rb +141 -0
- data/lib/monitor/server/syslog/syslog_capture.rb +28 -0
- data/lib/monitor/server/syslog/syslog_monitoring.rb +32 -0
- data/lib/monitor/server/syslog/syslog_ref.rb +136 -0
- data/lib/monitor/server/syslog/syslog_server.rb +43 -0
- data/lib/node.rb +1020 -0
- data/lib/node_db.rb +2668 -0
- data/lib/node_host.rb +215 -0
- data/lib/node_listener.rb +639 -0
- data/lib/node_network.rb +269 -0
- data/lib/node_property.rb +39 -0
- data/lib/notify/alarm.rb +247 -0
- data/lib/notify/irc_bot.rb +167 -0
- data/lib/notify/xmpp_bot.rb +107 -0
- data/lib/service.rb +36 -0
- data/lib/version.rb +8 -0
- data/pixmap/bg/map_bg.jpg +0 -0
- data/pixmap/bg/map_bg2.jpg +0 -0
- data/pixmap/logo.jpg +0 -0
- data/pixmap/logo_icon.png +0 -0
- data/pixmap/os/3com.png +0 -0
- data/pixmap/os/aix.gif +0 -0
- data/pixmap/os/amiga.png +0 -0
- data/pixmap/os/beos.png +0 -0
- data/pixmap/os/cisco.png +0 -0
- data/pixmap/os/freebsd.png +0 -0
- data/pixmap/os/hp.png +0 -0
- data/pixmap/os/hurd.gif +0 -0
- data/pixmap/os/irix.gif +0 -0
- data/pixmap/os/linux.png +0 -0
- data/pixmap/os/mac.png +0 -0
- data/pixmap/os/netbsd.gif +0 -0
- data/pixmap/os/netware.png +0 -0
- data/pixmap/os/openbsd.png +0 -0
- data/pixmap/os/os2warp.gif +0 -0
- data/pixmap/os/qnx.gif +0 -0
- data/pixmap/os/sco.gif +0 -0
- data/pixmap/os/sgi.xpm +111 -0
- data/pixmap/os/solaris.gif +0 -0
- data/pixmap/os/unix.gif +0 -0
- data/pixmap/os/unknown.png +0 -0
- data/pixmap/os/vms.xpm +345 -0
- data/pixmap/os/windows.png +0 -0
- data/pixmap/type/cloud.png +0 -0
- data/pixmap/type/device.png +0 -0
- data/pixmap/type/firewall.png +0 -0
- data/pixmap/type/gateway.png +0 -0
- data/pixmap/type/home.png +0 -0
- data/pixmap/type/host.png +0 -0
- data/pixmap/type/network.png +0 -0
- data/pixmap/type/printer.png +0 -0
- data/pixmap/type/router.png +0 -0
- data/pixmap/type/server.png +0 -0
- data/pixmap/type/switch.png +0 -0
- data/pixmap/type/vm.png +0 -0
- data/plugins/Defaultme.rb +7 -0
- data/plugins/DnsCheck.rb +46 -0
- data/plugins/FooMonitor.rb +26 -0
- data/plugins/HttpVirtualHostMonitor.rb +43 -0
- data/plugins/MysqlShowStatusMonitor.rb +64 -0
- data/plugins/PgsqlPercentConnectionMonitor.rb +72 -0
- data/plugins/SshCpuLoadMonitor.rb +85 -0
- data/plugins/SshDiskMonitor.rb +69 -0
- data/plugins/SshFgtAvExpiredMonitor.rb +75 -0
- data/plugins/SshPercentUsedRamMonitor.rb +74 -0
- data/plugins/TelnetCpuLoadMonitor.rb +69 -0
- data/plugins/example1.rb +15 -0
- data/plugins/example2.rb +7 -0
- data/sound/beep.wav +0 -0
- metadata +378 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
class NodeHostView < NodeView
|
2
|
+
|
3
|
+
def set_type(typ)
|
4
|
+
points=nil
|
5
|
+
icon_x = @icon.x
|
6
|
+
icon_y = @icon.y
|
7
|
+
to_size=get_node_size()
|
8
|
+
case typ
|
9
|
+
when "printer"
|
10
|
+
#hexagone: device
|
11
|
+
points = [[to_size/6.0, 0], [5*to_size/6.0, 0], [to_size, to_size/2.0], [5*to_size/6.0, to_size ], [to_size/6.0, to_size], [0, to_size/2.0]]
|
12
|
+
when "router"
|
13
|
+
#losange
|
14
|
+
points = [[to_size/2.0, 0], [0, to_size/2.0], [to_size/2.0, to_size], [to_size, to_size/2.0] ]
|
15
|
+
when "firewall"
|
16
|
+
#losange
|
17
|
+
points = [[to_size/2.0, 0], [0, to_size/2.0], [to_size/2.0, to_size], [to_size, to_size/2.0] ]
|
18
|
+
when "switch"
|
19
|
+
#octogone
|
20
|
+
points = [[to_size/3.0, 0], [2*to_size/3.0, 0], [to_size, to_size/3.0], [to_size, 2*to_size/3.0], [2*to_size/3, to_size], [to_size/3.0, to_size], [0,2*to_size/3.0], [0, to_size/3.0]]
|
21
|
+
end
|
22
|
+
@icon.parent.remove_child(@icon)
|
23
|
+
if points != nil
|
24
|
+
@icon=Goo::CanvasPolyline.new(@group, true, points,
|
25
|
+
:fill_color_rgba => $status_color[$status_value.index(node.status)],
|
26
|
+
:stroke_color => "black",
|
27
|
+
:line_width => 1.0)
|
28
|
+
else
|
29
|
+
@icon=Goo::CanvasRect.new(@group, 0, 0,
|
30
|
+
to_size, to_size,
|
31
|
+
:fill_color_rgba => $status_color[$status_value.index(node.status)],
|
32
|
+
:stroke_color => "black",
|
33
|
+
:line_width => 1.0)
|
34
|
+
end
|
35
|
+
@icon.x = icon_x
|
36
|
+
@icon.y = icon_y
|
37
|
+
@icon.lower(nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_form(root, status, icon_file, label)
|
41
|
+
|
42
|
+
node_size = get_node_size()
|
43
|
+
@group = Goo::CanvasGroup.new(root,{:x => 0.0,:y => 0.0, :can_focus => true})
|
44
|
+
@group.visibility = Goo::CanvasItem::HIDDEN
|
45
|
+
@icon=Goo::CanvasRect.new(@group, node.x, node.y,
|
46
|
+
node_size, node_size,
|
47
|
+
:fill_color_rgba => status,
|
48
|
+
:stroke_color => "black",
|
49
|
+
:line_width => 1.0)
|
50
|
+
|
51
|
+
if (icon_file == nil) || (!FileTest.exist?(icon_file))
|
52
|
+
icon_file="#{PIXMAP_PATH}/os/unknown.png"
|
53
|
+
end
|
54
|
+
begin
|
55
|
+
im=Gdk::Pixbuf.new(icon_file, node_size, node_size)
|
56
|
+
rescue Exception => msg
|
57
|
+
$log.error("Image is corrupted #{msg}")
|
58
|
+
end
|
59
|
+
@image=Goo::CanvasImage.new(@group, im, @icon.x1, @icon.y1,
|
60
|
+
:width => node_size,
|
61
|
+
:height => node_size,
|
62
|
+
:scale_to_fit => true
|
63
|
+
)
|
64
|
+
@image.width=(node_size)*80/100.0
|
65
|
+
@image.height=(node_size)*80/100.0
|
66
|
+
|
67
|
+
@image.x = @icon.x1+(node_size/2.0)-@image.width/2.0
|
68
|
+
@image.y = @icon.y1+(node_size/2.0)-@image.height/2.0
|
69
|
+
|
70
|
+
if label == nil
|
71
|
+
label = ""
|
72
|
+
end
|
73
|
+
#this is the background box for the label
|
74
|
+
cl = Integer("0x#{rgb_to_hex_color(Gdk::Color.new($config.label_bg[0],$config.label_bg[1],$config.label_bg[2]))}ff")
|
75
|
+
@bg_text=Goo::CanvasRect.new(@group, @icon.x1-3*label.size/2, @icon.y2+node_size/5-5,
|
76
|
+
node_size+3*label.size,
|
77
|
+
node_size/5+5,
|
78
|
+
:fill_color_rgba => cl,
|
79
|
+
:stroke_color_rgba => cl,
|
80
|
+
:line_width => 1.0)
|
81
|
+
|
82
|
+
#this is the label
|
83
|
+
@text=Goo::CanvasText.new(@group, label, @icon.x1+node_size/2, @icon.y2+2+node_size/5, 0,
|
84
|
+
Gtk::ANCHOR_CENTER,
|
85
|
+
:fill_color_rgba => Integer("0x#{rgb_to_hex_color(Gdk::Color.new($config.label_text[0],$config.label_text[1],$config.label_text[2]))}ff"),
|
86
|
+
:font => "Sans 8"
|
87
|
+
)
|
88
|
+
|
89
|
+
#this is the notification icon
|
90
|
+
circle_size = NODE_SIZE/2.0
|
91
|
+
@notification_group = Goo::CanvasGroup.new(@group,{:x => @icon.x+NODE_SIZE-circle_size/2.0,
|
92
|
+
:y => @icon.y-circle_size/2.0})
|
93
|
+
@notification_bg = Goo::CanvasEllipse.new(@notification_group, circle_size/2.0, circle_size/2.0, circle_size/2.0, circle_size/2.0,
|
94
|
+
:fill_color_rgba => $status_color[$status_value.index(@notification_sev)],
|
95
|
+
:stroke_color => "white", :line_width => 2.0)
|
96
|
+
notification_count_total = @notification_count.inject(0, :+)
|
97
|
+
notification_text_label = notification_count_total >= 10 ? "*" : notification_count_total.to_s
|
98
|
+
@notification_text=Goo::CanvasText.new(@notification_group,
|
99
|
+
notification_text_label, circle_size/2.0, circle_size/2.0, 12, Gtk::ANCHOR_CENTER,
|
100
|
+
:fill_color => "white",
|
101
|
+
:font => "Sans 12 Bold"
|
102
|
+
)
|
103
|
+
|
104
|
+
show_notification_icon()
|
105
|
+
setup_item(@group)
|
106
|
+
|
107
|
+
#it s easier to change the canvas icon here based on the node type
|
108
|
+
if node.type != "host"
|
109
|
+
set_type(node.type)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def resize_notification_icon(sz)
|
114
|
+
@notification_text.x = sz/2.0
|
115
|
+
@notification_text.y = sz/2.0
|
116
|
+
@notification_bg.width = sz
|
117
|
+
@notification_bg.height = sz
|
118
|
+
end
|
119
|
+
|
120
|
+
def update_notification_icon()
|
121
|
+
notification_count_total = @notification_count.inject(0, :+)
|
122
|
+
@notification_text.text = notification_count_total >= 10 ? "*" : notification_count_total.to_s
|
123
|
+
@notification_bg.fill_color_rgba = $status_color[$status_value.index(@notification_sev)]
|
124
|
+
show_notification_icon()
|
125
|
+
end
|
126
|
+
|
127
|
+
def show_notification_icon()
|
128
|
+
if (@notification_count.inject(0, :+) < 2) or (@notification_sev < MINOR)
|
129
|
+
@notification_group.visibility = Goo::CanvasItem::INVISIBLE
|
130
|
+
else
|
131
|
+
@notification_group.visibility = Goo::CanvasItem::VISIBLE
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
#define a tooltip
|
136
|
+
def show_tooltips()
|
137
|
+
if @tooltips==nil
|
138
|
+
@tooltips=Gtk::Window.new(Gtk::Window::POPUP)
|
139
|
+
@tooltips.set_decorated(false)
|
140
|
+
@tooltips.set_size_request(-1,-1)
|
141
|
+
@tooltips.set_window_position(Gtk::Window::POS_NONE)
|
142
|
+
@tooltips.border_width=1
|
143
|
+
x,y=$win.position
|
144
|
+
@tooltips.move(node.x+x+50, node.y+y+40)
|
145
|
+
@tooltips.app_paintable=true
|
146
|
+
@tooltips.realize
|
147
|
+
drawable=@tooltips.window
|
148
|
+
gc = Gdk::GC.new(drawable)
|
149
|
+
|
150
|
+
#green = Gdk::Color.new(0, 65535, 0)
|
151
|
+
#colormap = Gdk::Colormap.system
|
152
|
+
#colormap.alloc_color(green, false, true)
|
153
|
+
|
154
|
+
@tooltips.modify_bg(Gtk::STATE_NORMAL,$light_yellow)
|
155
|
+
@tooltips.signal_connect("expose-event") do |win, evt|
|
156
|
+
tooltips_width, tooltips_height=@tooltips.size
|
157
|
+
|
158
|
+
drawable.draw_rectangle(gc,false, 0, 0, tooltips_width-1, tooltips_height-1)
|
159
|
+
drawable.draw_rectangle(gc,false, 1, 1, tooltips_width-3, tooltips_height-3)
|
160
|
+
false
|
161
|
+
|
162
|
+
end
|
163
|
+
vbox=Gtk::VBox.new
|
164
|
+
vbox.border_width=5
|
165
|
+
ttips_text="<span weight=\"bold\" size=\"small\">IP: </span>#{self.node.ip}"
|
166
|
+
ttips_text+="\n<span weight=\"bold\" size=\"small\">Mask: </span>#{self.node.netmask}"
|
167
|
+
if self.node.dns_name?
|
168
|
+
ttips_text+="\n<span weight=\"bold\" size=\"small\">Dns name: </span>#{self.node.dns_name}"
|
169
|
+
|
170
|
+
end
|
171
|
+
if self.node.description?() &&( self.node.description != "")
|
172
|
+
ttips_text+="\n<span weight=\"bold\" size=\"small\">Description: </span>#{self.node.description}"
|
173
|
+
end
|
174
|
+
label = Gtk::Label.new.set_markup(ttips_text)
|
175
|
+
label.set_alignment(0,0.5)
|
176
|
+
vbox.add label
|
177
|
+
|
178
|
+
if self.node.os && (self.node.os != "unknown")
|
179
|
+
tos=Gtk::Table.new(1,0,false)
|
180
|
+
vbox.add tos
|
181
|
+
label_os = Gtk::Label.new.set_markup("<span weight=\"bold\" size=\"small\">OS: </span>")
|
182
|
+
label_os.set_alignment(0,0.5)
|
183
|
+
label_os.show
|
184
|
+
tos.add label_os
|
185
|
+
begin
|
186
|
+
pxb = Gdk::Pixbuf.new(PIXMAP_PATH+"/#{find_extension("os/#{self.node.os}")}",20,20)
|
187
|
+
pxb_pixmap,pxb_mask=pxb.render_pixmap_and_mask(128)
|
188
|
+
img=Gtk::Image.new(pxb_pixmap,pxb_mask)
|
189
|
+
img.show
|
190
|
+
tos.attach(img,0,1,0,1, Gtk::FILL)
|
191
|
+
tos.show
|
192
|
+
rescue
|
193
|
+
#no os image
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
if self.node.type
|
199
|
+
ttype=Gtk::Table.new(1,0,false)
|
200
|
+
vbox.add ttype
|
201
|
+
label_type = Gtk::Label.new.set_markup("<span weight=\"bold\" size=\"small\">Type: </span>")
|
202
|
+
label_type.set_alignment(0,0.5)
|
203
|
+
label_type.show
|
204
|
+
ttype.add label_type
|
205
|
+
begin
|
206
|
+
pxb = Gdk::Pixbuf.new(PIXMAP_PATH+"/#{find_extension("type/#{self.node.type}")}",20,20)
|
207
|
+
pxb_pixmap,pxb_mask=pxb.render_pixmap_and_mask(128)
|
208
|
+
img=Gtk::Image.new(pxb_pixmap,pxb_mask)
|
209
|
+
img.show
|
210
|
+
ttype.attach(img,0,1,0,1, Gtk::FILL)
|
211
|
+
ttype.show
|
212
|
+
rescue
|
213
|
+
#no type image
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
sev_str=$status[$status_value.index(self.node.avail_sev)]
|
218
|
+
ttips_text_sev="<span weight=\"bold\" size=\"small\">Availability Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
219
|
+
sev_str=$status[$status_value.index(self.node.service_sev)]
|
220
|
+
ttips_text_sev="<span weight=\"bold\" size=\"small\">Service Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
221
|
+
sev_str=$status[$status_value.index(self.node.snmp_sev)]
|
222
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">SNMP Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
223
|
+
sev_str=$status[$status_value.index(self.node.wmi_sev)]
|
224
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">WMI Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
225
|
+
sev_str=$status[$status_value.index(self.node.jmx_sev)]
|
226
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">JMX Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
227
|
+
sev_str=$status[$status_value.index(self.node.custom_sev)]
|
228
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">Custom Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
229
|
+
sev_str=$status[$status_value.index(self.node.syslog_sev)]
|
230
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">Syslog Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
231
|
+
sev_str=$status[$status_value.index(self.node.trap_sev)]
|
232
|
+
ttips_text_sev+="\n<span weight=\"bold\" size=\"small\">Trap Severity: </span><span color=\"##{rgb_to_hex_color(get_color_from_status(sev_str))}\">#{sev_str}</span>"
|
233
|
+
|
234
|
+
label_sev = Gtk::Label.new.set_markup(ttips_text_sev)
|
235
|
+
label_sev.set_alignment(0,0.5)
|
236
|
+
label_sev.show
|
237
|
+
vbox.add label_sev
|
238
|
+
|
239
|
+
vbox.show
|
240
|
+
label.show
|
241
|
+
|
242
|
+
@tooltips.add vbox
|
243
|
+
end
|
244
|
+
if !@tooltips.visible?
|
245
|
+
@tooltips.show()
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
def hide_tooltips()
|
251
|
+
if @tooltips != nil
|
252
|
+
@tooltips.hide()
|
253
|
+
#with this the tooltips is always refreshed
|
254
|
+
@tooltips.destroy
|
255
|
+
@tooltips=nil
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def initialize(rootcanvas, nd, status, icon_file, label)
|
260
|
+
@dragging=false
|
261
|
+
@size=get_node_size()
|
262
|
+
@tooltips=nil
|
263
|
+
self.node=nd
|
264
|
+
self.selected=false
|
265
|
+
reset_notification()
|
266
|
+
|
267
|
+
setup_form(rootcanvas, status, icon_file, label)
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
@@ -0,0 +1,1059 @@
|
|
1
|
+
class NodeNetworkProperty
|
2
|
+
|
3
|
+
def initialize (node)
|
4
|
+
|
5
|
+
window=Gtk::Window.new
|
6
|
+
@window=window
|
7
|
+
|
8
|
+
window.set_transient_for($win)
|
9
|
+
window.set_title("Network property of "+node.ip+"/#{node.netmask}")
|
10
|
+
window.set_size_request(480, 520)
|
11
|
+
window.set_modal(true)
|
12
|
+
vboxb = Gtk::VBox::new
|
13
|
+
window.add vboxb
|
14
|
+
vboxb.show
|
15
|
+
window.signal_connect("key_press_event") {|w,e|
|
16
|
+
if e.keyval == Gdk::Keyval::GDK_Escape
|
17
|
+
window.destroy
|
18
|
+
end
|
19
|
+
}
|
20
|
+
|
21
|
+
notebook = Gtk::Notebook::new()
|
22
|
+
notebook.set_tab_pos(Gtk::POS_TOP)
|
23
|
+
vboxb.add notebook
|
24
|
+
notebook.show
|
25
|
+
|
26
|
+
########################## status tab ###############
|
27
|
+
|
28
|
+
frame = Gtk::Frame::new
|
29
|
+
frame.border_width=10
|
30
|
+
frame.set_size_request(300, 390)
|
31
|
+
frame.show
|
32
|
+
vbox = Gtk::VBox::new(false,2)
|
33
|
+
vbox.show
|
34
|
+
frame.add vbox
|
35
|
+
|
36
|
+
frame_st=Gtk::Frame.new("General")
|
37
|
+
frame_st.border_width=10
|
38
|
+
table_st = Gtk::Table.new(1,3,false)
|
39
|
+
table_st.show
|
40
|
+
label_percent = Gtk::Label.new("Current")
|
41
|
+
label_percent.show
|
42
|
+
#label_nbhost = Gtk::Label.new
|
43
|
+
#label_nbhost.show
|
44
|
+
entry_status = Gtk::Entry.new
|
45
|
+
rgb=hexa_to_rgb_color($status_color[$status_value[node.status]])
|
46
|
+
tstyle=Gtk::Style.new
|
47
|
+
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
|
48
|
+
entry_status.set_style(tstyle)
|
49
|
+
entry_status.set_text($status[$status_value[node.status]])
|
50
|
+
|
51
|
+
entry_status.set_size_request(100,-1)
|
52
|
+
entry_status.set_xalign(0.5);
|
53
|
+
entry_status.set_editable false
|
54
|
+
entry_status.show
|
55
|
+
bbox=Gtk::HButtonBox.new
|
56
|
+
bbox.show
|
57
|
+
bbox.add entry_status
|
58
|
+
table_st.attach(label_percent,0,1,0,1)
|
59
|
+
#table_st.attach(label_nbhost,1,2,0,1)
|
60
|
+
table_st.attach(bbox,1,2,0,1)
|
61
|
+
frame_st.add table_st
|
62
|
+
frame_st.show
|
63
|
+
vbox.add frame_st
|
64
|
+
frame_dt_label="Inner node detail by status"
|
65
|
+
|
66
|
+
if node.nb_node > 0
|
67
|
+
frame_dt=Gtk::Frame.new(frame_dt_label)
|
68
|
+
frame_dt.border_width=10
|
69
|
+
|
70
|
+
if !$defined_lib_gruff
|
71
|
+
|
72
|
+
refresh_node_sev_display=Thread.start {
|
73
|
+
old_table=nil
|
74
|
+
while (window != nil) do
|
75
|
+
table = Gtk::Table.new(3,3,false)
|
76
|
+
table.show
|
77
|
+
begin
|
78
|
+
#do stat for each internal node network severity
|
79
|
+
sev_stat=Array.new($status_value.size,0)
|
80
|
+
tstyle=Gtk::Style.new
|
81
|
+
rgb=hexa_to_rgb_color($status_color[$status_value[node.status]])
|
82
|
+
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
|
83
|
+
entry_status.set_style(tstyle)
|
84
|
+
entry_status.set_text($status[$status_value[node.status]])
|
85
|
+
|
86
|
+
#refresh number of host
|
87
|
+
if node.nb_node > 1
|
88
|
+
frame_dt.label=frame_dt_label + " ("+node.nb_node.to_s()+ " nodes found)"
|
89
|
+
end
|
90
|
+
node.get_node().each_value do |n|
|
91
|
+
sev_stat[$status_value.index(n.status)]+=1
|
92
|
+
end
|
93
|
+
|
94
|
+
status_index=0
|
95
|
+
$status.each do |stat|
|
96
|
+
entry_sev = Gtk::Entry.new
|
97
|
+
tstyle=Gtk::Style.new
|
98
|
+
|
99
|
+
rgb=hexa_to_rgb_color($status_color[status_index])
|
100
|
+
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
|
101
|
+
entry_sev.set_style(tstyle)
|
102
|
+
label_sev = Gtk::Label.new(sev_stat[status_index].to_s()+" node(s)")
|
103
|
+
label_sev.show
|
104
|
+
sev_percent=0
|
105
|
+
if node.nb_node>0
|
106
|
+
sev_percent=(sev_stat[status_index]*100)/node.nb_node.to_f()
|
107
|
+
end
|
108
|
+
label_sev_percent = Gtk::Label.new(sev_percent.round().to_s()+" %")
|
109
|
+
label_sev_percent.show
|
110
|
+
entry_sev.set_text(stat)
|
111
|
+
entry_sev.set_size_request(100,-1)
|
112
|
+
entry_sev.set_xalign(0.5);
|
113
|
+
entry_sev.set_editable false
|
114
|
+
entry_sev.show
|
115
|
+
bbox=Gtk::HButtonBox.new
|
116
|
+
bbox.show
|
117
|
+
bbox.add entry_sev
|
118
|
+
if sev_stat[status_index] > 0
|
119
|
+
table.attach(label_sev_percent,0,1,status_index,status_index+1)
|
120
|
+
table.attach(label_sev,1,2,status_index,status_index+1)
|
121
|
+
table.attach(bbox,2,3,status_index,status_index+1)
|
122
|
+
end
|
123
|
+
status_index+=1
|
124
|
+
end
|
125
|
+
if old_table != nil
|
126
|
+
frame_dt.remove old_table
|
127
|
+
end
|
128
|
+
frame_dt.add table
|
129
|
+
sleep(10)
|
130
|
+
old_table=table
|
131
|
+
rescue Exception => msg
|
132
|
+
$log.debug("Exception in refresh_node_sev_display for #{node.ip}: #{msg}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
}
|
136
|
+
|
137
|
+
else
|
138
|
+
refresh_node_sev_display=Thread.start {
|
139
|
+
old_vbox=nil
|
140
|
+
while (window != nil) do
|
141
|
+
begin
|
142
|
+
tstyle=Gtk::Style.new
|
143
|
+
rgb=hexa_to_rgb_color($status_color[$status_value[node.status]])
|
144
|
+
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
|
145
|
+
entry_status.set_style(tstyle)
|
146
|
+
entry_status.set_text($status[$status_value[node.status]])
|
147
|
+
#refresh number of host
|
148
|
+
if node.nb_node > 1
|
149
|
+
frame_dt.label=frame_dt_label + " ("+node.nb_node.to_s()+ " nodes found)"
|
150
|
+
end
|
151
|
+
|
152
|
+
loader=Gdk::PixbufLoader.new
|
153
|
+
loader.last_write(network_status_pie(node, 400))
|
154
|
+
pix = loader.pixbuf
|
155
|
+
img=Gtk::Image.new(pix)
|
156
|
+
img.show
|
157
|
+
vbox_img=Gtk::VBox.new
|
158
|
+
vbox_img.show
|
159
|
+
vbox_img.add img
|
160
|
+
if old_vbox != nil
|
161
|
+
frame_dt.remove old_vbox
|
162
|
+
end
|
163
|
+
frame_dt.add vbox_img
|
164
|
+
sleep(10)
|
165
|
+
old_vbox=vbox_img
|
166
|
+
rescue Exception => msg
|
167
|
+
$log.debug("Exception in refresh_node_sev_display for #{node.ip}: #{msg}")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
frame_dt.show
|
174
|
+
vbox.add frame_dt
|
175
|
+
end
|
176
|
+
hbox = Gtk::HBox.new(FALSE, 1)
|
177
|
+
hbox.add Gtk::Image.new(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize::MENU)
|
178
|
+
hbox.add Gtk::Label::new("Status")
|
179
|
+
hbox.show_all
|
180
|
+
notebook.append_page frame, hbox
|
181
|
+
|
182
|
+
###############
|
183
|
+
|
184
|
+
frame = Gtk::Frame::new
|
185
|
+
frame.border_width=10
|
186
|
+
frame.set_size_request(300, 390)
|
187
|
+
frame.show
|
188
|
+
|
189
|
+
table = Gtk::Table.new(10,2,false)
|
190
|
+
table.show
|
191
|
+
vbox = Gtk::VBox.new
|
192
|
+
vbox.show
|
193
|
+
frame.add vbox
|
194
|
+
vbox.add table
|
195
|
+
|
196
|
+
label_icon = Gtk::Label.new "Icon"
|
197
|
+
label_icon.show
|
198
|
+
entry_type = Gtk::ImageComboList.new("type", "#{node.type}")
|
199
|
+
entry_type.set_size_request(200,-1)
|
200
|
+
entry_type.show
|
201
|
+
|
202
|
+
bbox=Gtk::HButtonBox.new
|
203
|
+
bbox.show
|
204
|
+
bbox.add entry_type
|
205
|
+
|
206
|
+
table.attach(label_icon,0,1,0,1)
|
207
|
+
table.attach(bbox,1,2,0,1)
|
208
|
+
|
209
|
+
label_xy = Gtk::Label.new "X:Y"
|
210
|
+
label_xy.show
|
211
|
+
entry_x = Gtk::Entry.new
|
212
|
+
entry_x.set_editable false
|
213
|
+
entry_x.set_text("#{node.x.to_i}")
|
214
|
+
entry_x.set_size_request(96,-1)
|
215
|
+
entry_x.set_max_length 4
|
216
|
+
entry_x.show
|
217
|
+
bbox=Gtk::HButtonBox.new
|
218
|
+
bbox.set_layout_style Gtk::ButtonBox::EDGE
|
219
|
+
bbox.show
|
220
|
+
bbox.add entry_x
|
221
|
+
table.attach(label_xy,0,1,1,2)
|
222
|
+
|
223
|
+
entry_y = Gtk::Entry.new
|
224
|
+
entry_y.set_editable false
|
225
|
+
entry_y.set_text("#{node.y.to_i}")
|
226
|
+
entry_y.set_size_request(96,-1)
|
227
|
+
entry_y.set_max_length 4
|
228
|
+
entry_y.show
|
229
|
+
|
230
|
+
bbox.add entry_y
|
231
|
+
|
232
|
+
table.attach(bbox,1,2,1,2,Gtk::EXPAND)
|
233
|
+
label_ip = Gtk::Label.new "IP"
|
234
|
+
label_ip.show
|
235
|
+
entry_ip = Gtk::Entry.new
|
236
|
+
entry_ip.set_editable false
|
237
|
+
entry_ip.set_text(node.ip)
|
238
|
+
entry_ip.set_size_request(200,-1)
|
239
|
+
entry_ip.show
|
240
|
+
bbox=Gtk::HButtonBox.new
|
241
|
+
bbox.show
|
242
|
+
bbox.add entry_ip
|
243
|
+
|
244
|
+
table.attach(label_ip,0,1,2,3)
|
245
|
+
table.attach(bbox,1,2,2,3)
|
246
|
+
|
247
|
+
label_mask = Gtk::Label.new "Mask"
|
248
|
+
label_mask.show
|
249
|
+
entry_mask = Gtk::Entry.new
|
250
|
+
entry_mask.set_text(node.netmask.to_s) unless node.netmask == nil
|
251
|
+
entry_mask.set_size_request(200,-1)
|
252
|
+
entry_mask.show
|
253
|
+
bbox=Gtk::HButtonBox.new
|
254
|
+
bbox.show
|
255
|
+
bbox.add entry_mask
|
256
|
+
|
257
|
+
table.attach(label_mask,0,1,3,4)
|
258
|
+
table.attach(bbox,1,2,3,4)
|
259
|
+
|
260
|
+
label_map = Gtk::Label.new "Network"
|
261
|
+
label_map.show
|
262
|
+
entry_map = Gtk::Entry.new
|
263
|
+
entry_map.set_editable false
|
264
|
+
if node.map == nil
|
265
|
+
entry_map.set_sensitive(false)
|
266
|
+
entry_map.set_sensitive(false)
|
267
|
+
entry_map.set_text("ROOT")
|
268
|
+
else
|
269
|
+
entry_map.set_text(node.map)
|
270
|
+
end
|
271
|
+
entry_map.set_size_request(200,-1)
|
272
|
+
entry_map.show
|
273
|
+
bbox=Gtk::HButtonBox.new
|
274
|
+
bbox.show
|
275
|
+
bbox.add entry_map
|
276
|
+
table.attach(label_map,0,1,4,5)
|
277
|
+
table.attach(bbox,1,2,4,5)
|
278
|
+
|
279
|
+
label_name = Gtk::Label.new "Name"
|
280
|
+
label_name.show
|
281
|
+
entry_name = Gtk::Entry.new
|
282
|
+
entry_name.set_text(node.name) unless node.name == nil
|
283
|
+
entry_name.set_size_request(200,-1)
|
284
|
+
entry_name.show
|
285
|
+
bbox=Gtk::HButtonBox.new
|
286
|
+
bbox.show
|
287
|
+
bbox.add entry_name
|
288
|
+
|
289
|
+
table.attach(label_name,0,1,5,6)
|
290
|
+
table.attach(bbox,1,2,5,6)
|
291
|
+
|
292
|
+
label_dname = Gtk::Label.new "Domain Name"
|
293
|
+
label_dname.show
|
294
|
+
entry_dname = Gtk::Entry.new
|
295
|
+
entry_dname.set_text(node.dns_domain) unless node.dns_domain == nil
|
296
|
+
entry_dname.set_size_request(200,-1)
|
297
|
+
entry_dname.show
|
298
|
+
bbox=Gtk::HButtonBox.new
|
299
|
+
bbox.show
|
300
|
+
bbox.add entry_dname
|
301
|
+
table.attach(label_dname,0,1,6,7)
|
302
|
+
table.attach(bbox,1,2,6,7)
|
303
|
+
|
304
|
+
label_netbiosname = Gtk::Label.new "Netbios Group"
|
305
|
+
label_netbiosname.show
|
306
|
+
entry_netbiosname = Gtk::Entry.new
|
307
|
+
entry_netbiosname.set_text(node.netbios_domain) unless node.netbios_domain == nil
|
308
|
+
entry_netbiosname.set_size_request(200,-1)
|
309
|
+
entry_netbiosname.show
|
310
|
+
bbox=Gtk::HButtonBox.new
|
311
|
+
bbox.show
|
312
|
+
bbox.add entry_netbiosname
|
313
|
+
|
314
|
+
table.attach(label_netbiosname,0,1,7,8)
|
315
|
+
table.attach(bbox,1,2,7,8)
|
316
|
+
label_os = Gtk::Label.new "OS"
|
317
|
+
label_os.show
|
318
|
+
entry_os = Gtk::ImageComboList.new("os", "#{node.os}")
|
319
|
+
entry_os.set_size_request(200,-1)
|
320
|
+
entry_os.show
|
321
|
+
bbox=Gtk::HButtonBox.new
|
322
|
+
bbox.show
|
323
|
+
bbox.add entry_os
|
324
|
+
|
325
|
+
table.attach(label_os,0,1,8,9)
|
326
|
+
table.attach(bbox,1,2,8,9)
|
327
|
+
label_desc = Gtk::Label.new "Description"
|
328
|
+
label_desc.show
|
329
|
+
entry_desc = Gtk::Entry.new
|
330
|
+
entry_desc.set_text(node.description)
|
331
|
+
entry_desc.set_size_request(200,-1)
|
332
|
+
entry_desc.show
|
333
|
+
bbox=Gtk::HButtonBox.new
|
334
|
+
bbox.show
|
335
|
+
bbox.add entry_desc
|
336
|
+
|
337
|
+
table.attach(label_desc,0,1,9,10)
|
338
|
+
table.attach(bbox,1,2,9,10)
|
339
|
+
|
340
|
+
hbox = Gtk::HBox.new(FALSE, 1)
|
341
|
+
hbox.add Gtk::Image.new(Gtk::Stock::INFO, Gtk::IconSize::MENU)
|
342
|
+
hbox.add Gtk::Label::new("Information")
|
343
|
+
hbox.show_all
|
344
|
+
notebook.append_page frame, hbox
|
345
|
+
|
346
|
+
###############SNMP tab################################
|
347
|
+
|
348
|
+
frame = Gtk::Frame::new("Configuration")
|
349
|
+
frame.border_width=10
|
350
|
+
frame.set_size_request(300, 390)
|
351
|
+
frame.show
|
352
|
+
table = Gtk::Table.new(6,2,false)
|
353
|
+
table.show
|
354
|
+
frame.add table
|
355
|
+
|
356
|
+
label_snmp_version = Gtk::Label.new "SNMP version"
|
357
|
+
label_snmp_version.show
|
358
|
+
combo_snmp_version = Gtk::ComboBox.new
|
359
|
+
combo_snmp_version.append_text(SNMPv1)
|
360
|
+
combo_snmp_version.append_text(SNMPv2)
|
361
|
+
val=nil
|
362
|
+
if node.ip == ROOTMAPADDR
|
363
|
+
val=$config.snmp_version
|
364
|
+
combo_snmp_version.set_sensitive false
|
365
|
+
else
|
366
|
+
val=node.snmp_version
|
367
|
+
end
|
368
|
+
if val==SNMPv1
|
369
|
+
combo_snmp_version.set_active(0)
|
370
|
+
else
|
371
|
+
combo_snmp_version.set_active(1)
|
372
|
+
end
|
373
|
+
combo_snmp_version.set_size_request(100,-1)
|
374
|
+
combo_snmp_version.show
|
375
|
+
bbox=Gtk::HButtonBox.new
|
376
|
+
bbox.show
|
377
|
+
bbox.add combo_snmp_version
|
378
|
+
|
379
|
+
table.attach(label_snmp_version,0,1,0,1)
|
380
|
+
table.attach(bbox,1,2,0,1)
|
381
|
+
|
382
|
+
label_snmp_port = Gtk::Label.new "Port"
|
383
|
+
label_snmp_port.show
|
384
|
+
if node.ip == ROOTMAPADDR
|
385
|
+
adj = Gtk::Adjustment::new($config.snmp_port.to_f, 1.0, 65534.0, 1.0, 5.0, 0.0)
|
386
|
+
port_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
387
|
+
port_spinner.set_sensitive false
|
388
|
+
else
|
389
|
+
adj = Gtk::Adjustment::new(node.snmp_port.to_f, 1.0, 65534.0, 1.0, 5.0, 0.0)
|
390
|
+
port_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
391
|
+
end
|
392
|
+
port_spinner.set_wrap(true)
|
393
|
+
port_spinner.show
|
394
|
+
bbox=Gtk::HButtonBox.new
|
395
|
+
bbox.show
|
396
|
+
bbox.add port_spinner
|
397
|
+
|
398
|
+
table.attach(label_snmp_port,0,1,1,2)
|
399
|
+
table.attach(bbox,1,2,1,2)
|
400
|
+
|
401
|
+
label_snmp_timeout = Gtk::Label.new "Timeout (in s)"
|
402
|
+
label_snmp_timeout.show
|
403
|
+
if node.ip == ROOTMAPADDR
|
404
|
+
adj = Gtk::Adjustment::new($config.snmp_timeout.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0)
|
405
|
+
timeout_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
406
|
+
timeout_spinner.set_sensitive false
|
407
|
+
else
|
408
|
+
adj = Gtk::Adjustment::new(node.snmp_timeout.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0)
|
409
|
+
timeout_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
410
|
+
end
|
411
|
+
timeout_spinner.set_wrap(true)
|
412
|
+
timeout_spinner.show
|
413
|
+
bbox=Gtk::HButtonBox.new
|
414
|
+
bbox.show
|
415
|
+
bbox.add timeout_spinner
|
416
|
+
|
417
|
+
table.attach(label_snmp_timeout,0,1,2,3)
|
418
|
+
table.attach(bbox,1,2,2,3)
|
419
|
+
|
420
|
+
label_snmp_retry = Gtk::Label.new "Retry"
|
421
|
+
label_snmp_retry.show
|
422
|
+
if node.ip == ROOTMAPADDR
|
423
|
+
adj = Gtk::Adjustment::new($config.snmp_retry.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0)
|
424
|
+
retry_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
425
|
+
retry_spinner.set_sensitive false
|
426
|
+
else
|
427
|
+
adj = Gtk::Adjustment::new(node.snmp_retry.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0)
|
428
|
+
retry_spinner = Gtk::SpinButton::new(adj, 0, 0)
|
429
|
+
end
|
430
|
+
retry_spinner.set_wrap(true)
|
431
|
+
retry_spinner.show
|
432
|
+
bbox=Gtk::HButtonBox.new
|
433
|
+
bbox.show
|
434
|
+
bbox.add retry_spinner
|
435
|
+
|
436
|
+
table.attach(label_snmp_retry,0,1,3,4)
|
437
|
+
table.attach(bbox,1,2,3,4)
|
438
|
+
|
439
|
+
hbox = Gtk::HBox.new(FALSE, 1)
|
440
|
+
hbox.add Gtk::Image.new(Gtk::Stock::EDIT, Gtk::IconSize::MENU)
|
441
|
+
hbox.add Gtk::Label::new("SNMP")
|
442
|
+
hbox.show_all
|
443
|
+
notebook.append_page frame, hbox
|
444
|
+
|
445
|
+
#### account tab ########################################
|
446
|
+
|
447
|
+
eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
|
448
|
+
|
449
|
+
#### ALERT TAB from config_window.rb modified to be adapted to the node ####################
|
450
|
+
|
451
|
+
frame = Gtk::Frame::new("Notification based security level")
|
452
|
+
frame.border_width=10
|
453
|
+
frame.set_size_request(200, 150)
|
454
|
+
frame.show
|
455
|
+
|
456
|
+
@entry_level = Gtk::ComboBox.new
|
457
|
+
for l in $LEVEL
|
458
|
+
@entry_level.append_text(l)
|
459
|
+
end
|
460
|
+
@entry_level.set_active(0)
|
461
|
+
@old_sev_level=@entry_level.active_text
|
462
|
+
@entry_level.show
|
463
|
+
|
464
|
+
bbox=Gtk::VButtonBox.new
|
465
|
+
bbox.show
|
466
|
+
|
467
|
+
#add button from inherit from general conf
|
468
|
+
inherit_conf_cb=Gtk::CheckButton.new("Inherit general configuration")
|
469
|
+
inherit_conf_cb.show
|
470
|
+
inherit_conf_cb.set_active(node.inherit_from_global)
|
471
|
+
@entry_level.set_sensitive(!node.inherit_from_global)
|
472
|
+
|
473
|
+
bbox.add inherit_conf_cb
|
474
|
+
bbox.add @entry_level
|
475
|
+
frame.add bbox
|
476
|
+
|
477
|
+
chbutton = []
|
478
|
+
|
479
|
+
for alert_type in $talert_type
|
480
|
+
pos=$talert_type.index(alert_type)
|
481
|
+
cb_t=Gtk::CheckButton.new alert_type.capitalize()
|
482
|
+
cb_t.set_active(node.alert_type_by_level[@entry_level.active_text][pos])
|
483
|
+
cb_t.set_sensitive(!inherit_conf_cb.active?)
|
484
|
+
cb_t.show
|
485
|
+
chbutton.push cb_t
|
486
|
+
if alert_type == "mail"
|
487
|
+
cb_t.set_label("Mail recipient")
|
488
|
+
@entry_mail = []
|
489
|
+
@entry_mail_button = Gtk::Button.new("Configure contacts")
|
490
|
+
if node.mail_by_level[@entry_level.active_text]
|
491
|
+
@entry_mail=node.mail_by_level[@entry_level.active_text]
|
492
|
+
end
|
493
|
+
if @entry_mail.size > 0
|
494
|
+
contact_str="Selected contact(s):\n"
|
495
|
+
@entry_mail.each {|contact|
|
496
|
+
contact_str+=contact.firstname+" "+contact.lastname+"\n"
|
497
|
+
}
|
498
|
+
@entry_mail_button.set_tooltip_text(contact_str)
|
499
|
+
end
|
500
|
+
|
501
|
+
@entry_mail_button.signal_connect("clicked") {
|
502
|
+
ConfigWindow::contact_selection_window("Mail",@entry_mail,@entry_mail_button)
|
503
|
+
}
|
504
|
+
|
505
|
+
@entry_mail_button.show
|
506
|
+
|
507
|
+
bhbox_mail=Gtk::HButtonBox.new
|
508
|
+
bhbox_mail.add cb_t
|
509
|
+
bhbox_mail.add @entry_mail_button
|
510
|
+
bhbox_mail.show
|
511
|
+
@cb_mail=cb_t
|
512
|
+
@cb_mail.set_sensitive($config.mail_server && !node.inherit_from_global)
|
513
|
+
@entry_mail_button.set_sensitive(!node.inherit_from_global && cb_t.active? && $config.mail_server && (Contact::contact_nb_entry()>0))
|
514
|
+
bbox.add bhbox_mail
|
515
|
+
elsif alert_type == "beep"
|
516
|
+
label_soundfile = Gtk::Label.new "Sound file"
|
517
|
+
label_soundfile.show
|
518
|
+
@entry_soundfile = Gtk::ComboBox.new
|
519
|
+
@entry_soundfile.set_size_request 140,-1
|
520
|
+
files_tmp=Dir.entries(SOUND_DIR)
|
521
|
+
files_tmp << ConfigGlobal::DEFAULT_SOUND_FILE
|
522
|
+
|
523
|
+
files=Array.new
|
524
|
+
files_tmp.each do |val|
|
525
|
+
if val.match('[^.]')
|
526
|
+
files << val
|
527
|
+
@entry_soundfile.append_text(val)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
current_level=@entry_level.active_text
|
531
|
+
if node.sound_file_path_by_level[current_level] != nil
|
532
|
+
iter=files.index(node.sound_file_path_by_level[current_level])
|
533
|
+
if iter == nil
|
534
|
+
@entry_soundfile.set_active(files.size()-1)
|
535
|
+
else
|
536
|
+
@entry_soundfile.set_active(iter)
|
537
|
+
end
|
538
|
+
else
|
539
|
+
@entry_soundfile.set_active(files.size()-1)
|
540
|
+
end
|
541
|
+
@entry_soundfile.show
|
542
|
+
hbox_sound=Gtk::HBox.new
|
543
|
+
bhbox_sound_file=Gtk::HButtonBox.new
|
544
|
+
bhbox_sound_file.add label_soundfile
|
545
|
+
bhbox_sound_file.add @entry_soundfile
|
546
|
+
bhbox_sound_file.set_sensitive(cb_t.active? && !node.inherit_from_global)
|
547
|
+
cb_t.set_sensitive(!node.inherit_from_global)
|
548
|
+
bhbox_sound_file.show
|
549
|
+
hbox_sound.add cb_t
|
550
|
+
hbox_sound.add bhbox_sound_file
|
551
|
+
hbox_sound.show
|
552
|
+
bbox.add hbox_sound
|
553
|
+
elsif alert_type == "sms"
|
554
|
+
cb_t.set_label("SMS mobile number")
|
555
|
+
@entry_sms = []
|
556
|
+
@entry_sms_button = Gtk::Button.new("Configure contacts")
|
557
|
+
if node.sms_num_by_level[@entry_level.active_text]
|
558
|
+
@entry_sms=node.sms_num_by_level[@entry_level.active_text]
|
559
|
+
end
|
560
|
+
if @entry_sms.size > 0
|
561
|
+
contact_str="Selected contact(s):\n"
|
562
|
+
@entry_sms.each {|contact|
|
563
|
+
contact_str+=contact.firstname+" "+contact.lastname+"\n"
|
564
|
+
}
|
565
|
+
@entry_sms_button.set_tooltip_text(contact_str)
|
566
|
+
end
|
567
|
+
@entry_sms_button.signal_connect("clicked") {
|
568
|
+
ConfigWindow::contact_selection_window("SMS",@entry_sms,@entry_sms_button)
|
569
|
+
}
|
570
|
+
@entry_sms_button.show
|
571
|
+
bhbox_sms=Gtk::HButtonBox.new
|
572
|
+
bhbox_sms.add cb_t
|
573
|
+
bhbox_sms.add @entry_sms_button
|
574
|
+
bhbox_sms.show
|
575
|
+
@cb_sms=cb_t
|
576
|
+
@cb_sms.set_sensitive(!node.inherit_from_global && ($config.sms_device != ""))
|
577
|
+
@entry_sms_button.set_sensitive(!node.inherit_from_global && cb_t.active? && (Contact::contact_nb_entry()>0) && ($config.sms_device != ""))
|
578
|
+
bbox.add bhbox_sms
|
579
|
+
elsif alert_type == "im"
|
580
|
+
cb_t.set_label("IM Recipient")
|
581
|
+
@entry_im = []
|
582
|
+
@entry_im_button = Gtk::Button.new("Configure contacts")
|
583
|
+
if node.im_dest_by_level[$config.level]
|
584
|
+
@entry_im=node.im_dest_by_level[@entry_level.active_text]
|
585
|
+
end
|
586
|
+
if @entry_im.size > 0
|
587
|
+
contact_str="Selected contact(s):\n"
|
588
|
+
@entry_im.each {|contact|
|
589
|
+
contact_str+=contact.firstname+" "+contact.lastname+"\n"
|
590
|
+
}
|
591
|
+
@entry_im_button.set_tooltip_text(contact_str)
|
592
|
+
end
|
593
|
+
@entry_im_button.signal_connect("clicked") {
|
594
|
+
ConfigWindow::contact_selection_window("IM",@entry_im,@entry_im_button)
|
595
|
+
}
|
596
|
+
@entry_im_button.show
|
597
|
+
|
598
|
+
bhbox_im=Gtk::HButtonBox.new
|
599
|
+
bhbox_im.add cb_t
|
600
|
+
bhbox_im.add @entry_im_button
|
601
|
+
bhbox_im.show
|
602
|
+
@cb_im=cb_t
|
603
|
+
@cb_im.set_sensitive($config.im_daemon && !node.inherit_from_global)
|
604
|
+
@entry_im_button.set_sensitive(!node.inherit_from_global && cb_t.active? && $config.im_daemon && (Contact::contact_nb_entry()>0))
|
605
|
+
bbox.add bhbox_im
|
606
|
+
elsif alert_type == "script"
|
607
|
+
cb_t.set_label("Script path to execute")
|
608
|
+
@entry_script = Gtk::Entry.new
|
609
|
+
@entry_script.show
|
610
|
+
if node.script_name_by_level != nil && node.script_name_by_level[@entry_level.active_text] != nil
|
611
|
+
@entry_script.set_text(node.script_name_by_level[@entry_level.active_text])
|
612
|
+
end
|
613
|
+
bhbox_script=Gtk::HButtonBox.new
|
614
|
+
bhbox_script.add cb_t
|
615
|
+
bhbox_script.add @entry_script
|
616
|
+
bhbox_script.show
|
617
|
+
@entry_script.set_sensitive(cb_t.active?)
|
618
|
+
@cb_script=cb_t
|
619
|
+
bbox.add bhbox_script
|
620
|
+
elsif alert_type == "pager"
|
621
|
+
cb_t.set_sensitive(false)
|
622
|
+
else
|
623
|
+
bbox.add cb_t
|
624
|
+
end
|
625
|
+
|
626
|
+
inherit_conf_cb.signal_connect("clicked") {|s|
|
627
|
+
@entry_level.set_sensitive(!inherit_conf_cb.active?)
|
628
|
+
for alert_check_button in chbutton
|
629
|
+
alert_check_button.set_sensitive(!inherit_conf_cb.active?)
|
630
|
+
if alert_check_button.label.downcase.gsub(/\s.*/,"") == "mail"
|
631
|
+
@cb_mail.set_sensitive(Contact::contact_nb_entry()>0)
|
632
|
+
@entry_mail_button.set_sensitive(!inherit_conf_cb.active? && alert_check_button.active? && $config.mail_server && (Contact::contact_nb_entry()>0))
|
633
|
+
end
|
634
|
+
if alert_check_button.label.downcase.gsub(/\s.*/,"") == "im"
|
635
|
+
@cb_im.set_sensitive(Contact::contact_nb_entry()>0)
|
636
|
+
@entry_im_button.set_sensitive(!inherit_conf_cb.active? && alert_check_button.active? && $config.im_daemon && (Contact::contact_nb_entry()>0))
|
637
|
+
end
|
638
|
+
if alert_check_button.label.downcase.gsub(/\s.*/,"") == "sms"
|
639
|
+
@cb_sms.set_sensitive(Contact::contact_nb_entry()>0)
|
640
|
+
@entry_sms_button.set_sensitive(!inherit_conf_cb.active? && alert_check_button.active? && ($config.sms_device != "") && (Contact::contact_nb_entry()>0))
|
641
|
+
end
|
642
|
+
if alert_check_button.label.downcase == "beep"
|
643
|
+
bhbox_sound_file.set_sensitive(!inherit_conf_cb.active? && alert_check_button.active?)
|
644
|
+
end
|
645
|
+
if alert_check_button.label.downcase.gsub(/\s.*/,"") == "script"
|
646
|
+
@entry_script.set_sensitive(!inherit_conf_cb.active? && alert_check_button.active?)
|
647
|
+
end
|
648
|
+
end
|
649
|
+
#toggle inherit value
|
650
|
+
node.inherit_from_global=inherit_conf_cb.active?
|
651
|
+
}
|
652
|
+
|
653
|
+
|
654
|
+
cb_t.signal_connect("clicked") {|s|
|
655
|
+
lbl=s.label.downcase.gsub(/\s.*/,"")
|
656
|
+
pos=$talert_type.index(lbl)
|
657
|
+
node.alert_type_by_level[@entry_level.active_text][pos] = s.active?
|
658
|
+
if lbl == "mail"
|
659
|
+
@entry_mail_button.set_sensitive(s.active? && (Contact::contact_nb_entry()>0))
|
660
|
+
elsif lbl == "beep"
|
661
|
+
@entry_soundfile.set_sensitive(s.active?)
|
662
|
+
label_soundfile.set_sensitive(s.active?)
|
663
|
+
elsif lbl == "sms"
|
664
|
+
@entry_sms_button.set_sensitive(s.active? && (Contact::contact_nb_entry()>0))
|
665
|
+
elsif lbl == "im"
|
666
|
+
@entry_im_button.set_sensitive(s.active? && (Contact::contact_nb_entry()>0))
|
667
|
+
elsif lbl == "script"
|
668
|
+
@entry_script.set_sensitive(s.active?)
|
669
|
+
end
|
670
|
+
}
|
671
|
+
|
672
|
+
end
|
673
|
+
|
674
|
+
@entry_soundfile.signal_connect("changed") {
|
675
|
+
if @entry_soundfile.active_text == ConfigGlobal::DEFAULT_SOUND_FILE
|
676
|
+
node.sound_file_path_by_level[@entry_level.active_text] = nil
|
677
|
+
else
|
678
|
+
node.sound_file_path_by_level[@entry_level.active_text] = @entry_soundfile.active_text
|
679
|
+
end
|
680
|
+
}
|
681
|
+
|
682
|
+
@entry_level.signal_connect("changed") {
|
683
|
+
if (@entry_level.active_text != "")
|
684
|
+
#store old level info
|
685
|
+
node.mail_by_level[@old_sev_level]=@entry_mail
|
686
|
+
if @entry_soundfile.active_text == ConfigGlobal::DEFAULT_SOUND_FILE
|
687
|
+
node.sound_file_path_by_level[@old_sev_level] = nil
|
688
|
+
else
|
689
|
+
node.sound_file_path_by_level[@old_sev_level] = @entry_soundfile.active_text
|
690
|
+
end
|
691
|
+
node.script_name_by_level[@old_sev_level] = @entry_script.text
|
692
|
+
node.sms_num_by_level[@old_sev_level] = @entry_sms
|
693
|
+
node.im_dest_by_level[@old_sev_level] = @entry_im
|
694
|
+
#reload checkbox depending on level selected
|
695
|
+
i=0
|
696
|
+
current_level=@entry_level.active_text
|
697
|
+
for cb in chbutton
|
698
|
+
cb.set_active(node.alert_type_by_level[current_level][i])
|
699
|
+
i+=1
|
700
|
+
end
|
701
|
+
#reload specific entry
|
702
|
+
if node.mail_by_level[current_level]
|
703
|
+
@entry_mail=node.mail_by_level[current_level]
|
704
|
+
else
|
705
|
+
@entry_mail.clear
|
706
|
+
end
|
707
|
+
if $config.mail_server && (Contact::contact_nb_entry()>0)
|
708
|
+
@cb_mail.set_sensitive true
|
709
|
+
else
|
710
|
+
@cb_mail.set_sensitive false
|
711
|
+
end
|
712
|
+
if $config.mail_server && @cb_mail.active? && (Contact::contact_nb_entry()>0)
|
713
|
+
@entry_mail_button.set_sensitive true
|
714
|
+
else
|
715
|
+
@entry_mail_button.set_sensitive false
|
716
|
+
end
|
717
|
+
|
718
|
+
if node.sound_file_path_by_level[current_level] != nil
|
719
|
+
iter=files.index(node.sound_file_path_by_level[current_level])
|
720
|
+
if iter == nil
|
721
|
+
@entry_soundfile.set_active(files.size()-1)
|
722
|
+
else
|
723
|
+
@entry_soundfile.set_active(iter)
|
724
|
+
end
|
725
|
+
else
|
726
|
+
@entry_soundfile.set_active(files.size()-1)
|
727
|
+
end
|
728
|
+
|
729
|
+
if node.script_name_by_level[current_level] && (node.script_name_by_level[current_level] != "")
|
730
|
+
@entry_script.set_text node.script_name_by_level[current_level]
|
731
|
+
else
|
732
|
+
@entry_script.set_text("")
|
733
|
+
@cb_script.active=false
|
734
|
+
end
|
735
|
+
|
736
|
+
if node.sms_num_by_level[current_level]
|
737
|
+
@entry_sms=node.sms_num_by_level[current_level]
|
738
|
+
else
|
739
|
+
@entry_sms.clear
|
740
|
+
end
|
741
|
+
if ($config.sms_device != "") && (Contact::contact_nb_entry()>0)
|
742
|
+
@cb_sms.set_sensitive(true)
|
743
|
+
else
|
744
|
+
@cb_sms.set_sensitive(false)
|
745
|
+
end
|
746
|
+
if ($config.sms_device != "") && @cb_sms.active? && (Contact::contact_nb_entry()>0)
|
747
|
+
@entry_sms_button.set_sensitive(true)
|
748
|
+
else
|
749
|
+
@entry_sms_button.set_sensitive(false)
|
750
|
+
end
|
751
|
+
if node.im_dest_by_level[current_level] != nil
|
752
|
+
@entry_im=node.im_dest_by_level[current_level]
|
753
|
+
else
|
754
|
+
@entry_im.clear
|
755
|
+
end
|
756
|
+
if $config.im_daemon && (Contact::contact_nb_entry()>0)
|
757
|
+
@cb_im.set_sensitive(true)
|
758
|
+
else
|
759
|
+
@cb_im.set_sensitive(false)
|
760
|
+
end
|
761
|
+
if $config.im_daemon && @cb_im.active? && (Contact::contact_nb_entry()>0)
|
762
|
+
@entry_im_button.set_sensitive(true)
|
763
|
+
else
|
764
|
+
@entry_im_button.set_sensitive(false)
|
765
|
+
end
|
766
|
+
|
767
|
+
@old_sev_level=current_level
|
768
|
+
end
|
769
|
+
}
|
770
|
+
hbox = Gtk::HBox.new(FALSE, 1)
|
771
|
+
hbox.add Gtk::Image.new(Gtk::Stock::FIND_AND_REPLACE, Gtk::IconSize::MENU)
|
772
|
+
hbox.add Gtk::Label::new("Alert")
|
773
|
+
hbox.show_all
|
774
|
+
notebook.append_page frame, hbox
|
775
|
+
|
776
|
+
|
777
|
+
###### GENERAL TAB #########
|
778
|
+
|
779
|
+
frame = Gtk::Frame::new
|
780
|
+
frame.border_width=10
|
781
|
+
frame.set_size_request(300, 390)
|
782
|
+
frame.show
|
783
|
+
vbox = Gtk::VButtonBox.new
|
784
|
+
vbox.set_layout_style(Gtk::ButtonBox::SPREAD)
|
785
|
+
vbox.show
|
786
|
+
frame.add vbox
|
787
|
+
|
788
|
+
#resize node icon
|
789
|
+
hbox = Gtk::HButtonBox.new
|
790
|
+
hbox.set_layout_style(Gtk::ButtonBox::SPREAD)
|
791
|
+
hbox.show
|
792
|
+
vbox.add hbox
|
793
|
+
|
794
|
+
button_ps = Gtk::CheckButton.new "Resize node icon"
|
795
|
+
button_ps.show
|
796
|
+
hbox.add button_ps
|
797
|
+
|
798
|
+
entry_pixmap_size = Gtk::Entry.new
|
799
|
+
entry_pixmap_size.show
|
800
|
+
entry_pixmap_size.set_size_request 3,-1
|
801
|
+
if node.node_size == nil
|
802
|
+
entry_pixmap_size.set_text($config.pixmap_size.to_s())
|
803
|
+
else
|
804
|
+
entry_pixmap_size.set_text(node.node_size.to_s())
|
805
|
+
end
|
806
|
+
|
807
|
+
entry_pixmap_size.set_sensitive node.node_size != nil
|
808
|
+
button_ps.active=node.node_size != nil
|
809
|
+
|
810
|
+
button_ps.signal_connect("toggled") {
|
811
|
+
if !button_ps.active?
|
812
|
+
entry_pixmap_size.set_sensitive false
|
813
|
+
entry_pixmap_size.set_text($config.pixmap_size.to_s())
|
814
|
+
else
|
815
|
+
entry_pixmap_size.set_sensitive true
|
816
|
+
if node.node_size == nil
|
817
|
+
entry_pixmap_size.set_text($config.pixmap_size.to_s())
|
818
|
+
else
|
819
|
+
entry_pixmap_size.set_text(node.node_size.to_s())
|
820
|
+
end
|
821
|
+
end
|
822
|
+
}
|
823
|
+
hbox.add entry_pixmap_size
|
824
|
+
|
825
|
+
#end of resize node icon
|
826
|
+
|
827
|
+
#bg color
|
828
|
+
hbb=Gtk::HButtonBox.new
|
829
|
+
hbb.set_layout_style(Gtk::ButtonBox::SPREAD)
|
830
|
+
hbb.show
|
831
|
+
|
832
|
+
colorchk = Gtk::CheckButton.new("Color")
|
833
|
+
colorchk.show
|
834
|
+
vbox.add colorchk
|
835
|
+
|
836
|
+
color_button = Gtk::ColorButton.new
|
837
|
+
color_button.set_use_alpha(false)
|
838
|
+
|
839
|
+
gdk_color=nil
|
840
|
+
if (node.map_bg_data == nil) || (node.map_bg_type != "color")
|
841
|
+
gdk_color=Gdk::Color.new($config.rgb[0].to_f, $config.rgb[1].to_f, $config.rgb[2].to_f)
|
842
|
+
else
|
843
|
+
gdk_color=Gdk::Color.new(node.map_bg_data[0].to_f, node.map_bg_data[1].to_f, node.map_bg_data[2].to_f)
|
844
|
+
end
|
845
|
+
color_button.set_color(gdk_color)
|
846
|
+
hbb.add color_button
|
847
|
+
color_button.show
|
848
|
+
vbox.add hbb
|
849
|
+
|
850
|
+
#end of bg color
|
851
|
+
|
852
|
+
#bg image
|
853
|
+
|
854
|
+
imagechk = Gtk::CheckButton.new("Image")
|
855
|
+
imagechk.show
|
856
|
+
vbox.add imagechk
|
857
|
+
|
858
|
+
hbb2=Gtk::HButtonBox.new
|
859
|
+
hbb2.set_layout_style(Gtk::ButtonBox::SPREAD)
|
860
|
+
hbb2.show
|
861
|
+
|
862
|
+
#remove dir name and file format from file bg path
|
863
|
+
file_bg = nil
|
864
|
+
if node.map_bg_data and (node.map_bg_type == "image")
|
865
|
+
file_bg = node.map_bg_data[1+ String.new("bg").size, node.map_bg_data.size - 2 - String.new("bg").size - String.new("jpg").size]
|
866
|
+
else
|
867
|
+
if $config.image_path
|
868
|
+
file_bg = $config.image_path[1+ String.new("bg").size, $config.image_path.size - 2 - String.new("bg").size - String.new("jpg").size]
|
869
|
+
end
|
870
|
+
end
|
871
|
+
|
872
|
+
entry_image = Gtk::ImageComboList.new("bg", file_bg, "jpg")
|
873
|
+
entry_image.show
|
874
|
+
hbb2.add entry_image
|
875
|
+
vbox.add hbb2
|
876
|
+
|
877
|
+
if node.map_bg_type != nil
|
878
|
+
if node.map_bg_type == "image"
|
879
|
+
colorchk.set_active false
|
880
|
+
color_button.set_sensitive false
|
881
|
+
imagechk.set_active true
|
882
|
+
entry_image.set_sensitive true
|
883
|
+
else
|
884
|
+
colorchk.set_active true
|
885
|
+
color_button.set_sensitive true
|
886
|
+
imagechk.set_active false
|
887
|
+
entry_image.set_sensitive false
|
888
|
+
end
|
889
|
+
else
|
890
|
+
colorchk.set_active false
|
891
|
+
color_button.set_sensitive false
|
892
|
+
imagechk.set_active false
|
893
|
+
entry_image.set_sensitive false
|
894
|
+
end
|
895
|
+
|
896
|
+
colorchk.signal_connect("toggled") {
|
897
|
+
if colorchk.active?
|
898
|
+
color_button.set_sensitive(true)
|
899
|
+
imagechk.set_active false
|
900
|
+
entry_image.set_sensitive false
|
901
|
+
else
|
902
|
+
color_button.set_sensitive(false)
|
903
|
+
end
|
904
|
+
|
905
|
+
}
|
906
|
+
imagechk.signal_connect("clicked") {
|
907
|
+
if imagechk.active?
|
908
|
+
entry_image.set_sensitive(true)
|
909
|
+
colorchk.set_active false
|
910
|
+
color_button.set_sensitive false
|
911
|
+
else
|
912
|
+
entry_image.set_sensitive(false)
|
913
|
+
end
|
914
|
+
}
|
915
|
+
|
916
|
+
hbox = Gtk::HBox.new(FALSE, 1)
|
917
|
+
hbox.add Gtk::Image.new(Gtk::Stock::SELECT_COLOR, Gtk::IconSize::MENU)
|
918
|
+
hbox.add Gtk::Label::new("Display")
|
919
|
+
hbox.show_all
|
920
|
+
notebook.append_page frame, hbox
|
921
|
+
|
922
|
+
###############
|
923
|
+
|
924
|
+
ok_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
925
|
+
ok_button.signal_connect("clicked") {
|
926
|
+
|
927
|
+
#general
|
928
|
+
if entry_x.text.to_i >= 0 && entry_x.text.to_i <= $win.window.geometry[2]
|
929
|
+
node.x = entry_x.text.to_i
|
930
|
+
end
|
931
|
+
if entry_y.text.to_i >= 0 && entry_y.text.to_i <= $win.window.geometry[3]
|
932
|
+
node.y = entry_y.text.to_i
|
933
|
+
end
|
934
|
+
|
935
|
+
need_reload_icon=0
|
936
|
+
if entry_os.name != node.os || entry_type.name != node.type
|
937
|
+
need_reload_icon=1
|
938
|
+
end
|
939
|
+
|
940
|
+
nodeid=db_get_node_id(node.ip, NETWORKNODE)
|
941
|
+
node.netmask = entry_mask.text.to_i
|
942
|
+
db_set_mask(nodeid, node.netmask)
|
943
|
+
|
944
|
+
if (entry_name.text=="") || (entry_name.text.match('\s+'))
|
945
|
+
node.name=Node::NONAME_PROPERTY
|
946
|
+
else
|
947
|
+
node.name = entry_name.text
|
948
|
+
end
|
949
|
+
if (entry_dname.text=="") || (entry_dname.text.match('\s+'))
|
950
|
+
node.dns_domain=Node::NONAME_PROPERTY
|
951
|
+
else
|
952
|
+
node.dns_domain = entry_dname.text
|
953
|
+
end
|
954
|
+
if (entry_netbiosname.text=="") || (entry_netbiosname.text.match('\s+'))
|
955
|
+
node.netbios_domain=Node::NONAME_PROPERTY
|
956
|
+
else
|
957
|
+
node.netbios_domain = entry_netbiosname.text
|
958
|
+
end
|
959
|
+
if (entry_desc.text=="") || (entry_desc.text.match('\s+'))
|
960
|
+
node.description=Node::NODESCR_PROPERTY
|
961
|
+
else
|
962
|
+
node.description = entry_desc.text
|
963
|
+
end
|
964
|
+
db_set_description(nodeid, node.description)
|
965
|
+
|
966
|
+
node.snmp_version = combo_snmp_version.active_text
|
967
|
+
node.snmp_port = port_spinner.value_as_int
|
968
|
+
node.snmp_timeout = timeout_spinner.value_as_int
|
969
|
+
node.snmp_retry = retry_spinner.value_as_int
|
970
|
+
db_set_snmp_parameter(nodeid, node.snmp_version, node.snmp_port, node.snmp_timeout, node.snmp_retry)
|
971
|
+
|
972
|
+
node.os = entry_os.name
|
973
|
+
if entry_type.filename != nil
|
974
|
+
node.type = entry_type.name
|
975
|
+
end
|
976
|
+
node.change_label()
|
977
|
+
if need_reload_icon == 1
|
978
|
+
node.reload()
|
979
|
+
end
|
980
|
+
|
981
|
+
node.node_size=entry_pixmap_size.text.to_i
|
982
|
+
db_set_node_size(nodeid, node.node_size)
|
983
|
+
|
984
|
+
#store account only in db as the lived value is already stored in @acccount hash
|
985
|
+
node.clear_db_accounts()
|
986
|
+
account_table = Array.new()
|
987
|
+
@account_view.model.each {|model, path, iter|
|
988
|
+
idname = iter[0]
|
989
|
+
login = iter[1]
|
990
|
+
password = iter[2]
|
991
|
+
account_table.push([idname, login, password])
|
992
|
+
}
|
993
|
+
if account_table.length > 0
|
994
|
+
node.add_db_account(account_table)
|
995
|
+
end
|
996
|
+
|
997
|
+
#store alert override in db if needed
|
998
|
+
|
999
|
+
#store current level entries
|
1000
|
+
node.mail_by_level[@entry_level.active_text]=@entry_mail
|
1001
|
+
node.sms_num_by_level[@entry_level.active_text]=@entry_sms
|
1002
|
+
node.im_dest_by_level[@entry_level.active_text]=@entry_im
|
1003
|
+
node.script_name_by_level[@entry_level.active_text]=@entry_script.text
|
1004
|
+
#sound file entry was already saved in the on changed event
|
1005
|
+
|
1006
|
+
db_del_alert_override(node.ip)
|
1007
|
+
if !node.inherit_from_global
|
1008
|
+
#this node has its own alert conf
|
1009
|
+
db_set_alert_override(node, NETWORKNODE)
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
if colorchk.active?
|
1013
|
+
node.map_bg_type="color"
|
1014
|
+
node.map_bg_data=color_button.color().to_a()
|
1015
|
+
db_set_background(nodeid, node.map_bg_type, node.map_bg_data.join(" "))
|
1016
|
+
else
|
1017
|
+
if imagechk.active?
|
1018
|
+
node.map_bg_type="image"
|
1019
|
+
node.map_bg_data=entry_image.filename
|
1020
|
+
else
|
1021
|
+
node.map_bg_type=nil
|
1022
|
+
node.map_bg_data=nil
|
1023
|
+
end
|
1024
|
+
db_set_background(nodeid, node.map_bg_type, node.map_bg_data)
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
Thread.kill(refresh_node_sev_display) unless !refresh_node_sev_display
|
1028
|
+
Gtk.thread_flush
|
1029
|
+
window.destroy
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
|
1033
|
+
cancel_button.signal_connect("clicked") {
|
1034
|
+
#we rollback here the account from the db to the @account hash
|
1035
|
+
node.init_account_from_db()
|
1036
|
+
Thread.kill(refresh_node_sev_display) unless !refresh_node_sev_display
|
1037
|
+
Gtk.thread_flush
|
1038
|
+
window.destroy
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
hbox=Gtk::HBox.new(FALSE, 10)
|
1042
|
+
hbox.border_width=10
|
1043
|
+
hbox.show
|
1044
|
+
hbox.pack_start(ok_button, TRUE, TRUE, 0)
|
1045
|
+
ok_button.set_flags(Gtk::Widget::CAN_DEFAULT);
|
1046
|
+
hbox.pack_start(cancel_button, TRUE, TRUE, 0)
|
1047
|
+
cancel_button.set_flags(Gtk::Widget::CAN_DEFAULT);
|
1048
|
+
separator = Gtk::HSeparator::new()
|
1049
|
+
vboxb.pack_start(separator, FALSE, TRUE, 0)
|
1050
|
+
separator.show
|
1051
|
+
vboxb.pack_start(hbox, FALSE, TRUE, 0)
|
1052
|
+
|
1053
|
+
ok_button.show
|
1054
|
+
cancel_button.show
|
1055
|
+
|
1056
|
+
window.show
|
1057
|
+
|
1058
|
+
end
|
1059
|
+
end
|