Skip to content

Instantly share code, notes, and snippets.

@tkulick
Created August 31, 2017 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkulick/c3a0c48c70f95829960259b09978b92f to your computer and use it in GitHub Desktop.
Save tkulick/c3a0c48c70f95829960259b09978b92f to your computer and use it in GitHub Desktop.
landscape-common items for macOS
#####MOTD
#!/bin/sh
cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
[ "$cores" -eq "0" ] && cores=1
threshold="${cores:-1}.0"
if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
echo
echo -n " System information as of "
/bin/date
echo
/usr/bin/landscape-sysinfo
else
echo
echo " System information disabled due to load higher than $threshold"
fi
#####/usr/bin/landscape-sysinfo
#! /usr/bin/python
import sys, os
try:
if os.path.dirname(os.path.abspath(sys.argv[0])) == os.path.abspath("scripts"):
sys.path.insert(0, "./")
else:
from landscape.lib.warning import hide_warnings
hide_warnings()
from twisted.internet import reactor
from landscape.sysinfo.deployment import run
except ImportError:
# For some reasons the libraries are not importable for now. We are
# probably during an upgrade procedure, so let's exit, expecting the
# dependencies to be fixed at next run.
sys.exit(2)
if __name__ == "__main__":
run(sys.argv[1:], reactor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment