From silent_freak, 2 Years ago, written in Plain Text.
  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. # * ascii berry
  55. set head { .~ .~~~..~. _ _
  56. : .~.'~'.~. : ___ ___ ___ ___| |_ ___ ___ ___ _ _ ___|_|
  57. ~ ( ) ( ) ~ | _| .'|_ -| . | . | -_| _| _| | | | . | |
  58. ( : '~'.~.'~' : ) |_| |__,|___| _|___|___|_| |_| |_ | | _|_|
  59. ~ .~ ( ) ~. ~ |_| |___| |_|
  60. ( : '~' : )
  61. '~ .~~~. ~'
  62. '~'}
  63. # * ascii leaf
  64. set head2 {
  65. .~~. .~~.
  66. '. \ ' ' / .'}
  67. # * display kernel version
  68. set uname [exec -- /bin/uname -snrvm]
  69. set unameoutput0 [lindex $uname 0]
  70. set unameoutput [lindex $uname 1]
  71. set unameoutput2 [lindex $uname 2]
  72. set unameoutput3 [lindex $uname 3]
  73. set unameoutput4 [lindex $uname 4]
  74. # * display temperature
  75. set temp [exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"]
  76. set tempoutput [lindex $temp 0]
  77. # * display GPU version
  78. set gpu [exec -- /opt/vc/bin/vcgencmd version]
  79. set gpuoutput [lindex $gpu 0]
  80. set gpuoutput1 [lindex $gpu 1]
  81. set gpuoutput2 [lindex $gpu 2]
  82. set gpuoutput3 [lindex $gpu 8]
  83. set gpuoutput4 [lindex $gpu 9]
  84.  
  85. # * Print Results
  86. puts "\033\[01;32m$head2\033\[0m"
  87. puts "\033\[02;31m$head\033\[0m"
  88. puts " System........: $unameoutput0 $unameoutput $unameoutput2 $unameoutput3 $unameoutput4"
  89. puts " GPU Version...: $gpuoutput $gpuoutput1 $gpuoutput2, $gpuoutput3 $gpuoutput4"
  90. puts " Last Login....: $ll(1) $ll(2) $ll(3) $ll(4) from $ll(5)"
  91. puts " Uptime........: $up(days)days $up(hours)hours $up(mins)minutes $up(secs)seconds"
  92. puts " Temperature...: $tempoutputĀ°C"
  93. puts " Load..........: $sysload(1) (1minute) $sysload(5) (5minutes) $sysload(15) (15minutes)"
  94. puts " Memory MB.....: Total: $mem(t) Used: $mem(u) Free: $mem(f) Cached: $mem(c) Swap: $mem(s)"
  95. puts " Disk Usage....: You're using ${usage}MB in $var(home)"
  96. puts " SSH Logins....: Currently $logins user(s) logged in."
  97. puts " Processes.....: You're running ${psu} which makes a total of ${psa} running"
  98.  
  99. if {[file exists /etc/changelog]&&[file readable /etc/changelog]} {
  100. puts " . .. More or less important system informations:\n"
  101. set fp [open /etc/changelog]
  102. while {-1!=[gets $fp line]} {
  103. puts " ..) $line"
  104. }
  105. close $fp
  106. puts ""
  107. }
captcha