Sendmail does not provide a command-line argument to remove messages from the mail queue. It may be necessary to manually remove messages from the mail queue rather than allowing Sendmail to attempt redelivery of messages for Timeout.queureturn days (5, by default).
The proper way to remove messages from the mail queue is to use the qtool.pl program included in the contrib subdirectory of the Sendmail source code distribution. qtool.pl uses the same file locking mechanism as Sendmail.
Removing "double bounce" messages
The following is a Perl script that calls /usr/local/bin/qtool.pl to remove "double bounce" messages. A "double bounce" is a message that is addressed to a non-existent user and that is sent from an invalid return address. Busy mail relays often have hundreds to thousands of these messages.
The script below will delete a queued message if it is (1) "deferred" (unable to be returned to the sender), (2) being sent from our postmaster email address, and (3) the subject is unique to delivery failure notifications.
#!/usr/bin/perl
use strict;
my $qtool = "/usr/local/bin/qtool.pl";
my $mqueue_directory = "/var/spool/mqueue";
my $messages_removed = 0;
use File::Find;
# Recursively find all files and directories in $mqueue_directory
find(\&wanted, $mqueue_directory);
sub wanted {
# Is this a qf* file?
if ( /^qf(\w{14})/ ) {
my $qf_file = $_;
my $queue_id = $1;
my $deferred = 0;
my $from_postmaster = 0;
my $delivery_failure = 0;
my $double_bounce = 0;
open (QF_FILE, $_);
while(<QF_FILE>) {
$deferred = 1 if ( /^MDeferred/ );
$from_postmaster = 1 if ( /^S<>$/ );
$delivery_failure = 1 if \
( /^H\?\?Subject: DELIVERY FAILURE: (User|Recipient)/ );
if ( $deferred && $from_postmaster && $delivery_failure ) {
$double_bounce = 1;
last;
}
}
close (QF_FILE);
if ($double_bounce) {
print "Removing $queue_id...\n";
system "$qtool", "-d", $qf_file;
$messages_removed++;
}
}
}
print "\n$messages_removed total \"double bounce\" message(s) removed from ";
print "mail queue.\n";
Queued mail by domain
The following Perl script will show all queued mail by domain. A message may be counted more than once if it has multiple envelope recipients from different domains.
#!/usr/bin/perl
use strict;
my $mqueue_directory = "/var/spool/mqueue";
my %occurrences;
use File::Find;
# Recursively find all files and directories in $mqueue_directory
find(\&wanted, $mqueue_directory);
sub wanted {
# Is this a qf* file?
if ( /^qf\w{14}/ ) {
open (QF_FILE, $_);
while(<QF_FILE>) {
# Lines beginning with R contain an envelope recipient
if ( /^R.*:<.*\@(.*)>$/ ) {
my $domain = lc($1);
# Add 1 to the %occurrences hash
$occurrences{$domain}++;
}
}
}
}
# Subroutine to sort hash by ascending value
sub hashValueAscendingNum {
$occurrences{$a} <=> $occurrences{$b};
}
# Print sorted results
foreach my $key (sort hashValueAscendingNum (keys(%occurrences))) {
print "$occurrences{$key} $key\n";
}
Removing mail by domain
The following Perl script will remove all mail in the mail queue addressed to domain. Messages with multiple envelope recipients to different domains will not be deleted.
#!/usr/bin/perl
use strict;
# Exit immediately if domain was not specified as command-line argument
if (!(defined($ARGV[0]))) {
(my $basename = $0) =~ s!^.*/!!;
print "Usage: $basename domain\n";
exit 1;
}
# Convert domain supplied as command-line argument to lowercase
my $domain_to_remove = lc($ARGV[0]);
my $qtool = "/usr/local/bin/qtool.pl";
my $mqueue_directory = "/var/spool/mqueue";
my $messages_removed = 0;
use File::Find;
# Recursively find all files and directories in $mqueue_directory
find(\&wanted, $mqueue_directory);
sub wanted {
# Is this a qf* file?
if ( /^qf\w{14}/ ) {
my $QF_FILE = $_;
my $envelope_recipients = 0;
my $match = 1;
open (QF_FILE, $_);
while(<QF_FILE>) {
# If any of the envelope recipients contain a domain other than
# $domain_to_remove, do not match the message
if ( /^R.*:<.*\@(.*)>$/ ) {
my $recipient_domain = lc($1);
$envelope_recipients++;
if ($recipient_domain ne $domain_to_remove) {
$match = 0;
last;
}
}
}
close (QF_FILE);
# $QF_FILE may not contain an envelope recipient at the time it is opened
# and read. Do not match $QF_FILE in that case.
if ($match == 1 && $envelope_recipients != 0) {
print "Removing $QF_FILE...\n";
system "$qtool", "-d", $QF_FILE;
$messages_removed++;
}
}
}
print "$messages_removed total message(s) removed from mail queue.\n";
Queued mail by email address
The following Perl script will show all queued mail by email address. A message may be counted more than once if it has multiple envelope recipients.
#!/usr/bin/perl
use strict;
my $mqueue_directory = "/var/spool/mqueue";
my %occurrences;
use File::Find;
# Recursively find all files and directories in $mqueue_directory
find(\&wanted, $mqueue_directory);
sub wanted {
# Is this a qf* file?
if ( /^qf\w{14}/ ) {
open (QF_FILE, $_);
while(<QF_FILE>) {
# Lines beginning with R contain an envelope recipient
if ( /^R.*:<(.*)>$/ ) {
my $domain = lc($1);
# Add 1 to the %occurrences hash
$occurrences{$domain}++;
}
}
}
}
# Subroutine to sort hash by ascending value
sub hashValueAscendingNum {
$occurrences{$a} <=> $occurrences{$b};
}
# Print sorted results
foreach my $key (sort hashValueAscendingNum (keys(%occurrences))) {
print "$occurrences{$key} $key\n";
}
Removing mail by email address
The following Perl script will remove all mail in the mail queue addressed to email_address. Messages with multiple envelope recipients will not be deleted.
#!/usr/bin/perl
use strict;
# Exit immediately if email_address was not specified as command-line argument
if (!(defined($ARGV[0]))) {
(my $basename = $0) =~ s!^.*/!!;
print "Usage: $basename email_address\n";
exit 1;
}
# Convert email address supplied as command-line argument to lowercase
my $address_to_remove = lc($ARGV[0]);
my $qtool = "/usr/local/bin/qtool.pl";
my $mqueue_directory = "/var/spool/mqueue";
my $messages_removed = 0;
use File::Find;
# Recursively find all files and directories in $mqueue_directory
find(\&wanted, $mqueue_directory);
sub wanted {
# Is this a qf* file?
if ( /^qf\w{14}/ ) {
my $QF_FILE = $_;
my $envelope_recipients = 0;
my $match = 1;
open (QF_FILE, $_);
while(<QF_FILE>) {
# If any of the envelope recipients contain an email address other than
# $address_to_remove, do not match the message
if ( /^R.*:<(.*)>$/ ) {
my $recipient_address = lc($1);
$envelope_recipients++;
if ($recipient_address ne $address_to_remove) {
$match = 0;
last;
}
}
}
close (QF_FILE);
# $QF_FILE may not contain an envelope recipient at the time it is opened
# and read. Do not match $QF_FILE in that case.
if ($match == 1 && $envelope_recipients != 0) {
print "Removing $QF_FILE...\n";
system "$qtool", "-d", $QF_FILE;
$messages_removed++;
}
}
}
print "$messages_removed total message(s) removed from mail queue.\n";
Older notes
Note: the preferred method of queue removal is to use qtool.pl as illustrated above.
In order to remove mail from the queue, you have to delete the df* and qf* files from your mail queue directory, generally /var/spool/mqueue. The qf* file is the header of the message and the control file, and the df* file is the body of the message.
script to move undeliverable email in our /var/spool/mqueue mail queue to an alternate /tmp/mqueue directory.
#!/bin/sh
if [ -z $@ ] ; then
echo "Usage: $0 email_address"
exit 1
fi
for i in `(cd /var/spool/mqueue; grep -l "To:.*$1" qf* | cut -c3-)`
do
mv /var/spool/mqueue/*$i /tmp/mqueue
done
If you have multiple mail queues, such as q1, q2, q3, q4, and q5, you can use the following script:
#!/bin/sh
if [ -z $@ ] ; then
echo "Usage: $0 email_address"
exit 1
fi
for i in q1 q2 q3 q4 q5
do
for j in `(cd /var/spool/mqueue/$i; grep -l "To:.*$1" qf* | cut -c3-)`
do
mv /var/spool/mqueue/$i/*$j /tmp/mqueue
done
done
For example, running the script while passing the command-line argument badsender@baddomain.com will look for each qf* file in the mail queue containing To:.*badsender@baddomain.com. The regular
expression .* will match zero or more occurrences of any characters, numbers, or whitespace. For example, it would match:
To: badsender@baddomain.com
To: Bad Sender <badsender@baddomain.com>
The script then moves any other files (i.e. the body of the message) in the mail queue with the same Sendmail message ID to the alternate directory. It does this with the cut -c3- command, as the Sendmail message ID is the 3rd through the last character.
The mail is moved to /tmp/mqueue. If you are confident that you do not want the messages, you can delete them from this directory, or you could change the script to remove the files.
MRTG: Install and Configure in centOS
The Multi Router Traffic Grapher MRTG is a tool to monitor the traffic load on network-links.
MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic. You need the following packages:
Requirements:
mrtg : Multi Router Traffic Grapher
net-snmp and net-snmp-utils : SNMP (Simple Network Management Protocol) is a protocol used for network management. The NET-SNMP project includes various SNMP tools. net-snmp package contains the snmpd and snmptrapd daemons, documentation, etc. Net-snmp-utils package
1:Install MRTG
Type the following command to install packages using yum command under CentOS / Fedora Linux:
# yum install mrtg net-snmp net-snmp-utils
2:Configure snmpd
If you need to monitor localhost including interface and other stuff such as CPU, memory etc, configure snmpd. Open /etc/snmp/snmpd.conf, enter:
# vi /etc/snmp/snmpd.conf
Update it as follows to only allow access from localhost:
com2sec local localhost public
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
view all included .1 80
access MyRWGroup "" any noauth exact all all none
syslocation Your_Location
syscontact Root <your@emailaddress.com>
Save and close the file.
# chkconfig snmpd on
# service snmpd restart
Make sure you see interface IP, by running the following command:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
Sample Outputs:
IP-MIB::ipAdEntIfIndex.123.xx.yy.zzz = INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
3:Configure MRTG
Use cfgmaker command to creates /etc/mrtg/mrtg.cfg file.
# cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost
--global 'WorkDir: /var/www/mrtg' : add global config entries i.e. set workdir to store MRTG graphs.
--output /etc/mrtg/mrtg.cfg: configr output filename
public@localhost: public is the community name and it is by default. Using the wrong community name you will give no response from the device. localhost is the DNS name or the IP number of an SNMP-managable device.
Finally, run indexmaker to create web pages which display the status of an array of mrtg interface status pages
# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
4: Verify Cron Job
/etc/cron.d/mrtg runs mrtg command to monitor the traffic load on network links
# cat /etc/cron.d/mrtg
Sample Output
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file
/var/lib/mrtg/mrtg.ok
# chkconfig --list crond
If it is off in run level # 3, run the following to turn on crond service:
# chkconfig crond on
# service crond on
View mrtg graphs:
You need Apache web server to view graphs:
# yum install httpd
# chkconfig httpd on
# service httpd on
Go to a web browser and type
http://your-ip.add.ress/mrtg/
Mount partitions with ntfs file system with read/write access
If the rpmforge repo is disabled by default,
# yum --enablerepo=rpmforge install fuse fuse-ntfs-3g
For CentOS 6,
# yum install ntfs-3g
if you prefer to leave EPEL disabled by default
# yum --enablerepo epel install ntfs-3g
For Additional Functionality
# yum install ntfsprogs ntfsprogs-gnomevfs
Mounting NTFS Drives
# mkdir /mnt/drv1
# mkdir /mnt/drv2
# mkdir /mnt/drv3
Mounting with Read Only Access, add the line in /etc/fstab
/dev/sda1 /mnt/drv1 ntfs-3g ro,umask=0222,defaults 0 0
Mounting with Read Write Access, add the line in /etc/fstab
/dev/sda1 /mnt/drv1 ntfs-3g ro,umask=0222,defaults 0 0
/dev/sda1 /mnt/drv2 ntfs-3g ro,umask=0222,defaults 0 0
/dev/sda1 /mnt/drv3 ntfs-3g ro,umask=0222,defaults 0 0
# mount /mnt/drv1
# mount /mnt/drv2
# mount /mnt/drv3
Thats All, Enjoy Linux
# yum --enablerepo=rpmforge install fuse fuse-ntfs-3g
For CentOS 6,
# yum install ntfs-3g
if you prefer to leave EPEL disabled by default
# yum --enablerepo epel install ntfs-3g
For Additional Functionality
# yum install ntfsprogs ntfsprogs-gnomevfs
Mounting NTFS Drives
# mkdir /mnt/drv1
# mkdir /mnt/drv2
# mkdir /mnt/drv3
Mounting with Read Only Access, add the line in /etc/fstab
/dev/sda1 /mnt/drv1 ntfs-3g ro,umask=0222,defaults 0 0
Mounting with Read Write Access, add the line in /etc/fstab
/dev/sda1 /mnt/drv1 ntfs-3g ro,umask=0222,defaults 0 0
/dev/sda1 /mnt/drv2 ntfs-3g ro,umask=0222,defaults 0 0
/dev/sda1 /mnt/drv3 ntfs-3g ro,umask=0222,defaults 0 0
# mount /mnt/drv1
# mount /mnt/drv2
# mount /mnt/drv3
Thats All, Enjoy Linux
System Information Related Commands
Show architecture of machine
# arch
Show the timetable of 2007
# cal 2007
Show information CPU info
# cat /proc/cpuinfo
Show interrupts
# cat /proc/interrupts
Verify memory use
# cat /proc/meminfo
Show file(s) swap
# cat /proc/swaps
Show version of the kernel
# cat /proc/version
Show network adpters and statistics
# cat /proc/net/dev
Show mounted file system(s)
# cat /proc/mounts
Save date changes on BIOS
# clock -w
Show system date
# date
set date and time - MonthDayhoursMinutesYear.Seconds
# date 041217002007.00
Show hardware system components - (SMBIOS / DMI)
# dmidecode -q
Displays the characteristics of a hard-disk
# hdparm -i /dev/hda
Perform test reading on a hard-disk
# hdparm -tT /dev/sda
Display PCI devices
# lspci -tv
Show USB devices
# lsusb -tv
Show architecture of machine
# uname -m
Show used kernel version
# uname -r
# arch
Show the timetable of 2007
# cal 2007
Show information CPU info
# cat /proc/cpuinfo
Show interrupts
# cat /proc/interrupts
Verify memory use
# cat /proc/meminfo
Show file(s) swap
# cat /proc/swaps
Show version of the kernel
# cat /proc/version
Show network adpters and statistics
# cat /proc/net/dev
Show mounted file system(s)
# cat /proc/mounts
Save date changes on BIOS
# clock -w
Show system date
# date
set date and time - MonthDayhoursMinutesYear.Seconds
# date 041217002007.00
Show hardware system components - (SMBIOS / DMI)
# dmidecode -q
Displays the characteristics of a hard-disk
# hdparm -i /dev/hda
Perform test reading on a hard-disk
# hdparm -tT /dev/sda
Display PCI devices
# lspci -tv
Show USB devices
# lsusb -tv
Show architecture of machine
# uname -m
Show used kernel version
# uname -r
Archiving and Backup related commands
Decompress a file called 'file1.bz2'
# bunzip2 file1.bz2
Compress a file called 'file1'
# bzip2 file1
Decompress a file called 'file1.gz'
# gunzip file1.gz
Compress a file called 'file1'
# gzip file1
Compress with maximum compression
# gzip -9 file1
Create an archive rar called 'file1.rar'
# rar a file1.rar test_file
Compress 'file1', 'file2' and 'dir1' simultaneously
# rar a file1.rar file1 file2 dir1
Decompress rar archive
# rar x file1.rar
Create a uncompressed tarball
# tar -cvf archive.tar file1
Create an archive containing 'file1', 'file2' and 'dir1'
# tar -cvf archive.tar file1 file2 dir1
Show contents of an archive
# tar -tf archive.tar
Extract a tarball
# tar -xvf archive.tar
Extract a tarball into / tmp
# tar -xvf archive.tar -C /tmp
Create a tarball compressed into bzip2
# tar -cvfj archive.tar.bz2 dir1
Decompress a compressed tar archive in bzip2
# tar -xvfj archive.tar.bz2
Create a tarball compressed into gzip
# tar -cvfz archive.tar.gz dir1
Decompress a compressed tar archive in gzip
# tar -xvfz archive.tar.gz
Decompress rar archive
# unrar x file1.rar
Decompress a zip archive
# unzip file1.zip
Create an archive compressed in zip
# zip file1.zip file1
Compress in zip several files and directories simultaneously
# zip -r file1.zip file1 file2 dir1
Hard Disk related commands in Linux
Checking Disk capacity, Partition tables, etc.
[root@server ~]# fdisk -l
Get Detailed/current information directly from hard drive
[root@server ~]# hdparm -I /dev/sda
Check available/used/free spaces in each partitions
[root@server ~]# df -h
Check Hard drive speeds
[root@server ~]# hdparm -Tt /dev/sda
To list the partition tables for the specified devices
#fdisk -l
Pass print option to displays the partition table
#parted /dev/sda print
To display all disks and storage controllers in the system
#lshw -class disk -class storage
Find Out Disks Name Only
#lshw -short -C disk
The smartctl command act as a control and monitor Utility for SMART disks under Linux and Unix like operating systems
#smartctl -d ata -a -i /dev/sda
Partition the new disk using fdisk command
#fdisk -l | grep '^Disk'
Format the new disk using mkfs.ext3 command
#mkfs.ext3 /dev/sdb1
Mount the new disk using mount command
#mkdir /disk1
#mount /dev/sdb1 /disk1
#df -H
Label the partition
#e2label /dev/sdb1 /backup
Checking the Hard Disk for errors
#fsck.file_system_type, E.g #fsck.ext3
Show list of partitions mounted
# df -h [man]
show the used space by installed deb packages, sorting by size
#dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n
Estimate space used by directory 'dir1'
#du -sh dir1
Show size of the files and directories sorted by size
#du -sk * | sort -rn
Show size of the files and directories ordered by size
#ls -lSr |more
Show space used by rpm packages installed sorted by size
# rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n
Format a floppy disk
# fdformat -n /dev/fd0
Create a filesystem type linux ext2 on hda1 partition
# mke2fs /dev/hda1
Create a filesystem type linux ext3 on hda1 partition
# mke2fs -j /dev/hda1
Create a filesystem type linux on hda1 partition
# mkfs /dev/hda1
Create a FAT32 filesystem
# mkfs -t vfat 32 -F /dev/hda1
Create a swap filesystem
# mkswap /dev/hda3
Force umount when the device is busy
# fuser -km /mnt/hda2
Mount disk called hda2 - verify existence of the directory '/ mnt/hda2'
# mount /dev/hda2 /mnt/hda2
Mount a floppy disk
# mount /dev/fd0 /mnt/floppy
Mount a cdrom / dvdrom
# mount /dev/cdrom /mnt/cdrom
Mount a cdrw / dvdrom
# mount /dev/hdc /mnt/cdrecorder
Mount a cdrw / dvdrom [man]
# mount /dev/hdb /mnt/cdrecorder
Mount a file or iso image
# mount -o loop file.iso /mnt/cdrom
Mount a Windows FAT32 file system
# mount -t vfat /dev/hda5 /mnt/hda5
Mount a usb pen-drive or flash-drive
# mount /dev/sda1 /mnt/usbdisk
Mount a windows network share
# mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share
Unmount disk called hda2 - exit from mount point '/ mnt/hda2' first
# umount /dev/hda2
Run umount without writing the file /etc/mtab - useful when the file is read-only or the hard disk is full
# umount -n /mnt/hda2
Munin Installation in CentOS
Munin is a monitoring tool for servers. It uses RRDtool to log and graph data from your servers. The plugin API is very easy to grasp. Actually, I haven’t read the API documentation yet. I just looked at the output of the plugins and it looks easy to achieve. The data can be accessed through the web.
Munin works by polling your servers for the data hence two applications, Munin and Munin Node. The former periodically gathers data (cronned) and the latter serves the data to the former. Please refer to the following for our example configuration. You can make up a domain if you want Munin to group your servers similar to the live demo.
Munin “Graph Server” – graph-server.net (10.10.10.1)
A Munin Node – munin-sample.net (100.100.100.2)
1. Installing and Configuring Munin
In this section, we set it up on graph-server.net
Add the RPMforge repository.
#rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
This step is optional if your Linux distribution has the packages in its default repositories.
Install munin.
#yum -y install munin
Change the ownership of the Munin web docroot to munin.
#chown -R munin:munin /var/www/munin
The default configuration file (in version 1.2.5-1) the value for the web docroot points to the wrong directory. Replace the value of htmldir from /var/www/html/munin to /var/www/munin at /etc/munin/munin.conf (line 7).
Restart Apache and Cron, service httpd restart && service crond restart
You can check if it’s working through your browser (i.e. http://10.10.10.1/munin/). You will get a 404 (not found) if you don’t supply a trailing slash.
2. Add a Node
In this section, we will configure munin-sample.net.
Add the RPMforge repository (see 1.1).
Install Munin Node.
#yum -y install munin-node
Configure. Edit /etc/munin/munin-node.conf with your favorite text editor.
Allow the graph server (graph-server.net/10.10.10.1) to poll the node.
allow ^192\.168\.1\.1$
If your server doesn’t report the correct hostname, add the following line
host_name munin-sample.net
If your servers have two interfaces and on the same LAN (e.g. one for Internet and another for LAN), you can configure the node to bind and listen on the local interface by changing the value of host (line 13) from * to the local IP of the node.
Start munin-node and set to start on bootup.
#service munin-node start
#chkconfig munin-node on
Edit Munin’s configuration on the graph server (/etc/munin/munin.conf).
[munin-sample.net]
address 100.100.100.2
use_node_name yes
Wait for at least 5 minutes for the new node to appear. You can also install the node on the graph server. The default node configuration will work out of the box.
3. Install/Activate Some Plugins
This section should familiarize you with the plugin installation routine. Plugins are installed in the nodes.
Apache
Create a symbolic link to the Apache plugins (stored in /usr/share/munin/plugins) in the plugin folder.
#ln -s /usr/share/munin/plugins/apache_* /etc/munin/plugins/
Enable server status reports. Add the following to Apache’s configuration file.
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
Restart Apache and the node
service httpd restart && service munin-node restart
Asterisk
Download the plugins for your Asterisk version from here.
Extract them to /usr/share/munin/plugins.
Make the files executable
#chmod 755 /usr/share/munin/plugins/asterisk_*
Configure Asterisk Manager by adding/changing the following in /etc/asterisk/manager.conf
[general]
enabled = yes
port = 5038
[munin]
secret = somepassword
permit = 127.0.0.1 ;if this doesn't work, use the local IP
write = system,call,log,verbose,command,agent,user
Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
[asterisk_*]
env.username munin
env.secret somepassword
Reload Asterisk's configuration and restart the node.
asterisk -rx reload >> /dev/null && service munin-node restart
MySQL
Create a symbolic link to the MySQL plugins (stored in /usr/share/munin/plugins) in the plugin folder.
#ln -s /usr/share/munin/plugins/mysql_* /etc/munin/plugins/
If your root user has a password (or want to use a different user), edit the plugin configuration file in /etc/munin/plugin-conf.d/munin-node and uncomment line 16 by removing the leading hash (#). Then change the parameters that will be used when mysqladmin is run.
Restart the node
#service munin-node restart
MTR
Make sure you have the latest version of MTR.
#yum -y install mtr && yum -y update mtr
Extract to /usr/share/munin/plugins
Make the file executable.
#chmod 755 /usr/share/munin/plugins/mtr100_
Create a symbolic link to the plugin (stored in /usr/share/munin/plugins) in the plugin folder. Append the host that you want to query to the link of the name.
#ln -s /usr/share/munin/plugins/mtr100_ /etc/munin/plugins/mtr100_somehost.com
To add another host to query, just create another symbolic link.
Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
[mtr100_*]
timeout 60
Restart the node
#service munin-node restart
Munin works by polling your servers for the data hence two applications, Munin and Munin Node. The former periodically gathers data (cronned) and the latter serves the data to the former. Please refer to the following for our example configuration. You can make up a domain if you want Munin to group your servers similar to the live demo.
Munin “Graph Server” – graph-server.net (10.10.10.1)
A Munin Node – munin-sample.net (100.100.100.2)
1. Installing and Configuring Munin
In this section, we set it up on graph-server.net
Add the RPMforge repository.
#rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
This step is optional if your Linux distribution has the packages in its default repositories.
Install munin.
#yum -y install munin
Change the ownership of the Munin web docroot to munin.
#chown -R munin:munin /var/www/munin
The default configuration file (in version 1.2.5-1) the value for the web docroot points to the wrong directory. Replace the value of htmldir from /var/www/html/munin to /var/www/munin at /etc/munin/munin.conf (line 7).
Restart Apache and Cron, service httpd restart && service crond restart
You can check if it’s working through your browser (i.e. http://10.10.10.1/munin/). You will get a 404 (not found) if you don’t supply a trailing slash.
2. Add a Node
In this section, we will configure munin-sample.net.
Add the RPMforge repository (see 1.1).
Install Munin Node.
#yum -y install munin-node
Configure. Edit /etc/munin/munin-node.conf with your favorite text editor.
Allow the graph server (graph-server.net/10.10.10.1) to poll the node.
allow ^192\.168\.1\.1$
If your server doesn’t report the correct hostname, add the following line
host_name munin-sample.net
If your servers have two interfaces and on the same LAN (e.g. one for Internet and another for LAN), you can configure the node to bind and listen on the local interface by changing the value of host (line 13) from * to the local IP of the node.
Start munin-node and set to start on bootup.
#service munin-node start
#chkconfig munin-node on
Edit Munin’s configuration on the graph server (/etc/munin/munin.conf).
[munin-sample.net]
address 100.100.100.2
use_node_name yes
Wait for at least 5 minutes for the new node to appear. You can also install the node on the graph server. The default node configuration will work out of the box.
3. Install/Activate Some Plugins
This section should familiarize you with the plugin installation routine. Plugins are installed in the nodes.
Apache
Create a symbolic link to the Apache plugins (stored in /usr/share/munin/plugins) in the plugin folder.
#ln -s /usr/share/munin/plugins/apache_* /etc/munin/plugins/
Enable server status reports. Add the following to Apache’s configuration file.
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
Restart Apache and the node
service httpd restart && service munin-node restart
Asterisk
Download the plugins for your Asterisk version from here.
Extract them to /usr/share/munin/plugins.
Make the files executable
#chmod 755 /usr/share/munin/plugins/asterisk_*
Configure Asterisk Manager by adding/changing the following in /etc/asterisk/manager.conf
[general]
enabled = yes
port = 5038
[munin]
secret = somepassword
permit = 127.0.0.1 ;if this doesn't work, use the local IP
write = system,call,log,verbose,command,agent,user
Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
[asterisk_*]
env.username munin
env.secret somepassword
Reload Asterisk's configuration and restart the node.
asterisk -rx reload >> /dev/null && service munin-node restart
MySQL
Create a symbolic link to the MySQL plugins (stored in /usr/share/munin/plugins) in the plugin folder.
#ln -s /usr/share/munin/plugins/mysql_* /etc/munin/plugins/
If your root user has a password (or want to use a different user), edit the plugin configuration file in /etc/munin/plugin-conf.d/munin-node and uncomment line 16 by removing the leading hash (#). Then change the parameters that will be used when mysqladmin is run.
Restart the node
#service munin-node restart
MTR
Make sure you have the latest version of MTR.
#yum -y install mtr && yum -y update mtr
Extract to /usr/share/munin/plugins
Make the file executable.
#chmod 755 /usr/share/munin/plugins/mtr100_
Create a symbolic link to the plugin (stored in /usr/share/munin/plugins) in the plugin folder. Append the host that you want to query to the link of the name.
#ln -s /usr/share/munin/plugins/mtr100_ /etc/munin/plugins/mtr100_somehost.com
To add another host to query, just create another symbolic link.
Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
[mtr100_*]
timeout 60
Restart the node
#service munin-node restart
Why Email Server in Linux are popular?
Supports POP3, IMAP and Web mail access. These are standard services that ideally should be available in any mail system for flexible email access.
Is extremely fast, reliable and scalable. Linux performs well and its uptime is very, very good.
Does not require expensive hardware. Thanks to its fast and efficient services, expensive high end hardware is not necessary.
Is very secured. The Linux operating system is very difficult to exploit. The National Security Agency even contributed to allow Linux to support even stronger levels of security.
Has a powerful anti-spam filter. SpamAssassin uses a wide variety of local and network tests to identify spam signatures.
Has an effective and regularly updated anti-virus. The open source nature of Clam Antivirus allows it to respond to new viruses even faster than commercial antivirus softwares.
Has small to zero (as in free) software cost depending on your support needs. Depending on your support needs, you have the option of using a community supported Linux or a company supported one.
Works with Microsoft Active Directory. You can integrate Microsoft Active Directory user accounts and distribution list into your Linux mail server to simplify administration.
configure: error: C++ compiler cannot create executables
SOLUTIONS:
If you are getting the following error while running configuration file
configure: error: C++ compiler cannot create executables
It means that you have not installed c++ libraries to fix that please execute the below command.
yum install *gcc-c++*
which will install gcc-c++ libraries which will fix the issue.
Mail Server Setup in details
For deploying a consistent, efficient email server, pay heeds to the following considerations
Linux Distribution
Red Hat Enterprise Linux is a Linux distribution produced by Red Hat and targeted toward the commercial market, including mainframes. Red Hat commits to supporting each version of RHEL for 7 years after its release.
CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by Red Hat.
Mail Delivery and Transfer
Postfix is an open source SMTP Server that is fast, easy to administer, flexible while at the same time being sendmail compatible enough to not upset existing users. Written by security expert Wietse Venema, it is built from the ground up to be secure.
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems. It complements Postfix with its high performance, ease of administration and rock solid security.
Web Mail Access
Apache is an open-source HTTP server supporting a wide range of operating systems including UNIX and Windows NT. Apache is a secure, efficient and extensible HTTP server that provides HTTP services in sync with the current HTTP standards.
Squirrelmail is an open source standards-based webmail package written in PHP.
Anti-Spam and Anti-Virus
MailScanner is an open source anti-virus and anti-spam filter for email servers. The anti-virus and anti-spam portion is delegated to third party applications.
ClamAV is an open source (GPL) anti-virus toolkit for UNIX, designed especially for e-mail scanning on mail gateways.
SpamAssassin is a mail filter, written in Perl, that identifies spam using a wide range of heuristic tests on mail headers and body text.
Lightweight Directory Access Protocol (LDAP)
Fedora Directory Server is an enterprise-class Open Source LDAP server for Linux. It is full-featured, supports multi-master replication, and already handles many of the largest LDAP deployments in the world.
OpenLDAP is an open source implementation of the Lightweight Directory Access Protocol.
JXplorer is a standards compliant general purpose open source ldap browser that can be used to read and search any ldap directory, or any X500 directory with an ldap interface.
Active Directory Integration
Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients.
System Administration
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more.
For more: http://linux-circles.blogspot.com/2012/07/email-server-in-details.html
Linux Distribution
Red Hat Enterprise Linux is a Linux distribution produced by Red Hat and targeted toward the commercial market, including mainframes. Red Hat commits to supporting each version of RHEL for 7 years after its release.
CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by Red Hat.
Mail Delivery and Transfer
Postfix is an open source SMTP Server that is fast, easy to administer, flexible while at the same time being sendmail compatible enough to not upset existing users. Written by security expert Wietse Venema, it is built from the ground up to be secure.
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems. It complements Postfix with its high performance, ease of administration and rock solid security.
Web Mail Access
Apache is an open-source HTTP server supporting a wide range of operating systems including UNIX and Windows NT. Apache is a secure, efficient and extensible HTTP server that provides HTTP services in sync with the current HTTP standards.
Squirrelmail is an open source standards-based webmail package written in PHP.
Anti-Spam and Anti-Virus
MailScanner is an open source anti-virus and anti-spam filter for email servers. The anti-virus and anti-spam portion is delegated to third party applications.
ClamAV is an open source (GPL) anti-virus toolkit for UNIX, designed especially for e-mail scanning on mail gateways.
SpamAssassin is a mail filter, written in Perl, that identifies spam using a wide range of heuristic tests on mail headers and body text.
Lightweight Directory Access Protocol (LDAP)
Fedora Directory Server is an enterprise-class Open Source LDAP server for Linux. It is full-featured, supports multi-master replication, and already handles many of the largest LDAP deployments in the world.
OpenLDAP is an open source implementation of the Lightweight Directory Access Protocol.
JXplorer is a standards compliant general purpose open source ldap browser that can be used to read and search any ldap directory, or any X500 directory with an ldap interface.
Active Directory Integration
Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients.
System Administration
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more.
For more: http://linux-circles.blogspot.com/2012/07/email-server-in-details.html
Subscribe to:
Posts (Atom)