Advertisement
Guest User

sysinfo_page

a guest
Aug 7th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # sysinfo_page - A script to produce a system information HTML file
  4.  
  5. ##### Constants
  6.  
  7. TITLE="System Information for $HOSTNAME"
  8. RIGHT_NOW=$(date +"%x %R %Z")
  9. TIME_STAMP="Updated on $RIGHT_NOW by $USER"
  10.  
  11. ##### Functions
  12.  
  13. system_info()
  14. {
  15.     echo "<h2>System release info</h2>"
  16.     echo "<p>Function not yet implemented</p>"
  17. }
  18.  
  19. show_uptime()
  20. {
  21.     echo "<h2>System uptime</h2>"
  22.     echo "<pre>"
  23.     uptime
  24.     echo "</pre>"
  25. }
  26.  
  27. drive_space()
  28. {
  29.     echo "<h2>Filesystem space</h2>"
  30.     echo "<pre>"
  31.     df
  32.     echo "</pre>"
  33. }
  34.  
  35. home_space()
  36. {
  37.     # Only the superuser can get this information
  38.    
  39.     if [ "$(id -u)" = "0" ]; then
  40.         echo "<h2>Home directory space by user</h2>"
  41.         echo "<pre>"
  42.         echo "Bytes Directory"
  43.             du -s /home/* | sort -nr
  44.         echo "<pre>"
  45.     fi
  46. }
  47.  
  48. ##### Main
  49.  
  50. cat <<- _EOF_
  51. <html>
  52.     <head>
  53.         <title>$TITLE</title>
  54.     </head>
  55.  
  56.     <body>
  57.         <h1>$TITLE</h1>
  58.         <p>$TIME_STAMP</p>
  59.         $(system_info)
  60.         $(show_uptime)
  61.         $(drive_space)
  62.         $(home_space)
  63.     </body>
  64. </html>
  65. _EOF_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement