Class: Listener
Instance Method Summary collapse
- #init_attr ⇒ Object
- #init_service_attr ⇒ Object
- #init_snmp_attr ⇒ Object
- #init_snmptrap_attr ⇒ Object
- #init_syslog_attr ⇒ Object
- #init_wmi_attr ⇒ Object
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
- #text(text) ⇒ Object
Instance Method Details
#init_attr ⇒ Object
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 |
# File 'lib/node_db.rb', line 1906 def init_attr() @uuid=nil @ip=nil @ipv6=nil @mask=nil @mask6=nil @mac=nil @dns_name=nil @netbios_name=nil @status=1 @avail_sev=UNMANAGED @snmp_sev=UNMANAGED @custom_sev=UNMANAGED @trap_sev=UNMANAGED @service_sev=UNMANAGED @wmi_sev=UNMANAGED @syslog_sev=UNMANAGED @jmx_sev=UNMANAGED @x=0 @y=0 @icon=nil @description=nil @snmp_version=nil @snmp_port=nil @snmp_timeout=nil @snmp_retry=nil @type=nil @os=nil @map=nil @name=nil @dns_domain=nil @netbios_domain=nil @node_size=nil @map_bg_type=nil @map_bg_data=nil @custom_monitor=nil @inherit_from_global=nil end |
#init_service_attr ⇒ Object
1870 1871 1872 1873 1874 1875 1876 |
# File 'lib/node_db.rb', line 1870 def init_service_attr() @protocol=nil @port=nil @service_name=nil @monitor=nil @service_sev=nil end |
#init_snmp_attr ⇒ Object
1878 1879 1880 1881 1882 1883 1884 |
# File 'lib/node_db.rb', line 1878 def init_snmp_attr() @snmp_state=nil @oid_ref=nil @snmp_oper=nil @snmp_threshold=nil @oid_sev=nil end |
#init_snmptrap_attr ⇒ Object
1894 1895 1896 1897 1898 |
# File 'lib/node_db.rb', line 1894 def init_snmptrap_attr() @snmptrap_state=nil @snmptrap_ref=nil @trapsev=nil end |
#init_syslog_attr ⇒ Object
1900 1901 1902 1903 1904 |
# File 'lib/node_db.rb', line 1900 def init_syslog_attr() @syslog_state=nil @syslog_ref=nil @syslog_sev=nil end |
#init_wmi_attr ⇒ Object
1886 1887 1888 1889 1890 1891 1892 |
# File 'lib/node_db.rb', line 1886 def init_wmi_attr() @wmi_state=nil @wmi_ref=nil @wmi_oper=nil @wmi_value=nil @wmi_sev=nil end |
#tag_end(name) ⇒ Object
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 |
# File 'lib/node_db.rb', line 2201 def tag_end(name) # puts "End #{name}" if name == "Host" #puts @ip, @mask.to_i, @map, @mac, @dns_name, @netbios_name, @port, @status.to_i, @x.to_i, @y.to_i, @icon, @description, @type, @os nnode=Host.new(@ip, @mask.to_i, @ipv6, @mask6.to_i, @map, @mac, @dns_name, @netbios_name, @services, @status.to_i, @x.to_i, @y.to_i, @icon, @description, @type, @os, @uuid) if @name != Node::NONAME_PROPERTY nnod.name = @name end nnode.set_severities(@avail_sev.to_i, @snmp_sev.to_i, @custom_sev.to_i, @trap_sev.to_i, @service_sev.to_i, @wmi_sev.to_i, @syslog_sev.to_i, @jmx_sev.to_i) nnode.snmp_version=@snmp_version nnode.snmp_port=@snmp_port nnode.snmp_timeout=@snmp_timeout nnode.snmp_retry=@snmp_retry nnode.reload $host[@ip]=nnode if defined?(@snmp_monitor) && (@snmp_monitor != nil) @snmp_monitor.each do |mon,tab| oidref, state, oper, threshold, sev = mon, tab[0], tab[1], tab[2], tab[3] $host[@ip].add_snmp_monitoring(state.to_i(), oidref, oper.to_i(), threshold, sev.to_i()) end end if defined?(@wmi_monitor) && (@wmi_monitor != nil) @wmi_monitor.each do |mon,tab| wmiref, state, oper, val, sev = mon, tab[0], tab[1], tab[2], tab[3] $host[@ip].add_wmi_monitoring(state.to_i(), wmiref, oper.to_i(), val, sev.to_i()) end end if defined?(@snmptrap_monitor) && (@snmptrap_monitor != nil) @snmptrap_monitor.each do |mon,tab| snmptrap_ref, state, trapsev = mon, tab[0], tab[1] $host[@ip].add_snmptrap_monitoring(state.to_i(), snmptrap_ref, trapsev.to_i()) end end if defined?(@custom_monitor) && (@custom_monitor != nil) @custom_monitor.each do |name,tab| state, param, sev = tab[0], tab[1], tab[2] $host[@ip].add_custom_monitoring(state.to_i(), name, param, sev.to_i()) end end if defined?(@syslog_monitor) && (@syslog_monitor != nil) @syslog_monitor.each do |ref,tab| state, sev = tab[0], tab[1] $host[@ip].add_syslog_monitoring(state.to_i(), ref, sev.to_i()) end end #we update network host list #we assume here networks are already loaded $network[@map].add_host(nnode) $network[@map].update_status() return end if name == "Network" #puts @ip, @mask #we assume here first network loaded is root network ROOTMAPADDR if @ip==ROOTMAPADDR && $network != nil && $network[@ip]!=nil #we already have a root map network node else nnode=Network.new(@ip, @mask.to_i, @ipv6, @mask6.to_i, @map, @services, @status.to_i, @x.to_i, @y.to_i, @icon, @description, @type, @os, @name, @dns_domain, @netbios_domain, @uuid) nnode.snmp_version=@snmp_version nnode.snmp_port=@snmp_port nnode.snmp_timeout=@snmp_timeout nnode.snmp_retry=@snmp_retry if @node_size != nil && isInteger(@node_size) nnode.node_size=@node_size.to_i() end if @map_bg_type != "" nnode.map_bg_type=@map_bg_type nnode.map_bg_data=@map_bg_data end nnode.set_inherit_conf(i2b(@inherit_from_global)) nnode.reload $network[@ip]=nnode end return end if name == "services" init_service_attr() end if name == "service" @service_name="?" unless @service_name != nil @monitor=1 unless @monitor != nil @services["#{@protocol}/#{@port}"] = Service.new(@protocol, @port, @service_name, @monitor, @service_sev) unless @services == nil end #for each snmp_monitor under block if name == "snmp" if defined?(@oid_ref) && (@oid_ref != nil) @snmp_monitor["#{@oid_ref}"]=[@snmp_state, @snmp_oper, @snmp_threshold, @oid_sev] end init_snmp_attr() end #for each wmi_monitor under block if name == "wmi" if defined?(@wmi_ref) && (@wmi_ref != nil) @wmi_monitor["#{@wmi_ref}"]=[@wmi_state, @wmi_oper, @wmi_value, @wmi_sev] end init_wmi_attr() end #for each snmptrap_monitor under block if name == "snmptrap" if defined?(@snmptrap_ref) && (@snmptrap_ref != nil) @snmptrap_monitor["#{@snmptrap_ref}"]=[@snmptrap_state, @trapsev] end init_snmptrap_attr() end #for each syslog_monitor under block if name == "syslog" if defined?(@syslog_ref) && (@syslog_ref != nil) @syslog_monitor["#{@syslog_ref}"]=[@syslog_state, @syslog_sev] end init_syslog_attr() end end |
#tag_start(name, attributes) ⇒ Object
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 |
# File 'lib/node_db.rb', line 1944 def tag_start(name, attributes) #puts "Start #{name}" #test if tag is a new node if name == "Host" || name == "Network" init_attr() elsif name == "services" @services=Hash.new elsif name == "service" init_service_attr() elsif name == "snmp_monitor" @snmp_monitor=Hash.new elsif name == "wmi_monitor" @wmi_monitor=Hash.new elsif name == "snmptrap_monitor" @snmptrap_monitor=Hash.new elsif name == "snmptrap" init_snmptrap_attr() elsif name == "syslog_monitor" @syslog_monitor=Hash.new elsif name == "syslog" init_syslog_attr() end @tag=name end |
#text(text) ⇒ Object
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 |
# File 'lib/node_db.rb', line 1968 def text(text) if @tag == "uuid" @uuid=text return end if @tag == "ip" @ip=text return end if @tag == "ipv6" @ipv6=text return end if @tag == "mask" @mask=text return end if @tag == "mask6" @mask6=text return end if @tag == "mac" @mac=text return end if @tag == "dns_name" @dns_name=text return end if @tag == "netbios_name" @netbios_name=text return end if @tag == "protocol" @protocol=text return end if @tag == "port" @port=text return end if @tag == "monitor" @monitor=text return end if @tag == "service_sev" @service_sev=text return end if @tag == "status" @status=text return end if @tag == "avail_sev" @avail_sev=text return end if @tag == "snmp_sev" @snmp_sev=text return end if @tag == "custom_sev" @custom_sev=text return end if @tag == "trap_sev" @trap_sev=text return end if @tag == "service_sev" @service_sev=text return end if @tag == "wmi_sev" @wmi_sev=text return end if @tag == "syslog_sev" @syslog_sev=text return end if @tag == "jmx_sev" @jmx_sev=text return end if @tag == "x" @x=text return end if @tag == "y" @y=text return end if @tag == "icon" @icon=text return end if @tag == "description" @description=text return end if @tag == "snmp_version" @snmp_version=text return end if @tag == "snmp_port" @snmp_port=text return end if @tag == "snmp_timeout" @snmp_timeout=text return end if @tag == "snmp_retry" @snmp_retry=text return end if @tag == "type" @type=text return end if @tag == "os" @os=text return end if @tag == "map" @map=text return end if @tag == "name" @name=text return end if @tag == "dns_domain" @dns_domain=text return end if @tag == "netbios_domain" @netbios_domain=text return end if @tag == "node_size" @node_size=text return end if @tag == "map_bg_type" @map_bg_type=text return end if @tag == "map_bg_data" if @map_bg_type == "color" @map_bg_data=text.split else @map_bg_data=text end return end if @tag == "inherit_from_global" @inherit_from_global=text return end if @tag == "snmp_state" @snmp_state=text return end if @tag == "oid_ref" @oid_ref=text return end if @tag == "snmp_oper" @snmp_oper=text return end if @tag == "snmp_threshold" @snmp_threshold=text return end if @tag == "oid_sev" @oid_sev=text return end if @tag == "wmi_state" @wmi_state=text return end if @tag == "wmi_ref" @wmi_ref=text return end if @tag == "wmi_oper" @wmi_oper=text return end if @tag == "wmi_value" @wmi_value=text return end if @tag == "wmi_sev" @wmi_sev=text return end if @tag == "snmptrap_state" @snmptrap_state=text return end if @tag == "snmptrap_ref" @snmptrap_ref=text return end if @tag == "trapsev" @trapsev=text return end if @tag == "custom_monitor" @custom_monitor=text return end if @tag == "syslog_state" @syslog_state=text return end if @tag == "syslog_ref" @syslog_ref=text return end if @tag == "syslog_sev" @syslog_sev=text return end if text.chomp != "" puts "Unknown xml tag #{@tag} value #{text.chomp}" end end |