Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log snapshot of running processes every 5 mins #17640

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions bin/snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

LOG_HOME="$HOME/log/snapshots"
mkdir -p "$LOG_HOME"

if [ "$1" == "last" ]; then
ls -1tr "$LOG_HOME"/* | tail -1 | xargs less

elif [ "$1" == "list" ]; then
ls -lhtr "$LOG_HOME"/*

else
log="$LOG_HOME/$(date -d @$((($(date -u +%s)/300)*300)) -u +snapshot.%H.%M)"
echo "Snapshot: $(date -u) on $(hostname)" > "$log"

echo "--------------------------------------------------------------------------------" >> "$log"
free -mh >> "$log"

echo "--------------------------------------------------------------------------------" >> "$log"
top -c -b -n 5 >> "$log"

fi
1 change: 1 addition & 0 deletions cookbooks/cdo-apps/templates/default/crontab.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
# This should be run shortly after the commit_content job run on levelbuilder.
cronjob at:'20 22 * * 1-5', do:deploy_dir('bin', 'cron', 'deploy_to_levelbuilder')
cronjob at:'*/5 * * * 1-5', do:deploy_dir('bin', 'cron', 'deploy_to_test')
cronjob at:'*/5 * * * *', do:deploy_dir('bin', 'snapshot')
end

if node.chef_environment == 'levelbuilder'
Expand Down