You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=90
  4. STOP=10
  5. USE_PROCD=1
  6. PROG=/usr/lib/sysstat/sadc
  7. SYSSTAT_CFG="/etc/sysstat/sysstat"
  8. validate_sysstat_section() {
  9. uci_load_validate sysstat sysstat "$1" "$2" \
  10. 'log_history:uinteger' \
  11. 'compressafter:uinteger' \
  12. 'sadc_options:string' \
  13. 'sa_dir:string' \
  14. 'zip:string' \
  15. 'enabled:string'
  16. }
  17. start_sysstat_instance() {
  18. [ "$2" = 0 ] || {
  19. echo "validation failed"
  20. return 1
  21. }
  22. [ -d /var/log/sysstat ] || mkdir -p /var/log/sysstat
  23. {
  24. echo "HISTORY=$log_history"
  25. echo "COMPRESSAFTER=$compressafter"
  26. echo "SADC_OPTIONS=\"$sadc_options\""
  27. echo "SA_DIR=\"$sa_dir\""
  28. echo "ZIP=\"$zip\""
  29. echo "ENABLED=\"$enabled\""
  30. } > $SYSSTAT_CFG
  31. procd_open_instance
  32. procd_set_param command $PROG -S DISK -F -L -
  33. procd_set_param file $SYSSTAT_CFG
  34. procd_close_instance
  35. }
  36. start_service() {
  37. validate_sysstat_section sysstat start_sysstat_instance
  38. }
  39. service_triggers()
  40. {
  41. procd_add_reload_trigger "sysstat"
  42. procd_add_validation validate_sysstat_section
  43. }