r00t-err0r

cpu

Mar 27th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.06 KB | None | 0 0
  1. bind pub - !cpu cpuv
  2.  
  3. bind pub - !mem memv
  4.  
  5. bind pub - !timerz listtimers
  6.  
  7. proc listtimers {nick host handle chan arg} {
  8.     if { $chan != "#staff" } { return }
  9.     putserv "PRIVMSG $chan :[timers]"
  10. }
  11.  
  12. proc cpuv {nick host handle chan arg} {
  13.     global botnick
  14.    
  15.     if { $chan != "#staff" } { return }
  16.     set load [exec cat /proc/loadavg]
  17.     if { $arg == "all" || $arg == $botnick } { putserv "PRIVMSG $chan :$botnick LoadAvg:\002 \0034 [lindex $load 0] [lindex $load 1] [lindex $load 2]" }
  18.     if { [lindex $load 1] > 0.80 } { putserv "PRIVMSG $chan :$botnick LoadAvg:\002 \0034 WARNING!! SERVER LOAD ABOVE 0.80 FOR THE PAST 5 MINUTES" }
  19.     if { [llength [timers]] != 0 } { foreach timer [timers] { killtimer [lindex $timer end] } }
  20.    
  21.     timer 5 [list cpuv "$nick" "$host" "$handle" "$chan" "yep"]
  22. }
  23.  
  24. proc memv {nick host handle chan arg} {
  25.     global botnick
  26.  
  27.     if { $chan != "#staff" } { return }
  28.     set load [exec free -m]
  29.     if { $arg == "all" || $arg == $botnick } { putserv "PRIVMSG $chan :Free Memory on $botnick:\002 \0034 [expr 1000 - [lindex [lindex [split $load '\n'] 1] 2]]" }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment