Artifact
41c902dab5047b646a9f86014bc70c46eb364b78:
Attachment "bigscanner.tcl" to
ticket [f084c0dc03]
added by
resuna
2016-06-29 13:08:54.
(unpublished)
#!/usr/local/bin/tclsh8.6
package require http
package require autoproxy
package require tls
proc init1 {} {
set http_proxy_host "proxy.example.com"
set http_proxy_port 8118
::autoproxy::init
::http::register https 443 [list ::autoproxy::tls_socket -ssl2 0 -ssl3 0 -tls1 1]
::autoproxy::configure -proxy_host $http_proxy_host -proxy_port $http_proxy_port
}
proc init2 {} {
::http::register https 443 ::tls::socket
}
proc scrape {} {
set pageUrl "https://www.google.com/"
set fp [::http::geturl $pageUrl -timeout 10000]
set status [::http::status $fp]
set ncode [::http::ncode $fp]
set html [::http::data $fp]
array set headers [::http::meta $fp]
::http::cleanup $fp
}
global nstats
proc nstats {ns} {
if {"$ns" == "::"} {
set pat ::*
} else {
set pat "${ns}::*"
}
set stats [list]
set vars [list]
set nssize 0
foreach v [info vars $pat] {
incr nssize [string length $v]
if [array exists $v] { # it's an array
set l [string length [array get $v]]
incr nssize $l
lappend vars "${v}*" $l
} elseif [info exists $v] { # It's a variable
set l [string length [set $v]]
incr nssize $l
lappend vars ${v} $l
} else { # it's an uninitialized variable or global
lappend vars ${v} ?
}
}
lappend stats SIZE $nssize
lappend stats VARS $vars
lappend stats PROCS [info procs $pat]
return $stats
}
proc scanner {ns} {
global nstats
set stats [nstats $ns]
if [info exists nstats($ns)] {
if {$stats != $nstats($ns)} {
puts "$ns {$nstats($ns)} -> {$stats}"
}
}
set nstats($ns) $stats
foreach nns [namespace children $ns] {
scanner $nns
}
}
init1
for {set i 0} {$i <= 10000} {incr i} {
if {$i} {puts -nonewline "$i "; flush stdout}
scrape
if {$i % 10 == 0} {
puts "\n[exec "/bin/ps" "auxw" "-p" [pid]]"
scanner ::
}
}