Monday, December 26, 2011

Zabbix Installation on CentOS

1. Install all the necessary pieces

rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
yum --enablerepo=webtatic install ntp php php-bcmath php-gd php-mysql httpd mysql gcc
mysql-server mysql-devel net-snmp net-snmp-utils net-snmp-devel net-snmp-libs curl-devel mak
php-mbstring

2. Start the NTP Service

/etc/init.d/ntpd start

3. Download the below rpm file and install it

wget http://dag.wieers.com/rpm/packages/fping/fping-2.4-1.b2.2.el5.rf.i386.rpm
rpm -Uvh fping-2.4-1.b2.2.el5.rf.i386.rpm

chmod 7555 /usr/sbin/fping

4. Add zabbix user

useradd zabbix
5. Download zabbix and untar it.

wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/1.8.9/zabbix-1.8.9.tar.gz?r=http%3A%2F%2Fwww.zabbix.com%2Fdownload.php&ts=1324895422&use_mirror=nchc

tar -zxvf zabbix-1.8.9.tar.gz

6. Start MySQL, and change the root password.

/usr/bin/mysqladmin -u root password pdl12345

7. Connect to DB using the newly created password

mysql -u root -ppdl12345

mysql> CREATE DATABASE zabbix;

mysql> GRANT DROP,INDEX,CREATE,SELECT,INSERT,UPDATE,ALTER,DELETE ON zabbix.* TO zabbix@localhost IDENTIFIED BY ‘zabbix@123’;

mysql> quit;

8. Create the DB Schema and Install server and client with the required setting

cd zabbix-1.8.9

cat create/schema/mysql.sql | mysql -u zabbix -pzabbix@123 zabbix

cat create/data/data.sql | mysql -u zabbix -pzabbix@123 zabbix

cat create/data/images_mysql.sql | mysql -u zabbix -pzabbix@123 zabbix

./configure –enable-server –prefix=/usr/local/zabbix –with-mysql –with-net-snmp –with-libcurl

make install

Compile the agent

./configure –enable-agent –prefix=/usr/local/zabbix

make install

Add the zabbix server and agent ports to your /etc/services file.

echo ‘zabbix_agent 10050/tcp’ >> /etc/services

echo ‘zabbix_trap 10051/tcp’ >> /etc/services

Copy the sample configs to /etc/zabbix for server and agentd.

mkdir /etc/zabbix

cp misc/conf/zabbix_agentd.conf /etc/zabbix

cp misc/conf/zabbix_server.conf /etc/zabbix

in /etc/zabbix/zabbix_server.conf, modify:

DBUser=zabbix

DBPassword=zabbix@123


in /etc/zabbix/zabbix_agentd.conf, modify:

Server=127.0.0.1,yourserveripaddress

Comment Hostname Parameter

cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/zabbix_agentd
cp misc/init.d/redhat/zabbix_server_ctl /etc/init.d/zabbix_server

in /etc/init.d/zabbix_agentd AND /etc/init.d/zabbix_server:

BASEDIR=/usr/local/zabbix

in /etc/init.d/zabbix_agentd (Note the # hash marks, they are necessary), add near the top, just below #!/bin/sh:

# chkconfig: 345 95 95
# description: Zabbix Agentd

in /etc/init.d/zabbix_server (again, note the # Hash marks, they are required), add near the top, just below #!/bin/sh:

# chkconfig: 345 95 95
# description: Zabbix Server

Configure automatic starting and stopping of services.

chkconfig –level 345 zabbix_server on

chkconfig –level 345 zabbix_agentd on

chkconfig –level 345 httpd on

chkconfig –level 345 mysqld on

chkconfig –level 0123456 iptables off

/etc/init.d/iptables stop

Note: I turn the iptables firewall OFF because my box is behind a firewall. You should consult with your network folks before turning off the firewall. At the very least you should poke holes for port 80, 10050, and 10051 in the firewall.

cp -r frontends/php /var/www/html/zabbix

in /etc/php.ini, modify:

max_execution_time = 300

max_input_time = 600

memory_limit = 256M

date.timezone = Africa/Lagos

post_max_size = 32M


Now start httpd service

/etc/init.d/httpd start

chmod 777 /var/www/html/zabbix/conf

Launch http://yourserveripaddress/zabbix inyour browser
For
http://www.muck.net/wp-content/uploads/2007/10/zabbix_prereq_small.jpg

Sunday, October 16, 2011

Make Your Files Immutable Which Even Root Can't Delete

A cool tip on how you can make files on your system immutable. By immutable, I mean evenroot can't delete the files if he choose to. Linux ships with a tool called chattr which can be used for the purpose . 'chattr' is similar to the 'attrib' DOS equivalent tool but much more powerful and flexible.
To make your file (test_file) immutable
# chattr +i test_file
... You can only do it logged in as root. Here the +i option sets the immutable bit for the file. Once this bit is set, even root can't delete or tamper with the file.
If you want to unset the immutable flag, just run the following command:
# chattr -i test_file
You can check what are the attributes of a file by using the following command:
# lsattr test_file
----i-------- test_file
If the immutable flag is set, there will be an 'i' in the listing. This command is used by system administrators to restrict the users from changing a file in a particular way or even the administrator can by mistake delete a critical file because of a mis-typed command. But if the immutable flag is set, these mistakes can be avoided.

chattr can be used to set/unset many more file attributes. Like if you want to allow everybody to just append data to a file and not change already entered data, you can set the append bit as follows:
# chattr +a test_file
Now the test_file can only be opened in append mode for writing data. You can unset the append attribute as follows:
# chattr -a test_file
To know more about this very useful tool in the system administrator's forte, check the man page forchattr.

Thursday, May 26, 2011

Critical system files in Linux

In Linux, almost all configuration parameters are stored in ordinary text files. And there is a special location under which the configuration files are stored namely /etc. The following table lists all major configuration files found in Linux and their purpose.

Critical system files in Linux
File/DirectoryPermissionsDescription
/var/log/751Directory containing all log files.
/var/log/messages644System messages.
/etc/crontab600System wide crontab file.
/etc/syslog.conf640Syslog daemon configuration file.
/etc/logrotate.conf640Controls rotation of system log files.
/var/log/wtmp660Who is logged in now. Use who to view.
/var/log/lastlog640Who has logged in before. Use last to view.
/etc/ftpusers600List of users who cannot FTP to the machine.
/etc/passwd644List of system’s user accounts.
/etc/shadow600Contains encrypted account passwords.
/etc/pam.d750PAM configuration files.
/etc/hosts.allow600Access control file.
/etc/hosts.deny600Access control file.
/boot/grub/grub.conf600Boot configuration file for GRUB bootloader.
/etc/securetty600TTY interfaces that allow root logins.
/etc/shutdown.allow400Users allowed to ctrl-alt-del
/etc/security700System access security policy files.
/etc/rc.d/init.d/750Program startup files on Red Hat systems.
/etc/init.d/750Program startup files on Debian systems.
/etc/sysconfig751System and network config files on Red Hat.
/etc/ssh750Secure shell configuration files.
/etc/sysctl.conf400Contains kernel tunable options.

Tuesday, May 24, 2011

Free Up Cache Memory in Linux

In the past, I've been forced to do ridiculous things like cat a file larger than available RAM to /dev/null and edit gigabyte files which flood my cache with this data. Luckily, Linux kernels 2.6.16 and newer provide a mechanism to clear the inode, page, and dentry caches on demand avoiding all this headache. All you have to do is echo a value to the proc filesystem, and you're done.

To use /proc/sys/vm/drop_caches, just echo a number to it.

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the user should run "sync" first!

This was originally found @ http://www.linuxinsight.com/proc_sys_vm_drop_caches.html

Screen Quick Reference

http://aperiodic.net/screen/quick_reference