Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #11  
Old 23rd June 2011, 10:04
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,181
Thanks: 829
Thanked 5,414 Times in 4,257 Posts
Default

You can use the sys_config table.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Sponsored Links
  #12  
Old 1st July 2011, 17:40
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
Default

Is there a variable where to check if I am a slave or if I am master server?

Right now, I am checking if $conf['dbmaster_host'] is empty or not to know if I am a slave or master... this is not the best way to check it...

(as I could see, in master server that variable is empty, if it is slave, it has the hostname of the master server...)

I think that there is a better way to check this... more simple I think... could you help me? I did'nt have enough time to check all ispconfig structure and variables...

My approach is:

If I am a slave, I have to save locally timestamp of last read line in ftptraffic log and next save traffic in ftp_traffic in master server.

If I am master, I have to save both locally, timestamp and ftp traffic.
Reply With Quote
  #13  
Old 4th July 2011, 12:48
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,181
Thanks: 829
Thanked 5,414 Times in 4,257 Posts
Default

Quote:
Originally Posted by erosbk View Post
Is there a variable where to check if I am a slave or if I am master server?
if ($app->dbmaster == $app->db) {
echo "This is a master server";
}
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #14  
Old 5th July 2011, 16:52
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
 
Default

I made the script, I can assume that it will work for a multiserver (with one or more ftp/web servers) environment -Debian, pureftpd, log set as stats:-

Only tested with ftp/web server in master server... I will test it in VMs in the next weeks to see if it is working correctly (only thing I need to test, is to add ftp_traffic in master server, give INSERT, UPDATE, SELECT privileges for each slave (or just for ftp slave?) and test, test and test...

Right now, It is just crude code, including this files: require('/usr/local/ispconfig/server/lib/config.inc.php');
require('/usr/local/ispconfig/server/lib/app.inc.php');

But only using a few variables/classes/functions of them...

I don't have enought time to investigate all ispconfig as I wish, so... I need your guidance...

1) Have a look here please if you want to see the "ugly working code" (will be improved soon...)

http://www.tecatest.com.ar/test.txt

2) How can I replace this check? (do I am a FTP server??)

Code:
$myhostname = gethostname();

$conn = mysql_connect($conf['db_host'], $conf['db_user'], $conf['db_password']) or die                      ('Error connecting to mysql');
mysql_select_db($conf['db_database']);
$result = mysql_query("select count(server_id) FROM server WHERE file_server=1 and server_name='$myhostname'");
mysql_close($conn);

$ftpvalid = mysql_fetch_array($result);

if ($ftpvalid[0] > 0) //Do I am a FTP server???, if yes... continues, master or slave is the same

3) I think that ISPConfig3 has some functions to handle update/insert to dbmaster/dblocal... how can I replace this?

Code:
$conn = mysql_connect($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password']) or die            $
mysql_select_db($conf['dbmaster_database']);
$result = mysql_query("select count(username) from ftp_traffic where username='$ftp_user' and traffic_date='$ftp_dat$
$row = mysql_fetch_array($result);
mysql_close($conn);
if ($row[0] == 0) // No record found, so... insert in master into ftp_traffic
{
        $query = "insert into ftp_traffic values ('$ftp_domain[0]','$ftp_user','$ftp_date',$ftp_type,'$ftp_bytes')";
}
else // Update ftp_traffic in master
{
       $query = "update ftp_traffic set traffic_bytes=traffic_bytes+'$ftp_bytes' where username='$ftp_user' and tra$
}
$conn = mysql_connect($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password']) or die            $
mysql_select_db($conf['db_database']);
mysql_query($query);
mysql_close($conn);
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amavisd not identfying spam properly Cracklefish Installation/Configuration 11 22nd December 2009 11:05
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 09:29
ftp is very slow and asks for user/passwd continuously chico58 Installation/Configuration 7 8th October 2008 12:43
How to add a subdomain? malinens Installation/Configuration 2 10th March 2008 23:16
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18


All times are GMT +2. The time now is 10:13.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.