- # uptime.tcl by Jobe
- # 2008
- bind pub - !uptime doUptime
- bind pub - !botup doBotUp
- setudef flag uptime
- proc doUptime {nick uhost hand chan arg} {
- if {![channel get $chan "uptime"]} { return }
- global botnick
- if {[llength [join $arg]] > 0} {
- if {[string compare -nocase [lindex [join $arg] 0] $botnick]} {
- return
- }
- }
- catch {exec uptime} uptime
- catch {exec hostname} hostname
- set osver [lindex [unames] 0]
- putquick "PRIVMSG $chan :Uptime for $hostname ($osver): $uptime"
- }
- proc doBotUp {nick uhost hand chan arg} {
- if {![channel get $chan "uptime"]} { return }
- global botnick
- if {[llength [join $arg]] > 0} {
- if {[string compare -nocase [lindex [join $arg] 0] $botnick]} {
- return
- }
- }
- bind pub - !mem pub:memusage
- proc pub:memusage {nick host hand chan text} {
- set mem [exec free -m | grep Mem: | awk {{print $3/1024}}]
- putquick "PRIVMSG $chan :Memory usage: $mem GB"
- }
- global uptime
- global server-online
- set myuptime [duration [expr [clock seconds] - $uptime]]
- set myonline [duration [expr [clock seconds] - ${server-online}]]
- putquick "PRIVMSG $chan :I have been running for $myuptime"
- putquick "PRIVMSG $chan :I have been connected for $myonline"
- }