initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.
This commit is contained in:
commit
43e0f5b59e
329 changed files with 31937 additions and 0 deletions
150
egstats/php/egstats.php
Executable file
150
egstats/php/egstats.php
Executable file
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/php5
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This set of scripts is indended to accomplish the following:
|
||||
*
|
||||
* For each of a number of configured "domains" on this or another
|
||||
* server, this script will
|
||||
* a. mirror (rsync) a designated HTTP common access_logs to a
|
||||
* local access_log.
|
||||
* b. if it does not already exist, create the appropriate AWStats
|
||||
* configuration file, including global and Egressive-specific
|
||||
* configuration defaults as required.
|
||||
* c. if it has not be performed already, initialise the
|
||||
* statistics database
|
||||
* d. update the statistics database
|
||||
* e. produce a series of HTML pages based on the statistics
|
||||
* f. copy the relevant icon and graphics files into a suitable
|
||||
* subdirectory so that they're available for the HTML pages to include
|
||||
* g. put those HTML pages into a web-viewable directory appropriate to
|
||||
* the month within the domain's directory
|
||||
* h. create a sensible "index.html" page so that a browser clicking on
|
||||
* that month directory sees the summary page for that month and can
|
||||
* access the other, more specific pages linked in that summary
|
||||
*/
|
||||
|
||||
/* PEAR_LIB_DIR PEAR library directory. */
|
||||
define('PEAR_LIB_DIR', '/usr/share/pear');
|
||||
/* system constants */
|
||||
define('EG_DIR','/etc/egscripts/egawstats');
|
||||
define('EG_CONF',EG_DIR.'conf');
|
||||
// the rsync command
|
||||
define('RSYNC','/usr/bin/rsync');
|
||||
// rsync command flags
|
||||
define('FLAGS','-e ssh --stats');
|
||||
// the chown command
|
||||
define('CHOWN','/bin/chown');
|
||||
// AWStats related defines
|
||||
define('AWSBIN','/var/www/cgi-bin/awstats.pl');
|
||||
define('AWSDIR','/usr/share/awstats');
|
||||
define('AWSCONF_DIR',EG_DIR.'/awstatsconf');
|
||||
define('AWSCONF_PREFIX','awstats');
|
||||
define('AWSCONF_SUFFIX','conf');
|
||||
define('AWS_ARGS','-update -awstatsprog='.AWSBIN);
|
||||
|
||||
/**
|
||||
* Domain class - information related to a particular virtual domain
|
||||
* requiring awstats reports (http://awstats.sourceforge.net)
|
||||
*
|
||||
* @author Dave Lane <dave@egressive.com>
|
||||
* @copyright Copyright (C) 2005 Egressive Limited (www.egressive.com)
|
||||
* @version $Id: egawstats.php 0 2005-08-18 08:07:26Z dave $
|
||||
* @package egawstats
|
||||
*/
|
||||
|
||||
class Domain {
|
||||
/**
|
||||
* @var array $domain a mixed array of "name" and "values"
|
||||
* for the current domain.
|
||||
* @access private
|
||||
*/
|
||||
private $domain = array();
|
||||
|
||||
/**
|
||||
* @var array $domain_array two dimensional array containing arrays
|
||||
* of parsed domains.
|
||||
* @access private
|
||||
*/
|
||||
private $domain_array = array();
|
||||
|
||||
private $logger = null;
|
||||
|
||||
public function __construct($logger) {
|
||||
$this->logger = $logger;
|
||||
|
||||
$this->logger->log(__CLASS__.'->'.__FUNCTION__,PEAR_LOG_DEBUG);
|
||||
|
||||
// domain info
|
||||
$this->domain_array[0]["NAME"] = "far.org.nz";
|
||||
$this->domain_array[0]["ALIASES"] = array('www.far.org.nz',
|
||||
'far.egressive.com');
|
||||
$this->domain_array[0]["SKIP_HOST"] = "REGEX[^192\.168\.] 203.97.50.115 203.97.51.110";
|
||||
// source information
|
||||
$this->domain_array[0]["SRC_HOST"] = "warhol.kc";
|
||||
$this->domain_array[0]["SRC_PATH"] = "/home/far/logs";
|
||||
$this->domain_array[0]["SRC_FILE"] = "access_log";
|
||||
$this->domain_array[0]["SRC_USER"] = "root";
|
||||
// destination information
|
||||
$this->domain_array[0]["DST_HOST"] = ""; // leave blank for localhost
|
||||
$this->domain_array[0]["DST_PATH"] = "/home/sites/logs/far";
|
||||
$this->domain_array[0]["DST_FILE"] = "access_log";
|
||||
$this->domain_array[0]["DST_USER"] = "sites";
|
||||
$this->domain_array[0]["DST_GROUP"] = "sites";
|
||||
}
|
||||
|
||||
/**
|
||||
* print the state of the current class
|
||||
*/
|
||||
/*public function print() {
|
||||
|
||||
}*/
|
||||
|
||||
/**
|
||||
* run the rsync that synchronises the logs on the main machine to the
|
||||
* copy on the machine running awstats
|
||||
*/
|
||||
private function sync_logs() {
|
||||
$this->logger->log(__CLASS__.'->'.__FUNCTION__,PEAR_LOG_DEBUG);
|
||||
|
||||
//$this->domain[]
|
||||
|
||||
/*if ($this->logger->log('testing logger',PEAR_LOG_NOTICE)) {
|
||||
echo "logging worked\n";
|
||||
} else {
|
||||
echo "logging folded\n";
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* run the whole process...
|
||||
*/
|
||||
public function run() {
|
||||
$this->logger->log(__CLASS__.'->'.__FUNCTION__,PEAR_LOG_DEBUG);
|
||||
|
||||
foreach ($this->domain_array as $this->domain) {
|
||||
$this->sync_logs();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* PHP ini set to local PEAR library */
|
||||
ini_set('include_path', PEAR_LIB_DIR);
|
||||
/* Require main PEAR class and PLUM classes. */
|
||||
require_once('PEAR.php');
|
||||
/* include the logging functionality */
|
||||
require_once('Log.php');
|
||||
/* include file reading/writing functionality */
|
||||
require_once('File.php');
|
||||
|
||||
$logger = &Log::singleton('console','','egawstats.php');
|
||||
$logger->log("***** Starting egawstats.php *****",PEAR_LOG_DEBUG);
|
||||
|
||||
|
||||
$conf_filename="";
|
||||
|
||||
$domain = new Domain($logger);
|
||||
|
||||
$domain->run();
|
||||
$logger->log("===== Finishing egawstats.php =====",PEAR_LOG_DEBUG);
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue