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