daily pastebin goal
37%
SHARE
TWEET

raspberrypi.gen.tr

a guest Mar 19th, 2013 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env tclsh
  2. # MOTD script original? / mod mewbies.com
  3.  
  4. # * Variables
  5. set var(user) $env(USER)
  6. set var(path) $env(PWD)
  7. set var(home) $env(HOME)
  8.  
  9. # * Check if we're somewhere in /home
  10. #if {![string match -nocase "/home*" $var(path)]} {
  11. if {![string match -nocase "/home*" $var(path)] && ![string match -nocase "/usr/home*" $var(path)] } {
  12.   return 0
  13. }
  14.  
  15. # * Calculate last login
  16. set lastlog [exec -- lastlog -u $var(user)]
  17. set ll(1)  [lindex $lastlog 7]
  18. set ll(2)  [lindex $lastlog 8]
  19. set ll(3)  [lindex $lastlog 9]
  20. set ll(4)  [lindex $lastlog 10]
  21. set ll(5)  [lindex $lastlog 6]
  22.  
  23. # * Calculate current system uptime
  24. set uptime    [exec -- /usr/bin/cut -d. -f1 /proc/uptime]
  25. set up(days)  [expr {$uptime/60/60/24}]
  26. set up(hours) [expr {$uptime/60/60%24}]
  27. set up(mins)  [expr {$uptime/60%60}]
  28. set up(secs)  [expr {$uptime%60}]
  29.  
  30. # * Calculate usage of home directory
  31. set usage [lindex [exec -- /usr/bin/du -ms $var(home)] 0]
  32.  
  33. # * Calculate SSH logins:
  34. set logins    [lindex [exec -- who -q | cut -c "9-11"] 0]
  35.  
  36. # * Calculate processes
  37. set psu [lindex [exec -- ps U $var(user) h | wc -l] 0]
  38. set psa [lindex [exec -- ps -A h | wc -l] 0]
  39.  
  40. # * Calculate current system load
  41. set loadavg     [exec -- /bin/cat /proc/loadavg]
  42. set sysload(1)  [lindex $loadavg 0]
  43. set sysload(5)  [lindex $loadavg 1]
  44. set sysload(15) [lindex $loadavg 2]
  45.  
  46. # * Calculate Memory
  47. set memory  [exec -- free -m]
  48. set mem(t)  [lindex $memory 7]
  49. set mem(u)  [lindex $memory 8]
  50. set mem(f)  [lindex $memory 9]
  51. set mem(c)  [lindex $memory 16]
  52. set mem(s)  [lindex $memory 19]
  53.  
  54.  
  55. # * ascii berry
  56. set head {          .~ .~~~..~.                      _                          _
  57.          : .~.'~'.~. :     ___ ___ ___ ___| |_ ___ ___ ___ _ _    ___|_|
  58.         ~ (   ) (   ) ~   |  _| .'|_ -| . | . | -_|  _|  _| | |  | . | |
  59.        ( : '~'.~.'~' : )  |_| |__,|___|  _|___|___|_| |_| |_  |  |  _|_|
  60.         ~ .~ (   ) ~. ~               |_|                 |___|  |_|    
  61.          (  : '~' :  )
  62.           '~ .~~~. ~'
  63.               '~'}
  64. # * ascii leaf
  65. set head2 {
  66.           .~~.   .~~.
  67.          '. \ ' ' / .'}
  68. # * display kernel version
  69. set uname [exec -- /bin/uname -snrvm]
  70. set unameoutput0 [lindex $uname 0]
  71. set unameoutput [lindex $uname 1]
  72. set unameoutput2 [lindex $uname 2]
  73. set unameoutput3 [lindex $uname 3]
  74. set unameoutput4 [lindex $uname 4]
  75. # * display temperature
  76. set temp [exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"]
  77. set tempoutput [lindex $temp 0]
  78. # * display GPU version
  79. set gpu [exec -- /opt/vc/bin/vcgencmd version]
  80. set gpuoutput [lindex $gpu 0]
  81. set gpuoutput1 [lindex $gpu 1]
  82. set gpuoutput2 [lindex $gpu 2]
  83. set gpuoutput3 [lindex $gpu 8]
  84. set gpuoutput4 [lindex $gpu 9]
  85.  
  86. # * Print Results
  87. puts "\033\[01;32m$head2\033\[0m"
  88. puts "\033\[02;31m$head\033\[0m"
  89. puts "   System........: $unameoutput0 $unameoutput $unameoutput2 $unameoutput3 $unameoutput4"
  90. puts "   GPU Version...: $gpuoutput $gpuoutput1 $gpuoutput2, $gpuoutput3 $gpuoutput4"
  91. puts "   Last Login....: $ll(1) $ll(2) $ll(3) $ll(4) from $ll(5)"
  92. puts "   Uptime........: $up(days)days $up(hours)hours $up(mins)minutes $up(secs)seconds"
  93. puts "   Temperature...: $tempoutputĀ°C"
  94. puts "   Load..........: $sysload(1) (1minute) $sysload(5) (5minutes) $sysload(15) (15minutes)"
  95. puts "   Memory MB.....: Total: $mem(t)  Used: $mem(u)  Free: $mem(f)  Cached: $mem(c)  Swap: $mem(s)"
  96. puts "   Disk Usage....: You're using ${usage}MB in $var(home)"
  97. puts "   SSH Logins....: Currently $logins user(s) logged in."
  98. puts "   Processes.....: You're running ${psu} which makes a total of ${psa} running"
  99.  
  100. if {[file exists /etc/changelog]&&[file readable /etc/changelog]} {
  101.   puts " . .. More or less important system informations:\n"
  102.   set fp [open /etc/changelog]
  103.   while {-1!=[gets $fp line]} {
  104.     puts "  ..) $line"
  105.   }
  106.   close $fp
  107.   puts ""
  108. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top