Monday, October 8, 2012

Ping IP address Batch Script with function UP/Down

A lot my friend asking me that have any tool can make their work more less rather ping each servers on their list. Here is the ping batch that i'm learning and find the web and the best part that include status showed "UP"/"DOWN".
========================================================================
1st Step ==> create basch script that called PingList.cmd
========================================
PingList.cmd batch script (used notepad than copy below script)


@ECHO OFF
COLOR 1f

:HEADER
CLS
ECHO    -------------------------------------------------------------------------------
ECHO    AUTHOR:         By Programmer (name)
ECHO    TITLE:          Ping-List
ECHO    LAST CHANGE:    04/08/2010
ECHO    VERSION:        1.002
ECHO    LINK:           (you can insert your URL link
ECHO    -------------------------------------------------------------------------------
ECHO.
PAUSE

:NOTES
REM     +The text file with your list of hostnames should be named hostlist.txt
REM     +The hostnames can be seperated by a comma or carriage return
REM     +The output file will be a text file named PingResults.txt
REM     +The output file is setup to be comma delimited for easy import to Excel
REM     +Changed output file to be csv

REM Delete the output file if it exists from a previous run.

IF EXIST "PingResults.txt" del /q PingResults.txt

REM Delete the temp file.

IF EXIST "pinglog" del /q pinglog

REM Description Header for top row in Excel

ECHO Hostname,IP from Ping,Ping Status,Data of Ping,Time of Ping > PingResults.csv

REM Pull hostnames from text file until the end of the text file list

for /f "tokens=* delims=," %%I in (Hostlist.txt) do call :sub1 %%I
goto :eof

:sub1

REM Display in the command window which hostname is being processed so we know

REM something is happening.
ECHO    %1

REM Ping the current hostname set as %1 and redirect the output to pinglog file.

ping -a -n 1 -w 500 %1 > pinglog

SET status=UNKNOWN

find /i "unknown host" < pinglog > nul
if not errorlevel 1 set status=UNKNOWN HOST

find /i "could not find host" < pinglog > nul
if not errorlevel 1 set status=HOST NOT FOUND

find /i "reply" < pinglog > nul
if not errorlevel 1 set status=UP

find /i "expired in transit" < pinglog > nul
if not errorlevel 1 set status=EXPIRED IN TRANSIT

find /i "Request timed out" < pinglog > nul
if not errorlevel 1 set status=DOWN

SET PINGIP=NO IP

REM Pull the IP address of the line that has Pinging in it and IP between []

FOR /F "tokens=1,2 delims=[]" %%A IN ('FIND "Pinging" pinglog') DO IF NOT "%%B"=="" SET PINGIP=%%B

REM Append line of gathered information including the hostname from the source.

REM No spaces so it falls into Excel easier
>> PingResults.csv echo %*,%PINGIP%,%status%,%DATE%,%TIME%

REM Delete the temp file.

IF EXIST "pinglog" del /q pinglog

goto :eof

COLOR 1a
CLS
ECHO.
ECHO    *********************************************
ECHO    *********************************************
ECHO    **                                         **
ECHO    **           PROCESS COMPLETED!            **
ECHO    **                                         **
ECHO    ** The Output Filename is PingResults.txt  **
ECHO    **                                         **
ECHO    *********************************************
ECHO    *********************************************
ECHO.
ECHO.
PAUSE


:END
exit











=========
2nd Step  ==> create Hostlist file (used notepad to create it)
=========
Hostlist File 


=============================
3rd Step ===> Execute the script PingList.cmd













Sunday, October 7, 2012

Understanding the function of FSTAB in linux



Understanding the function of  FSTAB in linux.
fstab is a file startup boot that to present when system is bootup.

Example 1 :-
 
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>      <options>           <dump>     <pass>
  proc            /proc           proc    defaults                  0       0
 /dev/sda2       /               ext3    defaults,errors=remount-ro 0       1
 /dev/sda1       /boot           ext3    defaults                   0       2
 /dev/hdc        /media/cdrom0   udf,iso9660 user,noauto            0       0
 /dev/fd0        /media/floppy0  auto    rw,user,noauto             0       0
 /dev/fileserver/share   /var/share     ext3       rw,noatime       0       0
 /dev/fileserver/backup    /var/backup      xfs        rw,noatime   0       0
 /dev/fileserver/media    /var/media      reiserfs   rw,noatime     0       0



# device name   mount point     fs-type      options                                        <dump> <pass>
 LABEL=/         /               ext4         defaults                                           1 1
/dev/sda6       swap            swap         defaults                                            0 0
none            /dev/pts        devpts       gid=5,mode=620                                      0 0
none            /proc           proc         defaults                                            0 0
none            /dev/shm        tmpfs        defaults                                            0 0
 
# Removable media
/dev/cdrom      /mnt/cdrom      udf,iso9660  noauto,owner,ro                                     0 0
 
# NTFS Windows 7 partition
/dev/sda1       /mnt/Windows    ntfs-3g      quiet,defaults,locale=en_US.utf8,umask=0,noexec     0 0
 
# Partition shared by Windows and Linux
/dev/sda7       /mnt/shared     vfat         umask=000                                           0 0
 
# mounting tmpfs
tmpfs           /mnt/tmpfschk   tmpfs        size=100m                                           0 0
 
# mounting cifs
//pingu/ashare  /store/pingu    cifs         credentials=/root/smbpass.txt                       0 0
 
# mounting NFS
pingu:/store    /store          nfs          rw                                                  0 0


***note ***note*** note *** !!!
dump-freq adjusts the archiving schedule for the partition (used by dump).

pass-num<pass> Controls the order in which fsck checks the device/partition for 
               errors at boot time. 
               The root device should be 1. Other partitions should be either ;
               2(to check after root) or
               0 (to disable checking for that partition altogether). 
**********************************************************************************


The options common to all filesystems are:
atime / noatime / relatime / strictatime (Linux-specific)
The Unix stat structure records when files are last accessed (atime), modified (mtime), and changed (ctime). One result is that atime is written every time a file is read, which has been heavily criticized for causing performance degradation and increased wear. However, atime is used by some applications and desired by some users, and thus is configurable as atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30 (9 June 2009), relatime is the default.[1]
auto / noauto
With the auto option, the device will be mounted automatically at bootup or when the mount -a command is issued. auto is the default option. If you do not want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be only mounted explicitly.
dev / nodev
Interpret/do not interpret block special devices on the filesystem.
exec / noexec
exec lets you execute binaries that are on that partition, whereas noexec does not let you do that. noexec might be useful for a partition that contains no binaries, like /var, or contains binaries you do not want to execute on your system, or that cannot even be executed on your system. Last might be the case of a Windows partition.
ro
Mount read-only.
rw
Mount the filesystem read-write. Again, using this option might alleviate confusion on the part of new Linux users who are frustrated because they cannot write to their floppies, Windows partitions, or other media.
sync / async
How the input and output to the filesystem should be done. sync means it is done synchronously. If you look at the example fstab, you will notice that this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.
suid / nosuid
Permit/Block the operation of suid, and sgid bits.
user / users / nouser
user permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless overridden. If nouser is specified, only root can mount the filesystem. If users is specified, every user in group users will be able to unmount the volume.
owner (This is Linux-specific)
Permit the owner of device to mount.
defaults
Use default settings. Default settings are defined per file system at the file system level. For ext3 file systems these can be set with the tune2fs command. The normal default for Ext3 file systems is equivalent to rw,suid,dev,exec,auto,nouser,async(no acl support). Modern Red Hat based systems set acl support as default on the root file system but not on user created Ext3 file systems. Some file systems such as XFS enable acls by default. Default file system mount attributes can be overridden in /etc/fstab.


Monday, October 1, 2012

Install PhpMyadmin on CentOS 5.8

Install PhpMyAdmin on Centos 5.8
Below are the list by manual packages

Download packages:
1)php-php-gettext-1.0.11-4.el5.remi.noarch.rpm
2)php-mcrypt-5.3.17-2.el5.remi.i386.rpm
3)libmcrypt-2.5.8-4.el5.centos.i386.rpm
4)tllib-5.1.1-9.el.i386.rpm
5)php-gd-5.3.17-2.el5.remi.i386.rpm
6)php-mbstring-5.3.17-2.el5.remi.i386.rpm
7)phpMyAdmin-3.5.2.2-1.el5.remi.1.noarch.rpm

or
yum install  --enablerepo=remi  install phpmyadmin