Monday, June 20, 2011

How to Install and Configure Cacti


Cacti is a complete frontend to RRDTool, it stores all of the necessary information to create graphs and populate them with data in a MySQL database. Required softwares to install Cacti.
You need to install the following software to install cacti.
a)      MySQL Server : Store cacti data
b)      NET-SNMP server – SNMP (Simple Network Management Protocol) is a protocol used for network management.
c)      PHP with net-snmp module – Access SNMP data using PHP.
d)     Apache / lighttpd / ngnix webserver : Web server to display graphs created with PHP and RRDTOOL.
Install the software
You can install the softwares  using yum command. Run the following:-
# 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
Configure MySQL server
Setting up root password:-
# mysqladmin -u root password NEWPASSWORD
Create cacti MySQL database
# mysql -u root -p -e ‘create database cacti’
Create a user name cacti with a password your password, then enter
Login to mysql
# mysql -u root –p
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘your password’;
mysql> FLUSH privileges;
mysql> ¥q
Intall snmpd
Type the following command to install net-snmpd
# yum install net-snmp-utils php-snmp net-snmp-libs
To configure snmpd, open the snmpd.conf configuration file.
# vi /etc/snmp/snm pd.conf
And modify the conafiguration file. As see below.
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
Save and closed the configuration file and start the snmp service. Type the following.
# /etc/init.d/snmpd start
# chkconfig snmpd on
Install cacti
Update the repository:< o:p>
# yum install cacti
Install cacti tables
Type the following command to find out cacti.sql path:
# rpm -ql cacti | grep cacti.sql
Sample output:
/usr/share/doc/cacti-0.8.7d/cacti.sql
Type the following command to install cacti tables (you need to type the cacti user password):
# mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.7d/cacti.sql
Configure cacti database string:-Open /var/www/cacti/include< br># config.php
Modify the following changes as follows:
/* make sure these values refect your actual database/host/user/password */
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cacti”;
$database_password = “your password”;
$database_port = “3306″;

Configure httpd for cacti.
Update allow from line, set to your LAN subnet to allow access to cacti:
Open /etc/httpd/conf.d/cacti.conf file
# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti/ /var/www/cacti/

DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from 172.16.0.0/16 #your network address
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
After changed start the httpd:-
# /etc/init.d/httpd  start
Setup cacti cronjob
Open /etc/cron.d/cacti file
# vi /etc/cron.d/cacti
Uncomment the line:
*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
Save and closed the file after uncomment.
Now cacti is ready, you can run the cacti type the following:-
Note:< /span> The default username and password for cacti is admin / admin.

MRTG Make sure snmp server installed


MRTG Make sure snmp server installed
Step # 1 : Make sure snmp server installed
Please note that snmpd configuration does not require using mrtg with remote network devices such as Routers and switches. If you just want mrtg graphs for router or switch then please refer to step # 4 (as all these devices comes preconfigured with snmpd software).
Run rpm commands query option to find out snmp server installed or not:
# rpm -qa | grep snmp
snmp installed then please refer step # 2; otherwise snmp server and utils were not present and your need to install them using following steps (login as a root user):
(a) Visit rpmfind.net to get snmp server and utilities rpms. If you are fedora user then use yum command as follows to install it:
# yum install net-snmp-utils net-snmp
(b) If you are RHEL s ubscriber then use up2date command as follows to install:
#up2date -v -i net-snmp-utils net-snmp
Step # 2 : Determine if snmp server is running or not
Run ‘ps’ command to see if snmp server is running or not:
# ps -aux | grep snmp
Output:
root   5512  0.0  2.3  5872 3012 pts/0    S    22:04   0:00 /usr/sbin/snmpd
Alternatively, you can try any of the following two commands as well:
# lsof -i :199
Output:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
snmpd   5512 root    4u  IPv4  34432       TCP *:smux (LISTEN)
OR try out netstat command:
# netstat -natv | grep ‘:199′
Output:
tcp        0      0 0.0.0.0:199             0.0.0.0:*        &nb sp;      LISTEN
If you found service is running or listing on port 199 then please see step #3; otherwise start service using following command:
# service snmpd start
Make sure snmpd service starts automatically, when linux comes us (add snmpd service):
# chkconfig –add snmpd
Step # 3 : Make sure snmp server configured properly
Run snmpwalk utility to request for tree of information about network entity. In simple words query snmp server for your IP address (assigned to eth0, eth1, lo etc):
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
If you can see your IP address then please proceed to step 4; else it is a time to configure snmp server as follows (by default RHEL an d RH 8/9 are not configured for snmp server for security reason):
Configure SNMP
(1) Edit file /etc/snmp/snmpd.conf using text editor:
# vi /etc/snmp/snmpd.conf
Chan ge/Modify line(s) as follows:
Find following Line:
com2sec notConfigUser  default       public
Replace with (make sure you replace 192.168.0.0/24 replace with your network IPs) following lines:
com2sec local  &nb sp;  localhost           public
com2sec mynetwork 192.168.0.0/24      public
Scroll down bit and change:
Find Lines:
group   notConfigGroup v1    & nbsp;      notConfigUser
group   notConfigGroup v2c           notConfigUser
Replace with:
group MyRWGroup v1         local
group MyR WGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
Again scroll down bit and locate following line:
Find line:
view    systemview     included      system
Re place with:
view all    included  .1                               80
Again scroll down bit and change:
Find line:
access  notConfigGroup “”      any       noauth    exact  systemview none none
Replace with:
access MyROGroup “”      any       noauth    exact  all    none   none
access MyRWGroup “”      any       noauth    exact  all    all    none
Scroll down bit and change:
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
Replace with (make sure you supply appropriate values):
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact Vivek G Gite <vivek@nixcraft.com>
For your convenient, here is my /etc/snmp/snmpd.conf file. Feel free to use this file. Make sure you make backup of your existing file if you use this file as it is.
Start your snmp server and test it:
(a) Make sure when linux comes up snmpd always starts:
# chkconfig snmpd on
(b) Make sure service start whenever Linux comes up (after reboot):
# service snmpd start
(c) Finally test your snmp server:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
Step # 4 : Install mrtg if not installed
Mrtg software may install during initial installation; you can verify if MRTG installed or not with following RPM command:
rpm -qa | grep mrtg
If mrtg already installed please see step # 5; else use rpmfind.net to find MRTG rpm or up2date command to install MRTG software:
# up2date -v - i mrtg
Fedora Linux user can use yum command as follows to install MRTG:
# yum install mrtg
cfgmaker -global ‘WorkDir: /var/www/html/mrtg’ -output /etc/mrtg/mrtg_local.cfg public@174.143.168.193
indexmaker –output=/var/www/html/mrtg/index.html  /etc/mrtg/mrtg_local.cfg
cp -av /var/www/mrtg/*.png /var/www/html/mrtg/
/usr/bin/mrtg      /etc/m rtg/mrtg_local.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg_local.cfg
Crontab
*/1 * * * *  env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg_local.cfg

Linux Convert ext3 to ext4 File system


Some time ago ext4 was released and available for Linux kernel. ext4 provides some additional benefits and perforce over ext3 file system. You can easily convert ext3 to ext4 file system. The next release of Fedora, 11, will default to the ext4 file system unless serious regressions are seen. In this quick tutorial you will learn about converting ext3 to ext4 file system.
ext4 Filesystem Features
The ext4 filesystem has more features and generally better performance than ext3, which is showing its age in the Linux filesystem world. Features include:
Delayed allocation & mballoc allocator for better on-disk allocation
* Sub-second timestamps
* Space preallocation
* Journal checksumming
* Large (>2T) file support
* Large (>16T) filesystem support
* Defragmentation support
WARNING! Once you run following commands, the filesystem will no longer be mountable using the ext3. Please note that ext4 may have some bugs so do not use for production servers (wait for sometime watch Linux kernel mailing list for ext4 bugs). It’s recommended that you keep /boot in a ext3 partition for sometime.
You need ext4 patch applied into kernel and compile kernel with ext4 support. Once done type the following command to convert an existing ext3 filesystem to use ext4, type:
# tune2fs -O extents,uninit_bg,dir_index /dev/dev-name
For example convert /dev/sdb1 to ext4, enter:
# cd /; umount /dev/sdb1
# tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
Next run fsck, enter:
# fsck -pf /dev/sdb1
How do I mount ext4 partition?
mount -t ext4 /dev/sdb1 /path
mount -t ext4 /dev/sdb1 /share
mount -t ext4 /dev/disk/by-uuid/YOUR-PARTITION-UUID /share
Use blkid to get UUID.
How do I boot from ext4 (/boot)?
If you have converted /boot file system (or / used for /boot), update /boot/grub.conf (/boot/grub/menu.lst). Open file and find out current kernel config file and append the following:
rootfstype=ext4
Here is sample config (note I’ve custom kernel names):
title  Ubuntu 8.10, kernel 2.6.28.1-vmware-guest-server
root  (hd0,1)
kernel /boot/vmlinuz-2.6.28.1-vmware-guest-server root=UUID=8c2da865-13f4-47a2-9c92-2f31738469e8 ro quiet splash rootfstype=ext4
initrd  /boot/initrd.img-2.6.28.1-vmware-guest-server
quiet
Save and close the file. And run update-grub:
$ sudo update-grub
Next, update your /etc/fstab file so that it can be mounted as ext4 file system:
UUID=41c22818-fbad-4da6-8196-c816df0b7aa8  /share ext4 defaults,errors=remount-ro,relatime 0       1
Finally, reboot the system:
$ sudo reboot

OpenERP


OpenERP follows a commercial open source business model. The development and community efforts are managed through Launchpad, using the Bazaar versioning system. The company maintains the copyright and determines what is accepted into the software code base and the direction of the software. The OpenERP community is organized on the OpenObject website, where you can find the forums, the IRC and all the available modules for OpenERP. The documentations are also managed on launchpad but a website dedicated to all books has been set up in 2009.
OpenERP is claimed to set up a business model with a win-win relationship between the community, the partner network and the editor. The partners are intended to create the market around OpenERP and the service offers, the editor is responsible for the quality and the vision on the development of the product and the community generates activities and contribute to the growth of the product.
Project-Open is a web-based ERP/Project Management application. It has
1.Project Management — Project Planing and Tracking,Resource Management,Workflow
2.IT Service Management–IT Helpdesk ,Configuration Managment
3.Timesheet Management–Work and time Accountability
4.Financial Management–Internal & External Finances ,Invoices ,Cost Record/Estimates , Financial Reporting
5.Knowledge Management & Collaboration–File Manager,Wiki,Forums
6.Human Resources–Skill Management,Absence Management,Employee Record,Surveys
7.Customer Relationship Management –Pre Sales activities,Email C om pains ,Customer Records.
I have installed Project Open on CentOS .The files downloaded from http://www.sourceforge.net/projects/project-open/files/
• aolserver-4.5-rhel5-rpms.tar (Support Files section)
• project-open-RHEL5-3.4.0.final.tgz (V3.4 section)¬¬
Login as root #groupadd projop
#mkdir /web/
#useradd -d /web/projop -g projop projop
#cd /web/projop/; tar xzf /tmp/project-open-RHEL5-3.4.0.final.tgz
#cd /web/projop/; tar xf /tmp/aolserver-4.5-rhel5-rpms.tar
#chown -R projop:projop /web/projop
Installation of AOL server , this is similar to Apache Tomcat Server. The RPMs are located by default in /web/projop/
#cd /web/projop/
#rpm -i *.rpm
In order to check that AOLserver is installed successfully execute
#/usr/local/aolserver/bin/nsd –h
Setup PostgreSql
#yum install postgresql postgresql-server postgresql-contrib postgresql-devel postgresql-docs
#/etc/init.d/postgresql start
edit the file /var/lib/pgsql/data/postgresql.conf and Change the following parameters,
• add_missing_from = on
• regex_flavor = extended
• default_with_oids = on
#/etc/init.d/postgresql restart
#su – postgres -c “createuser -s projop”
#su – projop -c “createdb -E utf8 -O projop projop”
#su – projop -c “createlang plpgsql projop”
#su – projop
#psql -f filestorage/backup/pg_dump.xxx.yyy.sql > import.log 2>&1
To check if the database dump has loaded correctly, execute:
#su – projop
#psql
#select count(*) from cc_users; (resulting in 194 users)
#\q
Other Software installation
#yum install cvs
#yum install ImageMagick
#rpm -i graphviz-2.8-1.el5.rf.i386.rpm (install GraphViz, afer downloading it from http://dag.wieers.com/rpm/packages/graphviz/
Start the Project Open
]project-open[ requires AOLserver and PostgreSQL to work properly. Once these two components are working execute the command as root:
#/usr/local/aolserver/bin/nsd -f -t /web/projop/etc/config.tcl -u projop -g projop
Notice: nssock: listening on 0.0.0.0:8000 will be seen at the terminal.
To login into Project Open , use demo system account which is given on the left panel of login screen.
To start the Server Automatically Add the following line at the end of /etc/inittab
ns1:345:respawn:/usr/local/aolserver/bin/nsd -it /web/projop/etc/config.tcl -u projop -g projop

Tripwire,Intrusion Detection System


Tripwire software can help to ensure the integrity of critical system files and directories by identifying all changes made to them. Tripwire configuration options include the ability to receive alerts via email if particular files are altered and automated integrity checking via a cron job. Using Tripwire for intrusion detection and damage assessment helps you keep track of system changes and can speed the recovery from a break-in by reducing the number of files you must restore to repair the system.
Tripwire compares files and directories against a baseline database of file locations, dates modified, and other data. It generates the baseline by taking a snapshot of specified files and directories in a known secure state. (For maximum security, Tripwire should be installed and the baseline created before the system is at risk from intrusion.) After creating the baseline database, Tripwire compares the current system to the baseline and reports any modifications, additions, or deletions.
1. Install Tripwire
Install Tripwire and customize the policy file — If not already done, install the tripwire RPM or download source fromwww.tripwire.org. Then, customize the sample configuration (/etc/tripwire/twcfg.txt) and policy (/etc/tripwire/twpol.txt) files and run the configuration script (/etc/tripwire/twinstall.sh).
*
Configuration file: /etc/tripwire/twcfg.txt
Usually it is not necessary to edit this file. The setting you may need to modify is MAILNOVIOLATIONS. By default this is set to true, which will send out an email everytime an integrity check is run. Setting MAILNOVIOLATIONS=false will cause Tripwire to only send an email if there is a violation.
*
Policy file: /etc/tripwire/twpol.txt
Most is already done, however there may be some files to check which doesn’t exist in the filesystem, uncomment them. Add your own files which should be checked.
Tripwire can email someone if a specific type of rule in the policy file is violated.
# Tripwire Binaries
(
rulename = “Tripwire Binaries”,
severity = $(SIG_HI),
emailto = martin dot zahn at akadia dot ch
)
*
Run the configuration script (/etc/tripwire/twinstall.sh).
# twinstall.sh
2. Initializing the Database
When initializing its database, Tripwire builds a collection of filesystem objects based on the rules in the policy file. This database serves as the baseline for integrity checks.
To initialize the Tripwire database, use the following command:
# tripwire –init
The The /var/lib/tripwire directory contains the Tripwire database of your system’s files (*.twd) and a report directory where Tripwire reports are stored. The Tripwire reports, named host_name-date_of_report-time_of_report.twr, detail the differences between the Tripwire database and your actual system files.
3. Run a Tripwire integrity check
When running an integrity check, Tripwire compares the current, actual filesystem objects with their properties as recorded in its database. Violations are printed to standard output and saved in a report file that can be accessed later by twprint.
An email configuration option in the policy file even allows particular email addresses to be sent notices when certain integrity violations occur.
To run an integrity check, use the following command:
# tripwire –check
4. Printing Reports
The twprint -m r command will display the contents of a Tripwire report in clear text. You must tell twprint which report file to display.
A twprint command for printing Tripwire reports looks similar to the following (all on one line):
# twprint -m r –twrfile /var/lib/tripwire/report/.twr
The -m r option in the command tells twprint to decode a Tripwire report. The –twrfile option tells twprint to use a specific Tripwire report file.
The name of the Tripwire report that you want to see includes the name of the host that Tripwire checked to generate the report, plus the creation date and time. You can review previously saved reports at any time. Simply type ls /var/lib/tripwire/report to see a list of Tripwire reports.
5. Take appropriate security measures
If monitored files have been altered inappropriately, you can either replace the originals from backups or reinstall the program.
6. Updating the Database after an Integrity Check
If you run an integrity check and Tripwire finds violations, you will first need to determine whether the violations discovered are actual security breaches or the product of authorized modifications. If you recently installed an application or edited critical system files, Tripwire will (correctly) report integrity check violations. In this case, you should update your Tripwire database so those changes are no longer reported as violations. However, if unauthorized changes are made to system files that generate integrity check violations, then you should restore the original file from a backup or reinstall the program.
To update your Tripwire database to accept the violations found in a report, you must specify the report you wish to use to update the database. When issuing the command to integrate those valid violations into your database, be sure to use the most recent report.
Type the following command (all on one line), where name is the name of the report to be used:
# tripwire –update –twrfile /var/lib/tripwire/report/.twr
Tripwire will show you the particular report using the default text editor (specified in the Tripwire configuration file on the EDITOR line). This is your chance to deselect files that you do not wish to be updated in the Tripwire database. It is important that you only allow authorized integrity violations to be changed in the database.
All proposed updates to the Tripwire database start with a [x] before the file name. If you want to specifically exclude a valid violation from being added to the Tripwire database, remove the x from the box. To accept any files with an x beside them as changes, write the file in the editor and quit the text editor. This signals to Tripwire to alter its database and not report these files as violations.
For example, the default text editor for Tripwire is vi. To write the file with vi and make the changes to the Tripwire database when updating with a specific report, type :wq in vi’s command mode and press [Enter]. You will be asked to enter your local passphrase. Then, a new database file will be written to include the valid violations.
After a new Tripwire database is written, the newly authorized integrity violations will no longer show up as warnings when the next integrity check is run.
7. Updating the Policy File
If you want to actually change the files Tripwire records in its database or modify the severity in which violations are reported, you need to edit your Tripwire policy file.
First, make whatever changes are necessary to the sample policy file (/etc/tripwire/twpol.txt). A common change to this policy file is to comment out any files that do not exist on your system so that they will not generate a file not found error in your Tripwire reports. For example, if your system does not have a /etc/smb.conf file, you can tell Tripwire not to try to look for it by commenting out its line in twpol.txt:
# /etc/smb.conf -> $(SEC_CONFIG) ;
Next, you must tell Tripwire to generate a new /etc/tripwire/tw.pol signed file and then generate an updated database file based on this policy information. Assuming /etc/tripwire/twpol.txt is the edited policy file, use this command:
# twadmin –create-polfile -S site.key /etc/tripwire/twpol.txt
You will be asked for the site passphrase. Then, the twpol.txt file will be parsed and signed.
It is important that you update the Tripwire database after creating a new /etc/tripwire/tw.pol file. The most reliable way to accomplish this is to delete your current Tripwire database and create a new database using the new policy file.
If your Tripwire database file is named /var/lib/tripwire/paragon.twd, type this command:
# rm /var/lib/tripwire/paragon.twd
Then type the command to create a new database:
# tripwire –init
A new database will be created according to the instructions in the new policy file. To make sure the database was correctly changed, run the first integrity check manually and view the contents of the resulting report. See the section called Running an Integrity Check and the section called Printing Reports for specific instructions on these points.
8. Signing the Configuration File
The text file with the configuration file changes (commonly /etc/tripwire/twcfg.txt) must be signed to replace the /etc/tripwire/tw.cfg and be used by Tripwire when it runs its integrity check. Tripwire will not recognize any configuration changes until the configuration text file is correctly signed and used to replace the /etc/tripwire/tw.pol file.
If your altered configuration text file is /etc/tripwire/twcfg.txt, type this command to sign it, replacing the current /etc/tripwire/tw.pol file:
# twadmin –create-cfgfile -S site.key /etc/tripwire/twcfg.txt
Since the configuration file does not not alter any Tripwire policies or files tracked by the application, it is not necessary to regenerate the database of monitored system files.
9. Run tripwire from cron
You can run a Tripwire integrity check daily by inserting the following commands in the script /etc/cron.daily/tripwire-check:
#!/bin/sh
HOST_NAME=`uname -n`
if [ ! -e /var/lib/tripwire/${HOST_NAME}.twd ]; then
echo “Error: Tripwire database for ${HOST_NAME} not found”
echo “Run “/etc/tripwire/twinstall.sh” and/or “tripwire –init”"
else
test -f /etc/tripwire/tw.cfg && /usr/sbin/tripwire –check
fi
10. Check if tripwire can send E-Mails
Tripwire can email someone if a specific type of rule in the policy file is violated. To configure Tripwire to do this, you first have to know the email address of the person to be contacted if a particular integrity violation occurs, plus the name of the rule you would like to monitor. Note that on large systems with multiple administrators, you can have different sets of people notified for certain violations and no one notified for minor violations.
Once you know who to notify and what to notify them about, add an emailto= line to the rule directive section of each rule. Do this by adding a comma after the severity= line and putting emailto= on the next line, followed by the email addresses to send the violation reports for that rule. Multiple emails will be sent if more than one email address is specified and they are separated by a semi-colon.
(
rulename = “Networking Programs”,
severity = $(SIG_HI),
emailto = suresh.sonu2@gmail.com
)
Sending Test Email Messages
To make sure that Tripwire’s email notification configuration can actually send email correctly, use the following command:
/usr/sbin/tripwire –test –email suresh.sonu2@gmail.com
A test email will immediately be sent to the email address by the tripwire program.