tag:blogger.com,1999:blog-75667959799359680482024-03-14T07:38:41.234+02:00Mad LabRNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-7566795979935968048.post-21790212365827442742013-07-19T16:26:00.000+02:002016-10-04T01:10:11.757+02:00DISK I/O - how to monitor with ZabbixIn the spirit of Zabbix and good monitoring I have decided to share a little something I have found and modified.<br />
<div>
<br /></div>
<div>
In this article I will explain and display how we can go about monitoring DISK I/O.</div>
<div>
<br />
<a name='more'></a><br /></div>
<div>
It should give you a rough idea of what your disks are doing and when it possibly could be a problem.</div>
<div>
<br /></div>
<div>
So here Goes:</div>
<div>
<br /></div>
<div>
First off I will explain a few things on the understanding of what is printed within "/proc/diskstats" for HD activity.<br />
<br />
Here is an example:<br />
<br />
cat /proc/diskstats<br />
8 0 sda 490 2002 17576 5984 66 17 220 3495 0 9435 9479<br />
<br />
I will give you a break down coupled with the explanation from the kernel iostats.txt file for what it is you are looking at:<br />
<br />
From left to right:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 1 - major number - Used for kernel/driver registration<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 2 - minor mumber - Used for kernel/driver registration but also maps position on device<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 3 - device name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 4 - reads completed successfully<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 5 - reads merged<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 6 - sectors read<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 7 - time spent reading (ms)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 8 - writes completed<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> 9 - writes merged<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>10 - sectors written<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>11 - time spent writing (ms)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>12 - I/Os currently in progress<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>13 - time spent doing I/Os (ms)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>14 - weighted time spent doing I/Os (ms)<br />
<br />
So now you asked yourself. What are all these numbers for and what could it possibly do for me. That my friend is a simple one. In most enterprise level data-centers today, it is not RAM or CPU that kills a server environment. It's DISK I/O. Waiting to write, waiting to read... Waiting... Waiting... Waiting...<br />
<br />
To begin our monitoring we add the following User Parameter into your zabbix_agentd.conf of the client/monitored server.<br />
<br />
<pre class="brush:php;">cat << STOP >> /usr/local/etc/zabbix_agentd.conf
#
#
#
### DISK I/O###
UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$4}'
UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$7}'
UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$8}'
UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$11}'
UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$12}'
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$13}'
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$6}'
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk '{print $$10}'
### DISK I/O###
STOP
</pre>
<br />
<br />
Coupled with our new user parameters, all we need is to specify a list of disks in our template name that we wish to monitor. I will paste the XML for the template below:<br />
<br />
Just copy my code from the template below. Save it as a *.xml. Import it to your Zabbix server and watch the monitoring grow<br />
Server Check IO: See at the bottom of the post, you will need to download it directly :)<br />
<br />
Once you have completed this you will need to restart the zabbix_agentd where you have added the new user parameters.<br />
<br />
If you have any questions... Feel free to drop me a note :)<br />
<br />
On a side note. You can easily clone the disk names once you have imported the template to include any other drives you may have on the system. This can simply be done by cloning an item in zabbix and changing the key value to the corresponding drive name for example: read.ms[sda] can be changed to read.ms[hda] if you have IDE drives.<br />
<br />
PS: Some credits to articles on the net I have read.... and also the beauty of LINUX "THE" MAN pages.<br />
<br />
PPS: Attached link to template - <a href="https://docs.google.com/file/d/0Bz59AvHfkM0cUnJhdnFsRHZWTGM/edit?usp=sharing">Zabbix IOSTAT Template</a></div>
RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com39tag:blogger.com,1999:blog-7566795979935968048.post-24409215316704766642013-07-17T12:39:00.000+02:002013-07-17T17:38:58.247+02:00Recent project focusesHello my few little readers,<br />
<br />
<a name='more'></a><br />
<br />
Due to my recent focus on monitoring. I have decided to continue the updates on using zabbix.<br />
For the next few posts you will find my own little zabbix scripts, custom checks and agentless checks.<br />
<br />
<br />
I will do my best to explain what does what and if I have a working template to go along with it I will upload it in the post.<br />
<br />
So keep your eyes peeled for updates.<br />
<br />
PS: feel free to ask for things you wish to have monitored. I am sure I can work something up :)<br />
RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com6tag:blogger.com,1999:blog-7566795979935968048.post-4256297021758842142013-07-15T16:37:00.001+02:002013-10-31T14:31:16.492+02:00Zabbix-Agent for Debian & RHL Linux distributions#Replace the values inside "{}" with your own settings<br />
#First we add the Monitoring server to our server host file:<br />
<pre class="brush:bash;">echo "{xxx.xxx.xxx.xxx} {your.server.tld}" >> /etc/hosts
</pre><br />
<a name='more'></a><br />
<br />
#Next we add the zabbix user and group<br />
<pre class="brush:bash;">groupadd zabbix
useradd -g zabbix zabbix
</pre><br />
#Now we need to set the firewall rules to allow zabbix access to our server:<br />
<pre class="brush:bash;">iptables -I INPUT 1 -p tcp -s {xxx.xxx.xxx.xxx} --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p tcp -s {xxx.xxx.xxx.xxx} --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p udp -s {xxx.xxx.xxx.xxx} --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p udp -s {xxx.xxx.xxx.xxx} --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT
</pre><br />
#We must set zabbix as a listed service in our system services:<br />
<pre class="brush:bash;">cat <<EOF>> /etc/services
### Zabbix Services ###
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
</pre><br />
<br />
#Create the download directory and grab the files of the net so we can install our monitoring:<br />
<pre class="brush:bash;">mkdir -p /downloads/zabbix
cd /downloads/zabbix
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz
tar zxvf zabbix-2.0.6.tar.gz
cd zabbix-2.0.6
</pre><br />
<br />
#Time to configure and install our monitoring agent from source:<br />
<pre class="brush:bash;">./configure --enable-agent --enable-static
make install
</pre><br />
<br />
#Copy the startup script to the server location:<br />
#For Debian<br />
<pre class="brush:bash;">cp /downloads/zabbix/zabbix-2.0.6/misc/init.d/debian/zabbix_agentd /etc/init.d/
</pre>#For RHL<br />
<pre class="brush:bash;">cp /downloads/zabbix/zabbix-2.0.6/misc/init.d/fedora/zabbix_agentd /etc/init.d/
</pre><br />
#Add the execute permisions:<br />
<pre class="brush:bash;">chmod +x /etc/init.d/zabbix-agentd
</pre><br />
#Then add it to our startup for the server:<br />
1<br />
2<br />
3<br />
4<br />
iptables -I INPUT 1 -p tcp -s {xxx.xxx.xxx.xxx} --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT<br />
iptables -I INPUT 1 -p tcp -s {xxx.xxx.xxx.xxx} --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT<br />
iptables -I INPUT 1 -p udp -s {xxx.xxx.xxx.xxx} --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT<br />
iptables -I INPUT 1 -p udp -s {xxx.xxx.xxx.xxx} --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT<br />
<br />
#For Debian<br />
<pre class="brush:bash;">update-rc.d zabbix-agentd defaults
</pre>#For RHL<br />
<pre class="brush:bash;">chkconfig --level 345 scriptname on
</pre><br />
#If you find that the startup script is not working for you, feel free to add the agent daemon to your rc.local, it can be done so:<br />
<pre class="brush:bash;">nano /etc/rc.local
</pre><br />
Alter the section that reads from<br />
<pre class="brush:bash;">[...]
zabbix_agentd
exit 0
[...]
</pre><br />
<br />
#Edit the following 2 files and be sure to add the monitoring server you listed in step one under the active monitoring server:<br />
<pre class="brush:bash;">nano /usr/local/etc/zabbix_agent.conf
nano /usr/local/etc/zabbix_agentd.conf
</pre><br />
#And we are ready to start our zabbix-agent:<br />
<pre class="brush:bash;">zabbix_agentd
</pre><br />
<br />
Thats all folks!RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com0tag:blogger.com,1999:blog-7566795979935968048.post-85103233559803717322013-07-12T11:43:00.001+02:002013-07-17T18:07:32.251+02:00Zabbix Server for Debian Wheezy#For this installation I used Zabbix version 2.0.6, there may be a new version released which you are more than welcome to release.<br />
<br />
<br />
<a name='more'></a><br />
<br />
<br />
#Edit the host file and make sure the hostname reflects what your building:<br />
#Replace {xxx.xxx.xxx.xxx} With your servers IP<br />
<pre class="brush:php;">[...]
127.0.0.1 localhost
{xxx.xxx.xxx.xxx} server.domain.tld server
[...]
</pre><br />
<br />
#Check your server hostname, if all is well you should see "server.domain.tld" if you run "hostname -f". #So lets check that.<br />
<pre class="brush:php;">hostname -f
echo $(hostname -f) > /etc/hostname
echo $(hostname -f) > /etc/hostname
/etc/init.d/hostname.sh start
hostname
hostname -f
</pre><br />
<br />
#Install SSH server so we can connect remotely:<br />
<pre class="brush:php;">apt-get install openssh-server
</pre><br />
<br />
#Add the damn user at the start!:<br />
<pre class="brush:php;">useradd zabbix
usermod -G adm zabbix
</pre><br />
<br />
#Lets do a full system update:<br />
<pre class="brush:php;">aptitude update
aptitude full-upgrade
</pre><br />
<br />
#My Favourites for Build Essentials and troubleshooting<br />
<pre class="brush:php;">aptitude install rkhunter binutils sudo gamin build-essential autoconf automake1.9 libtool flex bison debhelper sysstat iotop sysfsutils iptraf strace
</pre><br />
<br />
#Install Mysql + postfix:<br />
<pre class="brush:php;">aptitude install postfix postfix-doc mysql-client mysql-server openssl rkhunter binutils sudo gamin
</pre><br />
<br />
#Install Apache and modules(If you want to install less, you may--I just needed these for extra things):<br />
<pre class="brush:php;">aptitude install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libruby libapache2-mod-ruby php5-curl libcurl4-openssl-dev
</pre><br />
<br />
#Enable apache modules:<br />
<pre class="brush:php;">a2enmod suexec ssl actions include
a2enmod dav_fs dav auth_digest
</pre><br />
<br />
#Restart Apache:<br />
<pre class="brush:php;">/etc/init.d/apache2 restart
</pre><br />
<br />
#Install our dependencies for zabbix:<br />
<pre class="brush:php;">aptitude fping libsnmp-base libsnmp-dev libsnmp-perl libsnmp-python libsnmp15 libsnmp15-dbg snmp snmp-mibs-downloader snmpd snmptrapfmt openipmi libopenipmi-dev libopenipmi0
</pre><br />
<br />
#We are gonna need Java for JXE:<br />
<pre class="brush:php;">aptitude install sun-java6-jre sun-java6-plugin sun-java6-jdk
</pre><br />
<br />
#Install Jabber Library for IM notification:<br />
<pre class="brush:php;">aptitude install libiksemel-dev libiksemel-utils libiksemel3
mkdir -p /downloads/iksemel
cd /downloads/iksemel
wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
tar zxvf iksemel-1.4.tar.gz
cd iksemel-1.4/
./configure --prefix=/usr
</pre><br />
<br />
#Add the iptable rules:<br />
<pre class="brush:php;">iptables -I INPUT 1 -p tcp -s xxx.xxx.xxx.xxx --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p tcp -s xxx.xxx.xxx.xxx --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p udp -s xxx.xxx.xxx.xxx --dport 10050 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1 -p udp -s xxx.xxx.xxx.xxx --dport 10051 -m state --state NEW,ESTABLISHED -j ACCEPT
</pre><br />
<br />
#Register our services in the system service file:<br />
<pre class="brush:php;">cat <<EOF >> /etc/services
### Zabbix Services ###
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
</pre><br />
#Create downloads directory for temporary files:<br />
<pre class="brush:php;">mkdir -p /downloads/zabbix
cd /downloads/zabbix
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz
tar zxvf zabbix-2.0.6.tar.gz
cd zabbix-2.0.6
./configure --enable-java --enable-dependency-tracking --enable-server --enable-agent --enable-ipv6 --with-mysql --with-jabber=/usr --with-libcurl --with-net-snmp --with-ssh2 --with-openipmi
cp -Rvf /downloads/zabbix/zabbix-2.0.6/misc/init.d/debian/zabbix-* /etc/init.d/
chmod -Rvf 755 /etc/init.d/zabbix-*
</pre><br />
#Edit the Zabbix Server Configuration and change the following lines:<br />
<pre class="brush:php;">nano /usr/local/etc/zabbix_server.conf
[...]
[...]
</pre><br />
#Add the startup scripts for the server<br />
<pre class="brush:php;">update-rc.d zabbix-server defaults
update-rc.d zabbix-agent defaults
zabbix_server
zabbix_agentd
</pre><br />
<br />
#Create MySQL database:<br />
<pre class="brush:php;">mysql -p -e"create database zabbixdb01;"
mysql -p -e"grant all privileges on zabbixdb01.* to {USERNAME}@localhost identified by '{PASSWORD}';"
</pre><br />
<br />
#Now we import our database in the order below!:<br />
<pre class="brush:php;">cd /downloads/zabbix/zabbix-2.0.6/database/mysql
mysqldump -u root -p -d zabbixdb01 < schema.sql
mysqldump -u root -p -d zabbixdb01 < images.sql
mysqldump -u root -p -d zabbixdb01 < data.sql
</pre><br />
<br />
#Setup an SSL for our Server!<br />
<pre class="brush:php;">mkdir -p /home/zabbix/ssl/
cd /home/zabbix/ssl/
openssl genrsa -des3 -out monserver.key 4096
openssl req -new -key monserver.key -out monserver.csr -ssl.cnf
openssl x509 -req -days 3650 -in monserver.csr \
-signkey monserver.key -out monserver.crt
openssl rsa -in monserver.key -out monserver.key.insecure
mv monserver.key monserver.key.secure
mv monserver.key.insecure monserver.key
</pre><br />
<br />
#Now we add the Vhost:<br />
<pre class="brush:php;">nano /etc/apache2/sites-enabled/zabbix
[...]
<VirtualHost *:443>
ServerName your.server.tld
ServerAlias your.server.tld
DocumentRoot /home/zabbix/webui/
<Directory /home/zabbix/webui>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
SSLEngine On
SSLCertificateFile /home/zabbix/ssl/monserver.crt
SSLCertificateKeyFile /home/zabbix/ssl/monserver.key
</VirtualHost>
[...]
</pre><br />
#Next up we create the directory for our server documents:<br />
<pre class="brush:php;">mkdir -p /home/zabbix/webui/
cp -Rvf /downloads/zabbix/zabbix-2.0.6/frontends/* /home/zabbix/webui/
chown -Rvf zabbix:zabbix /home/zabbix/
</pre><br />
<br />
#Once this is complete you need to edit the zabbix configuration files.<br />
<pre class="brush:php;">nano /usr/local/etc/zabbix_server.conf
</pre><br />
<br />
<br />
#Set the agent server check to local host.<br />
<pre class="brush:php;">nano /usr/local/etc/zabbix_agent.conf
[...]
127.0.0.1
[...]
</pre><br />
#Extra measure is to set the agentd to local host as well.<br />
<pre class="brush:php;">nano /usr/local/etc/zabbix_agentd.conf
[...]
127.0.0.1
[...]
</pre><br />
#Copy the startup script to the server location:<br />
<pre class="brush:php;">cp /downloads/zabbix/zabbix-2.0.6/misc/init.d/debian/zabbix-* /etc/init.d/
</pre><br />
#Add the execute permissions:<br />
<pre class="brush:php;">chmod +x /etc/init.d/zabbix-*
</pre><br />
#Then add it to our startup for the server:<br />
<pre class="brush:php;">update-rc.d zabbix-server defaults
update-rc.d zabbix-agent defaults
</pre><br />
#If you find that the startup script is not working for you, feel free to add the agent and server daemon to your rc.local, it can be done so:<br />
<pre class="brush:php;">[...]
zabbix_server
zabbix_agentd
exit 0
[...]
</pre><br />
<br />
#Last step is to open a browser and navigate to your server:<br />
<pre class="brush:php;">http://your.server.tld/setup.php
</pre><br />
#Follow the steps provided by the setup wizard. its pretty simple but if you need help, drop me a comment and I will add another section :)<br />
######<br />
######<br />
######<br />
######<br />
######<br />
<br />
That about covers the installation for Zabbix server on Debian :)RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com0tag:blogger.com,1999:blog-7566795979935968048.post-37208147873669638342013-07-03T16:46:00.000+02:002013-07-17T18:28:20.412+02:00MyDNS for Debian WheezyThe complete MyDNS install for Debian Wheezy<br />
<br />
<a name='more'></a><br />
<br />
#Check your hostname:<br />
<pre class="brush:bash;">hostname
hostname -f
</pre><br />
#Set your hostname<br />
<pre class="brush:php;">echo HOSTNAME > /etc/hostname
echo HOSTNAME > /etc/mailname
/etc/init.d/hostname.sh start
</pre><br />
#Update the system<br />
<pre class="brush:php;">aptitude update
</pre><br />
# Always for all that is fucking holy install a base system with enough tools to troubleshoot and protect the server:<br />
<pre class="brush:php;">aptitude install rkhunter binutils sudo gamin build-essential autoconf automake1.9 libtool flex bison debhelper sysstat iotop sysfsutils fail2ban iptraf strace
</pre><br />
#Install Mysql and client<br />
<pre class="brush:php;">aptitude install mysql-client mysql-server
</pre><br />
#Install Apache and PhpMyAdmin for those who dont need to sit through a console MySQL interface<br />
<pre class="brush:php;">aptitude install apache2 apache2-mpm-prefork imagemagick mcrypt php5 php-auth php5-gd php5-imagick php5-imap php5-mcrypt php5-mysql php-pear phpmyadmin vlogger
</pre><br />
#Enable some apache modules and restart the service:<br />
<pre class="brush:php;">a2enmod suexec rewrite ssl actions include
/etc/init.d/apache2 restart
</pre><br />
#Install the mysql library for use with MAKE<br />
<pre class="brush:php;">aptitude install libmysqlclient-dev
</pre><br />
#Download the tarball for MyDNS<br />
<pre class="brush:php;">cd /tmp
wget http://sourceforge.net/projects/mydns-ng/files/mydns/1.2.8.31/mydns-1.2.8.31.tar.gz
tar xfz mydns-1.2.8.31.tar.gz
cd mydns-1.2.8.31/
</pre><br />
#Run the configure with the supplied parameter and make the source ready for your distrobution<br />
<pre class="brush:php;">./configure --without-pgsql --with-mysql-lib=/usr/lib/x86_64-linux-gnu --with-mysql-include=/usr/include/mysql --includedir=/usr/lib/x86_64-linux-gnu --with-zlib=/usr/lib/x86_64-linux-gnu
make
make install
</pre><br />
#Create a startup scritp:<br />
<pre class="brush:php;">nano /etc/init.d/mydns
</pre><br />
####################################################################################################<br />
<pre class="brush:php;">#! /bin/sh
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/mydns
NAME=mydns
DESC="DNS server"
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet \
--exec $DAEMON -- -b
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --stop --oknodo --quiet \
--exec $DAEMON
echo "."
;;
reload|force-reload)
echo -n "Reloading $DESC configuration..."
start-stop-daemon --stop --signal HUP --quiet \
--exec $DAEMON
echo "done."
;;
restart)
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --stop --quiet --oknodo \
--exec $DAEMON
sleep 1
start-stop-daemon --start --quiet \
--exec $DAEMON -- -b
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
</pre>####################################################################################################<br />
<br />
#Make sure the script runs at start:<br />
<pre class="brush:php;">chmod +x /etc/init.d/mydns
update-rc.d mydns defaults
</pre><br />
# Download and install MyDNS<br />
<pre class="brush:php;">cd /tmp
wget http://downloads.sourceforge.net/mydnsconfig/MyDNSConfig-3.0.1.tar.gz
tar xvfz MyDNSConfig-3.0.1.tar.gz
cd mydnsconfig/
</pre><br />
#Edit the MyDNS install php library file and edit the $dist variable to match your installed OS<br />
<pre class="brush:php;">nano /tmp/mydnsconfig/install/lib/install.lib.php
</pre><br />
# Continue to install MyDNS<br />
<pre class="brush:php;">cd install/
php -q install.php
</pre><br />
#Complete The steps required and your server should be installed.<br />
<br />
You can login to your machine from the following if you chose the defaults:<br />
<pre class="brush:php;">http://IP:8080
</pre>RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com2tag:blogger.com,1999:blog-7566795979935968048.post-29908141580612830262013-07-03T16:29:00.000+02:002017-01-17T09:08:32.653+02:00Troubleshooting - Mailqs<br />
Additions will be made as time goes by :)<br />
<br />
<br />
<a name='more'></a><br />
<br />
<br />
#############<br />
###Postfix###<br />
#############<br />
<br />
#Printing out the mailq to see who the fuckers are. Here are the 3 options you could possibly use:<br />
#Option 1:<br />
<pre class="brush:bash;">mailq | awk '$4 ~ /REPLACEWITHMONTH/ {print $7}' | awk '{a[$0]++}END{for(x in a){t=a[x]>1?"Mails":"Mails";print x " - "a[x],t}}' | awk '{print $3,$4,$2,$1}' | sort -n
</pre><br />
#Option 2:<br />
<br />
<pre class="brush:bash;">mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n
</pre><br />
#Option 3:<br />
<pre class="brush:bash;">mailq|grep ^[A-F0-9]|cut -c 42-80| sed 's/.*@//g'|sort |uniq -c|sort -n
</pre><br />
### Printing out the mailq to see where mail is going and who is being attacked. Here are the two options you could possibly use:<br />
#Option 1:<br />
<pre class="brush:bash;">mailq | awk '$1 ~ /\@/ {print $1}' | sed -e 's/.*@//' | awk '{a[$0]++}END{for(x in a){t=a[x]>1?"Mails":"Mails";print x " - "a[x],t}}' | awk '{print $3,$4,$2,$1}' | sort -n
</pre><br />
#Option 2:<br />
<pre class="brush:bash;">mailq | awk '$1 ~ /@/ {print}' | sed -e 's/.*@//' | uniq -c | sort -n
</pre><br />
### Searching the Queues<br />
#Mass read and Regex to find spam within all queues at this moment. Still impromptu.<br />
<pre class="brush:bash;">mailq | grep ^[A-F0-9]| cut -c 1-10 | xargs postcat -q | egrep -i --color 'SPAM|REGEX|FOO|BAR'
</pre>### Subject searches<br />
###<br />
###<br />
#Finding whats in the subject of deferred mail<br />
<pre class="brush:bash;">for i in `find /var/spool/postfix/deferred/ -type f`;do echo -n "$i ";postcat $i|egrep "^Subject";done
</pre><br />
#Finding whats in the subject of mail in the hold queue<br />
<pre class="brush:bash;">for i in `find /var/spool/postfix/hold/ -type f`;do echo -n "$i ";postcat $i|egrep "^Subject";done
</pre><br />
#Finding whats in the subject of mail in the bounce queue<br />
<pre class="brush:bash;">for i in `find /var/spool/postfix/bounce/ -type f`;do echo -n "$i ";postcat $i|egrep "^Subject";done
</pre><br />
#Finding whats in the subject of mail in the corrupt queue<br />
<pre class="brush:bash;">for i in `find /var/spool/postfix/corrupt/ -type f`;do echo -n "$i ";postcat $i|egrep "^Subject";done
</pre><br />
# Arranging subject matters to see what is on the top list of spam:<br />
<pre class="brush:bash;">for i in `find /var/spool/postfix/deferred/ -type f`;do echo -n "$i ";postcat $i|egrep "^Subject";done| awk '{$1=""; print $0}' | sort | uniq -c | sort -n
</pre><br />
###<br />
###<br />
### Subject searches<br />
<br />
#Finding which server host has connected to the mailserver and how many connections have been made<br />
<pre class="brush:bash;">awk '$6 ~ /connect/ {print $8}' /var/log/mail.log | uniq -c | sort -n
</pre><br />
<br />
#############<br />
###Postfix###<br />
#############<br />
<br />
#############<br />
###ASSP######<br />
#############<br />
<br />
ASSP<br />
#Finding which server host as connected to the server and how many connections have been made - ASSP SMTP only<br />
<pre class="brush:bash;">awk '$4 ~ /Connected/ {print $5}' /var/log/assp.log | sed -e 's/\:[0-9]*//' | awk '{a[$0]++}END{for(x in a){t=a[x]>1?"Connections":"Connections";print x " - "a[x],t}}' | awk '{print $3,$4,$2,$1}' | sort -n
</pre><br />
#############<br />
###ASSP######<br />
#############<br />
<br />
#############<br />
###Exim######<br />
#############<br />
#To Delete frozen mails<br />
<pre class="brush:bash;">exim -bp | awk '$6~"frozen" {print $3 }' | xargs exim -Mrm
</pre><br />
#This will show the number of mails for each domain<br />
<pre class="brush:bash;">exim -bp | exiqsumm | awk '{if ($1 >100)print $0 }' | sort -n
</pre><br />
#Find out spammers home directory in cpanel server:<br />
<pre class="brush:bash;">grep cwd /var/log/exim_mainlog|grep -v spool
</pre><br />
#Gives you the email who logged in<br />
<pre class="brush:bash;">exim -bp |awk '{print $3}' | sed -e '/^$/d'|while read line ; do grep $line /var/log/exim_mainlog|head -1 | sed -e 's/.*A\=dovecot\_login\://' | awk '{print $1}' | sed '/REPLACEWITHYEAR*/d' | sort -rn | uniq - c; done
</pre><br />
#Gives you the IP that logged in and how many mails they actively have in the mailq<br />
<pre class="brush:bash;">exim -bp |awk '{print $3}' | sed -e '/^$/d'|while read line ; do grep $line /var/log/exim_mainlog|head -1 | grep "dovecot_login" | awk '$8 ~ /([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4])/ {print $8}'| sed -e 's/\[//' -e 's/\].*//'; done
</pre><br />
<pre class="brush:bash;">tail -3000 /var/log/exim_mainlog |grep 'rejected RCPT' |awk '{print$4}'|awk -F\[ '{print $2} '|awk -F\] '{print $1} '|sort | uniq -c | sort -k 1 -nr | head -n 5
</pre><br />
<br />
#############<br />
###Exim######<br />
#############<br />
<div><br />
</div>RNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com2tag:blogger.com,1999:blog-7566795979935968048.post-44928665303784404182013-07-03T13:17:00.002+02:002013-07-03T16:45:32.053+02:00AboutAbout this place...<br />
<br />
What's here has probably already been done. In fact much of it comes from manuals and wiki's I stitched together into what you see now. Still as a Sysadmin we all have our ways. So here is mine. I thought I would share, I have always loved open-source and I feel knowledge should be shared on the same platform to encourage even greater creativity.<br />
<br />
What you will find is my works with Linux systems, everyday builds of servers serving a particular service if not multiple. From Vmware to BSD Jails. From hosted services to monitoring your toaster. If I have tried it I will post it. Stay tuned. I have tons of stuff to make life easier :)<br />
<br />
So sit back, have a read and if you find something useful let me know, leave a comment, hell you can <complete id="goog_1775167262">+plus it :)</complete><br />
<br />
NB*** As always!<br />
<b>I do not issue any guarantee that this will work for you!</b><br />
<br />
Thank you,<br />
RenaldoRNJudashttp://www.blogger.com/profile/04724125806804271294noreply@blogger.com0