webv - reports the the number of unique visitors for the current month to date.
webv
[
-c
<config_file>
]
[
-d
]
[
-v
]
<config_id>
|
-V
webv is a Bourne/Bash shell script which should work equally well on all versions of UNIX, Linux and Mac OS X.
webv uses the configuration id as a lookup key to the configuration file /usr/local/etc/webv.cf and finds the URI of an awstats report on a remote web server. The URI is used by wget to fetch the report and put it on a pipe to an awk script which extracts the required data item and performs a calculation of the average number of visitors per hour in the current month and the total number of unique visitors predicted by the month end.
The script was written to monitor a number of websites where changes were being made and checking the impact of the changes by inspection was becoming rather too time consuming.
-c Use the specified configuration file in preference to the default "/usr/local/etc/webv.cf" . If no configuration file is found the script will terminate with an error message.
-d Set debug mode on. The -x option is set within the shell and each command in the script is echoed to the console.
-v The usual output is just the 3 numbers repesenting the total number of unique visitors so far in the month, the daily average and the predicted outturn. With the -v option the output is formated and labled. This is particularly useful when used with cron to report on a number of different sites.
< config_id > The configuration identity is the key to the stanza in the configuration file which will be used to determine the required URI for the stats report.
-V Print version details and exit.
for key in ai cl fc fs t4l;do webv -v $key done
Each id is looked up in the default configuration file /usr/local/etc/webv.cf . Using the URI found the script fetches the awstats report, extracts the number of unique visitors for the day, calculates the daily average for the month and the predicted outturn at the month end. E.g.
ai - Visitors so far: 81 Ave: 8 Prediction: 251 cl - Visitors so far: 141 Ave: 14 Prediction: 437 fc - Visitors so far: 80 Ave: 8 Prediction: 248 fs - Visitors so far: 26 Ave: 3 Prediction: 81 t4l - Visitors so far: 139 Ave: 14 Prediction: 431
The script is quite crude and has very little, if any, error checking. The consequences of unexpected input are untested.
Clifford W Fulford, City Linux. Contact fulford@fulford.net or +44 (0)709 229 5385.
Copyright
© 2003-2017
Clifford W Fulford.
Fulford Consulting Ltd.
Regd. Co. 4250037 in England & Wales.
Regd. office 162, Edward Rd. Nottingham NG2 5GF, England, UK.
Related web sites: City Linux | Flare Support | West Bridgford | Fulford Portal | Joan Mary Fulford (Nottingham Writer) | Fulford Gallery | Amharic Interpreter | Arabic Interpreter | Tigrinya Interpreter
The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.