README 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. runcached (Run Cached)
  2. ------------------------------------------------------------------------------
  3. Execute commands while caching their output for subsequent calls.
  4. Command output will be cached for <cacheperiod> seconds and "replayed" for
  5. any subsequent calls. Original exit status will also be emulated.
  6. After cacheperiod has expired, command will be re-executed and a new result
  7. will be cached.
  8. Caching depends on command and arguments executed and the
  9. path of the runcached executable. Cache results are stored in /tmp
  10. You can use runcached to run resource-expensive commands multiple times,
  11. parsing different parts of its output each time. Those commands will be
  12. run only once for each cacheperiod.
  13. Implementation is provided in 3 languages, python, C, BASH.
  14. Usage:
  15. ======
  16. Python:
  17. runcached.py [-c cacheperiod] <command to execute with args>
  18. C:
  19. runcached [-c cacheperiod] <command to execute with args>
  20. Bash
  21. runcached.sh <command to execute with args>
  22. Example:
  23. ========
  24. 1) Run the date command. Produce a new "date" every 5 seconds.
  25. runcached.py -c 5 date
  26. 2) Zabbix userparameter which can be called multiple times , but actually executes only once every 20 seconds.
  27. Query multiple parameters of mysql at the same time, without re-running the query.
  28. UserParameter=mysql.globalstatus[*],/usr/local/bin/runcached.py -c 20 /usr/bin/mysql -ANe \"show global status\"|egrep '$1\b'|awk '{print $ 2}'