Sales leads were being sent to a single email account that a team for sales people were checking. The problem is that some leads were being worked twice. To help organize, track and distribute leads, I created a PHP script inside the search parts website that would choose at random a sales person to send a lead. This script is tied to a form that prospective customers fill out giving information about the product they are looking for. This form is parsed and emailed to a sales person to handle. All of this is put in to a mysql database so we can track which sales person handled which lead and how many leads they are getting per day.
Here is the script: (marked in green)
We pick a random number.
srand((float) microtime() * 10000000);
We put all of the sales people in to an array.
$eaddress[1]="salesperson1@domain.com";
$eaddress[2]="salesperson2@domain.com";
$eaddress[3]="salesperson3@domain.com";
We match the random number with a sales person inside the array.
$rn = array_rand($eaddress);
$pa_eaddress=$eaddress[$rn];
Next part we assign the two values $paname and $pa_ext, to the corresponding sales person's name and their extension number. This will be used inside the signature of the automated email the prospect will receive upon submitting a request.
if ($rn==1){
$paname="Sales Person1";
$pa_ext="5001";
} elseif ($rn==2) {
$paname="Sales Person2";
$pa_ext="5002";
} elseif ($rn==3) {
$paname="Sales Person3";
$pa_ext="5003";
} else {}
Here we use the $paname and $pa_eaddres to make it look like the email was sent by the sales person. So when the prospect receives the automated response the "from:" email address is that of the sales person.
$headers3 .= "From: ".$paname." <".$pa_eaddress.">. \r\n";
$headers3 .= "Content-Type: text/html; charset=iso-8859-1 \r\n";
This is the title or subject of the email the sales person and prospect both receive.
$m_subject = "Quote Request";
Next we fill out the email that is sent to the sales person. This is how we make the leads look like they were emailed by the prospect using the prospect's email address and first name they supplied in the online form. This email is also CC'd to a manager that reviews them and keeps them on file.
$headers1 = "";
$headers1 .= "From: ".$fname1." <".$sender_email1 .">\n";
$headers1 .= 'Cc: manager@domain.com' . "\r\n";
$headers1 .= "Content-Type: text/html; charset=iso-8859-1\n";
$todate1=date("Y-m-d");$todate2=date("h:i:s A");
To ensure that the prospect emails the sales person rather than the automated smtp server, we reinforce this by using the "Reply-To:" field represented by $extra.
$extra = "From:".$pa_eaddress."\r\nReply-To:".$pa_eaddress."\r\nContent-Type: text/html; charset=iso-8859-1\r\n";
We send the automated response to the prospect. $message1 is the body of the email letting them know that they will be contacted shortly. $message1 also contains at the bottom (to resemble a typical email signature) the name of the sales person, their phone number plus extension and email address.
mail($sender_email1, $m_subject, $message1, $extra);
We now send the mail to the sales person. $message is everything a sales person would need to look up the product and contact the prospect. $message is a created by parsing all of the values from the form that prospect filled out and rearranged to make it easier for a sales person to read.
if(mail($pa_eaddress, $m_subject, $message, $headers1))
This is a copy or CC to the manager. We do not use this anymore. We store everything in a database now. This line has been committed using // .
//mail("manager@domain.com", $m_subject, $message, $headers1);
This is a continuation of the if() statement above, just FYI.
{
Here we combine the first name ($fname) and last name ($lname), separated by a space, to create the full name of the prospect.
$name=$fname." ".$lname;
This is how we capture and store all of the leads in the database. Everything is stored in the table aptly named "data_mining". This is just a basic INSERT statement used on a mysql database. Proper syntax on the INSERT statement be found here http://dev.mysql.com/doc/refman/5.1/en/insert.html
$ins=mysql_query("INSERT INTO data_mining (`id`, `request_number`, `form_date`, `year`, `make`, `model`, `sub_model`, `engine_size`, `budget`, `condition`, `first_name`, `last_name`, `address1`, `address2`, `city`, `state`, `zip_code`, `phone`, `phone_ext`, `email_address`, `pa_name`) VALUES('','$tr_no','$todate1','$yr','$mk','$models','$submodels','$eng','$budget','$quote','$fname','$lname','$address1','$address2','$city','$state','$zip','$phone','$ext','$email','$paname')");
This is the message we display to the prospect after the email has been sent and everything stored in to the database. You can put anything you wish here or just have it redirect them back to the home page.
$msg="Thank you for filling out the form!";
}
This script requires a lot of hands on management, meaning it must be edited every time we have someone out of the office or if someone is under a high load we must adjust the amount they are getting. I'm currently working on a script that will allow changes to be made on the fly and allow for better report/monitoring using the "data_mining" table in the mysql database. I will cover this in a part 2.
20090928
Faxing
I was asked to come up with a fax solution because of the on going development the business app. The app has a fax button however its not connected to anything. This the same group of developers that are telling us they need 400 to 600 hours to create another tool to allow us to delete inventory from our msql database. Because the app allows the user to print POs and other type of documents that need to be faxed, I decided the easiest route would be installing a fax service.
Installing The Fax Service
Once the modem is installed and set up, you need to install the Fax Service onto your server. This service is included in all editions of Windows Server 2003 with the exception of the Web edition. To install this service, open the Control Panel and select the Add/Remove Programs option. Windows will next display the Add/Remove Programs dialog box. Click the Add/Remove Windows Components button and, after a brief delay, you'll see a list of all the various Windows components. Scroll until you locate the Fax Services option. Select this option and then click Next. Windows will prompt you for your Windows Server 2003 installation CD and begin copying the necessary files.
Creating A Fax Printer
The next step in the configuration process is to create a fax printer. The Fax Service handles faxing much like it handles document printing. The document is spooled to a queue similar to that used for printing, but it is redirected to a fax instead of actually being printed. Installing a fax printer is simple. Select the Printers And Faxes option from the Start menu. This window displays all of the currently configured printers. Now, right-click in an empty area of the window and select the Install A Local Fax Printer. A new printer named Fax will be created instantly. Now that you've installed a fax printer, you must share the printer so that remote users can send faxes through it. To share, right-click on the fax printer and select the Sharing. Select the Share This Printer radio button and then give the fax printer a share name.
Client
First, open the Printers And Faxes window located in the start button, and then click the Add A Printer link. Follow the prompts to install a network printer attached to another computer. Finally, enter the path to the remote fax printer that you set up earlier. Assuming that you named the printer "Fax", the path will be \\servername\Fax. Complete the wizard, and the client is ready to send its first fax.
Faxing Faxes
The users can send faxes from any application they can normally print from. For example, suppose a user wanted to fax a PO to a supplier. The user would open the PO and choose the Print option the File menu. Next, the user would choose the fax printer from the list of printers and click OK. Windows would launch the Send Fax Wizard. The Send Fax Wizard would next ask the user for the names and numbers of those receiving the fax. Windows would then ask the user to choose a fax cover. The user can select from a variety of built-in covers as well as use this screen to enter a subject line and a note to the recipient. The next screen would ask the user when to send the fax and what the fax’s priority should be. After entering this information, the user is given a chance to preview the fax. If everything looks good, the user would simply click Finish to send the fax.
Monitoring Faxes
Faxes can be monitored by using the Fax Console to located under Start > All Programs > Accessories > Communications > Fax menu.
Installing The Fax Service
Once the modem is installed and set up, you need to install the Fax Service onto your server. This service is included in all editions of Windows Server 2003 with the exception of the Web edition. To install this service, open the Control Panel and select the Add/Remove Programs option. Windows will next display the Add/Remove Programs dialog box. Click the Add/Remove Windows Components button and, after a brief delay, you'll see a list of all the various Windows components. Scroll until you locate the Fax Services option. Select this option and then click Next. Windows will prompt you for your Windows Server 2003 installation CD and begin copying the necessary files.
Creating A Fax Printer
The next step in the configuration process is to create a fax printer. The Fax Service handles faxing much like it handles document printing. The document is spooled to a queue similar to that used for printing, but it is redirected to a fax instead of actually being printed. Installing a fax printer is simple. Select the Printers And Faxes option from the Start menu. This window displays all of the currently configured printers. Now, right-click in an empty area of the window and select the Install A Local Fax Printer. A new printer named Fax will be created instantly. Now that you've installed a fax printer, you must share the printer so that remote users can send faxes through it. To share, right-click on the fax printer and select the Sharing. Select the Share This Printer radio button and then give the fax printer a share name.
Client
First, open the Printers And Faxes window located in the start button, and then click the Add A Printer link. Follow the prompts to install a network printer attached to another computer. Finally, enter the path to the remote fax printer that you set up earlier. Assuming that you named the printer "Fax", the path will be \\servername\Fax. Complete the wizard, and the client is ready to send its first fax.
Faxing Faxes
The users can send faxes from any application they can normally print from. For example, suppose a user wanted to fax a PO to a supplier. The user would open the PO and choose the Print option the File menu. Next, the user would choose the fax printer from the list of printers and click OK. Windows would launch the Send Fax Wizard. The Send Fax Wizard would next ask the user for the names and numbers of those receiving the fax. Windows would then ask the user to choose a fax cover. The user can select from a variety of built-in covers as well as use this screen to enter a subject line and a note to the recipient. The next screen would ask the user when to send the fax and what the fax’s priority should be. After entering this information, the user is given a chance to preview the fax. If everything looks good, the user would simply click Finish to send the fax.
Monitoring Faxes
Faxes can be monitored by using the Fax Console to located under Start > All Programs > Accessories > Communications > Fax menu.
Labels:
Fax Service,
Windows 2003,
Windows XP
20090925
Nagios
Traditionally I would build Nagios using the source but I recently found its in the yum repository (Fedora 11). "Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.". We currently rely on traditional methods of monitoring; wait for the user to become angry and report a problem manually. If you search for Nagios on yum you will find that there are a ton a plug-ins available. Using yum for this installation will help reduce the installation time and help with typical dependency issues.
My layout will include two Nagios servers monitoring 6 Windows Server 2000-2008 servers, 30 or so Xp workstations, 4 switches, 1 router, 5 to 6 printers and 3 websites. The primary monitoring server (Troy) is a Fedora 11 based system while the secondary system (Bugs) is Fedora 8.
Note that Nagios requires that you have Apache, PHP and the GD libs. All of these prerequisites can be found in yum.
I first install the nagios.i586 and nrpe.i586 packages then issue the yum install nagios* to fetch everything else. I'm sure that you could just issue yum install nagios* and get everything needed without any issues. Next you will need to edit the configuration files. I recommend a suite called Nconf. Nconf is a web based configuration tool for Nagios. I will cover Nconf in a separate document.
Next is to configure Apache. You must create a AuthUserFile so you don't have anonymous people logging in to the Nagios site. Use htpasswd -c /etc/nagios/passwd admin to create the AuthUserFile with a user name of admin. Make sure that you remember this password because you will need it to login to the Nagios web interface later. Next edit /etc/httpd/conf.d/nagios.conf to allow from any ip addresses that will need access to the web interface and make sure that the AuthUserFile is pointed to /etc/nagios/passwd.
Before starting Nagios run the verify command that checks your configuration for any issues. This command is done by using the v switch and pointing to your main config file. Example: nagios -v /etc/nagios/nagios.cfg. If the check comes back with no serious problems then you should be safe to start nagios. You can set Nagios to start during boot by issuing these two commands chkconfig --add nagios and chkconfig nagios on. Start Nagios manually by issuing the command service nagios start.
If you have problems viewing the web interface check that your firewall is allowing httpd connections. If you use SELinux in enforcing or targeted mode then you must add rules or just disable enforcing. Also check /etc/httpd/conf.d/nagios.conf is allowing the IP addresses you wish to have access to Nagios (remove deny from all).
NOTES:
Installing Nagios From YUM
yum install nagios.i586
yum install nrpe.i586
yum install nagios*
Apache Configuration
htpasswd -c /etc/nagios/passwd admin
vi /etc/httpd/conf.d/nagios.conf
Nagios Configuation
nagios -v /etc/nagios/nagios.cfg
Service Configuration
chkconfig --add nagios
chkconfig nagios on
Firewall Configuration
lokkit
SELinux Configuration
vi /etc/selinux/config
My layout will include two Nagios servers monitoring 6 Windows Server 2000-2008 servers, 30 or so Xp workstations, 4 switches, 1 router, 5 to 6 printers and 3 websites. The primary monitoring server (Troy) is a Fedora 11 based system while the secondary system (Bugs) is Fedora 8.
Note that Nagios requires that you have Apache, PHP and the GD libs. All of these prerequisites can be found in yum.
I first install the nagios.i586 and nrpe.i586 packages then issue the yum install nagios* to fetch everything else. I'm sure that you could just issue yum install nagios* and get everything needed without any issues. Next you will need to edit the configuration files. I recommend a suite called Nconf. Nconf is a web based configuration tool for Nagios. I will cover Nconf in a separate document.
Next is to configure Apache. You must create a AuthUserFile so you don't have anonymous people logging in to the Nagios site. Use htpasswd -c /etc/nagios/passwd admin to create the AuthUserFile with a user name of admin. Make sure that you remember this password because you will need it to login to the Nagios web interface later. Next edit /etc/httpd/conf.d/nagios.conf to allow from any ip addresses that will need access to the web interface and make sure that the AuthUserFile is pointed to /etc/nagios/passwd.
Before starting Nagios run the verify command that checks your configuration for any issues. This command is done by using the v switch and pointing to your main config file. Example: nagios -v /etc/nagios/nagios.cfg. If the check comes back with no serious problems then you should be safe to start nagios. You can set Nagios to start during boot by issuing these two commands chkconfig --add nagios and chkconfig nagios on. Start Nagios manually by issuing the command service nagios start.
If you have problems viewing the web interface check that your firewall is allowing httpd connections. If you use SELinux in enforcing or targeted mode then you must add rules or just disable enforcing. Also check /etc/httpd/conf.d/nagios.conf is allowing the IP addresses you wish to have access to Nagios (remove deny from all).
NOTES:
Installing Nagios From YUM
yum install nagios.i586
yum install nrpe.i586
yum install nagios*
Apache Configuration
htpasswd -c /etc/nagios/passwd admin
vi /etc/httpd/conf.d/nagios.conf
Nagios Configuation
nagios -v /etc/nagios/nagios.cfg
Service Configuration
chkconfig --add nagios
chkconfig nagios on
Firewall Configuration
lokkit
SELinux Configuration
vi /etc/selinux/config
20090924
FSCK'd
After messing up the superblock on the root partition and completely crashing one of the servers here at work. I figured that I would try the "rescue cd" to drop down to the shell and run fsck. My limited experience with LVM showed yesterday. After reading man page after man page I realized the LVM tools aren’t on the so called “rescue cd”. LVM is the standard implementation on fedora and It would only be logical to have LVM tools on the “rescue cd”. Nevertheless I used a knoppix cd to get to the shell and fsck'ed the root partition. The box boots now but its not giving me a log in prompt. I booted to shell again and mounting the lv_root to find that everything has been moved to the a lost+found directory and renamed to # followed by a bunch of numbers (inode number). After reading for hours I've come to the conclusion that the data cannot be automatically restored back to its original file name and location. I did a file count (ls -R wc) and it would require me to manually rename and move 2,826,046 files. I'm going to try running fsck again using alternate superblock locations in hopes that it will restore the file names, otherwise to save time I'm just going to format and reinstall Fedora.
NOTES:
Enabling The Volume Group & Mounting The Logical Volume
modprobe dm_mod (optional, not always required)
vgscan (locate LV's)
vgchange -a y (enable the LV's)
lvm lvs (list of LV's)
mount /dev/vg_(hostname)/lv_root /mnt
Checking The File System
DO NOT CHECK A MOUNTED FILE SYSTEM
fsck -a /dev/vg_(hostname)/lv_root (checking the file system and automatically repairing)
Locating Alternate Superblock Locations
mkfs -n /dev/vg_(hostname)/lv_root (the n switch means show me what you would do, but don’t actually do it)
NOTES:
Enabling The Volume Group & Mounting The Logical Volume
modprobe dm_mod (optional, not always required)
vgscan (locate LV's)
vgchange -a y (enable the LV's)
lvm lvs (list of LV's)
mount /dev/vg_(hostname)/lv_root /mnt
Checking The File System
DO NOT CHECK A MOUNTED FILE SYSTEM
fsck -a /dev/vg_(hostname)/lv_root (checking the file system and automatically repairing)
Locating Alternate Superblock Locations
mkfs -n /dev/vg_(hostname)/lv_root (the n switch means show me what you would do, but don’t actually do it)
Labels:
Lost+Found,
LVM,
superblock
Subscribe to:
Posts (Atom)
