Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Cargar fichero de configuracion
- #
- # monitor.conf:
- # server=192.168.0.222
- # port=8000
- source monitor.conf
- timestamp=$(date +%s)
- static_hostname=$(hostnamectl --static)
- machine_id=$(cat /etc/machine-id)
- source /etc/os-release # trae variables declaradas en el archivo
- operating_system=$PRETTY_NAME
- uptime=$(uptime -p)
- used_disk=$(df / | tail -n 1 | tr -s ' ' | cut -d ' ' -f5 | tr -d '%')
- json=$(
- python3 <<EOF
- import json
- data = {
- "timestamp": int("$timestamp"),
- "static_hostname": "$static_hostname",
- "machine_id": "$machine_id",
- "operating_system": "$operating_system",
- "uptime": "$uptime",
- "used_disk": "$used_disk"
- }
- print(json.dumps(data))
- EOF
- )
- curl -vX POST http://${server}:${port}/servers \
- -H "Content-Type: esto es cualqueir cosa" \
- -d "$json"
- echo ""
- echo $?
Advertisement