<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/19532" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2013-10-18T04:24:04-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/19532</id>

		<entry>
		<author><name><![CDATA[spithash]]></name></author>
		<updated>2013-10-18T04:24:04-04:00</updated>

		<published>2013-10-18T04:24:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102131#p102131</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102131#p102131"/>
		<title type="html"><![CDATA[!bw Bandwidth command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102131#p102131"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>namespace eval bandwidth {  variable api "/proc/net/dev"  variable interface "eth0:LAN" ;# for windows win:&lt;something&gt; without the others..  # %IFN% : example eth0 # %IFA% : example WAN # %INC% : Incomming traffic # %OUT% : Outgoing traffic  variable template "\[\002%IFA%\002\]: Incoming: \(\002%INC%\002\) kb/s Outgoing: \(\002%OUT%\002\) kb/s."  # 0: privmsg to channel # 1: privmsg to nick # 2: notice to nick  variable msgtype "0"  variable pubflag "-"  variable bandwidth "!bw"  variable version 0.2  switch -regexp [string tolower $::tcl_platform(platform)] {    "win" {      variable switch 1    }    "unix" {      variable switch 2    }    ".*" {       variable switch 0    }  }  switch  -exact $msgtype {    "0" { variable msg "PRIVMSG %CHAN%" }    "1" { variable msg "PRIVMSG %NICK%" }    "2" { variable msg "NOTICE %NICK%" }  } proc f {value} {  set test $value ; set unit 0 while {[set test [expr {$test / 1024}]] &gt; 0} { incr unit } return [format "%.2f %s" [expr {$value / pow(1024,$unit)}] [lindex [list B KB MB GB TB PB EB ZB YB] $unit]] }  proc totals {n u h c t} {variable interfaceset iface [lindex [split $interface ":"] 0]set network [lindex [split $interface ":"] 1]#catch {exec cut \-d. \-f1 /proc/uptime} reply; set secs [expr $reply % 60]; set mins [expr $reply / 60 % 60]; set hours [expr $reply / 3600 % 24]; set days [expr $reply / 86400]catch {set useless [exec uptime]} uptime#set uptime "${days}d ${hours}h ${mins}m ${secs}s"if {![catch {set data [exec /sbin/ifconfig $iface]} error]} {foreach line [split $data "\n"] {if {[string match "*RX bytes*" $line]} {set rxb [lindex [split [lindex $line 1] ":"] 1]set txb [lindex [split [lindex $line 5] ":"] 1]putserv "PRIVMSG $c :\002\[\002$network\002\]\002: total of [f $rxb] incoming, total of [f $txb] outgoing in $uptime."}}}}  proc bandwidth_pub {nick host hand chan arg} {totals $nick $host $hand $chan $arg    variable switch; variable template; variable interface; variable msg; variable api    if {[string equal 0 $switch]} {      putlog "Error unknown operating system."    } elseif {[string equal "1" $switch]} {      if {[regexp -nocase {^(win):([a-zA-Z0-9\-]{1,100})$} $interface -&gt; ifn ifa]} {        set s_inc 0; set s_out 0; set e_inc 0; set e_out 0        foreach {x} [split [exec netstat -e] \n] {          if {[string equal -nocase -length 4 byte $x]} {            set s_inc [lindex $x 1]            set s_out [lindex $x 2]          }        }        after 500        foreach {x} [split [exec netstat -e] \n] {          if {[string equal -nocase -length 4 byte $x]} {            set e_inc [lindex $x 1]            set e_out [lindex $x 2]          }        }        putserv "[string map [list %NICK% $nick %CHAN% $chan] $msg] :[string map [list %IFN% $ifn %IFA% $ifa %INC% [format %.2f [expr ($e_inc - $s_inc) / 512.0]] %OUT% [format %.2f [expr ($e_out - $s_out) / 512.0]]] $template]"      } else {      putlog "Script misconfiguration, check your settings."      }    } elseif {[string equal "2" $switch]} {      if {[file exists $api]} {        if {[file readable $api]} {          if {[regexp {win:} $interface]} {            putlog "Script misconfiguration, check your settings."          } else {            if {[catch {open $api} rf]} {              putlog "Error couldn't open $api for an unknown reason."            } else {            while {![eof $rf]} {              gets $rf x                foreach {ifn ifa} [split $interface \x3a\x2c] {                  regexp "$ifn:\[\x20\t\]{0,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}" $x -&gt; s_inc($ifn) s_out($ifn)                }              }              close $rf            }            after 500            if {[catch {open $api} rf]} {              putlog "Error couldn't open $api for an unknown reason."            } else {            while {![eof $rf]} {              gets $rf x                foreach {ifn ifa} [split $interface \x3a\x2c] {                  if {[regexp "$ifn:\[\x20\t\]{0,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}" $x -&gt; e_inc($ifn) e_out($ifn)]} {                    putserv "[string map [list %NICK% $nick %CHAN% $chan] $msg] :[string map [list %IFN% $ifn %IFA% $ifa %INC% [format %.2f [expr ($e_inc($ifn) - $s_inc($ifn)) / 512.0]] %OUT% [format %.2f [expr ($e_out($ifn) - $s_out($ifn)) / 512.0]]] $template]"                  }                }              }              close $rf            }          }        } else { putlog "Error $api is not readable."  }      } else { putlog "Error $api does not exist." }    } else { putlog "Error unknown operating system." }  }  bind pub $pubflag $bandwidth [namespace current]::bandwidth_pub}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9145">spithash</a> — Fri Oct 18, 2013 4:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Zecca93]]></name></author>
		<updated>2013-10-14T23:04:45-04:00</updated>

		<published>2013-10-14T23:04:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102118#p102118</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102118#p102118"/>
		<title type="html"><![CDATA[!bw Bandwidth command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102118#p102118"><![CDATA[
Hey is there script or can anybody make script for Bandwidth like this <br><br>&lt;me&gt; !bw<br>&lt;bot&gt; Upstream: 4.25kB/s (Uploaded: 3185.23MB) Downstream: 4.07kB/s (Downloaded: 592.80MB)<br><br>Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11982">Zecca93</a> — Mon Oct 14, 2013 11:04 pm</p><hr />
]]></content>
	</entry>
	</feed>
