-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from autopilotpattern/updates
updated ContainerPilot
- Loading branch information
Showing
4 changed files
with
143 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
help() { | ||
echo 'Uses cli tools free and top to determine current CPU and memory usage' | ||
echo 'for the telemetry service.' | ||
} | ||
|
||
# count of memcached evictions | ||
evictions() { | ||
(>&2 echo "evictions check fired") | ||
local evictions=$(echo -e 'stats\nquit' | nc 127.0.0.1 11211 | awk '/evictions/{print $3}') | ||
echo ${evictions} | ||
} | ||
|
||
# memory usage in percent | ||
sys_memory() { | ||
# awk oneliner to get memory usage | ||
# free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }' | ||
# output: | ||
# Memory Usage: 15804/15959MB (99.03%) | ||
(>&2 echo "sys memory check fired") | ||
local memory=$(free -m | awk 'NR==2{printf "%.2f", $3*100/$2 }') | ||
echo ${memory} | ||
} | ||
|
||
# cpu load | ||
sys_cpu() { | ||
# oneliner to display cpu load | ||
# top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}' | ||
(>&2 echo "sys cpu check fired") | ||
local cpuload=$(top -bn1 | grep load | awk '{printf "%.2f", $(NF-2)}') | ||
echo ${cpuload} | ||
} | ||
|
||
cmd=$1 | ||
if [ ! -z "$cmd" ]; then | ||
shift 1 | ||
$cmd "$@" | ||
exit | ||
fi | ||
|
||
help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters