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
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
|
# File 'lib/gui/node_host_property.rb', line 1456
def initialize (node)
@color_style = [$red, $orange, $yellow, $blue]
window=Gtk::Window.new
@window=window
window.set_transient_for($win)
window.set_title("Node property of "+node.ip+"/#{node.netmask}")
window.set_size_request(450, 450)
window.set_modal(true)
vboxb = Gtk::VBox::new
window.add vboxb
vboxb.show
notebook = Gtk::Notebook::new()
notebook.set_tab_pos(Gtk::POS_TOP)
vboxb.add notebook
notebook.show
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
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,2,false)
table_st.show
label_status = Gtk::Label.new "Current"
label_status.show
entry_status = Gtk::Entry.new
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]])
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_status,0,1,0,1)
table_st.attach(bbox,1,2,0,1)
frame_st.add table_st
frame_st.show
vbox.add frame_st
frame_dt=Gtk::Frame.new("Details")
frame_dt.border_width=10
table = Gtk::Table.new(8,2,false)
table.show
label_avail = Gtk::Label.new "Availability"
label_avail.show
entry_avail = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.avail_sev)])
entry_avail.set_text($status[$status_value.index(node.avail_sev)])
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_avail.set_style(tstyle)
entry_avail.set_size_request(100, -1)
entry_avail.set_xalign(0.5);
entry_avail.set_editable false
entry_avail.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_avail
table.attach(label_avail,0,1,0,1)
table.attach(bbox,1,2,0,1)
label_service = Gtk::Label.new "Service"
label_service.show
entry_service = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.port_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.service_sev)])
entry_service.set_text($status[$status_value.index(node.service_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_service.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_service.set_style(tstyle)
entry_service.set_size_request(100, -1)
entry_service.set_xalign(0.5);
entry_service.set_editable false
entry_service.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_service
table.attach(label_service,0,1,1,2)
table.attach(bbox,1,2,1,2)
label_snmp = Gtk::Label.new "SNMP"
label_snmp.show
entry_snmp = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.snmp_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.snmp_sev)])
entry_snmp.set_text($status[$status_value.index(node.snmp_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_snmp.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_snmp.set_style(tstyle)
entry_snmp.set_size_request(100, -1)
entry_snmp.set_xalign(0.5);
entry_snmp.set_editable false
entry_snmp.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_snmp
table.attach(label_snmp,0,1,2,3)
table.attach(bbox,1,2,2,3)
label_wmi = Gtk::Label.new "WMI"
label_wmi.show
entry_wmi = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.wmi_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.wmi_sev)])
entry_wmi.set_text($status[$status_value.index(node.wmi_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_wmi.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_wmi.set_style(tstyle)
entry_wmi.set_size_request(100, -1)
entry_wmi.set_xalign(0.5);
entry_wmi.set_editable false
entry_wmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_wmi
table.attach(label_wmi,0,1,3,4)
table.attach(bbox,1,2,3,4)
label_jmx = Gtk::Label.new "JMX"
label_jmx.show
entry_jmx = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.jmx_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.jmx_sev)])
entry_jmx.set_text($status[$status_value.index(node.jmx_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_jmx.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_jmx.set_style(tstyle)
entry_jmx.set_size_request(100, -1)
entry_jmx.set_xalign(0.5);
entry_jmx.set_editable false
entry_jmx.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_jmx
table.attach(label_jmx,0,1,4,5)
table.attach(bbox,1,2,4,5)
label_custom = Gtk::Label.new "Custom"
label_custom.show
entry_custom = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.custom_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.custom_sev)])
entry_custom.set_text($status[$status_value.index(node.custom_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_custom.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_custom.set_style(tstyle)
entry_custom.set_size_request(100, -1)
entry_custom.set_xalign(0.5)
entry_custom.set_editable false
entry_custom.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_custom
table.attach(label_custom,0,1,5,6)
table.attach(bbox,1,2,5,6)
label_syslog = Gtk::Label.new "Syslog"
label_syslog.show
entry_syslog = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.syslog_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.syslog_sev)])
entry_syslog.set_text($status[$status_value.index(node.syslog_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_syslog.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_syslog.set_style(tstyle)
entry_syslog.set_size_request(100, -1)
entry_syslog.set_xalign(0.5)
entry_syslog.set_editable false
entry_syslog.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_syslog
table.attach(label_syslog,0,1,6,7)
table.attach(bbox,1,2,6,7)
label_trap = Gtk::Label.new "SNMP Trap"
label_trap.show
entry_trap = Gtk::Entry.new
tstyle=Gtk::Style.new
rgb=nil
if $config.snmptrap_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.trap_sev)])
entry_trap.set_text($status[$status_value.index(node.trap_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_trap.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_trap.set_style(tstyle)
entry_trap.set_size_request(100, -1)
entry_trap.set_xalign(0.5)
entry_trap.set_editable false
entry_trap.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_trap
table.attach(label_trap,0,1,7,8)
table.attach(bbox,1,2,7,8)
frame_dt.add table
frame_dt.show
vbox.add frame_dt
refresh_node_sev_display=Thread.new {
while (window != nil) do
sleep(10)
begin
rgb=hexa_to_rgb_color($status_color[$status_value[node.status]])
Gtk.thread_protect do
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]])
rgb=nil
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.avail_sev)])
entry_avail.set_text($status[$status_value.index(node.avail_sev)])
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_avail.set_style(tstyle)
rgb=nil
if $config.port_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.service_sev)])
entry_service.set_text($status[$status_value.index(node.service_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_service.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_service.set_style(tstyle)
rgb=nil
if $config.snmp_mon || $config.wmi_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.snmp_sev)])
entry_snmp.set_text($status[$status_value.index(node.snmp_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_snmp.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_snmp.set_style(tstyle)
rgb=nil
if $config.wmi_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.wmi_sev)])
entry_wmi.set_text($status[$status_value.index(node.wmi_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_wmi.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_wmi.set_style(tstyle)
rgb=nil
if $config.jmx_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.jmx_sev)])
entry_jmx.set_text($status[$status_value.index(node.jmx_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_jmx.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_jmx.set_style(tstyle)
rgb=nil
if $config.custom_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.custom_sev)])
entry_custom.set_text($status[$status_value.index(node.custom_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_custom.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_custom.set_style(tstyle)
rgb=nil
if $config.syslog_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.syslog_sev)])
entry_syslog.set_text($status[$status_value.index(node.syslog_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_syslog.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_syslog.set_style(tstyle)
rgb=nil
if $config.snmptrap_mon
rgb=hexa_to_rgb_color($status_color[$status_value.index(node.trap_sev)])
entry_trap.set_text($status[$status_value.index(node.trap_sev)])
else
rgb=hexa_to_rgb_color($status_color[$status_value.index(UNMANAGED)])
entry_trap.set_text($status[$status_value.index(UNMANAGED)])
end
tstyle=Gtk::Style.new
tstyle.set_base(Gtk::STATE_NORMAL, rgb.red, rgb.green, rgb.blue)
entry_trap.set_style(tstyle)
end
rescue Exception => msg
$log.debug("Exception in refresh_node_sev_display for #{node.ip}: #{msg}")
end
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
window.signal_connect("key_press_event") {|w,e|
if e.keyval == Gdk::Keyval::GDK_Escape
node.init_account_from_db()
Thread.kill(@scan_port_th) unless @scan_port_th == nil
Gtk.thread_flush
Thread.kill(refresh_node_sev_display)
Gtk.thread_flush
window.destroy
end
}
notebook_info = Gtk::Notebook::new()
notebook_info.show
frame_stored = Gtk::Frame::new
frame_stored.border_width=10
frame_stored.set_size_request(300, 290)
frame_stored.show
table = Gtk::Table.new(10,2,false)
table.show
vbox = Gtk::VBox.new
vbox.show
frame_stored.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.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.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
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
entry_map.set_text(node.map)
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_mac = Gtk::Label.new "MAC"
label_mac.show
entry_mac = Gtk::Entry.new
entry_mac.set_text(node.mac)
entry_mac.set_size_request(200, -1)
entry_mac.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_mac
table.attach(label_mac,0,1,5,6)
table.attach(bbox,1,2,5,6)
label_name = Gtk::Label.new "DNS Name"
label_name.show
entry_name = Gtk::Entry.new
if node.hostname?() and !node.dns_name?()
entry_name.set_text(node.name)
else
entry_name.set_text(node.dns_name)
end
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,6,7)
table.attach(bbox,1,2,6,7)
label_netbiosname = Gtk::Label.new "Netbios Name"
label_netbiosname.show
entry_netbiosname = Gtk::Entry.new
entry_netbiosname.set_text(node.netbios_name)
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_info.append_page frame_stored, Gtk::Label::new("Stored")
frame_snmp_info = Gtk::Frame::new
frame_snmp_info.border_width=10
frame_snmp_info.set_size_request(300, 290)
frame_snmp_info.show
table = Gtk::Table.new(5,2,false)
table.show
frame_snmp_info.add table
label_desc = Gtk::Label.new "Description"
label_desc.show
entry_descsnmp = Gtk::Entry.new
entry_descsnmp.set_editable false
def snmp_description(entry, node, )
if $config.snmp_mon
entry.set_text "(polling...)"
Thread.start {
val=get_snmp_description(node)
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in snmp_description for #{node.ip}: #{msg}")
end
end
}
else
Gtk.thread_protect do
begin
entry.set_sensitive(false)
entry.set_text "(SNMP is disable)"
rescue
$log.debug("Exception in snmp_description for #{node.ip}: #{msg}")
end
end
end
end
if node.get_account_id("snmp")
login, password = node.get_account_id("snmp")
snmp_description(entry_descsnmp, node, login)
end
entry_descsnmp.set_size_request(200, -1)
entry_descsnmp.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_descsnmp
table.attach(label_desc,0,1,0,1)
table.attach(bbox,1,2,0,1)
label_uptime = Gtk::Label.new "Uptime"
label_uptime.show
entry_uptime = Gtk::Entry.new
entry_uptime.set_editable false
def snmp_uptime(entry, node, )
if $config.snmp_mon
entry.set_text "(polling...)"
Thread.start {
val=get_snmp_uptime(node)
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in snmp_uptime for #{node.ip}: #{msg}")
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(SNMP is disable)"
rescue Exception => msg
$log.debug("Exception in snmp_uptime for #{node.ip}: #{msg}")
end
end
end
if node.get_account_id("snmp")
login, password = node.get_account_id("snmp")
snmp_uptime(entry_uptime, node, login)
end
entry_uptime.set_size_request(200, -1)
entry_uptime.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_uptime
table.attach(label_uptime,0,1,1,2)
table.attach(bbox,1,2,1,2)
label_contact = Gtk::Label.new "Contact"
label_contact.show
entry_contact = Gtk::Entry.new
entry_contact.set_editable false
def snmp_contact(entry, node, )
if $config.snmp_mon
entry.set_text "(polling...)"
Thread.start {
val=get_snmp_contact(node)
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in snmp_contact for #{node.ip}: #{msg}")
end
end
}
else
Gtk.thread_protect do
begin
entry.set_sensitive(false)
entry.set_text "(SNMP is disable)"
rescue Exception => msg
$log.debug("Exception in snmp_contact for #{node.ip}: #{msg}")
end
end
end
end
if node.get_account_id("snmp")
login, password = node.get_account_id("snmp")
snmp_contact(entry_contact, node, login)
end
entry_contact.set_size_request(200, -1)
entry_contact.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_contact
table.attach(label_contact,0,1,2,3)
table.attach(bbox,1,2,2,3)
label_location = Gtk::Label.new "Location"
label_location.show
entry_location = Gtk::Entry.new
entry_location.set_editable false
def snmp_location(entry, node, )
if $config.snmp_mon
entry.set_text "(polling...)"
Thread.start {
val=get_snmp_location(node)
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in snmp_location for #{node.ip}: #{msg}")
end
end
}
else
Gtk.thread_protect do
begin
entry.set_sensitive(false)
entry.set_text "(SNMP is disable)"
rescue Exception => msg
$log.debug("Exception in snmp_location for #{node.ip}: #{msg}")
end
end
end
end
if node.get_account_id("snmp")
login, password = node.get_account_id("snmp")
snmp_location(entry_location, node, login)
end
entry_location.set_size_request(200, -1)
entry_location.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_location
table.attach(label_location,0,1,3,4)
table.attach(bbox,1,2,3,4)
hbbox=Gtk::HButtonBox.new
refresh_button = Gtk::Button.new(Gtk::Stock::REFRESH)
if !$config.snmp_mon
refresh_button.set_sensitive false
end
hbbox.add refresh_button
hbbox.show
refresh_button.signal_connect("clicked") do
if node.get_account_id("snmp")
login, password = node.get_account_id("snmp")
snmp_description(entry_descsnmp, node, login)
snmp_uptime(entry_uptime, node, login)
snmp_contact(entry_contact, node, login)
snmp_location(entry_location, node, login)
end
end
refresh_button.show
table.attach(hbbox,1,2,4,5)
notebook_info.append_page frame_snmp_info, Gtk::Label::new("SNMP")
frame_wmi_info = Gtk::Frame::new
frame_wmi_info.border_width=10
frame_wmi_info.set_size_request(300, 290)
frame_wmi_info.show
table = Gtk::Table.new(8,2,false)
table.show
frame_wmi_info.add table
label_desc = Gtk::Label.new "Description"
label_desc.show
entry_descwmi = Gtk::Entry.new
entry_descwmi.set_editable false
def wmi_description(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_description(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_description for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_description(entry_descwmi, node, login, password)
end
entry_descwmi.set_size_request(200, -1)
entry_descwmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_descwmi
table.attach(label_desc,0,1,0,1)
table.attach(bbox,1,2,0,1)
label_boot = Gtk::Label.new "Bootup State"
label_boot.show
entry_bootwmi = Gtk::Entry.new
entry_bootwmi.set_editable false
def wmi_boot(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_boot_state(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_boot for #{node.ip}: #{msg}")
end
end
end
}
else
Gtk.thread_protect do
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_boot(entry_bootwmi, node, login, password)
end
entry_bootwmi.set_size_request(200, -1)
entry_bootwmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_bootwmi
table.attach(label_boot,0,1,1,2)
table.attach(bbox,1,2,1,2)
label_thermal = Gtk::Label.new "Thermal State"
label_thermal.show
entry_thermalwmi = Gtk::Entry.new
entry_thermalwmi.set_editable false
def wmi_thermal(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_thermal_state(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_thermal for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_thermal(entry_thermalwmi, node, login, password)
end
entry_thermalwmi.set_size_request(200, -1)
entry_thermalwmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_thermalwmi
table.attach(label_thermal,0,1,2,3)
table.attach(bbox,1,2,2,3)
label_nbproc = Gtk::Label.new "Processor Number"
label_nbproc.show
entry_nbprocwmi = Gtk::Entry.new
entry_nbprocwmi.set_editable false
def wmi_nbproc(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_nb_proc(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_nbproc for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_nbproc(entry_nbprocwmi, node, login, password)
end
entry_nbprocwmi.set_size_request(200, -1)
entry_nbprocwmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_nbprocwmi
table.attach(label_nbproc,0,1,3,4)
table.attach(bbox,1,2,3,4)
label_systype = Gtk::Label.new "System Type"
label_systype.show
entry_systype = Gtk::Entry.new
entry_systype.set_editable false
def wmi_systype(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_system_type(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_systype for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_systype(entry_systype, node, login, password)
end
entry_systype.set_size_request(200, -1)
entry_systype.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_systype
table.attach(label_systype,0,1,4,5)
table.attach(bbox,1,2,4,5)
label_oswmi = Gtk::Label.new "OS"
label_oswmi.show
entry_oswmi = Gtk::Entry.new
entry_oswmi.set_editable false
def wmi_os(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_os(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_os for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_os(entry_oswmi, node, login, password)
end
entry_oswmi.set_size_request(200, -1)
entry_oswmi.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_oswmi
table.attach(label_oswmi,0,1,5,6)
table.attach(bbox,1,2,5,6)
label_producttype = Gtk::Label.new "Product Type"
label_producttype.show
entry_producttype = Gtk::Entry.new
entry_producttype.set_editable false
def wmi_producttype(entry, node, login ,pass)
if $config.wmi_mon
entry.set_text "(polling...)"
Thread.start {
val=get_wmi_product_type(login, pass, node.ip)
if val
Gtk.thread_protect do
begin
entry.set_position 0
entry.set_text val
rescue Exception => msg
$log.debug("Exception in wmi_producttype for #{node.ip}: #{msg}")
end
end
end
}
else
begin
entry.set_sensitive(false)
entry.set_text "(WMI is disable)"
rescue
end
end
end
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_producttype(entry_producttype, node, login, password)
end
entry_producttype.set_size_request(200, -1)
entry_producttype.show
bbox=Gtk::HButtonBox.new
bbox.show
bbox.add entry_producttype
table.attach(label_producttype,0,1,6,7)
table.attach(bbox,1,2,6,7)
hbbox=Gtk::HButtonBox.new
refresh_button_wmi = Gtk::Button.new(Gtk::Stock::REFRESH)
if !$config.wmi_mon
refresh_button_wmi.set_sensitive false
end
hbbox.add refresh_button_wmi
hbbox.show
refresh_button_wmi.signal_connect("clicked") do
if node.get_account_id("wmi")
login, password = node.get_account_id("wmi")
wmi_description(entry_descwmi, node, login, password)
wmi_boot(entry_bootwmi, node, login, password)
wmi_thermal(entry_thermalwmi, node, login, password)
wmi_nbproc(entry_nbprocwmi, node, login, password)
wmi_systype(entry_systype, node, login, password)
wmi_os(entry_oswmi, node, login, password)
wmi_producttype(entry_producttype, node, login, password)
end
end
refresh_button_wmi.show
table.attach(hbbox,1,2,7,8)
notebook_info.append_page frame_wmi_info, Gtk::Label::new("WMI")
notebook.append_page notebook_info, hbox
eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
frame = Gtk::Frame::new
frame.border_width=10
frame.show
vvbox = Gtk::VBox::new
vvbox.show
vvbox.add frame
vbox = Gtk::VBox::new(false,3)
vbox.show
frame.add vbox
@vbox_ports = Gtk::VBox::new
@vbox_ports.show
vbox.add @vbox_ports
@scan_port_th=nil
@cbutton=[]
@scanned_port_list=nil
ls = Gtk::ListStore.new(Integer, String, Integer, String, String)
@treeview = Gtk::TreeView.new(ls)
renderer = Gtk::CellRendererToggle.new
renderer.signal_connect('toggled') do |cell, path|
iter = @treeview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
@cbutton[path.to_i()]=fixed
iter[0] = fixed
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("Protocol",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
column3 = Gtk::TreeViewColumn.new("Port",
Gtk::CellRendererText.new, {:text => 2})
column3.set_sort_column_id(2)
column4 = Gtk::TreeViewColumn.new("Service",
Gtk::CellRendererText.new, {:text => 3})
column4.set_sort_column_id(3)
sev_renderer = Gtk::CellRendererText.new
column5 = Gtk::TreeViewColumn.new("Severity", sev_renderer, {:text => 4})
column5.set_sort_column_id(4)
column5.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[4] and iter[4] != ""
renderer.set_background_gdk(@color_style[$status.index(iter[4])])
else
renderer.background = nil
end
end
column1.signal_connect("clicked") do |column|
toggle_select_port()
end
@treeview.append_column(column1)
@treeview.append_column(column2)
@treeview.append_column(column3)
@treeview.append_column(column4)
@treeview.append_column(column5)
@treeview.show
= Gtk::Menu.new
item_add_serv = Gtk::ImageMenuItem.new("Add service")
image_item_add_serv = Gtk::Image.new()
image_item_add_serv.set_stock(Gtk::Stock::ADD)
item_add_serv.set_image(image_item_add_serv)
item_add_serv.signal_connect("activate") { add_monitored_service() }
.append(item_add_serv)
item_del_serv = Gtk::ImageMenuItem.new("Delete selected service")
image_item_del_serv = Gtk::Image.new()
image_item_del_serv.set_stock(Gtk::Stock::REMOVE)
item_del_serv.set_image(image_item_del_serv)
item_del_serv.signal_connect("activate") {
@treeview.model.remove(@treeview.selection.selected) unless @treeview.selection.selected==nil
}
.append(item_del_serv)
item_edit_serv = Gtk::ImageMenuItem.new("Edit service")
image_item_edit_serv = Gtk::Image.new()
image_item_edit_serv.set_stock(Gtk::Stock::EDIT)
item_edit_serv.set_image(image_item_edit_serv)
item_edit_serv.signal_connect("activate") { edit_monitored_service() }
.append(item_edit_serv)
scan_port_serv = Gtk::ImageMenuItem.new("Test service")
image_scan_port_serv = Gtk::Image.new()
image_scan_port_serv.set_stock(Gtk::Stock::DIALOG_QUESTION)
scan_port_serv.set_image(image_scan_port_serv)
scan_port_serv.signal_connect("activate") { scan_port_now(node) }
.append(scan_port_serv)
scan_ports_serv = Gtk::ImageMenuItem.new("Scan all ports")
image_scan_ports_serv = Gtk::Image.new()
image_scan_ports_serv.set_stock(Gtk::Stock::REFRESH)
scan_ports_serv.set_image(image_scan_ports_serv)
scan_ports_serv.signal_connect("activate") { scan_ports_now(node) }
.append(scan_ports_serv)
item_sw_serv = Gtk::MenuItem.new("Switch selection")
item_sw_serv.signal_connect("activate") { toggle_select_port() }
.append(item_sw_serv)
.show_all
@treeview.signal_connect("key_press_event") do |tview,e|
if e.keyval == Gdk::Keyval::GDK_Delete
tview.model.remove(tview.selection.selected) unless tview.selection.selected==nil
end
end
@treeview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @treeview.selection.selected==nil
item_edit_serv.set_sensitive(false)
item_del_serv.set_sensitive(false)
scan_port_serv.set_sensitive(false)
else
item_edit_serv.set_sensitive(true)
item_del_serv.set_sensitive(true)
scan_port_serv.set_sensitive(true)
end
if $config.nmap_vers.to_f() == 0.0
scan_ports_serv.set_sensitive(false)
else
scan_ports_serv.set_sensitive(true)
end
.(nil, nil, event.button, event.time)
elsif (@treeview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_service()
end
end
fill_port_list(node)
fill_port_view(node)
if !$config.port_mon
@treeview.set_sensitive false
@treeview.show
frame.set_label("This monitoring is disabled")
end
notebook_inside = Gtk::Notebook::new()
label_port = Gtk::Label::new("Service")
notebook_inside.append_page(vvbox, label_port)
notebook_inside.show
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
snmp_ls = Gtk::ListStore.new(Integer, String, String, String, String)
@snmpview = Gtk::TreeView.new(snmp_ls)
renderer_snmp = Gtk::CellRendererToggle.new
renderer_snmp.signal_connect('toggled') do |cell, path|
iter = @snmpview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
end
if !$config.snmp_mon
@snmpview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
if OIDRef::oid_ref_nb_entry() == 0
@snmpview.set_sensitive false
frame.set_label("No SNMP OID defined, go in Tools menu")
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer_snmp, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("OID label",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
column3 = Gtk::TreeViewColumn.new("Operator",
Gtk::CellRendererText.new, {:text => 2})
column3.set_sort_column_id(2)
tr=Gtk::CellRendererText.new
tr.mode=Gtk::CellRenderer::MODE_EDITABLE
column4 = Gtk::TreeViewColumn.new("Threshold",
tr, {:text => 3})
column4.set_sort_column_id(3)
sev_renderer = Gtk::CellRendererText.new
column5 = Gtk::TreeViewColumn.new("Severity", sev_renderer, {:text => 4})
column5.set_sort_column_id(4)
column5.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[4] and iter[4] != ""
renderer.set_background_gdk(@color_style[$status.index(iter[4])])
else
renderer.background = nil
end
end
@snmpview.append_column(column1)
@snmpview.append_column(column2)
@snmpview.append_column(column3)
@snmpview.append_column(column4)
@snmpview.append_column(column5)
@snmpview.show
= Gtk::Menu.new
item_add_snmp = Gtk::ImageMenuItem.new("Add SNMP Ref")
image_item_add_snmp = Gtk::Image.new()
image_item_add_snmp.set_stock(Gtk::Stock::ADD)
item_add_snmp.set_image(image_item_add_snmp)
item_add_snmp.signal_connect("activate") { add_monitored_snmp() unless OIDRef::get_oid_refs_name().size() == 0 }
.append(item_add_snmp)
item_del_snmp = Gtk::ImageMenuItem.new("Delete selected SNMP Ref")
image_item_del_snmp = Gtk::Image.new()
image_item_del_snmp.set_stock(Gtk::Stock::REMOVE)
item_del_snmp.set_image(image_item_del_snmp)
item_del_snmp.signal_connect("activate") {
@snmpview.model.remove(@snmpview.selection.selected) unless @snmpview.selection.selected==nil
}
.append(item_del_snmp)
item_edit_snmp = Gtk::ImageMenuItem.new("Edit SNMP Ref")
image_edit_snmp = Gtk::Image.new()
image_edit_snmp.set_stock(Gtk::Stock::EDIT)
item_edit_snmp.set_image(image_edit_snmp)
item_edit_snmp.signal_connect("activate") { edit_monitored_snmp() }
.append(item_edit_snmp)
.show_all
@snmpview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @snmpview.selection.selected==nil
item_edit_snmp.set_sensitive(false)
item_del_snmp.set_sensitive(false)
else
item_edit_snmp.set_sensitive(true)
item_del_snmp.set_sensitive(true)
end
if OIDRef::get_oid_refs_name().size() > 0
item_add_snmp.set_sensitive(true)
else
item_add_snmp.set_sensitive(false)
end
.(nil, nil, event.button, event.time)
elsif (@snmpview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_snmp()
end
end
node.snmp_monitoring.each_value do |snmp_mon|
iter = snmp_ls.append
iter[0] = snmp_mon.get_state()
iter[1] = snmp_mon.oidref
iter[2] = snmp_mon.oper
iter[3] = snmp_mon.threshold.to_s
iter[4] = snmp_mon.severity
end
vbox.add(@snmpview)
label_snmp = Gtk::Label::new("SNMP")
notebook_inside.append_page frame, label_snmp
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
wmi_ls = Gtk::ListStore.new(Integer, String, String, String, String)
@wmiview = Gtk::TreeView.new(wmi_ls)
renderer_wmi = Gtk::CellRendererToggle.new
renderer_wmi.signal_connect('toggled') do |cell, path|
iter = @wmiview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
end
if !$config.wmi_mon
@wmiview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
if WMIRef::wmi_ref_nb_entry() == 0
@wmiview.set_sensitive false
frame.set_label("No WMI request defined, go in Tools menu")
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer_wmi, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("WMI label",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
column3 = Gtk::TreeViewColumn.new("Operator",
Gtk::CellRendererText.new, {:text => 2})
column3.set_sort_column_id(2)
tr=Gtk::CellRendererText.new
tr.mode=Gtk::CellRenderer::MODE_EDITABLE
column4 = Gtk::TreeViewColumn.new("Threshold",
tr, {:text => 3})
column4.set_sort_column_id(3)
sev_renderer = Gtk::CellRendererText.new
column5 = Gtk::TreeViewColumn.new("Severity", sev_renderer, {:text => 4})
column5.set_sort_column_id(4)
column5.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[4] and iter[4] != ""
renderer.set_background_gdk(@color_style[$status.index(iter[4])])
else
renderer.background = nil
end
end
@wmiview.append_column(column1)
@wmiview.append_column(column2)
@wmiview.append_column(column3)
@wmiview.append_column(column4)
@wmiview.append_column(column5)
@wmiview.show
= Gtk::Menu.new
item_add_wmi = Gtk::ImageMenuItem.new("Add WMI Ref")
image_item_add_wmi = Gtk::Image.new()
image_item_add_wmi.set_stock(Gtk::Stock::ADD)
item_add_wmi.set_image(image_item_add_wmi)
item_add_wmi.signal_connect("activate") { add_monitored_wmi() unless WMIRef::get_wmi_refs_name().size() == 0 }
.append(item_add_wmi)
item_del_wmi = Gtk::ImageMenuItem.new("Delete selected WMI Ref")
image_item_del_wmi = Gtk::Image.new()
image_item_del_wmi.set_stock(Gtk::Stock::REMOVE)
item_del_wmi.set_image(image_item_del_wmi)
item_del_wmi.signal_connect("activate") {
@wmiview.model.remove(@wmiview.selection.selected) unless @wmiview.selection.selected==nil
}
.append(item_del_wmi)
item_edit_wmi = Gtk::ImageMenuItem.new("Edit WMI Ref")
image_edit_wmi = Gtk::Image.new()
image_edit_wmi.set_stock(Gtk::Stock::EDIT)
item_edit_wmi.set_image(image_edit_wmi)
item_edit_wmi.signal_connect("activate") { edit_monitored_wmi() }
.append(item_edit_wmi)
.show_all
@wmiview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @wmiview.selection.selected==nil
item_edit_wmi.set_sensitive(false)
item_del_wmi.set_sensitive(false)
else
item_edit_wmi.set_sensitive(true)
item_del_wmi.set_sensitive(true)
end
if WMIRef::get_wmi_refs_name().size() > 0
item_add_wmi.set_sensitive(true)
else
item_add_wmi.set_sensitive(false)
end
.(nil, nil, event.button, event.time)
elsif (@wmiview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_wmi()
end
end
node.wmi_monitoring.each_value do |wmi_mon|
iter = wmi_ls.append
iter[0] = wmi_mon.get_state()
iter[1] = wmi_mon.wmiref
iter[2] = wmi_mon.oper
iter[3] = wmi_mon.value.to_s
iter[4] = wmi_mon.severity
end
vbox.add(@wmiview)
label_wmi = Gtk::Label::new("WMI")
notebook_inside.append_page frame, label_wmi
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
jmx_ls = Gtk::ListStore.new(Integer, String, String, String)
@jmxview = Gtk::TreeView.new(jmx_ls)
renderer_jmx = Gtk::CellRendererToggle.new
renderer_jmx.signal_connect('toggled') do |cell, path|
iter = @jmxview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
node.jmx_monitoring[iter[1]].set_state(fixed.to_i)
end
if !$config.jmx_mon
@jmxview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
if JMXRef::jmx_ref_nb_entry() == 0
@jmxview.set_sensitive false
frame.set_label("No jmx request defined, go in Tools menu")
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer_jmx, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("Label",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
column3 = Gtk::TreeViewColumn.new("Protocol/Port",
Gtk::CellRendererText.new, {:text => 2})
column3.set_sort_column_id(2)
column4 = Gtk::TreeViewColumn.new("Auth",
Gtk::CellRendererText.new, {:text => 3})
column4.set_sort_column_id(3)
@jmxview.append_column(column1)
@jmxview.append_column(column2)
@jmxview.append_column(column3)
@jmxview.append_column(column4)
@jmxview.show
= Gtk::Menu.new
item_add_jmx = Gtk::ImageMenuItem.new("Add JMX Ref")
image_item_add_jmx = Gtk::Image.new()
image_item_add_jmx.set_stock(Gtk::Stock::ADD)
item_add_jmx.set_image(image_item_add_jmx)
item_add_jmx.signal_connect("activate") { add_monitored_jmx(node) unless JMXRef::get_jmx_refs_name().size() == 0 }
.append(item_add_jmx)
item_del_jmx = Gtk::ImageMenuItem.new("Delete selected JMX Ref")
image_item_del_jmx = Gtk::Image.new()
image_item_del_jmx.set_stock(Gtk::Stock::REMOVE)
item_del_jmx.set_image(image_item_del_jmx)
item_del_jmx.signal_connect("activate") {
@jmxview.model.remove(@jmxview.selection.selected) unless @jmxview.selection.selected==nil
}
.append(item_del_jmx)
item_edit_jmx = Gtk::ImageMenuItem.new("Edit JMX Ref")
image_edit_jmx = Gtk::Image.new()
image_edit_jmx.set_stock(Gtk::Stock::EDIT)
item_edit_jmx.set_image(image_edit_jmx)
item_edit_jmx.signal_connect("activate") { edit_monitored_jmx(node) }
.append(item_edit_jmx)
.show_all
@jmxview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @jmxview.selection.selected==nil
item_edit_jmx.set_sensitive(false)
item_del_jmx.set_sensitive(false)
else
item_edit_jmx.set_sensitive(true)
item_del_jmx.set_sensitive(true)
end
if JMXRef::get_jmx_refs_name().size() > 0
item_add_jmx.set_sensitive(true)
else
item_add_jmx.set_sensitive(false)
end
.(nil, nil, event.button, event.time)
elsif (@jmxview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_jmx(node)
end
end
node.jmx_monitoring.each_value do |jmx_mon|
iter = jmx_ls.append
iter[0] = jmx_mon.get_state()
iter[1] = jmx_mon.get_ref()
iter[2] = "#{jmx_mon.get_protocol()}/#{jmx_mon.get_port()}"
iter[3] = jmx_mon.get_auth()
end
vbox.add(@jmxview)
label_jmx = Gtk::Label::new("JMX")
notebook_inside.append_page frame, label_jmx
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
snmp_trap_ls = Gtk::ListStore.new(Integer, String, String, String)
@snmptrapview = Gtk::TreeView.new(snmp_trap_ls)
@snmptrapview.set_tooltip_column(3)
renderer_snmp = Gtk::CellRendererToggle.new
renderer_snmp.signal_connect('toggled') do |cell, path|
iter = @snmptrapview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
end
if !$config.snmptrap_mon
@snmptrapview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer_snmp, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("Trap label",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
sev_renderer = Gtk::CellRendererText.new
column3 = Gtk::TreeViewColumn.new("Severity", sev_renderer, {:text => 2})
column4 = Gtk::TreeViewColumn.new("Description",
Gtk::CellRendererText.new, {:text => 3})
column4.visible = false
column3.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[2] and iter[2] != ""
renderer.set_background_gdk(@color_style[$status.index(iter[2])])
else
renderer.background = nil
end
end
@snmptrapview.append_column(column1)
@snmptrapview.append_column(column2)
@snmptrapview.append_column(column3)
@snmptrapview.append_column(column4)
@snmptrapview.show
= Gtk::Menu.new
item_add_snmptrap = Gtk::ImageMenuItem.new("Add SNMP Trap")
image_item_add_snmptrap = Gtk::Image.new()
image_item_add_snmptrap.set_stock(Gtk::Stock::ADD)
item_add_snmptrap.set_image(image_item_add_snmptrap)
item_add_snmptrap.signal_connect("activate") { add_monitored_snmptrap() unless SnmpTrapRef::get_snmptrap_refs_name().size() == 0 }
.append(item_add_snmptrap)
item_del_snmptrap = Gtk::ImageMenuItem.new("Delete selected SNMP Trap")
image_item_del_snmptrap = Gtk::Image.new()
image_item_del_snmp.set_stock(Gtk::Stock::REMOVE)
item_del_snmptrap.set_image(image_item_del_snmptrap)
item_del_snmptrap.signal_connect("activate") {
@snmptrapview.model.remove(@snmptrapview.selection.selected) unless @snmptrapview.selection.selected==nil
}
.append(item_del_snmptrap)
item_edit_snmptrap = Gtk::ImageMenuItem.new("Edit SNMP Trap")
image_edit_snmptrap = Gtk::Image.new()
image_edit_snmptrap.set_stock(Gtk::Stock::EDIT)
item_edit_snmptrap.set_image(image_edit_snmptrap)
item_edit_snmptrap.signal_connect("activate") { edit_monitored_snmp() }
.append(item_edit_snmptrap)
.show_all
@snmptrapview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @snmptrapview.selection.selected==nil
item_edit_snmptrap.set_sensitive(false)
item_del_snmptrap.set_sensitive(false)
else
item_edit_snmptrap.set_sensitive(true)
item_del_snmptrap.set_sensitive(true)
end
if SnmpTrapRef::get_snmptrap_refs_name().size() > 0 && get_snmptrap_refs_left().size() > 0
item_add_snmptrap.set_sensitive(true)
else
item_add_snmptrap.set_sensitive(false)
end
.(nil, nil, event.button, event.time)
elsif (@snmptrapview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_snmptrap()
end
end
node.snmptrap_monitoring.each_value do |snmptrap_mon|
iter = snmp_trap_ls.append
iter[0] = snmptrap_mon.get_state()
iter[1] = snmptrap_mon.get_snmptrap_ref()
iter[2] = snmptrap_mon.severity()
iter[3] = $snmptrap_refs[snmptrap_mon.get_snmptrap_ref()].description
end
vbox.add(@snmptrapview)
label_snmptrap = Gtk::Label::new("SNMP trap")
notebook_inside.append_page frame, label_snmptrap
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
syslog_ls = Gtk::ListStore.new(Integer, String, String, String)
@syslogview = Gtk::TreeView.new(syslog_ls)
@syslogview.set_tooltip_column(3)
renderer_syslog = Gtk::CellRendererToggle.new
renderer_syslog.signal_connect('toggled') do |cell, path|
iter = @syslogview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
end
if !$config.syslog_mon
@syslogview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer_syslog, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("Syslog label",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
sev_renderer = Gtk::CellRendererText.new
column3 = Gtk::TreeViewColumn.new("Severity", sev_renderer, {:text => 2})
column4 = Gtk::TreeViewColumn.new("Description", Gtk::CellRendererText.new, {:text => 3})
column4.visible = false
column3.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[2] and iter[2] != ""
ind = $status.index(iter[2])
if ind
color = @color_style[ind]
if color
renderer.set_background_gdk(color)
end
next
end
end
renderer.background = nil
end
@syslogview.append_column(column1)
@syslogview.append_column(column2)
@syslogview.append_column(column3)
@syslogview.append_column(column4)
@syslogview.show
= Gtk::Menu.new
item_add_syslog = Gtk::ImageMenuItem.new("Add Syslog Ref")
image_item_add_syslog = Gtk::Image.new()
image_item_add_syslog.set_stock(Gtk::Stock::ADD)
item_add_syslog.set_image(image_item_add_syslog)
item_add_syslog.signal_connect("activate") {
add_monitored_syslog() unless SyslogRef::get_syslog_refs_name().size() == 0
}
.append(item_add_syslog)
item_del_syslog = Gtk::ImageMenuItem.new("Delete selected Syslog Ref")
image_item_del_syslog = Gtk::Image.new()
image_item_del_syslog.set_stock(Gtk::Stock::REMOVE)
item_del_syslog.set_image(image_item_del_syslog)
item_del_syslog.signal_connect("activate") {
@syslogview.model.remove(@syslogview.selection.selected) unless @syslogview.selection.selected==nil
}
.append(item_del_syslog)
item_edit_syslog = Gtk::ImageMenuItem.new("Edit Syslog Ref")
image_item_edit_syslog = Gtk::Image.new()
image_item_edit_syslog.set_stock(Gtk::Stock::EDIT)
item_edit_syslog.set_image(image_item_edit_syslog)
item_edit_syslog.signal_connect("activate") { edit_monitored_syslog() }
.append(item_edit_syslog)
.show_all
@syslogview.signal_connect("button_press_event") do |widget, event|
if event.kind_of? Gdk::EventButton and event.button == 3
if @syslogview.selection.selected==nil
item_edit_syslog.set_sensitive(false)
item_del_syslog.set_sensitive(false)
else
item_edit_syslog.set_sensitive(true)
item_del_syslog.set_sensitive(true)
end
if SyslogRef::get_syslog_refs_name().size() > 0 && get_syslog_refs_left().size() > 0
item_add_syslog.set_sensitive(true)
else
item_add_syslog.set_sensitive(false)
end
.(nil, nil, event.button, event.time)
elsif (@syslogview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
edit_monitored_syslog()
end
end
node.syslog_monitoring.each_value do |syslog_mon|
iter = syslog_ls.append
iter[0] = syslog_mon.get_state()
iter[1] = syslog_mon.get_syslog_ref()
if syslog_mon.raw_severity()>0
iter[2] = syslog_mon.severity()
else
iter[2] = MAP_SYSLOG_SEV
end
iter[3] = $syslog_refs[syslog_mon.get_syslog_ref()].description
end
vbox.add(@syslogview)
label_syslog = Gtk::Label::new("Syslog")
notebook_inside.append_page frame, label_syslog
frame = Gtk::Frame::new
frame.border_width=10
frame.set_size_request(300, 290)
frame.show
vbox = Gtk::VBox::new
vbox.show
frame.add vbox
custom_ls = Gtk::ListStore.new(Integer, String, String, String, String)
@customview = Gtk::TreeView.new(custom_ls)
@customview.set_tooltip_column(4)
if !$config.custom_mon
@customview.set_sensitive false
frame.set_label("This monitoring is disabled")
end
renderer = Gtk::CellRendererToggle.new
renderer.signal_connect('toggled') do |cell, path|
iter = @customview.model.get_iter(path)
fixed =iter[0]
fixed ^= 1
iter[0] = fixed
end
column1 = Gtk::TreeViewColumn.new("Enabled",
renderer, {:active => 0})
column1.set_clickable(true)
column2 = Gtk::TreeViewColumn.new("Name",
Gtk::CellRendererText.new, {:text => 1})
column2.set_sort_column_id(1)
renderer = Gtk::CellRendererText.new
renderer.set_editable(true)
sev_ls_value=Gtk::ListStore.new(String)
$status[0..3].each {|sev|
iter = sev_ls_value.append
iter[0] = sev
}
sev_renderer=Gtk::CellRendererCombo.new
column3 = Gtk::TreeViewColumn.new("Severity", sev_renderer, "text" => 2)
column3.set_sort_column_id(2)
sev_renderer.model = sev_ls_value
sev_renderer.text_column = 0
sev_renderer.has_entry = false
sev_renderer.editable = true
def custom_monitor_cell_set_parameter(cell, path_string, new_text, col)
iter = @customview.model.get_iter(path_string)
iter[col] = new_text
end
tr0 = Gtk::CellRendererText.new
tr0.editable = true
tr0.mode =Gtk::CellRenderer::MODE_EDITABLE
tr0.signal_connect("edited") { |renderer, iter, var|
custom_monitor_cell_set_parameter(renderer, iter, var, 3)
}
column4 = Gtk::TreeViewColumn.new("Parameter", tr0, {:text => 3})
column4.set_sort_column_id(3)
column5 = Gtk::TreeViewColumn.new("Description", renderer, {:text => 4})
column5.visible = false
column1.signal_connect("clicked") do |column|
toggle_select_custom()
end
sev_renderer.signal_connect("changed") {|cell, path, iter|
sev = cell.model.get_value(iter,0)
cell.set_background_gdk(@color_style[$status.index(sev)])
i = @customview.selection.selected
@customview.model.set_value(i, 2, sev)
}
column3.set_cell_data_func(sev_renderer) do |col, renderer, model, iter|
if iter[2] and iter[2] != ""
ind = $status.index(iter[2])
if ind
color = @color_style[ind]
if color
renderer.set_background_gdk(color)
end
next
end
end
renderer.background = nil
end
@customview.append_column(column1)
@customview.append_column(column2)
@customview.append_column(column3)
@customview.append_column(column4)
@customview.append_column(column5)
@customview.show
if $custom_monitor
$custom_monitor.each do |cm_name|
iter = custom_ls.append
if node.custom_monitoring[cm_name] != nil
iter[0] = node.custom_monitoring[cm_name].get_state()
else
iter[0] = 0
end
iter[1] = cm_name
if node.custom_monitoring[cm_name] != nil
iter[2] = node.custom_monitoring[cm_name].severity
else
begin
iter[2] = Object.const_get(cm_name).default_severity()
rescue
iter[2] = "CRITICAL"
end
end
if node.custom_monitoring[cm_name] != nil
iter[3] = node.custom_monitoring[cm_name].param.to_s
else
begin
iter[3] = Object.const_get(cm_name).parameter().to_s
rescue Exception => msg
$log.error("Can't instantiate #{cm_name} plugin class #{msg}")
iter[3] = ""
end
end
begin
iter[4] = Object.const_get(cm_name).name()
rescue Exception => msg
$log.error("Can't instantiate #{cm_name} plugin class #{msg}")
iter[4] = ""
end
end
end
vbox.add(@customview)
label_custom = Gtk::Label::new("Custom")
notebook_inside.append_page frame, label_custom
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 notebook_inside, hbox
ok_button = Gtk::Button.new(Gtk::Stock::SAVE)
ok_button.signal_connect("clicked") {
Thread.kill(@scan_port_th) unless @scan_port_th == nil
Gtk.thread_flush
if $config.port_mon
if defined?(@treeview)
node.clear_service()
@treeview.model.each {|model, path, iter|
selected = iter[0]
protocol = iter[1]
port = iter[2]
service_name = iter[3]
sev = iter[4]
node.add_service(protocol, port, service_name, selected, sev)
}
end
end
node.clear_snmp_monitoring()
nbline=0
@snmpview.model.each {|model, path, iter|
state = iter[0]
oidname = iter[1]
oper = iter[2]
threshold = iter[3]
severity = iter[4]
node.add_snmp_monitoring(state, oidname, oper, threshold, severity)
nbline+=1
}
if nbline > 0 && (node.snmp_sev == UNMANAGED)
node.set_snmp_severity(UNKNOWN)
end
node.clear_wmi_monitoring()
nbline=0
@wmiview.model.each {|model, path, iter|
state = iter[0]
wminame = iter[1]
oper = iter[2]
value= iter[3]
severity = iter[4]
node.add_wmi_monitoring(state, wminame, oper, value, severity)
nbline+=1
}
if nbline > 0 && (node.snmp_sev == UNMANAGED)
node.set_snmp_severity(UNKNOWN)
end
nbline=0
db_del_jmx_monitoring(node.ip, HOSTNODE)
node.jmx_monitoring.each_value { |jmx|
db_add_jmx_monitoring(node.ip, HOSTNODE, jmx.get_state(), jmx.get_ref(), jmx.get_protocol(), jmx.get_port(), jmx.get_auth(), jmx.get_attributes())
nbline+=1
}
if (nbline > 0) && (node.jmx_monitoring.size > 0) && (node.snmp_sev == UNMANAGED)
node.set_snmp_severity(UNKNOWN)
end
node.clear_custom_monitoring()
nbline=0
custom_mon_table = Array.new()
@customview.model.each {|model, path, iter|
state = iter[0]
name = iter[1]
severity = iter[2]
param = iter[3]
custom_mon_table.push(Array.[](state, name, param, $status.index(severity)))
nbline+=1
}
if nbline > 0
node.add_custom_monitoring_bulk(custom_mon_table)
end
if nbline > 0 && (node.custom_sev == UNMANAGED)
node.set_custom_severity(UNKNOWN)
end
node.clear_syslog_monitoring()
nbline=0
@syslogview.model.each {|model, path, iter|
state = iter[0]
syslog_ref = iter[1]
severity = iter[2]
node.add_syslog_monitoring(state, syslog_ref, severity)
nbline+=1
}
if nbline > 0 && (node.trap_sev == UNMANAGED)
node.set_trap_severity(UNKNOWN)
end
node.clear_snmptrap_monitoring()
nbline=0
@snmptrapview.model.each {|model, path, iter|
state = iter[0]
snmptrap_ref = iter[1]
severity = iter[2]
node.add_snmptrap_monitoring(state, snmptrap_ref, severity)
nbline+=1
}
if nbline > 0 && (node.trap_sev == UNMANAGED)
node.set_trap_severity(UNKNOWN)
end
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
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
if isValidIPv4(entry_ip.text)
node.ip = entry_ip.text
end
nodeid=db_get_node_id(node.ip, HOSTNODE)
node.netmask = entry_mask.text.to_i
db_set_mask(nodeid, node.netmask)
if (entry_mac.text=="") || (entry_mac.text.match('\s+'))
node.mac=Node::NOARP_PROPERTY
else
node.mac = entry_mac.text
end
db_set_mac(nodeid, node.mac)
if (entry_name.text=="") || (entry_name.text.match('\s+'))
node.dns_name=Node::NONAME_PROPERTY
else
node.dns_name = entry_name.text
end
if (entry_netbiosname.text=="") || (entry_netbiosname.text.match('\s+'))
node.netbios_name=Node::NONAME_PROPERTY
else
node.netbios_name = 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.os = entry_os.name
if entry_type.filename != nil
node.change_type(entry_type.name)
end
node.change_label()
if need_reload_icon == 1
node.reload
end
Thread.kill(refresh_node_sev_display)
Gtk.thread_flush
window.destroy
}
cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
cancel_button.signal_connect("clicked") {
node.init_jmx_from_db()
node.init_account_from_db()
Thread.kill(@scan_port_th) unless @scan_port_th == nil
Gtk.thread_flush
Thread.kill(refresh_node_sev_display)
Gtk.thread_flush
window.destroy
}
hbox=Gtk::HBox.new(FALSE, 10)
hbox.border_width=10
hbox.show
hbox.pack_start(ok_button, TRUE, TRUE, 0)
ok_button.set_flags(Gtk::Widget::CAN_DEFAULT);
hbox.pack_start(cancel_button, TRUE, TRUE, 0)
cancel_button.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)
ok_button.show
cancel_button.show
window.show
end
|