[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r9601: Brought nodemon up to new TorCtl interface. Fixed the tor bw (in torflow/trunk: . tordiffs)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r9601: Brought nodemon up to new TorCtl interface. Fixed the tor bw (in torflow/trunk: . tordiffs)
- From: mikeperry@xxxxxxxx
- Date: Sun, 18 Feb 2007 19:23:49 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 18 Feb 2007 19:24:00 -0500
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: mikeperry
Date: 2007-02-18 19:23:32 -0500 (Sun, 18 Feb 2007)
New Revision: 9601
Modified:
torflow/trunk/TorCtl.py
torflow/trunk/nodemon.py
torflow/trunk/tordiffs/orconn-bw.diff
Log:
Brought nodemon up to new TorCtl interface. Fixed the tor bw stat diff for
0.1.2.7.
Modified: torflow/trunk/TorCtl.py
===================================================================
--- torflow/trunk/TorCtl.py 2007-02-18 15:20:38 UTC (rev 9600)
+++ torflow/trunk/TorCtl.py 2007-02-19 00:23:32 UTC (rev 9601)
@@ -98,11 +98,11 @@
self.remote_reason = remote_reason
class ORConnEvent:
- def __init__(self, event_name, status, router_name, age, read_bytes,
+ def __init__(self, event_name, status, endpoint, age, read_bytes,
wrote_bytes, reason, ncircs):
self.event_name = event_name
self.status = status
- self.router_name = router_name
+ self.endpoint = endpoint
self.age = age
self.read_bytes = read_bytes
self.wrote_bytes = wrote_bytes
@@ -722,23 +722,12 @@
event = StreamEvent(evtype, ident, status, circ, target_host,
int(target_port), reason, remote)
elif evtype == "ORCONN":
- m = re.match(r"(\S+)\s+(\S+)(\s\S+)?(\s\S+)?(\s\S+)?(\s\S+)?(\s\S+)?", body)
+ m = re.match(r"(\S+)\s+(\S+)(\sAGE=\S+)?(\sREAD=\S+)?(\sWRITTEN=\S+)?(\sREASON=\S+)?(\sNCIRCS=\S+)?", body)
if not m:
raise ProtocolError("ORCONN event misformatted.")
target, status, age, read, wrote, reason, ncircs = m.groups()
- # XXX: Special hacks for bandwidth stat research
- if status == "READ":
- read = " READ=" + str(age)
- age = 0
- if status == "WRITE":
- wrote = " WRITTEN=" + str(age)
- age = 0
-
- if reason and not ncircs:
- if "NCIRCS=" in reason:
- ncircs = reason
- reason = None
+ #plog("DEBUG", "ORCONN: "+body)
if ncircs: ncircs = int(ncircs[8:])
else: ncircs = 0
if reason: reason = reason[8:]
@@ -876,7 +865,7 @@
else: reason = ""
if orconn_event.ncircs: ncircs = "NCIRCS="+str(orconn_event.ncircs)
else: ncircs = ""
- print " ".join((orconn_event.event_name, orconn_event.router_name,
+ print " ".join((orconn_event.event_name, orconn_event.endpoint,
orconn_event.status, age, read, wrote, reason, ncircs))
def msg(self, log_event):
Modified: torflow/trunk/nodemon.py
===================================================================
--- torflow/trunk/nodemon.py 2007-02-18 15:20:38 UTC (rev 9600)
+++ torflow/trunk/nodemon.py 2007-02-19 00:23:32 UTC (rev 9601)
@@ -51,18 +51,18 @@
errors_lock.acquire()
for ns in nslist:
try:
- key_to_name[ns.idhex] = ns.name
- name_to_key[ns.name] = ns.idhex
+ key_to_name[ns.idhex] = ns.nickname
+ name_to_key[ns.nickname] = ns.idhex
r = RouterStats(c.get_router(ns))
- if ns.name in errors:
- if errors[ns.name].idhex != r.idhex:
+ if ns.nickname in errors:
+ if errors[ns.nickname].idhex != r.idhex:
plog("NOTICE", "Router "+r.name+" has multiple keys: "
- +errors[ns.name].idhex+" and "+r.idhex)
+ +errors[ns.nickname].idhex+" and "+r.idhex)
errors[r.name] = r # XXX: We get names only from ORCONN :(
except TorCtl.ErrorReply:
bad_key += 1
if "Running" in ns.flags:
- plog("INFO", "Running router "+ns.name+"="
+ plog("INFO", "Running router "+ns.nickname+"="
+ns.idhex+" has no descriptor")
pass
except:
@@ -77,68 +77,68 @@
TorCtl.EventHandler.__init__(self)
self.c = c
- def or_conn_status(self, eventtype, status, target, age, read, wrote,
- reason, ncircs):
+ def or_conn_status(self, o):
# XXX: Count all routers as one?
- if re.search(r"^\$", target):
- if target not in key_to_name:
- target = "AllClients:HASH"
- else: target = key_to_name[target]
- elif target not in name_to_key:
- plog("DEBUG", "IP? " + target)
- target = "AllClients:IP"
+ if re.search(r"^\$", o.endpoint):
+ if o.endpoint not in key_to_name:
+ o.endpoint = "AllClients:HASH"
+ else: o.endpoint = key_to_name[o.endpoint]
+ elif o.endpoint not in name_to_key:
+ plog("DEBUG", "IP? " + o.endpoint)
+ o.endpoint = "AllClients:IP"
- if status == "READ" or status == "WRITE":
+ if o.status == "READ" or o.status == "WRITE":
#plog("DEBUG", "Read: " + str(read) + " wrote: " + str(wrote))
errors_lock.acquire()
- if target not in errors:
- plog("NOTICE", "Buh?? No "+target)
- errors[target] = RouterStats()
- errors[target].name = target
- errors[target].running_read += read
- errors[target].running_wrote += wrote
+ if o.endpoint not in errors:
+ plog("NOTICE", "Buh?? No "+o.endpoint)
+ errors[o.endpoint] = RouterStats()
+ errors[o.endpoint].name = o.endpoint
+ errors[o.endpoint].running_read += o.read_bytes
+ errors[o.endpoint].running_wrote += o.wrote_bytes
errors_lock.release()
- if status == "CLOSED" or status == "FAILED":
+ if o.status == "CLOSED" or o.status == "FAILED":
errors_lock.acquire()
- if target not in errors:
- plog("NOTICE", "Buh?? No "+target)
- errors[target] = RouterStats()
- errors[target].name = target
- if status == "FAILED" and not errors[target].down:
- status = status + "(Running)"
- reason = status+":"+reason
- if reason not in errors[target].reasons:
- errors[target].reasons[reason] = Reason(reason)
- errors[target].reasons[reason].ncircs += ncircs
- errors[target].reasons[reason].count += 1
- errors[target].tot_ncircs += ncircs
- errors[target].tot_count += 1
- if age: errors[target].tot_age += age
- if read: errors[target].tot_read += read
- if wrote: errors[target].tot_wrote += wrote
+ if o.endpoint not in errors:
+ plog("NOTICE", "Buh?? No "+o.endpoint)
+ errors[o.endpoint] = RouterStats()
+ errors[o.endpoint].name = o.endpoint
+ if o.status == "FAILED" and not errors[o.endpoint].down:
+ o.status = o.status + "(Running)"
+ o.reason = o.status+":"+o.reason
+ if o.reason not in errors[o.endpoint].reasons:
+ errors[o.endpoint].reasons[o.reason] = Reason(o.reason)
+ errors[o.endpoint].reasons[o.reason].ncircs += o.ncircs
+ errors[o.endpoint].reasons[o.reason].count += 1
+ errors[o.endpoint].tot_ncircs += o.ncircs
+ errors[o.endpoint].tot_count += 1
+ if o.age: errors[o.endpoint].tot_age += o.age
+ if o.read_bytes: errors[o.endpoint].tot_read += o.read_bytes
+ if o.wrote_bytes: errors[o.endpoint].tot_wrote += o.wrote_bytes
errors_lock.release()
else: return
- if age: age = "AGE="+str(age)
+
+ if o.age: age = "AGE="+str(o.age)
else: age = ""
- if read: read = "READ="+str(read)
+ if o.read_bytes: read = "READ="+str(o.read_bytes)
else: read = ""
- if wrote: wrote = "WRITTEN="+str(wrote)
+ if o.wrote_bytes: wrote = "WRITTEN="+str(o.wrote_bytes)
else: wrote = ""
- if reason: reason = "REASON="+reason
+ if o.reason: reason = "REASON="+o.reason
else: reason = ""
- if ncircs: ncircs = "NCIRCS="+str(ncircs)
+ if o.ncircs: ncircs = "NCIRCS="+str(o.ncircs)
else: ncircs = ""
plog("DEBUG",
- " ".join((eventtype, target, status, age, read, wrote,
+ " ".join((o.event_name, o.endpoint, o.status, age, read, wrote,
reason, ncircs)))
- def ns(self, eventtype, nslist):
- read_routers(self.c, nslist)
+ def ns(self, n):
+ read_routers(self.c, n.nslist)
- def new_desc(self, eventtype, identities):
- for i in identities: # Is this too slow?
+ def new_desc(self, d):
+ for i in d.idlist: # Is this too slow?
read_routers(self.c, self.c.get_network_status("id/"+i))
def bw_stats(key, f):
Modified: torflow/trunk/tordiffs/orconn-bw.diff
===================================================================
--- torflow/trunk/tordiffs/orconn-bw.diff 2007-02-18 15:20:38 UTC (rev 9600)
+++ torflow/trunk/tordiffs/orconn-bw.diff 2007-02-19 00:23:32 UTC (rev 9601)
@@ -1,8 +1,48 @@
-Index: src/or/control.c
-===================================================================
---- src/or/control.c (revision 9468)
-+++ src/or/control.c (working copy)
-@@ -3279,21 +3279,21 @@
+diff -ur tor-0.1.2.7-alpha/src/or/connection.c tor-0.1.2.7-mine/src/or/connection.c
+--- tor-0.1.2.7-alpha/src/or/connection.c 2007-02-05 14:52:29.000000000 -0600
++++ tor-0.1.2.7-mine/src/or/connection.c 2007-02-18 17:07:11.000000000 -0600
+@@ -1578,10 +1578,18 @@
+ if (n_read > 0) {
+ rep_hist_note_bytes_read(n_read, now);
+ connection_read_bucket_decrement(conn, n_read);
++ conn->bytes_read += n_read;
++ if(connection_speaks_cells(conn))
++ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_READ,
++ n_read);
+ }
+ if (n_written > 0) {
+ rep_hist_note_bytes_written(n_written, now);
+ global_write_bucket -= n_written;
++ conn->bytes_written += n_written;
++ if(connection_speaks_cells(conn))
++ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_WRITE,
++ n_written);
+ }
+ }
+
+@@ -1774,10 +1782,18 @@
+ if (n_written > 0) {
+ rep_hist_note_bytes_written(n_written, now);
+ global_write_bucket -= n_written;
++ conn->bytes_written += n_written;
++ if(connection_speaks_cells(conn))
++ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_WRITE,
++ n_written);
+ }
+ if (n_read > 0) {
+ rep_hist_note_bytes_read(n_read, now);
+ connection_read_bucket_decrement(conn, n_read);
++ conn->bytes_read += n_read;
++ if(connection_speaks_cells(conn))
++ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_READ,
++ n_read);
+ }
+ }
+
+diff -ur tor-0.1.2.7-alpha/src/or/control.c tor-0.1.2.7-mine/src/or/control.c
+--- tor-0.1.2.7-alpha/src/or/control.c 2007-02-05 20:49:17.000000000 -0600
++++ tor-0.1.2.7-mine/src/or/control.c 2007-02-18 17:39:31.000000000 -0600
+@@ -3301,21 +3301,21 @@
{
switch (r) {
case END_OR_CONN_REASON_DONE:
@@ -32,7 +72,7 @@
case 0:
return "";
default:
-@@ -3323,6 +3323,9 @@
+@@ -3346,6 +3346,9 @@
const char *status;
char name[128];
char ncircs_buf[32] = {0}; /* > 8 + log10(2^32)=10 + 2 */
@@ -42,7 +82,7 @@
switch (tp)
{
case OR_CONN_EVENT_LAUNCHED: status = "LAUNCHED"; break;
-@@ -3330,30 +3333,46 @@
+@@ -3353,31 +3356,48 @@
case OR_CONN_EVENT_FAILED: status = "FAILED"; break;
case OR_CONN_EVENT_CLOSED: status = "CLOSED"; break;
case OR_CONN_EVENT_NEW: status = "NEW"; break;
@@ -52,59 +92,65 @@
log_warn(LD_BUG, "Unrecognized status code %d", (int)tp);
return 0;
}
- ncircs = connection_or_count_pending_circs(conn);
+ ncircs = circuit_count_pending_on_or_conn(conn);
ncircs += conn->n_circuits;
- if (ncircs && (tp == OR_CONN_EVENT_FAILED || tp == OR_CONN_EVENT_CLOSED)) {
- tor_snprintf(ncircs_buf, sizeof(ncircs_buf), "%sNCIRCS=%d",
- reason ? " " : "", ncircs);
-+ if(tp == OR_CONN_EVENT_READ || tp == OR_CONN_EVENT_WRITE) {
-+ // XXX: Bloody fucking hack, but the odds of this being
-+ // approved for the official dist are slim to none
-+ tor_snprintf(read_buf, sizeof(read_buf), "%d", reason);
-+ reason = 0;
++ if(tp == OR_CONN_EVENT_READ) {
++ tor_snprintf(read_buf, sizeof(read_buf), "READ=%d", reason);
++ reason = 0;
}
-+ if (tp == OR_CONN_EVENT_FAILED || tp == OR_CONN_EVENT_CLOSED) {
-+ tor_snprintf(age_buf, sizeof(age_buf), "AGE=%d",
-+ (int)(time(NULL) - conn->_base.timestamp_created));
-+ tor_snprintf(read_buf, sizeof(read_buf), " READ=%Zu",
-+ conn->_base.bytes_read);
-+ tor_snprintf(wrote_buf, sizeof(wrote_buf), " WRITTEN=%Zu",
-+ conn->_base.bytes_written);
-+ if (ncircs)
-+ tor_snprintf(ncircs_buf, sizeof(ncircs_buf), " NCIRCS=%d", ncircs);
-+ }
-
- if (EVENT_IS_INTERESTING1S(EVENT_OR_CONN_STATUS)) {
- orconn_target_get_name(0, name, sizeof(name), conn);
- send_control1_event_extended(EVENT_OR_CONN_STATUS, SHORT_NAMES,
+-
+- if (EVENT_IS_INTERESTING1S(EVENT_OR_CONN_STATUS)) {
+- orconn_target_get_name(0, name, sizeof(name), conn);
+- send_control1_event_extended(EVENT_OR_CONN_STATUS, SHORT_NAMES,
- "650 ORCONN %s %s@%s%s\r\n",
- name, status,
- or_conn_end_reason_to_string(reason), ncircs_buf);
-+ "650 ORCONN %s %s@%s%s%s%s%s\r\n",
-+ name, status,
-+ age_buf, read_buf, wrote_buf,
-+ or_conn_end_reason_to_string(reason), ncircs_buf);
++ if(tp == OR_CONN_EVENT_WRITE) {
++ tor_snprintf(wrote_buf, sizeof(wrote_buf), "WRITTEN=%d", reason);
++ reason = 0;
}
- if (EVENT_IS_INTERESTING1L(EVENT_OR_CONN_STATUS)) {
+- if (EVENT_IS_INTERESTING1L(EVENT_OR_CONN_STATUS)) {
- orconn_target_get_name(1, name, sizeof(name), conn);
- send_control1_event_extended(EVENT_OR_CONN_STATUS, LONG_NAMES,
- "650 ORCONN %s %s@%s%s\r\n",
- name, status,
- or_conn_end_reason_to_string(reason), ncircs_buf);
++
++ if (tp == OR_CONN_EVENT_FAILED || tp == OR_CONN_EVENT_CLOSED) {
++ tor_snprintf(age_buf, sizeof(age_buf), "AGE=%d",
++ (int)(time(NULL) - conn->_base.timestamp_created));
++ tor_snprintf(read_buf, sizeof(read_buf), " READ=%Zu",
++ conn->_base.bytes_read);
++ tor_snprintf(wrote_buf, sizeof(wrote_buf), " WRITTEN=%Zu",
++ conn->_base.bytes_written);
++ if (ncircs)
++ tor_snprintf(ncircs_buf, sizeof(ncircs_buf), " NCIRCS=%d", ncircs);
+ }
++
++ if (EVENT_IS_INTERESTING1S(EVENT_OR_CONN_STATUS)) {
++ orconn_target_get_name(0, name, sizeof(name), conn);
++ send_control1_event_extended(EVENT_OR_CONN_STATUS, SHORT_NAMES,
++ "650 ORCONN %s %s@%s%s%s%s%s\r\n",
++ name, status, age_buf, read_buf, wrote_buf,
++ or_conn_end_reason_to_string(reason), ncircs_buf);
++ }
++ if (EVENT_IS_INTERESTING1L(EVENT_OR_CONN_STATUS)) {
+ orconn_target_get_name(1, name, sizeof(name), conn);
+ send_control1_event_extended(EVENT_OR_CONN_STATUS, LONG_NAMES,
+ "650 ORCONN %s %s@%s%s%s%s%s\r\n",
-+ name, status,
-+ age_buf, read_buf, wrote_buf,
++ name, status, age_buf, read_buf, wrote_buf,
+ or_conn_end_reason_to_string(reason), ncircs_buf);
- }
++ }
}
return 0;
-Index: src/or/or.h
-===================================================================
---- src/or/or.h (revision 9468)
-+++ src/or/or.h (working copy)
-@@ -710,6 +710,8 @@
+ }
+diff -ur tor-0.1.2.7-alpha/src/or/or.h tor-0.1.2.7-mine/src/or/or.h
+--- tor-0.1.2.7-alpha/src/or/or.h 2007-02-06 23:31:15.000000000 -0600
++++ tor-0.1.2.7-mine/src/or/or.h 2007-02-18 17:07:11.000000000 -0600
+@@ -743,6 +743,8 @@
* could write? */
time_t timestamp_created; /**< When was this connection_t created? */
@@ -113,7 +159,7 @@
uint32_t addr; /**< IP of the other side of the connection; used to identify
* routers, along with port. */
uint16_t port; /**< If non-zero, port on the other end
-@@ -2246,6 +2248,8 @@
+@@ -2282,6 +2284,8 @@
OR_CONN_EVENT_FAILED = 2,
OR_CONN_EVENT_CLOSED = 3,
OR_CONN_EVENT_NEW = 4,
@@ -122,45 +168,3 @@
} or_conn_status_event_t;
void control_update_global_event_mask(void);
-Index: src/or/connection.c
-===================================================================
---- src/or/connection.c (revision 9468)
-+++ src/or/connection.c (working copy)
-@@ -1578,10 +1578,18 @@
- if (n_read > 0) {
- rep_hist_note_bytes_read(n_read, now);
- connection_read_bucket_decrement(conn, n_read);
-+ conn->bytes_read += n_read;
-+ if(connection_speaks_cells(conn))
-+ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_READ,
-+ n_read);
- }
- if (n_written > 0) {
- rep_hist_note_bytes_written(n_written, now);
- global_write_bucket -= n_written;
-+ conn->bytes_written += n_written;
-+ if(connection_speaks_cells(conn))
-+ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_WRITE,
-+ n_written);
- }
- }
-
-@@ -1774,10 +1782,18 @@
- if (n_written > 0) {
- rep_hist_note_bytes_written(n_written, now);
- global_write_bucket -= n_written;
-+ conn->bytes_written += n_written;
-+ if(connection_speaks_cells(conn))
-+ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_WRITE,
-+ n_written);
- }
- if (n_read > 0) {
- rep_hist_note_bytes_read(n_read, now);
- connection_read_bucket_decrement(conn, n_read);
-+ conn->bytes_read += n_read;
-+ if(connection_speaks_cells(conn))
-+ control_event_or_conn_status(TO_OR_CONN(conn), OR_CONN_EVENT_READ,
-+ n_read);
- }
- }
-