sergio_educacionit

cliente_monitor

May 20th, 2026
68
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Cargar fichero de configuracion
  4. #
  5. # monitor.conf:
  6. # server=192.168.0.222
  7. # port=8000
  8.  
  9. source monitor.conf
  10.  
  11.  
  12. timestamp=$(date +%s)
  13. static_hostname=$(hostnamectl --static)
  14. machine_id=$(cat /etc/machine-id)
  15. source /etc/os-release # trae variables declaradas en el archivo
  16. operating_system=$PRETTY_NAME
  17. uptime=$(uptime -p)
  18. used_disk=$(df / | tail -n 1 | tr -s ' ' | cut -d ' ' -f5 | tr -d '%')
  19.  
  20.  
  21. json=$(
  22. python3 <<EOF
  23. import json
  24.  
  25. data = {
  26. "timestamp": int("$timestamp"),
  27. "static_hostname": "$static_hostname",
  28. "machine_id": "$machine_id",
  29. "operating_system": "$operating_system",
  30. "uptime": "$uptime",
  31. "used_disk": "$used_disk"
  32. }
  33.  
  34. print(json.dumps(data))
  35. EOF
  36. )
  37.  
  38. curl -vX POST http://${server}:${port}/servers \
  39. -H "Content-Type: esto es cualqueir cosa" \
  40. -d "$json"
  41.  
  42. echo ""
  43. echo $?
  44.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment