Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility with Mac OS X #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ The script version 1.4 and template are taken from https://www.zabbix.com/wiki/t

## What's new

### Version 1.6

* zapache now rund on a MacOS X (Darwin) host

### Version 1.5

* Zapache would cache received apache status page for 60 seconds by default. This eliminates the need to query apache for every item collected.
* Zapache would cache received apache status page for 60 seconds by default.
This eliminates the need to query apache for every item collected.
* Added worker threads graph to a template
* Added new items: status, ping, BusyWorkers, CPULoad
* Added trigger for Apache status to a template
Expand Down
18 changes: 14 additions & 4 deletions zapache
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
# Modified for using also as external script: Murat Koc, [email protected]
# Modified for outputting usage or ZBX_NOTSUPPORTED: Alejandro Michavila
# Modified to do cacheing for performance, [email protected]
# Modified to be compatible with Mac OS X: Thomas-Ganter
#
# Version: 1.5
# Version: 1.6
#

zapachever="1.5"
zapachever="1.6"
rval=0
value=""
cache_seconds="60"
Expand Down Expand Up @@ -78,8 +79,17 @@ esac
cache_prefix="zapache-${STATUS_URL//[^a-zA-Z0-9_-]/_}"
cache="$TMPDIR/$cache_prefix.cache"
cache_timestamp_check="$TMPDIR/$cache_prefix.ts"
# This assumes touch from coreutils
touch -d "@$((`date +%s` - ($cache_seconds - 1)))" "$cache_timestamp_check"

case "`uname`" in
'Darwin')
# Mac OS X has a different date / touch
touch -afmt "`date -v-${cache_seconds}S +%Y%m%d%H%M.%S`" "$cache_timestamp_check"
;;
*)
# This assumes touch from coreutils
touch -d "@$((`date +%s` - ($cache_seconds - 1)))" "$cache_timestamp_check"
;;
esac

if [ "$cache" -ot "$cache_timestamp_check" ]; then
curl="`which curl`"
Expand Down