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.

50 lines
1.1 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. echo "HISTORY=$log_history" > $SYSSTAT_CFG
  24. echo "COMPRESSAFTER=$compressafter" >> $SYSSTAT_CFG
  25. echo "SADC_OPTIONS=\"$sadc_options\"" >> $SYSSTAT_CFG
  26. echo "SA_DIR=\"$sa_dir\"" >> $SYSSTAT_CFG
  27. echo "ZIP=\"$zip\"" >> $SYSSTAT_CFG
  28. echo "ENABLED=\"$enabled\"" >> $SYSSTAT_CFG
  29. procd_open_instance
  30. procd_set_param command $PROG -S DISK -F -L -
  31. procd_set_param file $SYSSTAT_CFG
  32. procd_close_instance
  33. }
  34. start_service() {
  35. validate_sysstat_section sysstat start_sysstat_instance
  36. }
  37. service_triggers()
  38. {
  39. procd_add_reload_trigger "sysstat"
  40. procd_add_validation validate_sysstat_section
  41. }