Improve the IP-discover application.

Fix INADDR_LOOPBACK starvation.
Don't react to pings that come back from another address than what we
pinged.
This commit is contained in:
Poul-Henning Kamp 1997-03-06 16:38:07 +00:00
parent 6676d31872
commit e158218aab
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=5897
9 changed files with 123 additions and 243 deletions

View File

@ -1,69 +1,15 @@
--- ../tkined/apps/ip_discover.tcl Thu Sep 12 22:01:03 1996
+++ /usr/local/lib/tkined1.4.5/apps/ip_discover.tcl Tue Mar 4 23:05:50 1997
@@ -30,6 +30,7 @@
set columns 16
set report true
set debug false
+set communities {public private}
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
##
@@ -343,20 +344,22 @@
}
proc discover_snmp {} {
- global nodes address snmp
+ global nodes address snmp communities
global icmp_retries icmp_timeout
set start [clock seconds]
mib load rfc1213.mib
- foreach id [array names nodes] {
- set ip $address($id)
- if {[catch {snmp session -address $ip \
- -retries $icmp_retries -timeout $icmp_timeout} s]} continue
- if {[catch {
- $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
- } msg]} {
- writeln "Oops: $ip get sysObjectID.0: $msg"
+ foreach com $communities {
+ foreach id [array names nodes] {
+ set ip $address($id)
+ if {[catch {snmp session -address $ip -community $com \
+ -retries $icmp_retries -timeout $icmp_timeout} s]} continue
+ if {[catch {
+ $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
+ } msg]} {
+ writeln "Oops: $ip get sysObjectID.0: $msg"
+ }
+ update
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
- update
}
snmp wait
set count [llength [array names snmp]]
@@ -1276,6 +1279,7 @@
global email_trace
global report
global debug
+ global communities
set result [ined request "IP-Discover Parameter" \
[list [list "# of ICMP retries:" $icmp_retries scale 1 10] \
@@ -1287,7 +1291,8 @@
[list "Nodes per row:" $columns scale 10 40] \
[list "Email Discover Routes:" $email_trace radio true false] \
[list "Write Report:" $report radio true false] \
- [list "Debug Mode:" $debug radio true false] ] \
+ [list "Debug Mode:" $debug radio true false] \
+ [list "SNMP Communities:" $communities entry 10] ] \
[list "set values" cancel] ]
if {[lindex $result 0] == "cancel"} return
@@ -1302,6 +1307,7 @@
set email_trace [lindex $result 8]
set report [lindex $result 9]
set debug [lindex $result 10]
+ set communities [lindex $result 11]
icmp -retries $icmp_retries
icmp -timeout $icmp_timeout

View File

@ -1,15 +1,10 @@
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
--- ../tnm/generic/tnmPort.h Tue Aug 6 13:49:19 1996
+++ ../tnm/generic/tnmPort.h Thu Mar 6 17:10:29 1997
@@ -20,4 +20,7 @@
# include "../../unix/tnmUnixPort.h"
#endif
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001
+#endif
#endif /* _TNMPORT */

View File

@ -0,0 +1,19 @@
--- ../tnm/ntping/ntping.c Thu Sep 19 10:59:13 1996
+++ ../tnm/ntping/ntping.c Thu Mar 6 17:32:03 1997
@@ -749,7 +749,15 @@
return;
}
- dprintf (stderr, "* .. got host %s .. ", job->hname);
+ dprintf (stderr, "* .. got host %s .. %x %x ", job->hname,
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+
+ if ( type == ping && sfrom.sin_addr.s_addr != job->sa.sin_addr.s_addr)
+ {
+ dprintf (stderr, "* non-matching IP# was: %x should be:%x.\n",
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+ return;
+ }
switch (type)
{

View File

@ -1,69 +1,15 @@
--- ../tkined/apps/ip_discover.tcl Thu Sep 12 22:01:03 1996
+++ /usr/local/lib/tkined1.4.5/apps/ip_discover.tcl Tue Mar 4 23:05:50 1997
@@ -30,6 +30,7 @@
set columns 16
set report true
set debug false
+set communities {public private}
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
##
@@ -343,20 +344,22 @@
}
proc discover_snmp {} {
- global nodes address snmp
+ global nodes address snmp communities
global icmp_retries icmp_timeout
set start [clock seconds]
mib load rfc1213.mib
- foreach id [array names nodes] {
- set ip $address($id)
- if {[catch {snmp session -address $ip \
- -retries $icmp_retries -timeout $icmp_timeout} s]} continue
- if {[catch {
- $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
- } msg]} {
- writeln "Oops: $ip get sysObjectID.0: $msg"
+ foreach com $communities {
+ foreach id [array names nodes] {
+ set ip $address($id)
+ if {[catch {snmp session -address $ip -community $com \
+ -retries $icmp_retries -timeout $icmp_timeout} s]} continue
+ if {[catch {
+ $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
+ } msg]} {
+ writeln "Oops: $ip get sysObjectID.0: $msg"
+ }
+ update
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
- update
}
snmp wait
set count [llength [array names snmp]]
@@ -1276,6 +1279,7 @@
global email_trace
global report
global debug
+ global communities
set result [ined request "IP-Discover Parameter" \
[list [list "# of ICMP retries:" $icmp_retries scale 1 10] \
@@ -1287,7 +1291,8 @@
[list "Nodes per row:" $columns scale 10 40] \
[list "Email Discover Routes:" $email_trace radio true false] \
[list "Write Report:" $report radio true false] \
- [list "Debug Mode:" $debug radio true false] ] \
+ [list "Debug Mode:" $debug radio true false] \
+ [list "SNMP Communities:" $communities entry 10] ] \
[list "set values" cancel] ]
if {[lindex $result 0] == "cancel"} return
@@ -1302,6 +1307,7 @@
set email_trace [lindex $result 8]
set report [lindex $result 9]
set debug [lindex $result 10]
+ set communities [lindex $result 11]
icmp -retries $icmp_retries
icmp -timeout $icmp_timeout

View File

@ -1,15 +1,10 @@
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
--- ../tnm/generic/tnmPort.h Tue Aug 6 13:49:19 1996
+++ ../tnm/generic/tnmPort.h Thu Mar 6 17:10:29 1997
@@ -20,4 +20,7 @@
# include "../../unix/tnmUnixPort.h"
#endif
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001
+#endif
#endif /* _TNMPORT */

19
net/scotty/files/patch-ae Normal file
View File

@ -0,0 +1,19 @@
--- ../tnm/ntping/ntping.c Thu Sep 19 10:59:13 1996
+++ ../tnm/ntping/ntping.c Thu Mar 6 17:32:03 1997
@@ -749,7 +749,15 @@
return;
}
- dprintf (stderr, "* .. got host %s .. ", job->hname);
+ dprintf (stderr, "* .. got host %s .. %x %x ", job->hname,
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+
+ if ( type == ping && sfrom.sin_addr.s_addr != job->sa.sin_addr.s_addr)
+ {
+ dprintf (stderr, "* non-matching IP# was: %x should be:%x.\n",
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+ return;
+ }
switch (type)
{

View File

@ -1,69 +1,15 @@
--- ../tkined/apps/ip_discover.tcl Thu Sep 12 22:01:03 1996
+++ /usr/local/lib/tkined1.4.5/apps/ip_discover.tcl Tue Mar 4 23:05:50 1997
@@ -30,6 +30,7 @@
set columns 16
set report true
set debug false
+set communities {public private}
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
##
@@ -343,20 +344,22 @@
}
proc discover_snmp {} {
- global nodes address snmp
+ global nodes address snmp communities
global icmp_retries icmp_timeout
set start [clock seconds]
mib load rfc1213.mib
- foreach id [array names nodes] {
- set ip $address($id)
- if {[catch {snmp session -address $ip \
- -retries $icmp_retries -timeout $icmp_timeout} s]} continue
- if {[catch {
- $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
- } msg]} {
- writeln "Oops: $ip get sysObjectID.0: $msg"
+ foreach com $communities {
+ foreach id [array names nodes] {
+ set ip $address($id)
+ if {[catch {snmp session -address $ip -community $com \
+ -retries $icmp_retries -timeout $icmp_timeout} s]} continue
+ if {[catch {
+ $s get sysObjectID.0 [list discover_snmp_callback $id "%S" "%E"]
+ } msg]} {
+ writeln "Oops: $ip get sysObjectID.0: $msg"
+ }
+ update
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
- update
}
snmp wait
set count [llength [array names snmp]]
@@ -1276,6 +1279,7 @@
global email_trace
global report
global debug
+ global communities
set result [ined request "IP-Discover Parameter" \
[list [list "# of ICMP retries:" $icmp_retries scale 1 10] \
@@ -1287,7 +1291,8 @@
[list "Nodes per row:" $columns scale 10 40] \
[list "Email Discover Routes:" $email_trace radio true false] \
[list "Write Report:" $report radio true false] \
- [list "Debug Mode:" $debug radio true false] ] \
+ [list "Debug Mode:" $debug radio true false] \
+ [list "SNMP Communities:" $communities entry 10] ] \
[list "set values" cancel] ]
if {[lindex $result 0] == "cancel"} return
@@ -1302,6 +1307,7 @@
set email_trace [lindex $result 8]
set report [lindex $result 9]
set debug [lindex $result 10]
+ set communities [lindex $result 11]
icmp -retries $icmp_retries
icmp -timeout $icmp_timeout

View File

@ -1,15 +1,10 @@
--- ../tkined/apps/snmp_monitor.tcl Mon Sep 2 18:30:19 1996
+++ ..//tkined/apps/snmp_monitor.tcl Mon Mar 3 14:43:52 1997
@@ -482,8 +482,11 @@
--- ../tnm/generic/tnmPort.h Tue Aug 6 13:49:19 1996
+++ ../tnm/generic/tnmPort.h Thu Mar 6 17:10:29 1997
@@ -20,4 +20,7 @@
# include "../../unix/tnmUnixPort.h"
#endif
set args $ip
set i 0
+ set snmpconfig [ined attribute $id "SNMP:Config"]
foreach if $iflist {
- lappend args [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ set nid [CreateChart $id [expr 30+$i] [expr 30+$i]]
+ lappend args $nid
+ ined -noupdate attribute $nid "SNMP:Config" $snmpconfig
lappend args $if
incr i
}
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001
+#endif
#endif /* _TNMPORT */

View File

@ -0,0 +1,19 @@
--- ../tnm/ntping/ntping.c Thu Sep 19 10:59:13 1996
+++ ../tnm/ntping/ntping.c Thu Mar 6 17:32:03 1997
@@ -749,7 +749,15 @@
return;
}
- dprintf (stderr, "* .. got host %s .. ", job->hname);
+ dprintf (stderr, "* .. got host %s .. %x %x ", job->hname,
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+
+ if ( type == ping && sfrom.sin_addr.s_addr != job->sa.sin_addr.s_addr)
+ {
+ dprintf (stderr, "* non-matching IP# was: %x should be:%x.\n",
+ sfrom.sin_addr.s_addr, job->sa.sin_addr.s_addr );
+ return;
+ }
switch (type)
{