Class: ConfigWindow
- Inherits:
-
Object
- Object
- ConfigWindow
- Defined in:
- lib/gui/config_window.rb
Class Method Summary collapse
-
.contact_selection_window(alarm, contact_selected_array, contact_button) ⇒ Object
list all contact in a treeview and return an array of contact id selected.
Instance Method Summary collapse
- #cancel_action ⇒ Object
-
#initialize(cfg) ⇒ ConfigWindow
constructor
A new instance of ConfigWindow.
-
#save_config_yaml ⇒ Object
save configuration file as YAML.
-
#show ⇒ Object
main config window will all the frames.
-
#toggle_contact_selection(path = 0) ⇒ Object
toggle contact selection in contact selection window.
- #visible ⇒ Object
Constructor Details
#initialize(cfg) ⇒ ConfigWindow
Returns a new instance of ConfigWindow.
3 4 5 6 7 8 |
# File 'lib/gui/config_window.rb', line 3 def initialize(cfg) @window = nil @config=cfg @old_sev_level=@config.level @old_contact=nil end |
Class Method Details
.contact_selection_window(alarm, contact_selected_array, contact_button) ⇒ Object
list all contact in a treeview and return an array of contact id selected
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 |
# File 'lib/gui/config_window.rb', line 186 def ConfigWindow::contact_selection_window(alarm, contact_selected_array, ) @contact_selection=[] contact_window=Gtk::Window.new contact_window.set_title("Select contact for #{alarm} notifications") contact_window.set_size_request(250, 200) contact_window.set_modal(true) ls = Gtk::ListStore.new(Integer, String, String) @contact_treeview = Gtk::TreeView.new(ls) renderer = Gtk::CellRendererToggle.new renderer.signal_connect('toggled') do |cell, path| # get toggled iter iter = @contact_treeview.model.get_iter(path) fixed =iter[0] # do something with the value fixed ^= 1 @contact_selection[path.to_i()]=fixed # set new value iter[0] = fixed end column1 = Gtk::TreeViewColumn.new("Selected", renderer, {:active => 0}) column1.set_clickable(true) column2 = Gtk::TreeViewColumn.new("FirstName", Gtk::CellRendererText.new, {:text => 1}) column2.set_sort_column_id(1) column3 = Gtk::TreeViewColumn.new("LastName", Gtk::CellRendererText.new, {:text => 2}) column3.set_sort_column_id(2) column1.signal_connect("clicked") do |column| toggle_contact_selection() end @contact_treeview.append_column(column1) @contact_treeview.append_column(column2) @contact_treeview.append_column(column3) @contact_treeview.show #load existing entries #copy contact hash contact_hash_dup=$contact.dup contact_selected_array.each {|contact| iter=ls.append iter[0] = 1 iter[1] = contact.firstname iter[2] = contact.lastname contact_hash_dup.delete("#{contact.firstname}|#{contact.lastname}") } #add remaining contacts contact_hash_dup.each_key {|id| iter=ls.append iter[0] = 0 iter[1] = contact_hash_dup[id].firstname iter[2] = contact_hash_dup[id].lastname } unless !contact_hash_dup vbox_root = Gtk::VBox::new contact_window.add vbox_root vbox_root.show vbox_root.add @contact_treeview bbox =Gtk::HBox::new(FALSE, 10) bbox.border_width=10 bbox.show = Gtk::Button.new(Gtk::Stock::OK) .show .signal_connect("clicked") { #return an array of selected contact old_contact_selected_array=contact_selected_array.dup contact_selected_array.clear contact_str="Selected contact(s):\n" @contact_treeview.model.each {|model, path, iter| selected = iter[0] firstname = iter[1] lastname = iter[2] if selected.to_i == 1 contact_str+=firstname+" "+lastname+"\n" contact_selected_array.push(Contact_selected_info.new(firstname,lastname)) end } old_contact_selected_array.each {|contact| if !contact_selected_array.include?(contact) #so the contact has been removed Contact::del_use(contact.firstname, contact.lastname) end } contact_selected_array.each {|contact| if !old_contact_selected_array.include?(contact) #so the contact has been added Contact::add_use(contact.firstname, contact.lastname) end } #update the tooltips if contact_selected_array.size > 0 case alarm.downcase when "mail" then .set_tooltip_text(contact_str) when "sms" then .set_tooltip_text(contact_str) when "im" then .set_tooltip_text(contact_str) end else case alarm.downcase when "mail" then .set_tooltip_text("") when "sms" then .set_tooltip_text("") when "im" then .set_tooltip_text("") end end contact_window.destroy } = Gtk::Button.new(Gtk::Stock::CANCEL) .show .signal_connect("clicked") { contact_window.destroy } .set_flags(Gtk::Widget::CAN_DEFAULT) bbox.pack_start(, TRUE, TRUE, 0) .set_flags(Gtk::Widget::CAN_DEFAULT) bbox.pack_start(, TRUE, TRUE, 0) separator = Gtk::HSeparator::new() separator.show vbox_root.pack_start(separator, FALSE, TRUE, 0) vbox_root.pack_start(bbox, FALSE, TRUE, 0) contact_window.show end |
Instance Method Details
#cancel_action ⇒ Object
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 |
# File 'lib/gui/config_window.rb', line 2157 def cancel_action() #restore accounts contact_temp=$contact.dup $contact.clear $contact=@old_contact $contact.each_key {|id| if contact_temp.include?(id) $contact[id].nb_use=contact_temp[id].nb_use else #if it does not exist so it had been deleted $contact[id].nb_use=0 end } if FileTest.exist?(GLOBAL_CONF_FILE) @window.destroy @window = nil end end |
#save_config_yaml ⇒ Object
save configuration file as YAML
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 |
# File 'lib/gui/config_window.rb', line 13 def save_config_yaml() fic_tmp=Tempfile.new(File.basename(GLOBAL_CONF_FILE)) general = { 'default_width' => get_map_width(), 'default_height' => get_map_height(), 'default_map' => $map, 'host_label_view' => $config.host_label_view, 'host_icon_view' => $config.host_icon_view, 'network_label_view' => $config.network_label_view, 'network_icon_view' => $config.network_icon_view, 'map_display_view' => $config.map_display_view, 'show_label' => @button_show_label.active?, 'noshow_fqdn' => @button_noshow_fqdn.active?, 'show_tooltips' => @button_show_tooltips.active?, 'confirm_delete' => @button_confirm_delete.active?, 'confirm_quit' => @button_confirm_quit.active?, 'auto_save_map' => @button_auto_save_map.active?, 'auto_save_map_value' => @entry_auto_save_map.text.to_i, 'log_level' => @combo_log_level.active_text, 'mail_server' => @button_mail.active?, 'sms_device' => @entry_sms_device.text, 'im_daemon' => @button_im.active?, 'im_login' => @entry_im_login.text, 'im_password' => Base64.encode64(blowfish_encode(@entry_im_password.text)), 'irc_daemon' => @button_irc.active?, 'irc_server' => @entry_irc_server.text, 'irc_port' => @entry_irc_port.text, 'irc_channel' => @entry_irc_channel.text } snmp = { 'read_community' => @entry_read_community.text, 'write_community' => @entry_write_community.text, 'snmp_version' => @combo_snmp_version.active_text, 'snmp_port' => @port_spinner.value_as_int, 'snmp_timeout' => @timeout_spinner.value_as_int, 'snmp_retry' => @retry_spinner.value_as_int } notification = { 'level_alert_type' => $level_alert_type, 'level' => @entry_level.active_text, 'mail' => @config.mail_by_level, 'sound_file_path' => @config.sound_file_path_by_level, 'sms_num' => @config.sms_num_by_level, 'im_dest' => @config.im_dest_by_level, 'script_name' => @config.script_name_by_level } scan = { 'active_find_node' => { 'state' => @button_bp.active?, 'delay' => @entry_delay_bp.text.to_i, }, 'passive_find_node' => { 'state' => @button_passive_fn.active?, 'delay' => @entry_delay_passive_fn.text.to_i, }, 'mac' => { 'state' => @button_macf.active?, 'delay' => @entry_delay_macf.text.to_i, 'lock' => @button_macl.active?, 'manufacturer' => { 'state' => @button_macm.active? } }, 'node_resolving' => { 'state' => @button_nr.active?, 'delay' => @entry_delay_nr.text.to_i }, 'port' => { 'state' => @button_pm.active?, 'delay' => @entry_delay_pm.text.to_i }, 'snmp' => { 'state' => @button_snmp.active?, 'delay' => @entry_delay_snmp.text.to_i }, 'wmi' => { 'state' => @button_wmi.active?, 'delay' => @entry_delay_wmi.text.to_i }, 'custom' => { 'state' => @button_custom.active?, 'delay' => @entry_delay_custom.text.to_i }, 'jmx' => { 'state' => @button_jmx.active?, 'delay' => @entry_delay_jmx.text.to_i }, 'syslog' => { 'state' => @button_syslog_daemon.active?, 'port' => @entry_syslog_daemon_port.text.to_i }, 'snmptrap' => { 'state' => @button_snmptrap_daemon.active?, 'port' => @entry_snmptrap_daemon_port.text.to_i, 'community' => @entry_snmptrap_daemon_community.text } } path = { 'ping' => @entry_ping.text, 'nmap' => @entry_nmap.text, 'ssh' => @entry_ssh.text, 'telnet' => @entry_telnet.text, 'browser' => @entry_browser.text, 'vncviewer' => @entry_vncviewer.text, 'rdesktop' => @entry_rdesktop.text, 'terminal' => @entry_xterm.text, 'nmblookup' => @entry_nmblookup.text, 'xprobe' => @entry_xprobe.text, 'wmic' => @entry_wmic.text } if @colorchk.active? color="color" else color="image" end colors = { 'pixmap_size' => @entry_pixmap_size.text.to_i, 'bg_type' => color, 'label_text' => @cp_label_text.color.to_a(), 'label_bg' => @cp_label_bg.color.to_a(), 'rgb' => @cp.color.to_a(), 'image_path' => @entry_image.filename } YAML::dump(general) YAML::dump(snmp) YAML::dump(notification) YAML::dump(scan) YAML::dump(path) YAML::dump(colors) db = YAML::Store.new(fic_tmp.path) db.transaction{ db['general'] = general db['snmp'] = snmp db['notification'] = notification db['scan'] = scan db['path'] = path db['colors'] = colors } if File.stat(fic_tmp.path).size? FileUtils.move(fic_tmp.path, GLOBAL_CONF_FILE) $log.info("Configuration file saved as #{GLOBAL_CONF_FILE}") @config.read_config_yaml() end end |
#show ⇒ Object
main config window will all the frames
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 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 |
# File 'lib/gui/config_window.rb', line 335 def show() @window = Gtk::Window.new(Gtk::Window::TOPLEVEL) @window.set_title("Preference") @window.set_size_request(580,560) @window.border_width=0 @window.set_modal true @window.resizable=false @window.signal_connect("key_press_event") {|w,e| if e.keyval == Gdk::Keyval::GDK_Escape cancel_action() end } #init contact @old_contact=Hash.new $contact.each_key {|id| @old_contact[id]=$contact[id].dup } unless !$contact box1 = Gtk::VBox.new(FALSE, 0) @window.add(box1) box1.show box2 = Gtk::VBox.new(FALSE, 10) box2.border_width=10 box1.pack_start(box2, TRUE, TRUE, 0) box2.show notebook = Gtk::Notebook.new() notebook.set_tab_pos(Gtk::POS_TOP) box2.pack_start(notebook, TRUE, TRUE, 0) notebook.show #onglet 0 frame = Gtk::Frame::new("Overview") frame.border_width=10 frame.set_size_request(200, 150) frame.show table = Gtk::Table.new(13,2,false) table.show frame.add table @button_show_label = Gtk::CheckButton.new "Display label" @button_show_label.set_size_request 10,-1 @button_show_label.set_active @config.show_label @button_show_label.show table.attach(@button_show_label,0,1,1,2) @button_noshow_fqdn = Gtk::CheckButton.new "Display hostname instead of FQDN" @button_noshow_fqdn.set_size_request 10,-1 @button_noshow_fqdn.set_active @config.noshow_fqdn && @button_show_label.active? @button_noshow_fqdn.set_sensitive @button_show_label.active? @button_noshow_fqdn.show table.attach(@button_noshow_fqdn,0,1,2,3) @button_show_tooltips = Gtk::CheckButton.new "Display node tooltips" @button_show_tooltips.set_size_request 10,-1 @button_show_tooltips.set_active @config.show_tooltips @button_show_tooltips.show table.attach(@button_show_tooltips,0,1,3,4) @button_confirm_delete = Gtk::CheckButton.new "Confirm before removing node(s)" @button_confirm_delete.set_size_request 10,-1 @button_confirm_delete.set_active @config.confirm_delete @button_confirm_delete.show table.attach(@button_confirm_delete,0,1,4,5) @button_confirm_quit = Gtk::CheckButton.new "Confirm before quit" @button_confirm_quit.set_size_request 10,-1 @button_confirm_quit.set_active @config.confirm_quit @button_confirm_quit.show table.attach(@button_confirm_quit,0,1,5,6) label_log_level = Gtk::Label.new "Set log level to " @combo_log_level = Gtk::ComboBox.new levels = ["Debug", "Info", "Warning", "Error"] levels.each { |levl| @combo_log_level.append_text(levl) } ind = levels.index(@config.log_level) @combo_log_level.set_active(ind) if ind hbox=Gtk::HBox.new(false) hbox.pack_start label_log_level,false,true,0 hbox.pack_start @combo_log_level,false,false,0 hbox.show_all table.attach(hbox,0,1,6,7) @button_auto_save_map = Gtk::CheckButton.new "Autosave map frequency (in m)" @button_auto_save_map.set_active @config.auto_save_map hbbox=Gtk::HButtonBox.new() @entry_auto_save_map = Gtk::Entry.new @entry_auto_save_map.set_size_request(5,-1) @entry_auto_save_map.set_max_length 5 @entry_auto_save_map.set_text(@config.auto_save_map_value.to_s) @entry_auto_save_map.set_sensitive @button_auto_save_map.active? hbbox.add @entry_auto_save_map @button_auto_save_map.signal_connect("toggled") { @entry_auto_save_map.set_sensitive @button_auto_save_map.active? } hbox=Gtk::HBox.new() hbox.add @button_auto_save_map hbox.add hbbox hbox.show_all table.attach(hbox,0,1,7,8) @button_mail = Gtk::CheckButton.new "Configure mail server" @button_mail.set_active @config.mail_server hbbox=Gtk::VBox.new(false) hbbox.pack_start @button_mail,false,false,0 label_mail_server_addr = Gtk::Label.new "Mail server addr" label_mail_server_addr.show @entry_mail_server_addr = Gtk::Entry.new @entry_mail_server_addr.set_editable(true) if @config.mail_server_addr == nil @entry_mail_server_addr.set_text ConfigGlobal::DEFAULT_MAIL_SERVER else @entry_mail_server_addr.set_text @config.mail_server_addr end @entry_mail_server_addr.set_sensitive @button_mail.active? @entry_mail_server_addr.show bhbox_mail_server_addr=Gtk::HBox.new(true) bhbox_mail_server_addr.show bhbox_mail_server_addr.pack_start label_mail_server_addr,false,false,0 bhbox_mail_server_addr.pack_start @entry_mail_server_addr,false,false,0 hbbox.pack_start bhbox_mail_server_addr,false,false,0 label_mail_server_port = Gtk::Label.new "Mail server port" label_mail_server_port.show @entry_mail_server_port = Gtk::Entry.new @entry_mail_server_port.set_editable(true) if @config.mail_server_port == nil @entry_mail_server_port.set_text ConfigGlobal::DEFAULT_MAIL_SERVER_PORT else @entry_mail_server_port.set_text @config.mail_server_port.to_s end @entry_mail_server_port.set_sensitive @button_mail.active? @entry_mail_server_port.show bhbox_mail_server_port=Gtk::HBox.new(true) bhbox_mail_server_port.show bhbox_mail_server_port.pack_start label_mail_server_port,false,false,0 bhbox_mail_server_port.pack_start @entry_mail_server_port,false,false,0 hbbox.pack_start bhbox_mail_server_port,false,false,0 hbbox.show_all table.attach(hbbox,0,1,8,9) label_sms_device = Gtk::Label.new "Set SMS device " hbox=Gtk::HBox.new(false) hbox.pack_start label_sms_device,false,true,0 @entry_sms_device = Gtk::Entry.new if (@config.sms_device!=nil)&&(@entry_sms_device!="") @entry_sms_device.set_text(@config.sms_device) end hbox.pack_start @entry_sms_device,false,false,0 hbox.show_all table.attach(hbox,0,1,9,10) ######################################### Instant Messaging part ######################################### @button_im = Gtk::CheckButton.new "Configure IM bot (login and password)" @button_im.set_active @config.im_daemon hbbox=Gtk::VBox.new(false) hbbox.pack_start @button_im,false,false,0 hbox=Gtk::HBox.new(true) @entry_im_login = Gtk::Entry.new if (@config.im_login!=nil) && (@config.im_login!="") @entry_im_login.set_text(@config.im_login) end @entry_im_login.set_sensitive @button_im.active? hbox.pack_start @entry_im_login,false,false,0 @entry_im_password = Gtk::Entry.new @entry_im_password.visibility=false if (@config.im_password!=nil) && (@config.im_password!="") @entry_im_password.set_text(@config.im_password) end @entry_im_password.set_sensitive @button_im.active? hbox.pack_start @entry_im_password,false,false,0 hbbox.pack_start hbox,false,false,0 hbbox.show_all table.attach(hbbox,0,1,10,11) ######################################### IRC part ######################################### @button_irc = Gtk::CheckButton.new "Configure IRC bot (server, port, channel)" @button_irc.set_active @config.irc_daemon hbbox=Gtk::VBox.new(false) hbbox.add @button_irc hbox=Gtk::HBox.new(true) @entry_irc_server = Gtk::Entry.new if (@config.irc_server!=nil) && (@config.irc_server!="") @entry_irc_server.set_text(@config.irc_server) end @entry_irc_server.set_sensitive @button_irc.active? hbox.add @entry_irc_server @entry_irc_port = Gtk::Entry.new if (@config.irc_port!=nil) && (@config.irc_port!="") @entry_irc_port.set_text(@config.irc_port) else @entry_irc_port.set_text("6667") end @entry_irc_port.set_sensitive @button_irc.active? hbox.add @entry_irc_port @entry_irc_channel = Gtk::Entry.new if (@config.irc_channel!=nil) && (@config.irc_channel!="") @entry_irc_channel.set_text(@config.irc_channel) end @entry_irc_channel.set_sensitive @button_irc.active? hbox.add @entry_irc_channel hbbox.pack_start hbox,false,false,0 hbbox.show_all table.attach(hbbox,0,1,11,12) ######################################### END IRC part ##################################### hbox = Gtk::HBox.new(FALSE, 1) hbox.add Gtk::Image.new(Gtk::Stock::PROPERTIES, Gtk::IconSize::MENU) hbox.add Gtk::Label::new("General") hbox.show_all notebook.append_page frame, hbox #onglet 1 frame = Gtk::Frame.new("Configuration") frame.border_width=10 frame.set_size_request(300, 300) frame.show #read_community write_community version port timeout retry table = Gtk::Table.new(6,2,false) table.show frame.add table label_read_community = Gtk::Label.new "Read community" label_read_community.show @entry_read_community = Gtk::Entry.new if @config.read_community == "" || @config.read_community == nil @entry_read_community.set_text "public" else @entry_read_community.set_text @config.read_community end @entry_read_community.set_size_request(100,-1) @entry_read_community.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_read_community table.attach(label_read_community,0,1,0,1) table.attach(bbox,1,2,0,1) label_write_community = Gtk::Label.new "Write community" label_write_community.show @entry_write_community = Gtk::Entry.new if @config.write_community == "" || @config.write_community == nil @entry_write_community.set_text "private" else @entry_write_community.set_text @config.write_community end @entry_write_community.set_size_request(100,-1) @entry_write_community.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_write_community table.attach(label_write_community,0,1,1,2) table.attach(bbox,1,2,1,2) 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) if @config.snmp_version == "" || @config.snmp_version == nil || @config.snmp_version == "1" @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,2,3) table.attach(bbox,1,2,2,3) label_snmp_port = Gtk::Label.new "Port" label_snmp_port.show if @config.snmp_port == "" || @config.snmp_port == nil adj = Gtk::Adjustment::new(161.0, 1.0, 65534.0, 1.0, 5.0, 0.0) else adj = Gtk::Adjustment::new(@config.snmp_port.to_f, 1.0, 65534.0, 1.0, 5.0, 0.0) end @port_spinner = Gtk::SpinButton::new(adj, 0, 0) @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,3,4) table.attach(bbox,1,2,3,4) label_snmp_timeout = Gtk::Label.new "Timeout (in s)" label_snmp_timeout.show if @config.snmp_timeout == "" || @config.snmp_timeout == nil adj = Gtk::Adjustment::new(10.0, 1.0, 3600.0, 1.0, 5.0, 0.0) else adj = Gtk::Adjustment::new(@config.snmp_timeout.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0) end @timeout_spinner = Gtk::SpinButton::new(adj, 0, 0) @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,4,5) table.attach(bbox,1,2,4,5) label_snmp_retry = Gtk::Label.new "Retry" label_snmp_retry.show if @config.snmp_retry == "" || @config.snmp_retry == nil adj = Gtk::Adjustment::new(1.0, 1.0, 3600.0, 1.0, 5.0, 0.0) else adj = Gtk::Adjustment::new(@config.snmp_retry.to_f, 1.0, 3600.0, 1.0, 5.0, 0.0) end @retry_spinner = Gtk::SpinButton::new(adj, 0, 0) @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,5,6) table.attach(bbox,1,2,5,6) 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 #tab 2############################################################################################### 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 if @config.level == "" || @config.level == nil @entry_level.set_active(0) else @entry_level.set_active($LEVEL.index(@config.level)) end @old_sev_level=@entry_level.active_text @entry_level.show bbox=Gtk::VButtonBox.new bbox.show 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($level_alert_type[@entry_level.active_text][pos]) 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 @config.mail_by_level[@config.level] @entry_mail=@config.mail_by_level[@config.level] end @entry_mail_button.set_sensitive(cb_t.active? && @button_mail.active? && (Contact::contact_nb_entry()>0)) 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_t.set_sensitive(@button_mail.active? && (Contact::contact_nb_entry()>0)) @cb_mail=cb_t 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=Array.new if File.exists?(SOUND_DIR) files_tmp=Dir.entries(SOUND_DIR) files_tmp << ConfigGlobal::DEFAULT_SOUND_FILE files_tmp.each do |val| if val.match('[^.]') files << val @entry_soundfile.append_text(val) end end end current_level=@entry_level.active_text if @config.sound_file_path_by_level[current_level] != nil iter=files.index(@config.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 bhbox_sound_file=Gtk::HButtonBox.new bhbox_sound_file.add cb_t bhbox_sound_file.add label_soundfile bhbox_sound_file.add @entry_soundfile @entry_soundfile.set_sensitive(cb_t.active?) label_soundfile.set_sensitive(cb_t.active?) bhbox_sound_file.show bbox.add bhbox_sound_file elsif alert_type == "sms" cb_t.set_label("SMS mobile number") @entry_sms = [] @entry_sms_button = Gtk::Button.new("Configure contacts") if @config.sms_num_by_level[@config.level] @entry_sms=@config.sms_num_by_level[@config.level] end @entry_sms_button.set_sensitive(cb_t.active? && (Contact::contact_nb_entry()>0) && (@entry_sms_device.text != "")) 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((@entry_sms_device.text != "") && (Contact::contact_nb_entry()>0)) 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 @config.im_dest_by_level[@config.level] @entry_im=@config.im_dest_by_level[@config.level] end @entry_im_button.set_sensitive(cb_t.active? && @button_im.active? && (Contact::contact_nb_entry()>0)) 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_t.set_sensitive(@button_im.active? && (Contact::contact_nb_entry()>0)) @cb_im=cb_t 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 @config.script_name_by_level != nil && @config.script_name_by_level[@config.level] != nil && @config.script_name_by_level[@config.level] != "" @entry_script.set_text(@config.script_name_by_level[@config.level]) cb_t.active=true 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 == "irc" cb_t.set_sensitive(@button_irc.active?) @cb_irc=cb_t bbox.add cb_t else bbox.add cb_t end cb_t.signal_connect("clicked") {|s| lbl=s.label.downcase.gsub(/\s.*/,"") pos=$talert_type.index(lbl) $level_alert_type[@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 @config.level = @entry_level.active_text } end @button_im.signal_connect("toggled") { @entry_im_login.set_sensitive @button_im.active? @entry_im_password.set_sensitive @button_im.active? if (Contact::contact_nb_entry()==0) @cb_im.set_sensitive false else @cb_im.set_sensitive @button_im.active? end if !@button_im.active? @entry_im_button.set_sensitive @button_im.active? end } @button_irc.signal_connect("toggled") { @entry_irc_server.set_sensitive @button_irc.active? @entry_irc_port.set_sensitive @button_irc.active? @entry_irc_channel.set_sensitive @button_irc.active? @cb_irc.set_sensitive @button_irc.active? } @button_mail.signal_connect("toggled") { @entry_mail_server_addr.set_sensitive @button_mail.active? @entry_mail_server_port.set_sensitive @button_mail.active? if (Contact::contact_nb_entry()==0) @cb_mail.set_sensitive false else @cb_mail.set_sensitive @button_mail.active? end if !@button_mail.active? @entry_mail_button.set_sensitive @button_mail.active? end } @entry_soundfile.signal_connect("changed") { if @entry_soundfile.active_text == ConfigGlobal::DEFAULT_SOUND_FILE @config.sound_file_path_by_level[@entry_level.active_text] = nil else @config.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 @config.mail_by_level[@old_sev_level]=@entry_mail if @entry_soundfile.active_text == ConfigGlobal::DEFAULT_SOUND_FILE @config.sound_file_path_by_level[@old_sev_level] = nil else @config.sound_file_path_by_level[@old_sev_level] = @entry_soundfile.active_text end @config.script_name_by_level[@old_sev_level] = @entry_script.text @config.sms_num_by_level[@old_sev_level] = @entry_sms @config.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($level_alert_type[current_level][i]) i+=1 end #reload specific entry if @config.mail_by_level[current_level] @entry_mail=@config.mail_by_level[current_level] else @entry_mail.clear end if @button_mail.active? && @cb_mail.active? && (Contact::contact_nb_entry()>0) @entry_mail_button.set_sensitive true else @entry_mail_button.set_sensitive false end if @config.sound_file_path_by_level[current_level] != nil iter=files.index(@config.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 @config.script_name_by_level[current_level] && (@config.script_name_by_level[current_level] != "") @entry_script.set_text @config.script_name_by_level[current_level] else @entry_script.set_text("") @cb_script.active=false end if @config.sms_num_by_level[current_level] @entry_sms=@config.sms_num_by_level[current_level] else @entry_sms.clear end if (@entry_sms_device.text != "") && @cb_sms.active? && (Contact::contact_nb_entry()>0) @entry_sms_button.set_sensitive(true) else @entry_sms_button.set_sensitive(false) end if @config.im_dest_by_level[current_level] != nil @entry_im=@config.im_dest_by_level[current_level] else @entry_im.clear end if @button_im.active? && @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.signal_connect("switch-page") do |slf, page, page_num| #here page number 2 is the third page appended so it's "alert" if (page_num == 2) val=true if (Contact::contact_nb_entry()==0) || (@entry_sms_device.text == "") val=false end @cb_sms.set_sensitive(val) @entry_sms_button.set_sensitive(val && @cb_sms.active?) end end notebook.append_page frame, hbox ##################################contact tab###################################################### begin eval IO.read("#{GNMSLIB}"+'/gui/sub/contact_frame.rb') rescue Exception => msg $log.error("Can't load contact frame #{msg}") end ###################################active monitoring#################################################### vbox_frame=Gtk::VBox.new vbox_frame.show frame = Gtk::Frame::new("Active") frame.border_width=10 frame.show vbox_frame.add frame table = Gtk::Table.new(5,2,false) table.show frame.add table #find nodes using broadcast ping, and port scanning @button_bp = Gtk::CheckButton.new "Find new nodes delay (in s)" @button_bp.set_size_request 10,-1 @button_bp.set_active @config.active_find_node_state @button_bp.show @entry_delay_bp = Gtk::Entry.new @entry_delay_bp.show @entry_delay_bp.set_size_request 5,-1 if @config.active_find_node_delay == "" || @config.active_find_node_delay == nil @entry_delay_bp.set_text "300" else @entry_delay_bp.set_text @config.active_find_node_delay.to_s end @entry_delay_bp.set_sensitive @button_bp.active? @button_bp.signal_connect("toggled") { @entry_delay_bp.set_sensitive @button_bp.active? } table.attach(@button_bp,0,1,2,3) table.attach(@entry_delay_bp,1,2,2,3) @button_macf = Gtk::CheckButton.new "Find MAC address delay (in s)" @button_macf.set_active @config.mac_state @button_macf.show @entry_delay_macf = Gtk::Entry.new @entry_delay_macf.show @entry_delay_macf.set_size_request 5,-1 if @config.mac_delay == "" || @config.mac_delay == nil @entry_delay_macf.set_text "60" else @entry_delay_macf.set_text @config.mac_delay.to_s end @entry_delay_macf.set_sensitive @button_macf.active? table.attach(@button_macf,0,1,3,4) table.attach(@entry_delay_macf,1,2,3,4) @button_macl = Gtk::CheckButton.new "Lock MAC address" @button_macl.set_active @config.mac_lock @button_macl.show table.attach(@button_macl,0,1,4,5) vbox_macm=Gtk::VBox.new @button_macm = Gtk::CheckButton.new "Show manufacturer MAC address" @button_macm.set_active @config.mac_manufacturer @button_macm.show vbox_macm.add @button_macm if !mac_manufacturer_list_exist?() @button_macm.set_active false @button_macm.set_sensitive false #put a download OUIs button @button_macm_dl = Gtk::Button.new("Download MAC manufacturer") @button_macm_dl.signal_connect("clicked"){ Thread.start { @button_macm_dl.label="Processing OUIs from IEEE" Gtk.thread_protect do if get_mac_manufacturer_list() == 0 @button_macm.set_sensitive(true) unless !@button_macm @button_macm.set_active @config.mac_manufacturer unless !@button_macm @button_macm_dl.hide() else @button_macm_dl.label="Error when processing OUIs from IEEE" end end } } @button_macm_dl.show vbox_macm.add @button_macm_dl end vbox_macm.show table.attach(vbox_macm,0,1,5,6) @button_macf.signal_connect("toggled") { @entry_delay_macf.set_sensitive @button_macf.active? @button_macl.set_sensitive @button_macf.active? @button_macm.set_sensitive @button_macf.active? unless !mac_manufacturer_list_exist?() } @button_nr = Gtk::CheckButton.new "Node resolving delay (in s)" @button_nr.set_active @config.node_resolving @button_nr.show @entry_delay_nr = Gtk::Entry.new @entry_delay_nr.show @entry_delay_nr.set_size_request 5,-1 if @config.node_resolving_delay == "" || @config.node_resolving_delay == nil @entry_delay_nr.set_text "120" else @entry_delay_nr.set_text @config.node_resolving_delay.to_s end if ENV["USER"] != "root" @button_nr.set_active false @button_nr.set_sensitive false @entry_delay_nr.set_sensitive false else @entry_delay_nr.set_sensitive @button_nr.active? end @button_nr.signal_connect("toggled") { @entry_delay_nr.set_sensitive @button_nr.active? } table.attach(@button_nr,0,1,6,7) table.attach(@entry_delay_nr,1,2,6,7) @button_pm = Gtk::CheckButton.new "Host/Port monitoring delay (in s)" @button_pm.set_active @config.port_mon @button_pm.show @entry_delay_pm = Gtk::Entry.new @entry_delay_pm.show @entry_delay_pm.set_size_request 5,-1 if @config.port_mon_delay == "" || @config.port_mon_delay == nil @entry_delay_pm.set_text "60" else @entry_delay_pm.set_text @config.port_mon_delay.to_s end @entry_delay_pm.set_sensitive @button_pm.active? @button_pm.signal_connect("toggled") { @entry_delay_pm.set_sensitive @button_pm.active? } table.attach(@button_pm,0,1,8,9) table.attach(@entry_delay_pm,1,2,8,9) @button_snmp = Gtk::CheckButton.new "SNMP monitoring" @button_snmp.set_active @config.snmp_mon @button_snmp.show @entry_delay_snmp = Gtk::Entry.new @entry_delay_snmp.show @entry_delay_snmp.set_size_request 5,-1 if @config.snmp_mon_delay == "" || @config.snmp_mon_delay == nil @entry_delay_snmp.set_text "60" else @entry_delay_snmp.set_text @config.snmp_mon_delay.to_s end @entry_delay_snmp.set_sensitive @button_snmp.active? @button_snmp.signal_connect("toggled") { @entry_delay_snmp.set_sensitive @button_snmp.active? } table.attach(@button_snmp,0,1,9,10) table.attach(@entry_delay_snmp,1,2,9,10) @button_wmi = Gtk::CheckButton.new "WMI monitoring" @button_wmi.set_active @config.wmi_mon @button_wmi.show @entry_delay_wmi = Gtk::Entry.new @entry_delay_wmi.show @entry_delay_wmi.set_size_request 5,-1 if @config.wmi_mon_delay == "" || @config.wmi_mon_delay == nil @entry_delay_wmi.set_text "60" else @entry_delay_wmi.set_text @config.wmi_mon_delay.to_s end @entry_delay_wmi.set_sensitive @button_wmi.active? @button_wmi.signal_connect("toggled") { @entry_delay_wmi.set_sensitive @button_wmi.active? } table.attach(@button_wmi,0,1,10,11) table.attach(@entry_delay_wmi,1,2,10,11) @button_custom = Gtk::CheckButton.new "Custom monitoring" @button_custom.set_active @config.custom_mon @button_custom.show @entry_delay_custom = Gtk::Entry.new @entry_delay_custom.show @entry_delay_custom.set_size_request 5,-1 if @config.custom_mon_delay == "" || @config.custom_mon_delay == nil @entry_delay_custom.set_text "60" else @entry_delay_custom.set_text @config.custom_mon_delay.to_s end @entry_delay_custom.set_sensitive @button_custom.active? @button_custom.signal_connect("toggled") { @entry_delay_custom.set_sensitive @button_custom.active? } table.attach(@button_custom,0,1,11,12) table.attach(@entry_delay_custom,1,2,11,12) @button_jmx = Gtk::CheckButton.new "JMX monitoring" @button_jmx.set_active @config.jmx_mon @button_jmx.show @entry_delay_jmx = Gtk::Entry.new @entry_delay_jmx.show @entry_delay_jmx.set_size_request 5,-1 if @config.jmx_mon_delay == "" || @config.jmx_mon_delay == nil @entry_delay_jmx.set_text "60" else @entry_delay_jmx.set_text @config.jmx_mon_delay.to_s end @entry_delay_jmx.set_sensitive @button_jmx.active? @button_jmx.signal_connect("toggled") { @entry_delay_jmx.set_sensitive @button_jmx.active? } table.attach(@button_jmx,0,1,12,13) table.attach(@entry_delay_jmx,1,2,12,13) #passive monitoring frame_passive = Gtk::Frame::new("Passive") frame_passive.border_width=10 frame_passive.show vbox_frame.add frame_passive table_passive = Gtk::Table.new(4,2,false) table_passive.show frame_passive.add table_passive #find nodes using sniffing @button_passive_fn = Gtk::CheckButton.new "Find new nodes delay (in s)" @button_passive_fn.set_size_request 10,-1 @button_passive_fn.set_active @config.passive_find_node_state @button_passive_fn.show @entry_delay_passive_fn = Gtk::Entry.new @entry_delay_passive_fn.show @entry_delay_passive_fn.set_size_request 5,-1 if @config.passive_find_node_delay == "" || @config.passive_find_node_delay == nil @entry_delay_passive_fn.set_text "300" else @entry_delay_passive_fn.set_text @config.passive_find_node_delay.to_s end @entry_delay_passive_fn.set_sensitive @button_passive_fn.active? @button_passive_fn.signal_connect("toggled") { @entry_delay_passive_fn.set_sensitive @button_passive_fn.active? } table_passive.attach(@button_passive_fn,0,1,0,1) table_passive.attach(@entry_delay_passive_fn,1,2,0,1) @button_syslog_daemon = Gtk::CheckButton.new "Syslog server port" @button_syslog_daemon.set_active @config.syslog_mon @button_syslog_daemon.show @entry_syslog_daemon_port = Gtk::Entry.new @entry_syslog_daemon_port.show @entry_syslog_daemon_port.set_size_request 5,-1 @entry_syslog_daemon_port.set_max_length 5 if @config.syslog_port == "" || @config.syslog_port == nil @entry_syslog_daemon_port.set_text "514" else @entry_syslog_daemon_port.set_text @config.syslog_port.to_s end @entry_syslog_daemon_port.set_sensitive @button_syslog_daemon.active? @button_syslog_daemon.signal_connect("toggled") { @entry_syslog_daemon_port.set_sensitive @button_syslog_daemon.active? } table_passive.attach(@button_syslog_daemon,0,1,1,2) table_passive.attach(@entry_syslog_daemon_port,1,2,1,2) @button_snmptrap_daemon = Gtk::CheckButton.new "SNMP Trap server port" @button_snmptrap_daemon.set_active @config.snmptrap_mon @button_snmptrap_daemon.show @entry_snmptrap_daemon_port = Gtk::Entry.new @entry_snmptrap_daemon_port.show @entry_snmptrap_daemon_port.set_size_request 5,-1 @entry_snmptrap_daemon_port.set_max_length 5 if @config.snmptrap_port == "" || @config.snmptrap_port == nil @entry_snmptrap_daemon_port.set_text "162" else @entry_snmptrap_daemon_port.set_text @config.snmptrap_port.to_s end label_snmptrap_daemon_community=Gtk::Label.new("Community") label_snmptrap_daemon_community.set_alignment(0.2,0) label_snmptrap_daemon_community.show @entry_snmptrap_daemon_community = Gtk::Entry.new @entry_snmptrap_daemon_community.show @entry_snmptrap_daemon_community.set_size_request 5,-1 if @config.snmptrap_community == "" || @config.snmptrap_community == nil @entry_snmptrap_daemon_community.set_text "public" else @entry_snmptrap_daemon_community.set_text @config.snmptrap_community end @entry_snmptrap_daemon_port.set_sensitive @button_snmptrap_daemon.active? @entry_snmptrap_daemon_community.set_sensitive @button_snmptrap_daemon.active? @button_snmptrap_daemon.signal_connect("toggled") { @entry_snmptrap_daemon_port.set_sensitive @button_snmptrap_daemon.active? label_snmptrap_daemon_community.set_sensitive @button_snmptrap_daemon.active? @entry_snmptrap_daemon_community.set_sensitive @button_snmptrap_daemon.active? } table_passive.attach(@button_snmptrap_daemon,0,1,2,3) table_passive.attach(@entry_snmptrap_daemon_port,1,2,2,3) table_passive.attach(label_snmptrap_daemon_community,0,1,3,4) table_passive.attach(@entry_snmptrap_daemon_community,1,2,3,4) hbox = Gtk::HBox.new(FALSE, 1) hbox.add Gtk::Image.new(Gtk::Stock::EXECUTE, Gtk::IconSize::MENU) hbox.add Gtk::Label::new("Monitoring") hbox.show_all notebook.append_page vbox_frame, hbox #onglet 4 - need to be coded ! # # frame = Gtk::Frame::new("Where to store nodes") # frame.border_width=10 # frame.set_size_request(200, 150) # frame.show # # vbox = Gtk::VButtonBox.new # vbox.show # frame.add vbox # cbfile = Gtk::CheckButton.new("In file, support for 1 network") # cbfile.show # vbox.add cbfile # cbdb = Gtk::CheckButton.new("In DB, support for many networks/subnetworks") # cbdb.show # vbox.add cbdb # # label = Gtk::Label::new("Database") # notebook.append_page frame, label # #onglet 5 frame = Gtk::Frame::new("Executable File Path") frame.border_width=10 frame.set_size_request(200, 150) frame.show table = Gtk::Table.new(5,2,false) table.show frame.add table label_ping = Gtk::Label.new "ping" label_ping.show @entry_ping = Gtk::Entry.new if @config.ping_path == "" || @config.ping_path == nil ou=`/usr/bin/which ping | /bin/grep \/` @entry_ping.set_text ou.chomp else @entry_ping.set_text @config.ping_path end @entry_ping.set_size_request(140,-1) @entry_ping.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_ping table.attach(label_ping,0,1,0,1) table.attach(bbox,1,2,0,1) label_nmap = Gtk::Label.new "nmap" label_nmap.show @entry_nmap = Gtk::Entry.new if @config.nmap_path == "" || @config.nmap_path == nil ou=`/usr/bin/which nmap | /bin/grep \/` @entry_nmap.set_text ou.chomp else @entry_nmap.set_text @config.nmap_path end @entry_nmap.set_size_request(140,-1) @entry_nmap.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_nmap table.attach(label_nmap,0,1,2,3) table.attach(bbox,1,2,2,3) label_ssh = Gtk::Label.new "ssh" label_ssh.show @entry_ssh = Gtk::Entry.new if @config.ssh_path == "" || @config.ssh_path == nil ou=`/usr/bin/which ssh | /bin/grep \/` @entry_ssh.set_text ou.chomp else @entry_ssh.set_text @config.ssh_path end @entry_ssh.set_size_request(140,-1) @entry_ssh.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_ssh table.attach(label_ssh,0,1,3,4) table.attach(bbox,1,2,3,4) label_telnet = Gtk::Label.new "telnet" label_telnet.show @entry_telnet = Gtk::Entry.new if @config.telnet_path == "" || @config.telnet_path == nil ou=`/usr/bin/which telnet | /bin/grep \/` @entry_telnet.set_text ou.chomp else @entry_telnet.set_text @config.telnet_path end @entry_telnet.set_size_request(140,-1) @entry_telnet.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_telnet table.attach(label_telnet,0,1,4,5) table.attach(bbox,1,2,4,5) label_browser = Gtk::Label.new "browser" label_browser.show @entry_browser = Gtk::Entry.new if @config.browser_path == "" || @config.browser_path == nil for br in ["firefox", "mozilla", "netscape", "konqueror", "galeon"] ou=`/usr/bin/which #{br} | /bin/grep \/` if ou != "" break end end @entry_browser.set_text ou.chomp else @entry_browser.set_text @config.browser_path end @entry_browser.set_size_request(140,-1) @entry_browser.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_browser table.attach(label_browser,0,1,5,6) table.attach(bbox,1,2,5,6) label_vncviewer = Gtk::Label.new "VNC client" label_vncviewer.show @entry_vncviewer = Gtk::Entry.new if @config.vncviewer_path == "" || @config.vncviewer_path == nil ou=`/usr/bin/which vncviewer | /bin/grep \/` @entry_vncviewer.set_text ou.chomp else @entry_vncviewer.set_text @config.vncviewer_path end @entry_vncviewer.set_size_request(140,-1) @entry_vncviewer.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_vncviewer table.attach(label_vncviewer,0,1,6,7) table.attach(bbox,1,2,6,7) label_rdesktop = Gtk::Label.new "RDP client" label_rdesktop.show @entry_rdesktop = Gtk::Entry.new if @config.rdesktop_path == "" || @config.rdesktop_path == nil ou=`/usr/bin/which rdesktop | /bin/grep \/` @entry_rdesktop.set_text ou.chomp else @entry_rdesktop.set_text @config.rdesktop_path end @entry_rdesktop.set_size_request(140,-1) @entry_rdesktop.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_rdesktop table.attach(label_rdesktop,0,1,7,8) table.attach(bbox,1,2,7,8) label_xterm = Gtk::Label.new "terminal launcher" label_xterm.show @entry_xterm = Gtk::Entry.new if @config.xterm_path == "" || @config.xterm_path == nil ou=`/usr/bin/which xterm | /bin/grep \/` if ou @entry_xterm.set_text "#{ou.chomp} -e " end else @entry_xterm.set_text @config.xterm_path end @entry_xterm.set_size_request(140,-1) @entry_xterm.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_xterm table.attach(label_xterm,0,1,8,9) table.attach(bbox,1,2,8,9) label_nmblookup = Gtk::Label.new "nmblookup" label_nmblookup.show @entry_nmblookup = Gtk::Entry.new if @config.nmblookup_path == "" || @config.nmblookup_path == nil ou=`/usr/bin/which nmblookup | /bin/grep \/` @entry_nmblookup.set_text ou.chomp else @entry_nmblookup.set_text @config.nmblookup_path end @entry_nmblookup.set_size_request(140,-1) @entry_nmblookup.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_nmblookup table.attach(label_nmblookup,0,1,9,10) table.attach(bbox,1,2,9,10) label_xprobe = Gtk::Label.new "xprobe2" label_xprobe.show @entry_xprobe = Gtk::Entry.new if @config.xprobe_path == "" || @config.xprobe_path == nil ou=`/usr/bin/which xprobe2 | /bin/grep \/` @entry_xprobe.set_text ou.chomp else @entry_xprobe.set_text @config.xprobe_path end @entry_xprobe.set_size_request(140,-1) @entry_xprobe.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_xprobe table.attach(label_xprobe,0,1,10,11) table.attach(bbox,1,2,10,11) label_wmic = Gtk::Label.new "wmic" label_wmic.show @entry_wmic = Gtk::Entry.new if @config.wmic_path == "" || @config.wmic_path == nil ou=`/usr/bin/which wmic | /bin/grep \/` @entry_wmic.set_text ou.chomp else @entry_wmic.set_text @config.wmic_path end @entry_wmic.set_size_request(140,-1) @entry_wmic.show bbox=Gtk::HButtonBox.new bbox.show bbox.add @entry_wmic table.attach(label_wmic,0,1,11,12) table.attach(bbox,1,2,11,12) #end path elf hbox = Gtk::HBox.new(FALSE, 1) hbox.add Gtk::Image.new(Gtk::Stock::INDEX, Gtk::IconSize::MENU) hbox.add Gtk::Label::new("Path") hbox.show_all notebook.append_page frame, hbox #onglet 6 frame = Gtk::Frame::new("Accelerator") frame.border_width=10 frame.set_size_request(200, 150) frame.show label = Gtk::Label.new("keys are not yet dynamic") label.show frame.add label hbox = Gtk::HBox.new(FALSE, 1) hbox.add Gtk::Image.new(Gtk::Stock::SELECT_FONT, Gtk::IconSize::MENU) hbox.add Gtk::Label::new("Keys") hbox.show_all notebook.append_page frame, hbox #onglet 7 frame = Gtk::Frame::new("Default") frame.border_width=10 frame.set_size_request(200, 150) frame.show vbox = Gtk::VButtonBox.new vbox.set_layout_style(Gtk::ButtonBox::SPREAD) vbox.show frame.add vbox hbox = Gtk::HButtonBox.new hbox.set_layout_style(Gtk::ButtonBox::EDGE) 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 @config.pixmap_size == "" || @config.pixmap_size == nil @entry_pixmap_size.set_text "35" else @entry_pixmap_size.set_text(@config.pixmap_size.to_s()) end if @config.pixmap_size == "0" .set_active false else .set_active true end @entry_pixmap_size.set_sensitive .active? .signal_connect("toggled") { if !.active? @entry_pixmap_size.set_sensitive false @entry_pixmap_size.set_text "0" else @entry_pixmap_size.set_sensitive true @entry_pixmap_size.set_text(@config.pixmap_size.to_s()) end } hbox.add @entry_pixmap_size hbbl1=Gtk::HButtonBox.new hbbl1.set_layout_style(Gtk::ButtonBox::EDGE) hbbl1.show colorchk_label_text = Gtk::Label.new("Node text label color") colorchk_label_text.set_sensitive @button_show_label.active? colorchk_label_text.show hbbl1.add colorchk_label_text @cp_label_text = Gtk::ColorButton.new @cp_label_text.set_use_alpha(false) @cp_label_text.set_sensitive @button_show_label.active? gdk_color=nil if @config.label_text == nil gdk_color=Gdk::Color.new(0, 0, 0) else gdk_color=Gdk::Color.new(@config.label_text[0].to_f, @config.label_text[1].to_f, @config.label_text[2].to_f) end @cp_label_text.set_color(gdk_color) hbbl1.add @cp_label_text vbox.add hbbl1 @cp_label_text.show hbbl2=Gtk::HButtonBox.new hbbl2.set_layout_style(Gtk::ButtonBox::EDGE) hbbl2.show colorchk_bg_label = Gtk::Label.new("Node background label color") colorchk_bg_label.set_sensitive @button_show_label.active? colorchk_bg_label.show hbbl2.add colorchk_bg_label @cp_label_bg = Gtk::ColorButton.new @cp_label_bg.set_use_alpha(false) @cp_label_bg.set_sensitive @button_show_label.active? gdk_color=nil if @config.label_bg == nil gdk_color=Gdk::Color.new(65535, 65535, 65535) else gdk_color=Gdk::Color.new(@config.label_bg[0].to_f, @config.label_bg[1].to_f, @config.label_bg[2].to_f) end @cp_label_bg.set_color(gdk_color) hbbl2.add @cp_label_bg vbox.add hbbl2 @cp_label_bg.show @button_show_label.signal_connect("clicked") { @button_noshow_fqdn.set_sensitive(@button_show_label.active?) colorchk_label_text.set_sensitive(@button_show_label.active?) colorchk_bg_label.set_sensitive(@button_show_label.active?) @cp_label_text.set_sensitive(@button_show_label.active?) @cp_label_bg.set_sensitive(@button_show_label.active?) } hbb=Gtk::HButtonBox.new hbb.set_layout_style(Gtk::ButtonBox::EDGE) hbb.show @colorchk = Gtk::CheckButton.new("Map background color") @colorchk.show hbb.add @colorchk @cp = Gtk::ColorButton.new @cp.set_use_alpha(false) if @config.bg_type != nil if @config.bg_type == "color" @colorchk.set_active true @cp.set_sensitive true else @colorchk.set_active false @cp.set_sensitive false end end gdk_color=nil if @config.rgb == nil gdk_color=Gdk::Color.new(65535, 65535, 65535) else gdk_color=Gdk::Color.new(@config.rgb[0].to_f, @config.rgb[1].to_f, @config.rgb[2].to_f) end @cp.set_color(gdk_color) hbb.add @cp vbox.add hbb @cp.show hbb2=Gtk::HButtonBox.new hbb2.set_layout_style(Gtk::ButtonBox::EDGE) hbb2.show imagechk = Gtk::CheckButton.new("Map background image") imagechk.show hbb2.add imagechk #remove dir name and file format from file bg path file_ng = nil 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 @entry_image = Gtk::ImageComboList.new("bg", file_bg, "jpg") @entry_image.show hbb2.add @entry_image vbox.add hbb2 if @config.bg_type != nil if @config.bg_type == "image" imagechk.set_active(true) @entry_image.set_sensitive true else imagechk.set_active(false) @entry_image.set_sensitive false end end @colorchk.signal_connect("toggled") { if @colorchk.active? @cp.set_sensitive(true) imagechk.set_active(false) @entry_image.set_sensitive(false) else @cp.set_sensitive(false) imagechk.set_active(true) @entry_image.set_sensitive(true) end } imagechk.signal_connect("clicked") { if imagechk.active? @entry_image.set_sensitive(true) @colorchk.set_active(false) @cp.set_sensitive(false) else @entry_image.set_sensitive(false) @colorchk.set_active(true) @cp.set_sensitive(true) 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 #end separator = Gtk::HSeparator::new() box1.pack_start(separator, FALSE, TRUE, 0) separator.show box2 = Gtk::HBox::new(FALSE, 10) box2.border_width=10 box1.pack_start(box2, FALSE, TRUE, 0) box2.show = Gtk::Button::new(Gtk::Stock::SAVE) .signal_connect("clicked") do #save contacts $contact.each_key {|id| #for each entry we insert or update the db db_write_contact($contact[id].firstname, $contact[id].lastname, $contact[id].email, $contact[id].phone, $contact[id].mobile, $contact[id].pager, $contact[id].im, $contact[id].title, $contact[id].organization, $contact[id].location, $contact[id].note) @old_contact.delete(id) unless !@old_contact } #id in old_contact are delete entries if @old_contact @old_contact.each_key {|id| db_del_contact(@old_contact[id].firstname, @old_contact[id].lastname) } end #test if current map as color or image already set if get_map() and !$network[get_map()].map_bg_type if @colorchk.active? == true $canvas.unset_background_image() set_background_color(@cp.color()) else if @entry_image.filename!=nil && (FileTest.exist?("#{PIXMAP_PATH}"+"/"+@entry_image.filename)) $canvas.set_background_image("#{PIXMAP_PATH}"+"/"+@entry_image.filename) else $log.error("Warning: Image background #{PIXMAP_PATH}/#{@entry_image.filename} doesn't exist") #give focus to color imagechk.set_active(false) @colorchk.set_active(true) @config.bg_type="color" end end end old_config_show_label=@config.show_label old_config_noshow_fqdn=@config.noshow_fqdn old_config_show_tooltips=@config.show_tooltips old_config_log_level=@config.log_level old_config_pixmap_size=@config.pixmap_size old_config_label_text=@config.label_text old_config_label_bg=@config.label_bg #thread management old_port_mon=@config.port_mon old_snmp_mon=@config.snmp_mon old_wmi_mon=@config.wmi_mon old_jmx_mon=@config.jmx_mon old_custom_mon=@config.custom_mon old_active_find_node_state=@config.active_find_node_state old_passive_find_node_state=@config.passive_find_node_state old_mac_state=@config.mac_state old_node_resolving=@config.node_resolving old_syslog_mon=@config.syslog_mon old_syslog_mon_port=@config.syslog_port.to_i() old_snmptrap_mon=@config.snmptrap_mon old_snmptrap_mon_port=@config.snmptrap_port.to_i() old_auto_save_map=@config.auto_save_map old_auto_save_map_value=@config.auto_save_map_value old_im_daemon=@config.im_daemon old_im_login=@config.im_login old_im_password=@config.im_password old_irc_daemon=@config.irc_daemon old_irc_server=@config.irc_server old_irc_port=@config.irc_port old_irc_channel=@config.irc_channel #notification: store mail information for current severity @config.mail_by_level[@config.level]=@entry_mail #notification: store script name if @config.script_name_by_level == nil @config.init_script_name() end @config.script_name_by_level[@config.level]=@entry_script.text @config.sms_num_by_level[@config.level]=@entry_sms @config.im_dest_by_level[@config.level]=@entry_im if isInteger(@entry_delay_bp.text) && @entry_delay_bp.text.to_i > 5 && isInteger(@entry_delay_macf.text) && @entry_delay_macf.text.to_i > 5 && isInteger(@entry_delay_nr.text) && @entry_delay_nr.text.to_i > 5 && isInteger(@entry_delay_pm.text) && @entry_delay_pm.text.to_i > 5 && isInteger(@entry_delay_snmp.text) && @entry_delay_snmp.text.to_i > 5 && isInteger(@entry_delay_wmi.text) && @entry_delay_wmi.text.to_i > 5 && isInteger(@entry_delay_jmx.text) && @entry_delay_jmx.text.to_i > 5 && isInteger(@entry_delay_custom.text) && @entry_delay_custom.text.to_i > 5 && isInteger(@entry_auto_save_map.text) && @entry_auto_save_map.text.to_i > 5 if isValidPort(@entry_syslog_daemon_port.text.to_i()) if isValidPort(@entry_snmptrap_daemon_port.text.to_i()) if @entry_auto_save_map.text.to_i > 1 if (@entry_mail_server_addr.text == "") || (@entry_mail_server_port.text == "") #we can't enable mail notification is a parameter is missing @button_mail.set_active(false) end save_config_yaml() #reload label colors if (old_config_label_text != @config.label_text) or (old_config_label_bg != @config.label_bg) if $map.nil? #it's only root map $network[get_map()].node_view.reload_label_colors() else $network[get_map()].get_node().each_value {|n| n.node_view.reload_label_colors() } end end #once save, try to find nmap version check_scanner_version() #update snmp conf for root node $network[ROOTMAPADDR].set_snmp_conf(@entry_read_community.text, @entry_write_community.text, @combo_snmp_version.active_text, @port_spinner.value_as_int, @timeout_spinner.value_as_int, @retry_spinner.value_as_int, 1) unless !$network[ROOTMAPADDR] if old_port_mon != @button_pm.active? if @button_pm.active? add_monitoring_thread("Port monitoring",tmonitorport()) else del_monitoring_thread("Port monitoring") end end if old_snmp_mon != @button_snmp.active? if @button_snmp.active? add_monitoring_thread("Snmp monitoring",tmonitorsnmp()) else del_monitoring_thread("Snmp monitoring") end end if old_wmi_mon != @button_wmi.active? if @button_wmi.active? add_monitoring_thread("WMI monitoring",tmonitorwmi()) else del_monitoring_thread("WMI monitoring") end end if old_custom_mon != @button_custom.active? if @button_custom.active? add_monitoring_thread("Custom monitoring",tmonitorcustom()) else del_monitoring_thread("Custom monitoring") end end if old_jmx_mon != @button_jmx.active? if @button_jmx.active? add_monitoring_thread("JMX monitoring",tmonitorjmx()) else del_monitoring_thread("JMX monitoring") end end if old_active_find_node_state != @button_bp.active? if @button_bp.active? add_monitoring_thread("Local ping", t_find_local_segment_pinging()) add_monitoring_thread("Remote ping", t_find_remote_new_host()) else del_monitoring_thread("Local ping") del_monitoring_thread("Remote ping") end end if old_passive_find_node_state != @button_passive_fn.active? if @button_passive_fn.active? add_monitoring_thread("Local sniffing", t_find_local_segment_sniffing()) add_monitoring_thread("SSDP query", t_find_ssdp_discovery()) else del_monitoring_thread("Local sniffing") del_monitoring_thread("SSDP query") end end if old_mac_state != @button_macf.active? if @button_macf.active? add_monitoring_thread("Find mac",tmacip()) else del_monitoring_thread("Find mac") end end if old_node_resolving != @button_nr.active? if @button_nr.active? add_monitoring_thread("Resolve ip to name",tresolvip()) add_monitoring_thread("Resolve ip to netbios",tresolvnetbiosname()) add_monitoring_thread("Find os",tresolvos()) add_monitoring_thread("Find snmp",tresolvsnmp()) else del_monitoring_thread("Resolve ip to name") del_monitoring_thread("Resolve ip to netbios") del_monitoring_thread("Find os") del_monitoring_thread("Find snmp") end end if old_syslog_mon != @button_syslog_daemon.active? if @button_syslog_daemon.active? $syslog_capture=SyslogCapture.new() else if $syslog_capture != nil $syslog_capture.stop() end end elsif @button_syslog_daemon.active? && (old_syslog_mon_port != @entry_syslog_daemon_port.text.to_i()) $syslog_capture.stop() #and restart with new port sleep(1) $syslog_capture=SyslogCapture.new() end if @entry_im_login.text != "" if old_im_daemon != @button_im.active? if @button_im.active? $im_daemon=XmppBot.new() else if $im_daemon != nil $im_daemon.stop() $im_daemon = nil end end elsif @button_im.active? && ((old_im_login != @entry_im_login.text)||(old_im_password != @entry_im_password.text)) if $im_daemon $im_daemon.stop() $im_daemon = nil #and restart with new conf sleep(1) end $im_daemon=XmppBot.new() end else #no login so we desactivate the button $log.error("IM login not set, so IM notification is disabled") if @button_im.active? @button_im.set_active(false) if $im_daemon != nil $im_daemon.stop() $im_daemon = nil end end if (@entry_irc_server.text != "") and (@entry_irc_channel.text != "") if old_irc_daemon != @button_irc.active? if @button_irc.active? $irc_daemon=IrcBot.new() else if $irc_daemon != nil $irc_daemon.stop() $irc_daemon = nil end end elsif @button_irc.active? && ((old_irc_server != @entry_irc_server.text)||(old_irc_port != @entry_irc_port.text)||(old_irc_channel != @entry_irc_channel.text)) if $irc_daemon $irc_daemon.stop() $irc_daemon = nil #and restart with new conf sleep(1) end $irc_daemon=IrcBot.new() end else #no server or no channel so we desactivate the button $log.error("IRC server or channel is not set, so IRC notification is disabled") if @button_irc.active? @button_irc.set_active(false) if $irc_daemon != nil $irc_daemon.stop() $irc_daemon = nil end end if old_snmptrap_mon != @button_snmptrap_daemon.active? if @button_snmptrap_daemon.active? $snmptrap_capture=SnmpTrapCapture.new() else if $snmptrap_capture != nil $snmptrap_capture.stop() end end elsif @button_snmptrap_daemon.active? && (old_snmptrap_mon_port != @entry_snmptrap_daemon_port.text.to_i()) $snmptrap_capture.stop() #and restart with new port sleep(1) $snmptrap_capture=SnmpTrapCapture.new() end if old_config_show_label != @button_show_label.active? #remove label from nodes if $map.nil? #it's only root map $network[get_map()].set_label_visibility() else $network[get_map()].get_node().each_value {|n| n.set_label_visibility() } end end if old_config_noshow_fqdn != @button_noshow_fqdn.active? #only show fqdn on node host $network[get_map()].get_node().each_value {|n| if n.class == Host n.refresh_dns_name() end } end if old_config_log_level != @entry_level.active_text $log.level=txtlvl_to_loggerlvl(@config.log_level) end if old_config_pixmap_size.to_i() != @entry_pixmap_size.text.to_i() $network[get_map()].get_node().each_value {|n| n.node_view.resize() } end if (old_auto_save_map != @button_auto_save_map.active?) && @button_auto_save_map.active? if !exist_monitoring_thread("Map autosaving") add_monitoring_thread("Map autosaving",tauto_save_map()) else $log.info("Thread autosave map already active") end end @window.destroy @window = nil else errorEntry(@window, "Bad auto save value need to be greater than 1") end else errorEntry(@window, "Bad SNMP trap server port") end else errorEntry(@window, "Bad Syslog server port") end else errorEntry(@window, "Bad delay value") end end box2.pack_start(, TRUE, TRUE, 0) .set_flags(Gtk::Widget::CAN_DEFAULT); .grab_default .show = Gtk::Button::new(Gtk::Stock::CANCEL) .signal_connect("clicked") do cancel_action() end box2.pack_start(, TRUE, TRUE, 0) .set_flags(Gtk::Widget::CAN_DEFAULT); .grab_default .show @window.show end |
#toggle_contact_selection(path = 0) ⇒ Object
toggle contact selection in contact selection window
173 174 175 176 177 178 179 180 181 |
# File 'lib/gui/config_window.rb', line 173 def toggle_contact_selection(path=0) #switch all port @contact_treeview.model.each {|model, path, iter| fixed =iter[0] fixed ^= 1 @contact_selection[path.to_str().to_i()]=fixed iter[0] = fixed } end |
#visible ⇒ Object
327 328 329 330 |
# File 'lib/gui/config_window.rb', line 327 def visible() return @window.visible? if @window return false end |