Skip to content

Blog

Installing Cacti on Scientific Linux 6.4

Cacti is a network graphic monitoring tools which used the potential of RRDTool. RRDTool is a data logging and graphing system for time series data. Cacti can show us a real time performance of network or servers which make this software become one of the most popular open source monitoring software. Cacti Logo

Getting Started

Always update your box before we install new software.

# yum update

Install dependencies for cacti.

# yum install mysql-server mysql php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-pear-Net-SMTP php-mysql httpd

Then create database for cacti.

# mysql -uroot -p
mysql> create database cacti;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'password';
mysql> flush privileges;
mysql> quit

Install SNMPD

Install net-snmpd.

# yum install net-snmp-utils php-snmp net-snmp-libs

Edit net-snmpd config file snmpd.conf.

# vi /etc/snmp/snmpd.conf

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 Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat

Start snmpd.

# /etc/init.d/snmpd start
# chkconfig snmpd on

Install Cacti

Install cacti from EPEL Repository.

# yum --enablrepo=epel install cacti

Import cacti database.

# mysql -ucacti -p cacti < /usr/share/doc/cacti-*version*/cacti.sql

Then edit cacti configuration file db.php

# vi /etc/cacti/db.php

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "password";
$database_port = "3306";

Configure cacti httpd configuration to allow cacti in your network.

# vi /etc/httpd/conf.d/cacti.conf

 Allow from 192.168.45.0/24

Restart httpd.

# service httpd restart

Uncomment cacti cronjob in cron directory.

# vi /etc/cron.d/cacti

*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Then, run cacti installer by opening your cacti URL in web browser.

http://yourdomain/cacti

Follow the instruction and wait several moment while cacti gather the data from log files. Log in to cacti and check your graph.

Reference

http://www.cyberciti.biz/faq/fedora-rhel-install-cacti-monitoring-rrd-software/

Installing Icinga on Scientific Linux 6.4

Icinga is a well-known server or network monitoring that runs in many Unix/Linux distribution. Server/Network monitoring is an essential part of Network Operations Center because by monitoring network engineers can always get the feedback and status from network and production servers. This is a simple documentation of Icinga installation in Scientific Linux 6.4 server.

Getting started

Before we install icinga, it best to keep our system updated.

# yum update

Search icinga package using yum search in RPMForge repository.

# yum --enablerepo=rpmforge search icinga
Loaded plugins: priorities, refresh-packagekit, security
=============================== N/S Matched: icinga ==============================
icinga-api.x86_64 : PHP api for icinga
icinga-devel.x86_64 : Provides include files that Icinga-related applications may compile against
icinga-doc.x86_64 : documentation icinga
icinga-gui.x86_64 : Web content for icinga
icinga-idoutils.x86_64 : database broker module for icinga
icinga-idoutils-libdbi-mysql.x86_64 : database broker module for icinga
icinga-idoutils-libdbi-pgsql.x86_64 : database broker module for icinga
icinga-web-module-pnp.noarch : PNP Integration module for Icinga Web
icinga.x86_64 : Open Source host, service and network monitoring program
icinga-web.noarch : Open Source host, service and network monitoring Web UI
nagios-plugins.x86_64 : Host/service/network monitoring program plugins for Nagios/Icinga
nagios-plugins-setuid.x86_64 : Host/service/network monitoring program plugins for Nagios/Icinga requiring setuid
Name and summary matches only, use "search all" for everything.

Install icinga and the dependencies.

# yum --enablerepo=rpmforge install icinga icinga-gui icinga-doc icinga-idoutils-libdbi-mysql
# yum install mysql-server mysql-client libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql

Create database for icinga.

# mysql -uroot -p
mysql> CREATE DATABASE icinga;
mysql> GRANT USAGE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

After we create database for icinga, import the database template to icinga database.

# mysql -uicinga -p icinga < /usr/share/doc/icinga-idoutils-libdbi-mysql-1.8.4/db/mysql/mysql.sql

Don't forget to disable Selinux if you do not use it. Insert database credential into file ido2db.cfg.

# vi /etc/icinga/ido2db.cfg

db_name=icinga
db_user=icinga
db_pass=icinga

Now we can start icinga and don't forget to start ido2db too.

# /etc/rc.d/init.d/ido2db start
# /etc/rc.d/init.d/icinga start
# /etc/rc.d/init.d/httpd restart
# chkconfig ido2db on
# chkconfig icinga on

Add icinga user or update password of existing one using command below.

# htpasswd /etc/icinga/passwd youradmin

Testing Icinga

We can now access icinga via this URL on browser.

http://yourdomain/icinga

Review the status and fix errors if any. Now you have your own icinga up and running. Congrats!

Installing BIND DNS Server on CentOS 6.5

When we rent a VPS, we will get a public IP address so we can access our VPS from anywhere in this world. But, sometimes we want a better way to access our VPS using Domain Name. We will have to rent a domain name from a Domain Name Registrar and then set up our Name server so that our domain name refer to our IP address. There is usually an easier way by using our registrar control panel to set up NS records. But, if you still want to set up your own Name server, I hope this documentation will be useful for you.

BIND Name Server

BIND or Berkeley Internet Domain Name is open source software that implements the Domain Name System protocols. This is a documentation of installing BIND on CentOS 6.5 operating system.

Getting Started

Before we install BIND, or another software, always upgrade our system first.

# yum update

Install BIND using yum.

# yum install bind bind-utils

Use this if you don't use IPv6.

# echo 'OPTIONS = "4"' >> /etc/sysconfig/named

Edit file named.conf.

# vi /etc/named.conf

options {
   listen-on-v6 port 53 { none; };
   directory       "/var/named";
   dump-file       "/var/named/data/cache_dump.db";
   statistics-file "/var/named/data/named_stats.txt";
   memstatistics-file "/var/named/data/named_mem_stats.txt";
   allow-query     { any; };
   allow-transfer  { localhost; };
   recursion no;

   dnssec-enable yes;
   dnssec-validation yes;
   dnssec-lookaside auto;

   /* Path to ISC DLV key */
   bindkeys-file "/etc/named.iscdlv.key";

   managed-keys-directory "/var/named/dynamic";
};

logging {
   channel default_debug {
           file "data/named.run";
           severity dynamic;
   };
};

zone "." IN {
   type hint;
   file "named.ca";
};

zone "server.net" {
   type master;
   file "/etc/server.net.hosts";
   allow-update { none; };
};

zone "45.168.192.in-addr.arpa" IN {
   type master;
   file "/etc/45.168.192.db";
   allow-update { none; };
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

Configure zone server.net.hosts.

# vi /etc/server.net.hosts

$TTL 86400
@       IN      SOA     ns1.server.net. server.server.net. (
                2014011807      ;serial, todays date + todays serial
                28800           ;refresh, seconds
                7200            ;retry, seconds
                604800          ;expire, seconds
                86400           ;minimum, seconds;
)
server.net.   NS      ns1.server.net.
server.net.   NS      ns2.server.net.
ns1             A       192.168.45.32
ns2             A       192.168.45.32
server          A       192.168.45.32
mail            A       192.168.45.32
server.net.     A       192.168.45.32
                MX 10   mail.server.net.
www             A       192.168.45.32

Configure reverse 45.168.192.db.

# vi /etc/45.168.192.db

$TTL 86400
@       IN      SOA     ns1.server.net. server.server.net. (
             2014011807      ;serial, todays date + todays serial #
             28800           ;refresh, seconds
             7200            ;retry, seconds
             604800          ;expire, seconds
             86400           ;minimum, seconds;
)
45.168.192.in-addr.arpa.        IN      NS      ns1.server.net.
45.168.192.in-addr.arpa.        IN      NS      ns2.server.net.
32                              IN      PTR     deuterion.net.

Start BIND.

# service named start
# chkconfig named on

For PTR record, if you are having difficulties to set the PTR record in your NS server (the IP still does not point to your domain name), ask your registrar to configure it for you.

Testing NS Server

Change your DNS resolver to your NS server.

# vi /etc/resolv.conf

nameserver 192.168.45.32

Try to resolve domain names and IP address.

# dig server.net

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @192.168.45.32 server.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35404
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;server.net.                 IN      A

;; ANSWER SECTION:
server.net.          86400   IN      A       192.168.45.32

;; AUTHORITY SECTION:
server.net.          86400   IN      NS      ns2.server.net.
server.net.          86400   IN      NS      ns1.server.net.

;; ADDITIONAL SECTION:
ns1.server.net.      86400   IN      A       192.168.45.32
ns2.server.net.      86400   IN      A       192.168.45.32

;; Query time: 0 msec
;; SERVER: 192.168.45.32#53(192.168.45.32)
;; WHEN: Sun Feb  9 21:10:38 2014
;; MSG SIZE  rcvd: 115

# dig -x 192.168.45.32

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @192.168.45.32 -x 192.168.45.32
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50675
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;32.45.168.192.in-addr.arpa.   IN      PTR

;; ANSWER SECTION:
32.45.168.192.in-addr.arpa. 86400 IN   PTR     server.net.

;; AUTHORITY SECTION:
45.168.192.in-addr.arpa. 86400  IN      NS      ns1.server.net.
45.168.192.in-addr.arpa. 86400  IN      NS      ns2.server.net.

;; ADDITIONAL SECTION:
ns1.server.net.      86400   IN      A       192.168.45.32
ns2.server.net.      86400   IN      A       192.168.45.32

;; Query time: 0 msec
;; SERVER: 192.168.45.32#53(192.168.45.32)
;; WHEN: Sun Feb  9 21:13:23 2014
;; MSG SIZE  rcvd: 140

That's all, we have a working NS server.

Installing Postfix and Dovecot on CentOS 6.5

Hello, I want to share a documentation how to setup a mail server using CentOS 6.5 using Postfix as SMTP server and Dovecot as IMAP/POP3 server. Postfix is a well known Message Transfer Agent that mostly used today and Dovecot is also one of the widely used Mail User Agent.

Preparing The Machine

In this documentation we use a CentOS 6.5 server and before we start, let's update the system.

# yum update

A mail server needs to have a MX record in its DNS, so make sure we have that. It is also a good thing to set the PTR record pointing to our domain too.

# dig server.net -t ANY
;; ANSWER SECTION:
server.net.          86312   IN      MX      10 mail.server.net.
server.net.          86306   IN      A       192.168.45.32
server.net.          80528   IN      NS      ns2.server.net.
server.net.          80528   IN      NS      ns1.server.net.

Installing Postfix

Postfix Logo

Then install Postfix using yum if it's not already installed.

# yum install postfix

Edit Postfix configuration file main.cf,

# vi /etc/postfix/main.cf

This is a standard configuration,

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.server.net
myorigin = $mydomain
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
smtpd_banner = $myhostname ESMTP
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

# SASL configuration
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions =
    permit_mynetworks,
    reject_unknown_client,
    permit
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_auth_destination,
    permit_sasl_authenticated,
    reject

# TLS configuration
smtpd_use_tls = yes
smtpd_tls_key_file = /etc/pki/tls/private/ssl.key
smtpd_tls_cert_file = /etc/pki/tls/cert/ssl.crt
smtpd_tls_loglevel = 3
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

Restart Postfix,

# service postfix restart

Installing Dovecot

Dovecot Logo

Install Dovecot using yum,

# yum install dovecot

Edit Dovecot configuration file dovecot.conf,

# vi /etc/dovecot/dovecot.conf

protocols = imap pop3
listen = *
dict {
}
!include conf.d/*.conf

Edit 10-auth.conf,

# vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no
auth_mechanisms = plain login
!include auth-system.conf.ext

Edit 10-mail.conf,

# vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir
mbox_write_locks = fcntl

Edit 10-master.conf,

# vi /etc/dovecot/conf.d/10-master.conf

service imap-login {
  inet_listener imap {
  }
  inet_listener imaps {
  }
}
service pop3-login {
  inet_listener pop3 {
  }
  inet_listener pop3s {
  }
}
service lmtp {
  unix_listener lmtp {
  }
}
service imap {
}
service pop3 {
}
service auth {
  unix_listener auth-userdb {
  }
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}
service auth-worker {
}
service dict {
  unix_listener dict {
  }
}

Edit 10-ssl.conf,

# vi /etc/dovecot/conf.d/10-ssl.conf

ssl = yes
ssl_cert = </etc/pki/tls/cert/ssl.crt
ssl_key = </etc/pki/tls/private/ssl.key

Start Dovecot,

# service dovecot start
# chkconfig dovecot on

Testing Installation

Test your Postfix installation by sending a message using our newly installed server. Use telnet on your mail server on port 25.

$ telnet mail.server.net 25
Trying 192.168.45.32...
Connected to mail.server.net.
Escape character is '^]'.
220 mail.server.net ESMTP
EHLO mail.server.net
250-mail.server.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: <admin@server.net>
250 2.1.0 Ok
RCPT TO: <user@gmail.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
From: Administrator <admin@server.net>
To: User <user@gmail.com>
Subject: Test Mail Server
Test Mail Server
.
250 2.0.0 Ok: queued as 54549110F

Check your Gmail inbox to see if the message sent successfully. Then check Dovecot using telnet on your mail server on port 143.

$ telnet mail.server.net 143
Trying 192.168.45.32...
Connected to mail.server.net.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
aa login user password
aa OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
ab select INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded \*)] Flags permitted.
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1390092598] UIDs valid
* OK [UIDNEXT 7] Predicted next UID
* OK [HIGHESTMODSEQ 1] Highest
ab OK [READ-WRITE] Select completed.
ac logout
* BYE Logging out
ac OK Logout completed.
Connection closed by foreign host.

Congratulation! Now you have a working SMTP and IMAP/POP3 server! :D

Installing Nginx on CentOS 6.5

CentOS community now works together with Redhat alongside Fedora. It's good news. So, we can hope to get a better software and support for next release of our beloved CentOS. As one of Linux (CentOS) fan, I want to share my experience installing nginx (engine-x) in CentOS 6.5. My VPS was installed as minimal server and then I added new packages, such as "Development tools" group and new repos (EPEL, CentALT).

nginx logo in CentOS 6.5

First thing that I usually do before doing something is researching, usually. So, before I install nginx, I searched for tutorials and I found one in http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-ubuntu-11.10. But, it is for Ubuntu and with MySQL which we not really need, yet. It is okay, because this is the fun part. We get to find the right configuration for our Linux distros.

The easiest way to install a package in CentOS (or every Linux distro) is using package manager, like yum. So, I searched http://pkgs.org to find any nginx package for CentOS and I found the latest stable nginx in CentALT repository.

# yum --enablerepo=CentALT install nginx-stable
# /etc/rc.d/init.d/nginx start

Open a browser and open our web server. Voila!

running-nginx

We got a running nginx on CentOS. But, it is not everything yet. Now, we will make our nginx run PHP so we install php-fpm, a FastCGI Process Manager.

# yum install php-fpm
# /etc/rc.d/init.d/php-fpm start

The **php-fpm** daemon will start at localhost on port 9000. The nginx configuration is easy to understand and available at http://wiki.codemongers.com/NginxFullExample and http://wiki.codemongers.com/NginxFullExample2. Then, to make nginx can execute PHP files, we need to make some changes in nginx configuration file /etc/nginx/nginx.conf

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
 root           html;
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
 fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include        fastcgi_params;
}

Reload nginx.

# /etc/rc.d/init.d/nginx reload

To test if the FastCGI server works, create the following PHP file in document root.

<?php
 phpinfo();
?>

Save file as info.php and call that file in a browser.

running-php

If it's showing the PHP information, our installation is running nicely.

Final Project

I have reached the eight semester in my undergraduate study and it means this semester I have to finish a final project (Tugas Akhir, ID) as a requirement to graduate. Actually I don't really into my final project's topic. There are many factors behind it. In the new curriculum, my department decide to give a final project to a team consist of two students. This is a good news because the possibility of student who will graduate is increased. But, this is somewhat a setback for me. I don't usually work in a team and for my final project I want to do a final project which is a original, only for me, my own final project. The requirement that a final project must be done by a team makes me don't feel that this is really my own final project.

I often consider myself as a "lone wolf" and my skills and interests differ far from those in my department. For example, when most of students in my department have interest in control and instrumentation engineering or building engineering, my interest is in computation and materials engineering. Fortunately, I still like to get along well with my friends and I still can consider myself as an "activist" in my campus although my skills make me more suitable as nerd, and yes, I am starting to think that I am more nerd right now.

My department?

My department is Engineering Physics, a cool name, isn't it? But, I still don't know for clear what is the goal and the purpose of my own department. Some say that the core of my department is control and instrumentation engineering or building engineering. Some say that the core of my department is to measure or in instrumentation. Actually those definitions is a total demotivation because I think I do not fall into group of people who think like that.

But, I got some enlightenment this morning from one of my teacher. His opinion in my department makes me understand what role my department holds and my skill is not a waste in my department. They talk about control, instrumentation, or anything but the real thing is beyond that. We exist because world needs some guys who can control the physics phenomenons so people from other departments can use the phenomenons in their field effectively and in the process of controlling those phenomenons there is an act of measuring, instrumentation. Moreover, my department also involved in designing the whole system, we exist in every part in the system which interact with physical world.

Say some people from materials engineering want to process a material into something. For that purpose they need a spesific environment (temperature, pressure, etc.) or specific material. Who is responsible in creating such environment or preparing those specific (or special) material? Us. Say people from mining engineering want to explore new resources using ground signal sensor. Who is responsible in providing the sensor which suits the needs of people in mining engineering? Us. We are responsible, because if it's not us, who else will?

My lab?

My lab is Computational Materials Design, you hear the name. Maybe you think that this lab is suitable for me, isn't. Not really, I still do not really into this. I don't know why, this lab is my dream. But, maybe this is because the setbacks from my final project earlier. This lab is more research than engineering, actually. Here we calculate to define the properties of material we set in specific configuration and because of that this lab is somehow not really get along with the purpose of my department. Although my department needs this lab.

This lab's work is to compute and for that it needs computer, a lot of computers, with high performance. But, for this small lab, only a few of HPC (High Performance Computer) available, and sadly, not configured optimally. I am just newbie here so I still don't really know how this lab works and what will I really do. But I can say that the people in this lab is amazing. Their works are amazing too. They often go to abroad to attend international conference or something and get a chance to meet people from abroad. They often get offering to continue their study in Japan, Europe, or USA.

But still, it is really hard to start working. As the last person who enter this lab for this period, I often wonder how can I close the gap in knowledge and skill between mine and people who enters first. Moreover, I already have a job, and a hobby, in network engineering and administration. Although that boost my potential in computation field, it's no use if I don't know the theory and I do not like to be left behind. So, rather than struggling to study, I prefer to find a new field. So, my job now become my fall back, when I feel not motivated to study the theory. Honestly, this is what I feel now.

Now, what?

I don't know. Tomorrow I have to give a presentation on my final project's progress, when there is still no progress at all. This is only me anyway, I am the lazy one. Or maybe tonight I will try something new, trying to fing my dying motivation and revive it again. I think this is some kind of curse because I often compare myself with people around me and think low of myself.

But, someday I also want to say out loud that I am proud of what I really am. Not what people think of I am.