diff --git a/README.md b/README.md new file mode 100644 index 0000000..a144b6a --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Introduction + +This is a quick start script that collects system metrics such as CPU and memory usage, and sends them to GreptimeCloud. The metrics endpoint uses InfluxDB line protocol. + +Use the following command to start it: + +```shell +./quick-start.sh -h -d -u -p +``` + +## Release +1. Update the version in `quick-start.sh`. +2. Commit and push code +3. Create a tag with the version and push it + +```shell +git tag v.. +git push origin v.. +``` +5. Add release and upload the `quick-start.sh` file in the release page +6. Update the download link of `quick-start.sh` in the [quick start docs](https://docs.greptime.com/greptimecloud/overview) of GreptimeCloud. + diff --git a/quick-start.sh b/quick-start.sh new file mode 100755 index 0000000..fb379f3 --- /dev/null +++ b/quick-start.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +version="1.0.0" + +generate_data() +{ + unameOut="$(uname -s)" + case "${unameOut}" in + Linux*) + user_cpu_util=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}') + sys_cpu_util=$(top -bn1 | grep "Cpu(s)" | awk '{print $6}') + idle_cpu_util=$(top -bn1 | grep "Cpu(s)" | awk -F "," '{print $4}' | awk -F " " '{print $1}') + mem_util=$(free | grep Mem | awk '{print $3}') + ;; + Darwin*) + user_cpu_util=$(top -l 1 | awk '/^CPU usage: / { print substr($3, 1, length($3)-1) }') + sys_cpu_util=$(top -l 1 | awk '/^CPU usage: / { print substr($5, 1, length($5)-1) }') + idle_cpu_util=$(top -l 1 | awk '/^CPU usage: / { print substr($7, 1, length($7)-1) }') + mem_util=$(top -l 1 | awk '/^PhysMem:/ { print substr($6, 1, length($6)-1) }') + ;; + *) + user_cpu_util=$(shuf -i 10-15 -n 1) + sys_cpu_util=$(shuf -i 5-10 -n 1) + idle_cpu_util=$(shuf -i 70-80 -n 1) + mem_util=$(shuf -i 50-60 -n 1) + esac + now=$(($(date +%s)*1000000000)) + cat <