Skip to content

Commit

Permalink
Deprecate K in storage usage and % in cpu usage statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrykuzmenkov committed Jan 16, 2016
1 parent 130f2e0 commit 37325ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ If you want json output just use *--json* flag
```bash
sentinel --status --json
```
* Notice that every storage usage displays in KB not just bytes.
* Notice that every cpu usage displays in percents.

## Control Sentinel
To control Sentinel you just need to call sentinel command with special files
Expand Down
2 changes: 1 addition & 1 deletion src/env.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
export VERSION='0.3.1'
export VERSION='0.3.2'
export CHECK_TIMEOUT=3
export TASKS_DIR=$(readlink -f './tasks')
export WORK_DIR=$(readlink -f './proc')
Expand Down
22 changes: 11 additions & 11 deletions src/status-json.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ display_system_status() {
print_json_key 'cpu_nice' "$(get_system_cpu_nice)"
print_json_key 'cpu_idle' "$(get_system_cpu_idle)"
print_json_key 'cpu_wait' "$(get_system_cpu_wait)"
print_json_key 'memory_usage' "$(get_system_memory_usage)K"
print_json_key 'memory_usage' "$(get_system_memory_usage)"
print_json_key 'memory_usage_percent' "$(( $(get_system_memory_usage) * 100 / $(get_system_total_memory) ))"
print_json_key 'memory_total' "$(get_system_total_memory)K"
print_json_key 'memory_free' "$(get_system_free_memory)K"
print_json_key 'memory_cached' "$(get_system_cached_memory)K"
print_json_key 'swap_usage' "$(get_system_swap_usage)K"
print_json_key 'memory_total' "$(get_system_total_memory)"
print_json_key 'memory_free' "$(get_system_free_memory)"
print_json_key 'memory_cached' "$(get_system_cached_memory)"
print_json_key 'swap_usage' "$(get_system_swap_usage)"
print_json_key 'swap_usage_percent' "$(( $(get_system_swap_usage) * 100 / $TOTAL_SWAP ))"
print_json_key 'swap_total' "${TOTAL_SWAP}K"
print_json_key 'swap_free' "$(get_system_free_swap)K"
print_json_key 'swap_total' "${TOTAL_SWAP}"
print_json_key 'swap_free' "$(get_system_free_swap)"

task_count=$(ls $TASKS_DIR | wc -l)
print_json_key 'task_count' "$task_count"
Expand Down Expand Up @@ -93,12 +93,12 @@ display_task_status() {
print_json_key 'uid' "$(get_uid $pid)"
print_json_key 'gid' "$(get_gid $pid)"

print_json_key 'cpu' "$(get_cpu_usage $pid)%"
print_json_key 'memory_usage' "$(get_memory_usage $pid)K"
print_json_key 'cpu_usage' "$(get_cpu_usage $pid)"
print_json_key 'memory_usage' "$(get_memory_usage $pid)"
print_json_key 'memory_usage_percent' "$(( $(get_memory_usage $pid) * 100 / $(get_system_total_memory) ))"
print_json_key 'memory_peak' "$(get_memory_peak_usage $pid)K"
print_json_key 'memory_peak' "$(get_memory_peak_usage $pid)"

print_json_key 'swap_usage' "$(get_swap_usage $pid)K"
print_json_key 'swap_usage' "$(get_swap_usage $pid)"
print_json_key 'swap_usage_percent' "$(( $(get_swap_usage $pid) / $TOTAL_SWAP))"

uptime_ts=$(( $(date +%s) - $(stat --printf='%Y' $pid_file) ))
Expand Down

0 comments on commit 37325ec

Please sign in to comment.