Tikejhya: Ashish Nepal

Knowledgebase

Month: July 2011

Search text string (VI)

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

grep -r “string_to_search” /path/to/search

NSLookup (Mx Record)

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

[user@myhost ~]$ nslookup www.ashishnepal.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name: www.ashishnepal.com
Address: 8.8.8.8

[user@myhost ~]$ nslookup
> set type=mx
> ashishnepal.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
ashishnepal.com mail exchanger = 40 ashishnepal.com
Authoritative answers can be found from:
ashishnepal.com nameserver = ns1.ashishnepal.com.

Nagios In Linux Machine (CentOS)

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

yum install httpd gcc glibc glibc-common gd gd-devel php

Create Nagios User account and group
useradd -m nagios

Create nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Create Directory to store Nagios installation files
mkdir /opt/Nagios
Download Nagios and Plugins

Save file to directory /opt/Nagios
http://www.nagios.org/download/download.php

Extract Files:
cd /opt/Nagios

tar xzf nagios-Currentversion.gz

cd nagios-Currentversion.gz

Compile and Configure Nagios
./configure –with-command-group=nagcmd
Compile Nagios:
make all
Compile binaries, init script, sample config files:

make install
make install-init
make install-config
make install-commandmode

** Do Not Start Nagios **
Nagios has now been installed to the directory /usr/local/nagios/
Install Nagios Web Interface:
make install-webconf
Nagios Web Interface installed to /usr/local/nagios/share ( http conf file added to /etc/httpd/conf.d/nagios.conf )

Create Web Interface Login User:
** This is not the most secure method **
We will create user “nagiosadmin” ( remember the password you assign !)

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache:
service httpd restart
Install Nagios Plugins

Extract Files:
cd /opt/Nagios
tar xzf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins1.4.13
Compile and Configure Nagios Plugins
./configure –with-nagios-user=nagios –with-nagios-group=nagios

make
make install
Configure nagiosadmin email address for alerts
vi /usr/local/nagios/etc/objects/contacts.cfg

email support@a2co.com;
Verify the sample Nagios configuration files
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0
Total Errors: 0
Start Nagios

Enable Nagios to start at system startup / boot
chkconfig –add nagios
chkconfig nagios on
chkconfig httpd on
Start Nagios
service nagios start

Log into Web Interface
http://ip-address/nagios/

Remote File transfer (Remote to Local)

rsync -zarve “ssh -p 21736” root@69.53.222.4:/root/.ssh/* /root/.ssh

structure: [option] port source destination

Chattr (change file attributes)

# chattr +i file.txt

Change file attributes. , but with different options and a different invocation syntax, and it works only on ext2/ext3 filesystems.

This file attribute can be set or removed only by root.

Rsync File transfer (Without Rsync Daemon)

rsync -rave -p “ssh -i /local/dir/ -l user“ local/dir remote server:/path/to/dest

This can be done without installing Rsync Daemon , which is available with default Centos.

Dump mysql into remote machine

$ mysqldump -u username -p’password’ db-name | ssh user@host mysql -u username -p’password db-name

SCP from localhost to remote server

scp -P [here goes port number] -r [recursive ] /home/tikejhya/public_html/db.php root@24.249.254.132:/home/tikejhya/yopohota/

PHP – Time stamp (weekly time stamp)

Powered by WordPress & Theme by Anders Norén