Commit a7333537 authored by mcramer's avatar mcramer
Browse files

Added: vlogger mysql usage to store traffic reports

Added: interface module web traffic statistics
Fixed: mail_traffic is now reported to master server instead of local
Fixed: GRANTs for slave server database user on master database
parent bb5171da
......@@ -148,5 +148,7 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /bin/basename /usr/bin/dirname /usr/bin/nano';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -148,5 +148,7 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /bin/basename /usr/bin/dirname /usr/bin/nano';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -148,5 +148,7 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -148,5 +148,7 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /bin/basename /usr/bin/dirname /usr/bin/nano';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -97,5 +97,7 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -148,5 +148,8 @@ $conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
?>
\ No newline at end of file
......@@ -195,6 +195,10 @@ if($install_mode == 'standard') {
swriteln('Configuring Apache');
$inst->configure_apache();
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
......@@ -359,6 +363,10 @@ if($install_mode == 'standard') {
$conf['services']['web'] = true;
swriteln('Configuring Apache');
$inst->configure_apache();
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
}
//** Configure Firewall
......
......@@ -318,6 +318,21 @@ class installer_base {
if(!$this->dbmaster->query($query)) {
$this->error('Unable to create database user in master database: '.$conf['mysql']['master_ispconfig_user'].' Error: '.$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT, UPDATE ON ".$conf['mysql']['master_database'].".`mail_traffic` "
."TO '".$conf['mysql']['master_ispconfig_user']."'@'".$src_host."' "
."IDENTIFIED BY '".$conf['mysql']['master_ispconfig_password']."';";
if(!$this->dbmaster->query($query)) {
$this->error('Unable to create database user in master database: '.$conf['mysql']['master_ispconfig_user'].' Error: '.$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT, UPDATE ON ".$conf['mysql']['master_database'].".`web_traffic` "
."TO '".$conf['mysql']['master_ispconfig_user']."'@'".$src_host."' "
."IDENTIFIED BY '".$conf['mysql']['master_ispconfig_password']."';";
if(!$this->dbmaster->query($query)) {
$this->error('Unable to create database user in master database: '.$conf['mysql']['master_ispconfig_user'].' Error: '.$this->dbmaster->errorMessage);
}
}
}
......@@ -856,7 +871,32 @@ class installer_base {
}
public function configure_vlogger()
{
global $conf;
//** Configure vlogger to use traffic logging to mysql (master) db
$configfile = 'vlogger-dbi.conf';
if(is_file($conf["vlogger"]["config_dir"].'/'.$configfile)) copy($conf["vlogger"]["config_dir"].'/'.$configfile,$conf["vlogger"]["config_dir"].'/'.$configfile.'~');
if(is_file($conf["vlogger"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["vlogger"]["config_dir"].'/'.$configfile.'~');
$content = rf("tpl/".$configfile.".master");
if($conf['mysql']['master_slave_setup'] == 'y') {
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['master_ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$conf['mysql']['master_database'],$content);
$content = str_replace('{mysql_server_ip}',$conf["mysql"]["master_host"],$content);
} else {
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
$content = str_replace('{mysql_server_ip}',$conf["mysql"]["host"],$content);
}
wf($conf["vlogger"]["config_dir"].'/'.$configfile,$content);
exec('chmod 600 '.$conf["vlogger"]["config_dir"].'/'.$configfile);
exec('chown root:root '.$conf["vlogger"]["config_dir"].'/'.$configfile);
}
public function install_ispconfig()
{
global $conf;
......
......@@ -1016,6 +1016,20 @@ CREATE TABLE `web_database` (
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table `web_traffic`
--
CREATE TABLE `web_traffic` (
`hostname` varchar(255) NOT NULL,
`traffic_date` date NOT NULL,
`traffic_bytes` bigint(32) unsigned NOT NULL default '0',
PRIMARY KEY (`hostname`,`traffic_date`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
......
......@@ -5,7 +5,7 @@
################################################
LogFormat "%v %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig
CustomLog "| /usr/sbin/vlogger -s access.log -t \"%Y%m%d-access.log\" /var/log/ispconfig/httpd" combined_ispconfig
CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m%d-access.log\" -d \"/etc/vlogger-dbi.conf\" /var/log/ispconfig/httpd" combined_ispconfig
<Directory /var/www/clients>
AllowOverride None
......
dsn DBI:mysql:database={mysql_server_database};host={mysql_server_ip}:3306
user {mysql_server_ispconfig_user}
pass {mysql_server_ispconfig_password}
dump 30
\ No newline at end of file
......@@ -300,6 +300,10 @@ if($reconfigure_services_answer == 'yes') {
//** Configure Apache
swriteln('Configuring Apache');
$inst->configure_apache();
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
}
......
<?php
$wb['list_head_txt'] = 'Web traffic';
$wb['domain_txt'] = 'Domain';
$wb['this_month_txt'] = 'This month';
$wb['last_month_txt'] = 'Last month';
$wb['this_year_txt'] = 'This year';
$wb['last_year_txt'] = 'Last year';
?>
<?php
$wb['list_head_txt'] = 'Web Datenverkehr';
$wb['domain_txt'] = 'Domain';
$wb['this_month_txt'] = 'Diesen Monat';
$wb['last_month_txt'] = 'Letzten Monat';
$wb['this_year_txt'] = 'Dieses Jahr';
$wb['last_year_txt'] = 'Letztes Jahr';
?>
<?php
$wb["list_head_txt"] = 'Web traffic';
$wb["domain_txt"] = 'Domain';
$wb["this_month_txt"] = 'This month';
$wb["last_month_txt"] = 'Last month';
$wb["this_year_txt"] = 'This year';
$wb["last_year_txt"] = 'Last year';
?>
\ No newline at end of file
<?php
$wb['list_head_txt'] = 'Tráfico de xxxx';
$wb['domain_txt'] = 'xxxx';
$wb['this_month_txt'] = 'Este mes';
$wb['last_month_txt'] = 'Último mes';
$wb['this_year_txt'] = 'Este año';
$wb['last_year_txt'] = 'Último año';
?>
<?php
$wb['list_head_txt'] = 'Sähköpostiliikenne';
$wb['domain_txt'] = 'Sähköpostiosoite';
$wb['this_month_txt'] = 'Tässä kuussa';
$wb['last_month_txt'] = 'Viime kuussa';
$wb['this_year_txt'] = 'Tänä vuonna';
$wb['last_year_txt'] = 'Viime vuonna';
?>
<?php
$wb['list_head_txt'] = 'Web traffic';
$wb['domain_txt'] = 'Domain';
$wb['this_month_txt'] = 'This month';
$wb['last_month_txt'] = 'Last month';
$wb['this_year_txt'] = 'This year';
$wb['last_year_txt'] = 'Last year';
?>
<?php
$wb['list_head_txt'] = 'Web traffic';
$wb['domain_txt'] = 'Domain';
$wb['this_month_txt'] = 'This month';
$wb['last_month_txt'] = 'Last month';
$wb['this_year_txt'] = 'This year';
$wb['last_year_txt'] = 'Last year';
?>
<?php
$wb['list_head_txt'] = 'Web verkeer';
$wb['domain_txt'] = 'Domain';
$wb['this_month_txt'] = 'Deze maand';
$wb['last_month_txt'] = 'Laatste maand';
$wb['this_year_txt'] = 'Dit jaar';
$wb['last_year_txt'] = 'Vorig jaar';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment