cfk
Version:
Finbox's PaaS
47 lines (42 loc) • 1.45 kB
Plain Text
description "send slack notification on bootup"
start on (local-filesystems and net-device-up IFACE!=lo)
task
script
eval $(cfk-env)
cpu_count=$(cat /proc/cpuinfo | grep processor | wc -l)
total_mem=$(cat /proc/meminfo | grep MemTotal | awk -F : '{ print $2 }' | awk '{ print $1" "$2 }')
total_disk=$(df -h | awk '($6=="/") {print}' | awk '{ print $2 }')
disk_used=$(df -h | awk '($6=="/") {print}' | awk '{ print $3 }')
curl -X POST -H 'Content-type: application/json' \
--data "{ \
\"attachments\": [{ \
\"text\": \":thumbsup: $HOSTNAME has booted up\", \
\"fallback\": \":thumbsup: $HOSTNAME has booted up\", \
\"color\": \"good\", \
\"author_name\": \"$DOMAIN\", \
\"fields\": [{ \
\"title\": \"CPUs\", \
\"value\": \"$cpu_count\", \
\"short\": \"true\" \
},{ \
\"title\": \"Memory\", \
\"value\": \"$total_mem\", \
\"short\": \"true\" \
},{ \
\"title\": \"Disk Size\", \
\"value\": \"$total_disk\", \
\"short\": \"true\" \
},{ \
\"title\": \"Disk Used\", \
\"value\": \"$disk_used\", \
\"short\": \"true\" \
},{ \
\"title\": \"Version\", \
\"value\": \"v$CFK_VERSION\", \
\"short\": \"true\" \
}] \
}], \
\"channel\": \"#$SLACK_CHANNEL\" \
}" \
$SLACK_HOOK
end script