Kamis, 16 September 2010

Setup Nagios (NMS) om FEDORA

1- First install some tools : httpd, gcc, glib, glibc-common, gd and gd-devel

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

2- Create nagios user :

#/usr/sbin/useradd -m nagios
#passwd nagios

3- Add nagcmd group

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

4- Now go to http://www.nagios.org download files .

nagios-3.1.0.tar.gz nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz

tar  -zxvf  nagios-3.1.0.tar.gz  
cd  nagios-3.1.0
./configure --with-command-group=nagcmd
 #make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf

5- Edit your email admin address :

Go to

vi /usr/local/nagios/etc/objects/contacts.cfg

6- Create a nagiosadmin account for logging into the Nagios web interfaceassign to this you’ll need it later.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

enter the password.

7- Restart the httpd server :

#Service  httpd   restart

The second step : Extract and install plugins

1- Go to you downloaded nagios tools

 tar  -zxvf   nagios-plugins-1.4.13.tar.gz

2- cd nagios-plugins

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make; make   install

3- Now you have to add nagios to Chkconfig

chkconfig --add nagios
chkconfig nagios on

4- Verify if you have a good config of nagios with the command

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

5- Check if there are no errors displayed; then start nagios with command :

service  nagios  start

To simplify the procesure please disable the selinux and iptables and ip6tables

now open your browser and http://localhost/nagios orr http://ip/nagios

Selasa, 10 Agustus 2010

Reset Factory Default Cisco (SOHO & 2600 Series)

Jika sedang tugas lapangan, kadang sering harus berurusan dengan router propietary yang sebelumnya dipegang aksesnya oleh orang lain, lalu dilimpahkan tanpa dikasih tau login passwordnya. Seperti beberapa hari yang lalu saya mendapatkan 2 mesin Cisco (SOHO91 & 2600 Series) yang tidak tau login passwordnya. Setelah bertanya ke sana kemari, ternyata caranya adalah sebagai berikut:

  • Akses ke mesin Cisco dengan kabel console, lalu pada saat booting tekan tombol ctrl + break, hingga muncul prompt:
    rommon 1 > _

  • Pada prompt tersebut isikan confreg 0x2142, dilanjutkan dengan perintah reset seperti di bawah ini:

    rommon 1 > confreg 0x2142
    rommon 2 > reset

    Setiap kali kita mengisikan perintah dan menekan enter, maka index pada prompt akan bertambah.

  • Jika berhasil, maka proses booting akan muncul seperti:
    System Bootstrap, Version 12.2(8r) [cmong 8r], RELEASE SOFTWARE (fc1)
    Copyright (c) 2003 by cisco Systems, Inc.
    C2600 platform with 131072 Kbytes of main memory

    .............

    --- System Configuration Dialog ---

    Would you like to enter the initial configuration dialog? [yes/no]:


    Ketik no dan tekan enter, maka kita akan langsung masuk ke prompt Cisco tanpa ada password, dan setting sebelumnya sudah hilang.

Kamis, 11 Maret 2010

Check mailbox size of all accounts in Zimbra mail server

Buat File dengan isi Scrip di bawah ini :

################
#!/bin/bash
all_account=`zmprov gaa`;
for account in ${all_account}
do
mb_size=`zmmailbox -z -m ${account} gms`;
echo "Mailbox size of ${account} = ${mb_size}";
done
##############

misal nya : checkmailsize.sh

# chmod 755

untuk menjalankan nya

# ./checkmailsize.sh


Kamis, 11 Februari 2010

Automating Cisco Router Backups

Automating Cisco Router Backups


tep 1: Download and install rancid.
——————————————————————–

For additional information on rancid’s complete functionality see the following site.

http://www.shrubbery.net/rancid/

Install rancid, build-essential, and expect.

Code:
sudo apt-get install rancid-core rancid-util build-essential expect

Step 2: Create .cloginrc file in the rancid directory.
——————————————————————–

Opend a terminal and type the following.

Code:
sudo gedit /var/lib/rancid/.cloginrc

Add entries for each router, switch, pix firewall you’d like to backup by using the following format.

Code:
add password    IPADDRESS       {telnetpassword}      {enablepassword}

IPADDRESS = the actual ip address of the device you want to backup.
telnetpassword = the actual telnet password for the device you want to backup.
enablepassword = the actual enable password for the device you want to backup.

The “{}” are required. At the bottom of the .clogin add the following line if you require SSH access to your equipment.

Code:
add method     *    telnet ssh

With this clogin will first try to telnet then ssh to your equipment.

Step 3: Protect the .cloginrc file.
——————————————————————–

Code:
sudo chmod 640 /var/lib/rancid/.cloginrc

Step 4: Create a backup directory for backup configs.
——————————————————————–

Code:
sudo mkdir /var/lib/rancid/backups/

Step 5: Change ownership of the /usr/lib/rancid/backups/ directory.
——————————————————————–

Code:
sudo chown -R rancid.rancid /var/lib/rancid/backups/

Step 6: Change permissions to the rancid directory.
——————————————————————–

Code:
sudo chmod 770 /var/lib/rancid/

Step 7: Set password for rancid account
——————————————————————–

Code:
sudo passwd rancid

Step 8: Test .cloginrc
——————————————————————–

As the user rancid test accessing your equipment.

Code:
su rancid

Now using once of the network devices that you’ve put in the .cloginrc for rancid type the following in the open terminal.

Code:
/usr/lib/rancid/bin/clogin  IPADDESSOFDEVICE

You should see the clogin telnet (or ssh) to the device in question and switch to enable mode on the device. If everything works the proceed on to step 8. Otherwise take a look at your /var/lib/rancid/.cloginrc .


Step 9: Test grabing a backup config from the same device.

——————————————————————–

As rancid run the following test to make sure that you have everything setup correctly.

Code:
/usr/lib/rancid/bin/clogin  -c 'write term' IPADDESSOFDEVICE > /var/lib/rancid/backups/test.cfg

Verify the output:

Code:
less /var/lib/rancid/backups/test.cfg

If everthing checks out move on to step 10.

Step 10: Create the bash script for the backups
——————————————————————–

Here’s a sample script for you to copy and paste into a file (i.e. network_device_backup.sh) and to tweak, add, or change for your needs. But save the script somewhere the rancid user can access and execute the script from (i.e./var/lib/rancid/). If you are planning on backing up a various types of routers, switches, firewalls etc you may want to create serveral differnet scripts.

Code:
#!/bin/bash
# Variables

clogin=/usr/lib/rancid/bin/clogin
path=/var/lib/rancid/backups/
tdy=`date +%m%d%Y`

#backup network device

$clogin -c 'write term' 192.168.0.1 > $path/foo-$tdy.cfg

NOTE: When rancid is installed the default shell for the rancid user is csh. So for the script above to work the “#!/bin/bash’ is needed.

Step 11: Make the script executable to rancid.
——————————————————————–

Code:
sudo chmod 700 /path/to/script

Step 12: Test the backup script.
——————————————————————–

Test your script logged in as rancid.

Code:
su rancid

Now from wherever you put the backup script verify that it works before adding it as a cron job. For this example I’m going to use the following location /var/lib/rancid/.scripts/routers.sh with the output path being /var/lib/rancid/backups/.

Code:
 ./var/lib/rancid/.scripts/routers.sh

verify the config file that was generated to the output path you specified.

Code:
less /var/lib/rancid/backups/foo-12202005.cfg

Step 13: Add script to CRON.
——————————————————————–

As rancid add your script to CRONTAB.

Code:
su rancid

Now add an entry for your script.

Code:
crontab -e

To backup your equipment every Friday at 5pm should look like…

0 17 * * 5 /var/lib/rancid/.scripts/routers.sh >/dev/null 2>&1

Save the entry (crtl+x).

Verify the entry in crontab is correct.

Code:
crontab -l

For more infor on CRONTAB see the following post.
http://ubuntuforums.org/showthread.php?t=102626