Tuesday, April 24, 2012

ZABBIX installation on Linux (CentOS 6.2 or RedHat 6.2)

Install Zabbix Server + CentOS 6.2 (64 bit)



[root@imonitor-lr ~]# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
Retrieving http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
warning: /var/tmp/rpm-tmp.tFsRI4: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@imonitor-lr ~]#



- FROM EPEL Repos
# yum --enablerepo=epel -y install zabbix-server-mysql zabbix-agent zabbix-web-mysql

**** Do update  /etc/my.cnf
innodb_file_per_table=1

Reason
[InnoDB tables currently store data and indexes into a shared tablespace (/var/lib/mysql/ibdata1). Due to the shared tablespace, data corruption for one InnoDB table can result in MySQL failing to start up on the entire machine. Repairing InnoDB corruption can be extremely difficult to perform and can result in data loss for tables that were not corrupted originally during that repair process. 

Since MySQL 5.5 will be using InnoDB as the default storage engine, it is important to consider the consequences of continuing to utilize the shared tablespace in /var/lib/mysql/ibdata1 

Changing to per-table tablespace with innodb_file_per_table

As an option to resolve the issue, MySQL has a configuration variable called innodb_file per_table. To use this variable, the following could be placed into /etc/my.cnf to convert InnoDB to a per table file for each InnoDB engine table:innodb_file_per_table=1 ]

#cd /usr/share/doc/zabbix-server-mysql-*/create/schema
shell> mysql -u'username' -p'password'
mysql> create database zabbix character set utf8;
mysql> quit;
shell> cd create/schema
shell> cat mysql.sql | mysql -u'username' -p'password' zabbix
shell> cd ../data
shell> cat data.sql | mysql -u'username' -p'password' zabbix
shell> cat images_mysql.sql | mysql -u'username' -p'password' zabbix


FLUSH PRIVILEGES;  


in vim /etc/php.init

# line 440: change to Zabbix recomended

max_execution_time =
600
# line 449: change to Zabbix recomended

max_input_time =
600
# line 457: change to Zabbix recomended

memory_limit =
256M
# line 729: change to Zabbix recomended

post_max_size =
32M
# line 878: change to Zabbix recomended

upload_max_filesize =
16M
# line 946: uncomment and add your timezone

date.timezone =
Asia/Calcutta # whatever your timezone is


[root@imonitor ~]#
/etc/rc.d/init.d/zabbix-server start

Starting ZABBIX server:
[ OK ]

[root@imonitor ~]#
/etc/rc.d/init.d/zabbix-agent start

Starting ZABBIX agent:
[ OK ]

[root@imonitor ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[ OK ]

Starting httpd:
[ OK ]

[root@imonitor ~]#
chkconfig zabbix-server on

[root@imonitor ~]#
chkconfig zabbix-agent on





Install the Zabbix Agent only on CentOS 6.2  by YUM (On other Linux Hosts)

For 64 bit
rpm -Uvh http://mirror.cse.iitk.ac.in/fedora//epel/6/x86_64/epel-release-6-7.noarch.rpm

** if this does not work then browse/check the appropriate revision of  epel-release-6-7.noarch.rpm on the site.

yum install zabbix-agent

After Installing the zabbix agent it is a good idea for disable the EPEL repository
#perl -npi -e 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo


For 32 Bit
rpm -Uvh http://mirror.cse.iitk.ac.in/fedora//epel/6/i386/epel-release-6-5.noarch.rpm

Install the Zabbix Agent only on CentOS 6.2  from Source

Download the Zabbix from the zabbix.com/download


# mkdir /etc/zabbix

 wget http://prdownloads.sourceforge.net/zabbix/zabbix-1.8.11.tar.gz
 tar -xzvf zabbix-1.8.11.tar.gz

 cd zabbix-1.8.11
./configure --enable-agent
 -------------------------------------------
Configuration:
  Detected OS:           linux-gnu
  Install path:          /usr/local
  Compilation arch:      linux
  Compiler:              gcc
  Compiler flags:        -g -O2
  Enable server:         no
  Enable proxy:          no
  Enable agent:          yes
  Agent details:
    Linker flags:          -rdynamic
    Libraries:             -lm  -lresolv
  LDAP support:          no
  IPv6 support:          no
***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*                                  *
***********************************************************

-----------------------------------------------------

make install
make clean
#useradd -m -s /bin/bash zabbix
mkdir /etc/zabbix







cp misc/conf/zabbix_agentd.conf /etc/zabbix

vim /etc/zabbix/zabbix_agentd.conf
change the below two files as
     Server=[IP address or Name of your zabbix Server]
     Hostname=[Host Name of your agent machine]


cp misc/init.d/redhat/8.0/zabbix_agentd /etc/init.d/

vim /etc/init.d/zabbix_agentd
change the progdir to progdir=”/usr/local/sbin/”
 
#progdir="/usr/local/zabbix/bin/"
progdir="/usr/local/sbin/"

- Add the following lines in /etc/services:zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper


e.g
#echo "zabbix_agent 10050/tcp" >> /etc/services
#echo "zabbix_server 10051/tcp" >> /etc/services

#chkconfig --add zabbix_agentd
#chkconfig --level 35 zabbix_agentd on
#chmod 755 /etc/init.d/zabbix_agentd
[root@ZagentMachine init.d]# service zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]

Confirm if this is running

[root@ZagentMachine init.d]# ps -C zabbix_agentd
  PID TTY          TIME CMD
  528 ?        00:00:00 zabbix_agentd
  530 ?        00:00:00 zabbix_agentd
  531 ?        00:00:00 zabbix_agentd
  532 ?        00:00:00 zabbix_agentd
  533 ?        00:00:00 zabbix_agentd
  534 ?        00:00:00 zabbix_agentd

Now configure the Zabbix Server from the web for this agent...

Configuration>host>create host>
Name [name of the host you want to monitor]
Choose the group you want to put it in
Link it to the template Linux as this is agent installed on the linux box.
check the profile box and put some information about the machine , after this the machine will also be visible in the inventory tab.


Install a windows agent for zabbix
visit the below site and download the agent.

http://www.suiviperf.com/zabbix/index.php

Install them as per the architecture of your machine. [32 Bit or 64 Bit]


http://

Administration -> Media Types -> Email
  • Setup server, helo, email from address
Administration -> Users
  • Setup each user who'll get notified, make sure they have media type "Email" added with their address
Configuration -> Hosts -> Create host
  • In Linux Servers hostgroup
  • Define dns name, ip, connect by IP
  • If the machine is a simple networking device that will only be monitored using SNMP, add it to Template_SNMPv2_Device, and you're done. 
Configuration -> Templates -> Create template

    Give it a name (Template_CentOS_HTTP)
    In Templates group

Configuration -> Templates -> Template_CentOS_HTTP -> Items

    Create Item
    Host: Template_CentOS_HTTP
    Description: HTTP Basic Check
    Type: Simple_check
    Key: http,80

Configuration -> Templates -> Template_CentOS_HTTP -> Triggers

    Create Trigger
    Name: "HTTP Trigger"
    Expression: {Template_CentOS_HTTP:http,80.last(0)}#1
    Severity: High

Configuration -> Actions ->

    Create Action
    name: Email notifications
    Event source: triggers
    Default Subject: add "{HOST.DNS}:" to the beginning
    Default message: add "{HOST.DNS}:" to the beginning
    Conditions: make host have to be from "Linux Servers" hostgroup, and Template_CentOS_HTTP:HTTP trigger" is not 1
    Email affected users




Note:
/etc/my.cnf file  sample


[mysqld]
# paths
datadir                         = /var/lib/mysql/data
tmpdir                          = /tmp/mysqltmp
# network
connect_timeout                 = 60
wait_timeout                    = 28800
max_connections                 = 2048
max_allowed_packet              = 64M
max_connect_errors              = 1000
# limits
tmp_table_size                  = 512M
max_heap_table_size             = 256M
table_cache                     = 512
# logs
log_error                       = /var/log/mysql/mysql-error.log
slow_query_log_file             = /var/log/mysql/mysql-slow.log
slow_query_log                  = 1
long_query_time                 = 20
# innodb
innodb_data_home_dir            = /var/lib/mysql/data
innodb_data_file_path           = ibdata1:128M;ibdata2:128M:autoextend:max:4096M
innodb_file_per_table           = 1
innodb_status_file              = 1
innodb_additional_mem_pool_size = 128M
innodb_buffer_pool_size         = 14G
innodb_flush_method             = O_DIRECT
innodb_io_capacity              = 2000
innodb_flush_log_at_trx_commit  = 2
innodb_support_xa               = 0
innodb_log_file_size            = 512M
innodb_log_buffer_size          = 128M
# experimental
innodb_stats_update_need_lock   = 0
# other stuff
event_scheduler                 = 1
query_cache_type                = 0






** Use tmpfs filesystem for Temporary Files
Using memory instead of local disks will allow a much faster creation of temporary tables on MySQL.
First, create the mountpoint:
mkdir /tmp/mysqltmp

Add this line in your /etc/fstab:
tmpfs /tmp/mysqltmp tmpfs rw,uid=mysql,gid=mysql,size=1G,nr_inodes=10k,mode=0700 0 0
Finally, you need to define this path in /etc/my.cnf and restart MySQL:
tmpdir = /tmp/mysqltmp



===========================
To find out if any item is supported by the zabbix or not use the zabbix_get command from the server
For example to calculate the percent disk space used by the c drive in windows , run the below command.
[aqua~]# zabbix_get -s -k vfs.fs.size[c:,pfree]
77.957042

note: while creating an item here choose "numeric float" instead of "numeric unassigned"
Or to know the free disk space in c drive

[root@aqua ~]# zabbix_get -s 10.10.10.33 -k vfs.fs.size[c:,free]
56677367296

[root@aqua ~]# zabbix_get -s 10.10.10.33 -k system.cpu.load[,avg15]
0.172222



Saturday, April 14, 2012

Apache Logs


Find unique IP addresses that hit your webserver



cat /var/log/httpd/access_log |awk '{print $1}' | sort | uniq | wc -l
  1. first we use the cat command to list all the entries in the apache log file.
  2. we send that to awk which extracts the first item on each line which should be the IP
  3. then we sort all the IPs, this is needed for the uniq command
  4. we apply the uniq filtering command to remove duplicate IPs
  5. then we count the number of lines left using word count command wc
# filter out unique requests for a given day, in this case Jan 1st 2012
cat /var/log/httpd/access_log |  grep "\[01/Jan/2012" |awk '{print $1}' | sort | uniq | wc -l


# getting a list of unique referrers
cat /var/log/httpd/access_log | awk '{print $11};' | awk -F / '{print $3}' | sort | uniq


Install VMware tools by command line + CentOS 6.2

  1. In Sphere Client: Right click on the VM > Guest > Install/update VMware Tools
  2. On the VM console in command line, (without GUI installed):
  3. mkdir /cdrom, or anyother mount point you like
  4. mount the vitural cdrom from step 1; mount /dev/cdrom /cdrom
  5. cd /tmp
  6. tar -xvf /cdrom/VMwareTools (tab to auto-complete)
  7. cd vmware (tab to auto-complete)
  8. ./vmware-install.pl; accept defaults, you might have to install peral as well
  9. umount /cdrom
  10. In Vsphere Client: Guest > Install/upVMware Tools > OK
  11. To confirm the install; in the client > VM Summary tab and look for OK next to VMWare Tools
  12. Restart VM

Monday, April 9, 2012

Linux- copy methods


Linux- copy methods

wget
Download a file

Download a file whose URL contains a “&” (note quotes)
wget http://www.example.com/min.php?page=home&user=ma
Draw an entire site (recursive download)
wget-r http://www.example.com/
Resume a download
wget-c http://www.example.com/xyz.html
Download files only an extension (here,. Jpg)
wget-A.jpg http://www.example.com/
Limit download speed
wget – limit-rate = 30k http://www.example.com/
Download via ftp (With authentication)
wget-r l4 ftp://username:password @ example.com /

If there are a list of pages, files, and so on that I want to grab for the script, I can list one URL-formatted item per line within a file. For example, if the file was ~/bin/getme, I would use:

wget -i ~/bin/data/getme

To download a copy of a complete web site, up to five levels deep, you use the -r option (for recursive):

wget -r site.com -o logfile

Instead of having the progress messages displayed on the standard output, you can save it to a log file with the -o option:

SCP

Copy the file "foobar.txt" from a remote host to the local host
$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file "foobar.txt" from the local host to a remote host


Copy the directory "foo" from the local host to a remote host's directory "bar"



Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"

$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/

Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host

$ scp foo.txt bar.txt your_username@remotehost.edu:~

Copy multiple files from the remote host to your current directory on the local host


$ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\}  .

RSYNC

$ rsync options source destination

Source and destination could be either local or remote. In case of remote, specify the login name, remote server name and location.

Synchronize Two Directories in a Local Server

$ rsync -zvr /var/dir1/ /root/dir2
 
-z  :enable compression
-v :verbose
-r    : recursive
-a : preserve time stamp
-d : sync the directory tree structure

Preserve timestamps during Sync using rsync -a


rsync -azv /var/dir1/ /root/dir2

rsync -arzv /var/dir1/ /root/dir2       (this will do recursively)
 
 
 
a = archive - means it preserves permissions (owners, groups), times, symbolic links, and devices.
r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied 

Synchronize Only One File

To copy only one file, specify the file name to rsync command
 
rsync -v /var/singlefile /root/myfile/
 

Synchronize only the Directory Tree Structure (not the files)


rsync -v -d abc@192.168.200.10:/var/lib/ .

Use of "/" at the end of path:
When using "/" at the end of source, rsync will copy the content of the last folder.
When not using "/" at the end of source, rsync will copy the last folder and the content of the folder.

When using "/" at the end of destination, rsync will paste the data inside the last folder.
When not using "/" at the end of destination, rsync will create a folder with the last destination folder name and paste the data inside that folder.

Synchronize with the Directory Name
What if you wanted to not just copy all of the files under /myDir/, but also the /myDir/ directory name. Just leave off the last "/" after the "/myDir" directory name. This will tell rsync to copy the directory name and all files under that directory. On the remote server you will then see the directory structure /backups/myDir/.
rsync -avz /myDir user@remotemachine:/backups/

Incremental Backups using rsync

 
The following example will make an incremental backup of the directory /data/working/ and put a copy of any file that changes into a dated directory in /BACKUP/ . This can be used to keep a daily backup tree of any changed files and not have to overwrite the previous days files. Note that this method does need to copy the entire file if it changes as the new files are made in the directory named under current day.
 
rsync --backup --backup-dir=`date +%Y.%m.%d` -a /data/working/ /BACKUP/
 
LFTP




#!/bin/bash
HOST="your.ftp.host.dom"
USER="username" 
PASS="password"
LCD="/path/of/your/local/dir"
RCD="/path/of/your/remote/dir" 
lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST;
lcd $LCD;
cd $RCD; 
mirror --reverse \
        --delete \
        --verbose \
        --exclude-glob a-dir-to-exclude/ \
        --exclude-glob a-file-to-exclude \
        --exclude-glob a-file-group-to-exclude* \
        --exclude-glob other-files-to-exclude"


Upload a file

lftp -e 'put /local/path/yourfile.txt; bye' -u user,password ftp.remote.com 

Download a file

lftp -e 'set net:timeout 10; get yourfile.txt; bye' -u user,password ftp.remote.com 

Mirroring / Recursive upload

When using the mirror command, LFTP is recursive by default.
Mirror everything from the /local/path to the root of the remote FTP site, including all subdirectories and their files. The -R switch means “reverse mirror” which means “put” [upload]. Remote path is simply /, the root.

lftp -e 'mirror -R /local/path/ /' -u user,password ftp.remote.com

Recursive Download

To mirror remote to local, just omit the -R param and swap remote path with local. Be careful with this. Don’t overwrite your local changes.

lftp -e 'mirror / /local/path/' -u user,password ftp.remote.com  

Special Characters in Username or Password

Special characters in your username or password must be escaped with backslashes:

lftp -e 'put /pathToyourfile.txt; bye' -u user,password\!\! ftp.remote.com



Wednesday, March 14, 2012

"device eth0 does not seem to be present, delaying initialization" Error CentOS 6.2 + VMware Clone

CentOS 6.2 Cloned VM are having this issue 

# ls /sys/class/net
eth1 lo

There is a device manager, udev, which stores the settings from the NIC of the vm prior to the cloning? process.? When you clone a vm it also changes the mac address of the NIC and as a result the vm sees it as a new NIC and assigns it to /dev/eth1.

As a result, we now have to edit the udev config file as well as the ifcfg-eth0 file to get the newly update virtual NIC card to operate on the eth0 device.

1. Delete 70-persistent-net.rules which is under /etc/udev/rules.d/ and reboot the machine

OR


First, edit: /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:be:00:30", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:be:00:32", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


Delete or comment the first SUBSYSTEM entry in the file.

Update the 'eth1' attribute in the remaining entry to 'eth0'

Edit /etc/sysconfig/network-scripts/ifcfg-eth0
Change the HWADDR to match the new mac address listed in the newly edited 70-persistent-net.rules file. eg in my case 00:50:56:be:00:32

like
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:50:56:BE:00:32
BOOTPROTO=static
 


Reeboot the machine.


Thursday, January 5, 2012

Add static route to linux

add a remote host

remote host 192.168.1.20
local gateway 10.1.1.20
route add -host 192.168.1.20 gw 10.1.1.20

add a remote network

route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1
 
check the route 
route -n
 
Delete a route
route del -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8
 
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here.
 
To make the routing information persistent, add the “route add” line as seen above into the /etc/rc.local file.
Sample /etc/rc.local file.
or /etc/rc.d/rc.local

touch /var/lock/subsys/local
route add -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8



 


  
 

Wednesday, January 4, 2012

Error : Root File System Is Read-Only | linux based file system become read only

As a workaround, remount the Linux file system using this command to return it to the proper state:
 
mount -o remount /


Remount it. If /etc/fstab is correct, you can simply type:

mount -n -o remount /

If /etc/fstab is wrong, you must give the device name and possibly the
type, too: e.g.

mount -n -o remount -t ext2 /dev/hda2 /


VMware has identified a problem where file systems may become read-only after encountering busy I/O retry or SAN or iSCSI path failover errors.
 
The same behavior is expected even on a native Linux environment, where the time required for the file system to become read-only depends on the number of paths available to a particular target, the multi-path software installed on the operating system, and whether the failing I/O was to an EXT3 Journal. However, the problem is aggravated in an ESX host environment because ESX host manages multiple paths to the storage target and provides a single path to the guest operating system, which effectively reduces the number of retries done by the guest operating system.
 
These guest operating systems are affected:
  • RHEL5 (RedHat)
  • RHEL4 U6
  • RHEL4 U4
  • RHEL4 U3
  • SLES10
  • SLES9 SP3
  • Ubuntu 7.04 

    Note: This issue may affect other Linux distributions based on early 2.6 kernels as well, such as Ubuntu 7.04.
 

Monday, December 19, 2011

Focus back



You probably don’t want to admit it but you love distractions. In fact, just like monkeys, you get a shot of dopamine every time something pulls you in another direction. Why do you think you check your email so much?
Want to be more productive and get your focus back? There are no secret tricks here… do one thing at a time. Stop multitasking—it’s just another form of distraction.


Here are his tips for staying productive:
  1. Work backwards from goals to milestones to tasks. Writing “launch company website” at the top of your to-do list is a sure way to make sure you never get it done. Break down the work into smaller and smaller chunks until you have specific tasks that can be accomplished in a few hours or less: Sketch a wireframe, outline an introduction for the homepage video, etc. That’s how you set goals and actually succeed in crossing them off your list.
  2. Stop multi-tasking. No, seriously—stop. Switching from task to task quickly does not work. In fact, changing tasks more than 10 times in a day makes you dumber than being stoned. When you’re stoned, your IQ drops by five points. When you multitask, it drops by an average of 10 points, 15 for men, five for women (yes, men are three times as bad at multitasking than women). 
  3. Be militant about eliminating distractions. Lock your door, put a sign up, turn off your phone, texts, email, and instant messaging. In fact, if you know you may sneak a peek at your email, set it to offline mode, or even turn off your Internet connection. Go to a quiet area and focus on completing one task.
  4. Schedule your email. Pick two or three times during the day when you’re going to use your email. Checking your email constantly throughout the day creates a ton of noise and kills your productivity.
  5. Use the phone. Email isn’t meant for conversations. Don’t reply more than twice to an email. Pick up the phone instead. 
  6. Work on your own agenda. Don’t let something else set your day. Most people go right to their emails and start freaking out. You will end up at inbox-zero, but accomplish nothing. After you wake up, drink water so you rehydrate, eat a good breakfast to replenish your glucose, then set prioritized goals for the rest of your day. 
  7. Work in 60 to 90 minute intervals. Your brain uses up more glucose than any other bodily activity. Typically you will have spent most of it after 60-90 minutes. (That’s why you feel so burned out after super long meetings.) So take a break: Get up, go for a walk, have a snack, do something completely different to recharge. And yes, that means you need an extra hour for breaks, not including lunch, so if you’re required to get eight hours of work done each day, plan to be there for 9.5-10 hours.
for a complete article you can visit the below link

http://www.inc.com/ilya-pozin/7-things-highly-productive-people-do.html

Sunday, December 11, 2011

Monitoring Guidelines

  • Keep it simple stupid.
    • Start with simple monitoring, like PING to make sure that the host is up and standard checks like http, smtp and so on to make sure that standard services are up. Going from no monitoring to basic monitoring is a huge step and many organizations do not have the processes to handle more complex monitoring.
    • The next step is disk, CPU and memory on hosts. On network devices are port load, cpu load, network link.
    • Third step is to dig into bussiness critical applications and services.
  • Small iterations. Do not try to build a top of the line monitoring solution from day one. You will never leave the startup phase.
  • Let the monitoring solution pull the status instead of sending the status to the monitroing solution. This avoid complicated rules when different types of information is sent to the monitoring solution. So avoid sending SNMPtraps.
  • The monitoring solution is NOT a trashcan where to send tons of uninteresting garbage. It is far to common that HW vendors recommends to send thousands of unnecessary SNMPtraps to the monitoring solution and just a few is interesting. It is a nightmare to create the ruleset to figure out what is interesting, especially if there is dependencies where one message is interesting if another message has been sent before. The documentation is a badly written  MIB on a couple of hundered pages. In almost every case I’ve run into with this approch the implementation never ends and test cases are hard to create. When the systems are in production I can bet on that a critical event will occour which has not been taken care of and the production will stop. Managers will be upset, vendors will blame each other and customers will be angry.
  • Let the status be availiable easily:
    • via standard APIs, Perl and Bash is the most common.
    • SNMP via SNMPget instead of SNMPtraps
    • Status stored in a database, the monitoring solution can run SQL quries to get the status.
    • Commands the can be runned by the monitoring solution and the output parsed, or even better, exit codes are used and documented.
  • Normally it is not a good idea to read a log file to understand the status of of the software.
http://www.it-slav.net/blogs/2009/08/30/general-systems-and-network-management-guidelines-part-1/

Monday, November 7, 2011

How to Delete Exchange 2007 Logs manually | ESUTIL for intergrity Checking


Go to the bin directory of your exchange
C:\Program Files\Microsoft\Exchsrvr\bin>eseutil /mk  E:\Logs\e00.log

if you receive 
Operation terminated with error -1032 (JET_errFileAccessDenied, Cannot access file, the file is locked or in use) after 30.83 seconds.

that means that your data base is in mounted state, you have to dismount the exchange database and run the command again.


If the database is still mounted, use the following steps to dismount the database, and then run ESEUTIL:
  1. Start Exchange System Manager.
  2. Right-click the database that you want to dismount.
  3. Click All Tasks, and then click Dismount Store.
If you wish to use the ESEUTIL /k option on log files you'll need to stop the Microsoft Exchange Information Store service. To do so follow these steps:
  1. Start the Services applet in the Administrative Tools folder.
  2. Right-click the Microsoft Exchange Information Store service.
  3. Click Stop.
After the integrity check is over you must start the Microsoft Exchange Information Store service. To do so follow these steps:
  1. Start the Services applet in the Administrative Tools folder.
  2. Right-click the Microsoft Exchange Information Store service.
  3. Click Start.



 

Tuesday, October 4, 2011

Backup Deletion X no. of days

vi rmbackup.sh

#!/bin/bash
set -x
###Script for cron to delete backups
DIRECTORY=/home/BackupLocation/
DELETEOLDERTHAN="3"
find $DIRECTORY -type f -ctime +$DELETEOLDERTHAN
ls -la | mail -s "backup delete $HOSTNAME -'date'" abc@yourdoamin.com
exit 0

save and exit and chmod +x rmbackup.sh

Put the above script in cron
#crontab -e

*  3  * * * /home/rmbackup.sh

==================================================
Rsync Remote host backup script : Put this script on the machine where you want to take/pull the backup. generate the rsync key
#!/bin/sh
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/root/rsync/mirror-rsync-key
RUSER=ursync                                              : create a user for rsync
RHOST=hostname of the remote machine
RPATH=/var/www/html/                                : remote data backup path
LPATH=/var/www/html/                                : Local Path
$RSYNC -azq --delete -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH



Another way

Delete directory based on the time stamp. The below command will delete all the directories with time stamp 2012.

** you need to run this command in the same directory

rm -vrf `ls -lh | sed -n '/2012/p' | awk '{print $8}'`



Wednesday, September 7, 2011

How to Setup FTP and an anonymous FTP server with vsftpd with upload enable

Setup vsftpd in CentOS
yum install vsftpd
chkconfig vsftpd on
service vsftpd start
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.original
anonymous_enable=NO
listen=YES
local_enable=NO
anonymous_enable=YES
write_enable=NO
anon_root=/var/ftp
anon_max_rate=2048000
xferlog_enable=YES 


   
 
 
 
Setup Anonymous FTP with upload enable
#
vim /etc/vsftpd/vsftpd.conf
anon_root=/myftpDir/pub
listen_port=21
listen=YES
local_enable=YES
anonymous_enable=YES
write_enable=YES
anon_max_rate=2048000
xferlog_enable=YES
ftp_username=ftp
anon_upload_enable=YES
anon_mkdir_write_enable=YES
#anon_other_write_enable=YES
anon_world_readable_only=NO
ftpd_banner=(All Activities are monitored on this system!!)
log_ftp_protocol=YES
no_anon_password=YES
local_umask=022

save & exit by :wq

Now
Make sure that root directory  is not  being writable
The ftp root directory MUST NOT be owned by ftp for security reasons (it should be root:root).

Change the permission as below:
chmod u-w /myftpDir/pub
mkdir /myftpDir/pub/upload
chown u-w /myftpDir/pub/upload






Monday, September 5, 2011

SAMBA


yum -y install samba samba-client
service smb start
chkconfig smb on
mkdir /data
mkdir /data/share
chmod 766 /data/share
mv /etc/samba/smb.conf /etc/samba/smb.conf.backup
vim /etc/samba/smb.conf
 
Samba Config - smb.conf
[global]
workgroup = workgroup
netbios name = abc
security = SHARE
load printers = No
default service = global
path = /data
available = No
encrypt passwords = yes

guest account = nobody
[ShareLocation]
guest ok = yes
guest only = yes
path = /ShareLocation
read only = yes
browseable = yes
save and exit by :wq
============================