Advertisement
Guest User

50-landscape-sysinfo-->/usr/bin/landscape-sysinfo

a guest
Oct 24th, 2014
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.27 KB | None | 0 0
  1. #=========================================#
  2. # /etc/update-motd.d/50-landscape-sysinfo #
  3. #=========================================#
  4.  
  5. #!/bin/sh
  6. cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
  7. [ "$cores" -eq "0" ] && cores=1
  8. threshold="${cores:-1}.0"
  9. if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
  10.     echo
  11.     echo -n "  System information as of "
  12.     /bin/date
  13.     echo
  14.     /usr/bin/landscape-sysinfo
  15. else
  16.     echo
  17.     echo " System information disabled due to load higher than $threshold"
  18. fi
  19.  
  20.  
  21. #============================#
  22. # /usr/bin/landscape-sysinfo #
  23. #============================#
  24.  
  25. #! /usr/bin/python
  26. import sys, os
  27.  
  28. try:
  29.     if os.path.dirname(os.path.abspath(sys.argv[0])) == os.path.abspath("scripts"):
  30.         sys.path.insert(0, "./")
  31.     else:
  32.         from landscape.lib.warning import hide_warnings
  33.         hide_warnings()
  34.  
  35.     from twisted.internet import reactor
  36.  
  37.     from landscape.sysinfo.deployment import run
  38. except ImportError:
  39.     # For some reasons the libraries are not importable for now. We are
  40.     # probably during an upgrade procedure, so let's exit, expecting the
  41.     # dependencies to be fixed at next run.
  42.     sys.exit(2)
  43.  
  44.  
  45. if __name__ == "__main__":
  46.     run(sys.argv[1:], reactor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement