468x60 Ads

Tuesday, November 6, 2012

How to open live-updating log in terminal


tail [options]

#tail -f [your log file]

It's updating live feed in the terminal

#tail -f /var/adm/messages
Nov  6 13:38:50 NTU-HQ-GLOBAL dhcpd: [ID 702911 local0.info] DHCPREQUEST for 50.200.0.144 (172.16.0.2) from 00:c0:89:15:10:28 via 50.200.0.1
Nov  6 13:38:50 NTU-HQ-GLOBAL dhcpd: [ID 702911 local0.info] DHCPACK on 50.200.0.144 to 00:c0:89:15:10:28 via 50.200.0.1
Nov  6 13:40:00 NTU-HQ-GLOBAL sendmail[7308]: [ID 702911 mail.crit] My unqualified host name (NTU-HQ-GLOBAL) unknown; sleeping for retry
Nov  6 13:40:00 NTU-HQ-GLOBAL sendmail[7313]: [ID 702911 mail.crit] My unqualified host name (NTU-HQ-GLOBAL) unknown; sleeping for retry


Thursday, October 4, 2012

Create new empty files using "touch" command


The touch Command

The touch command is use to create new empty files.

It’s also use to change file access and modification times
touch's syntax :

#touch [option] file_name
Using touch command can create any number of files simultaneously.

Eg:
#touchfile1.txt file2.sql file3.bat

Monday, October 1, 2012

Find command in solaris 10 (Eg:Find some content inside files under some directory)


Find some content inside files and it will gives the files that content is available:

# find /usr/local/etc/ -type f-exec grep -l "00:C0:89:14:9F:6C" {} \;
/usr/local/etc/dhcplog.txt
/usr/local/etc/subnetfiles/50.200.0.0-19-server2

/usr/local/etc/ :Location that you want to dind

Use “.” To find in current directory

Eg: # find . -type f -exec grep -l "00:C0:89:14:9F:6C"{} \;

00:C0:89:14:9F:6C: The phrase that you want to find inside the file

-type type of file:
d - Directory
f - File
l - Link

# find/usr/local/etc/ -exec grep -ls 50.200.0 {} \;
/usr/local/etc/dhcpd.conf
/usr/local/etc/dhcplog.txt
/usr/local/etc/dhcpd.conf_subnet
/usr/local/etc/subnetfiles/50.200.0.0-19-server2
#


Search some files that have not been accessed for a specific time period and removing those Files

     The following command is for removes all files in /home/bacup  direc-
     tory  named  my.bac  or *.log  that have not been accessed for a week:

# find /home/bacup  \( -namemy.bac -o -name '*.log' \) \  -atime +7 -exec rm {} \;


Find all text files in the /user/local directory using the command, the -print option is used to display the results to standard out.

# find /user/local -name "*.txt"-print
/var/sadm/pkg/SUNWmozilla/save/pspool/SUNWmozilla/reloc/sfw/lib/mozilla/chrome/installed-chrome.txt
/var/sadm/pkg/SUNWlibusb/install/thirdpartylicensereadme.txt

Find files larger than 1 Gigabyte the commaand below may be used, notice unlike Linux, (Solaris 10 does not support the M(Megabyte) or G(Gigabyte) options)
c option for bytes.

#find / -size +1000000000c –print


The -exec flag may be used to apply a command to each of the files which have been found.
 ({}) represents the name of each file found.
 (\;)end of the command.

# find /usr/local/etc/ -name "*.txt" -print -exec wc -l {} \;

Find the file named readme.txt and view the content:

#find / -name "readme.txt" -exec cat {} \;

Friday, September 28, 2012

Installing Cacti on Solaris 10 (PART-2)


Install Cacti:

You can download latest version of cacti from http://cactiusers.org/  website
 Eg: cacti-plugin-0.8.7g-PA-v2.9.tar

Unzip file and rename it to cacti.
Copy cacti folder into /htdocs directory

Eg:

Change appropriate access permissions
Setup databases for cacti:
  1. Create the MySQL database:
  1. Import the default cacti database:
  1. Optional: Create a MySQL username and password for Cacti.
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;
  1. Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";
  1. Set the appropriate permissions on cacti's directories for graph and log. You should execute these commands from inside cacti's directory to change the permissions.
  1. Add a line to your /etc/crontab file similar to: for 5 minute cron intervals
If you are going to edit crontab using command shell:(solaris 10)

bash-3.2# crontab –e
0,5,10,15,20,25,30,35,40,45,50,55 * * * *   /usr/local/php/bin/php /usr/local/apache2/htdocs/cacti/poller.php --force >/dev/null 2>&1

(for wethermap):(solaris 10)

0,5,10,15,20,25,30,35,40,45,50,55 * * * *  /usr/local/php/bin/php  /var/apache2/htdocs/cacti/plugins/weathermap/weathermap-cacti-rebuild.php



01:Go to your browser and your local host or your cacti installed matching IP 

 http://172.16.0.1/cacti
or
 http://127.0.0.1/cacti
 02: Select new install if you are installing cacti at first time:
03:If you setup and install all necessary packages that need to run Cacti in this window it will indicate all the paths in green color:
if it's indicated in red color please check the paths and correct them or check in you install all the necessary plugging and running them perfectly. 


04: Login by default username and password admin:admin:

05: It will force you to change default password for admin login:




We can use Plugin Architecture (PIA) for installing additional useful plugins with Cacti.
There are two ways of install the Plugin Architecture. The first way is by using the patch files.

A patch file contains the difference between the original files and the “new” files, which makes them very small as they only contain exactly what we need to make the changes.

The other way is by using the pre-patched full files. These files are the full install of the necessary files.

Copy the files from the “files-0.8.7g” directory to your Cacti install directory, overriding any files if you are prompted.

Edit “include/config.php” and specify the database type, name, host, user and password for your Cacti configuration.

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
 
/* load up old style plugins here */
$plugins = array();
//$plugins[] = 'thold';
 
/*
   Edit this to point to the default URL of your Cacti install
   ex: if your cacti install as at http://serverip/cacti/ this
   would be set to /cacti/
*/
$url_path = "/cacti/";
 
/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";

Installing Plugins:

You can download plugin and add them under the folder plugins and add the plugin name in include/config.php  
Eg:
$plugins = array();
$plugins[] = 'thold';
$plugins[] = 'watermark'; 
$plugins[] = 'realtime';


then you can manage plugins through cacti.


To provide access to Plugin Management go to User Management and select the user in question. The Realm Permission tab will shows like this






Finally you can install/unstill/active/inactive those plugins:





Thursday, September 27, 2012

Installing Cacti on Solaris 10 (PART-1)


Installing Cacti on Solaris 10

Install Solaris 10 sparc in sun server:

­
Software Requirements:

Required packages for solaris 10 sparc x64(according to your system) can freely download from http://unixpackages.com/ or http://sunfreeware.com/ . (it’s better download new versions.)


libiconv


freetds


libintl


libssh2


libidn


gd

openssl


jpeg


curl


openldap


expat


mysql


fontconfig


libpng


zlib


xpm


freetype


sasl    


db


libxml2


openldap


flex


autoconf


gcc


automake


libtool


bash-3

make

bison


sed


Perl


libgcc

RRDtool


libsigsegv

libxml2


m4

NET-SNMP


re2c

ncuser     


xrender  


MySQL


pango    


libart_lgpl 


PHP


cairo  


Apache 2


libart_lgpl





Installing packages:

bash-3.2#gunzip gcc-3.4.6-sol10-x86-local.tar.gz
bash-3.2#pkgadd –d gcc-3.4.6-sol10-x86-local
The following packages are available:
  1  SMCgcc     gcc
                (sparc) 3.4.6

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:all

gunzip –d  ;-d means default installation
Default installation directry is : /usr/local/



 Preparing the system—basic prerequisites

In order to install and run Cacti, we need to make sure that all Cacti system requirements are met. Here I’ll describe main requirement that want to have in OS to run Cacti.

Web server

Cacti is built as a web interface, a web server is needed. This can be Apache httpd or Microsoft's Internet Information Server (IIS) if installing on Windows, but in fact, any PHP-capable web server can be used to run the web interface. For the Solaris I prefer Apache as a web server.

Configure apache 2:

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
ServerRoot "/usr/local/apache2"

#
# If you wish httpd to run as a different user or group, you must run
#
User daemon
Group daemon
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName 172.16.26.160:80
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/apache2/htdocs"
Use your normal procedure for starting the Apache server, e.g.:
or

NET-SNMP package

The NET-SNMP package provides the SNMP binaries used by Cacti and supports SNMPv1, SNMPv2c, and SNMPv3.
The NET-SNMP package also provides the SNMP daemon for UNIX.

*Note: The snmpd.conf file for Sun's agent is in the /etc/sma/snmp/ directory. This is the one you will want to edit to suit your needs.

   --- Make sure Sun's Agent is enabled ---

bash-3.00# svcadm enable dmi
bash-3.00# svcadm enable sma

Checking snmp is working properly:


Change the content of the snmpd.conf file


MySQL database

Cacti use the freely available MySQL database engine as its database server and it is also available on Solaris. For best performance, MySQL version 5 should be used.

Installation
 Removing older versions of MySQL on Solaris
#/usr/local/mysql/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
090211 14:30:35 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090211 14:30:35 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
Filling help tables...
090211 14:30:35 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090211 14:30:35 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system /etc/init.d/

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h vmsol01 password 'new-password'
Alternatively you can run:

/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com

Support MySQL by buying support/licenses at
http://shop.mysql.com/


Check for MySQL packages installed and remove them.

# pkginfo | grepmysql

The following packages SUNWmysqlr, SUNWmysqlt, SUNWmysqlu were found and removed. 

# pkgrm SUNWmysqlr # pkgrm SUNWmysqlt # pkgrm SUNWmysqlu

1. Create mysql user and group

#groupadd mysql
#useradd -g mysqlmysql

2. Extract and install the package

#gunzip -d mysql-x.x.x-solaris10-sparc-64bit.pkg.gz
#pkgadd -dmysql-5 x.x.x -solaris10-sparc-64bit.pkg

You will be asked to create installation directory. Answer with yes to continue installation. The installation process will put the files on /opt/my   sql/mysql or /usr/local/mysql/.

3. You will need to do these commands to change file/folders permission

#chown -R mysql:mysql /usr/local/mysql/
#chmod -R 550 /usr/local/mysql/
Or:
#chown -R mysql:mysql /opt/mysql/mysql
#chown -R mysql:mysql /var/lib/mysql
#chmod -R 550 /opt/mysql/mysql

4. Coppy configuration file into required location

 bash-3.2# pwd
/usr/local/mysql/share/mysql/
bash-3.2# cp my-medium.cnf /etc/my.cnf
bash-3.2#vi /etc/my.cnf

And edit required configurations...

5. Binary files will be located in /opt/mysql/mysql/bin after installation. Install mysql database with this command

#/opt/mysql/mysql/bin/mysql_install_db
or:
##/usr/local/mysql/bin/mysql_install_db


6.  Usually, we start the server with this command

#/opt/mysql/mysql/bin/mysqld_safe –user=mysql &

or
#/usr/local/mysql/bin/mysqld_safe –user=mysql &

or try
#/usr/local/mysql/bin/mysql –user=mysql &
or
#/usr/local/mysql/bin/mysqld –user=mysql&

But, MySQL 5.1.33 has a bug on this. Here the bug is: Installation process put data files on /var/lib/mysql, while default mysqld_safe command will look forward to /opt/mysql/mysql/data/. We can fix this by adding –datadir option. To start the server, the complete command will be like this

#/opt/mysql/mysql/bin/mysqld_safe –user=mysql –datadir=/var/lib/mysql &
Or
#/usr/local/mysql/bin/mysqld_safe–user=mysql –datadir=/var/lib/mysql &


7. Don’t forget to create mysql root password

#/opt/mysql/mysql/bin/mysqladmin -u root password ‘your new password’


Or

#usr/local/mysql/bin/mysqladmin-u root password ‘your new password’

#mysqladmin -u root -h 'hostname' password 'new-password'


Next command is optional



PHP

Cacti is built with the PHP programming language and therefore needs PHP to be installed on the system. Most UNIX distributions already have a base PHP environment installed, but we  might need additional packages for Cacti to function properly. (LDAP, SNMP, and MySQL extensions should be installed)

1. Stop apache server:


2. Setup your php.ini

bash-3.2#cp /usr/local/php/doc/php/php.ini-development /usr/local/lib/php.ini
You may edit your .ini file to set PHP options. If you prefer having php.ini in another location, use --with-config-file-path=/some/path in step

3. Edit your httpd.conf to load the PHP module. (Mention only edited points)

# LoadModule foo_module modules/mod_foo.so
#
LoadModule php5_module  modules/libphp5.so
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
    DirectoryIndex index.html index.php


    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi
    AddHandler php5-script   .php
    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    AddType text/html   .php
    #AddOutputFilter INCLUDES .shtml


4. Start apache server:


5. Checking php is working properly.

Copy index.php into htdocs folder with proper access permissions and open your browse http://172.16.26.15/index.php

index.php…



 <html> 

<head> 
        <title>PHP Test</title> 
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
</head> 
<body> 
        <h1>PHP Test</h1> 
        <p> 
        <b>An Example of PHP in Action</b><br />
                <?php echo "The Current Date and Time is: <br>"
                        echo date("g:i A l, F j Y.");?> 
        </p> 
        <h2>PHP Information</h2> 
        <p> 
                <?php phpinfo(); ?> 
        </p> 
</body> 
</html> 



Installing Cacti on Solaris 10 (PART-1)