5 airsearches_update_every=15
8 wget 2>/dev/null -O - "$airsearches_url" |\
9 sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" -e "s/^/airsearches_/g" |\
10 tr "[A-Z]\.\!@#\$%^&*()_+\-" "[a-z]_____________" |\
11 egrep "^airsearches_[a-z0-9_]+=[0-9]+$"
15 # make sure we have all the commands we need
16 require_cmd wget || return 1
18 # make sure we are configured
19 if [ -z "$airsearches_url" ]
21 echo >&2 "$PROGRAM_NAME: airsearches: not configured. Please set airsearches_url='url' in $confd/airsearches.conf"
25 # check once if the url works
26 wget 2>/dev/null -O /dev/null "$airsearches_url"
29 echo >&2 "$PROGRAM_NAME: airsearches: cannot fetch the url: $airsearches_url. Please set airsearches_url='url' in $confd/airsearches.conf"
33 # if the admin did not give any commands
34 # find the available ones
35 if [ -z "$airsearches_cmds" ]
37 airsearches_cmds="$(airsearches_get | cut -d '=' -f 1 | sed "s/^airsearches_//g" | sort -u)"
41 # did we find any commands?
42 if [ -z "$airsearches_cmds" ]
44 echo >&2 "$PROGRAM_NAME: airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf"
52 airsearches_create() {
53 [ -z "$airsearches_cmds" ] && return 1
57 echo "CHART airsearches.affiliates '' 'Air Searches per affiliate' 'requests / min' airsearches '' stacked 20000 $airsearches_update_every"
58 for x in $airsearches_cmds
60 echo "DIMENSION $x '' incremental 60 1"
66 airsearches_update() {
67 # the first argument to this function is the microseconds since last update
68 # pass this parameter to the BEGIN statement (see bellow).
70 # do all the work to collect / calculate the values
72 # remember: KEEP IT SIMPLE AND SHORT
74 # get the values from airsearches
75 eval "$(airsearches_get)"
77 # write the result of the work.
80 echo "BEGIN airsearches.affiliates $1"
81 for x in $airsearches_cmds
83 eval "v=\$airsearches_$x"