Friday, July 13, 2012

Clon Hdd for EXSI

Before proceed, first you must enable SSH in EXSi

then you can transfer your own ready make .vmdk by scp or winscp into EXSi
but for myself, i make a standard template in EXSi so i can easily deploy other server in future.

create a new VM but skip the hdd creation 
SSH into EXSi and use this command
# vmkfstools -i <input.vmdk> <output.vmdk>
then edit the VM, add hdd into it but click
use an existing virtual disk and select the newly cron disk

usually the location of the vm is at 
/vmfs/volumes/<random.number>/
so you need to identify out the location

if you re-cron back to the same EXSi server, there might be network problem with the newly cron server because the network card MAC will be different. so you need to go to
/etc/udev/rules.d/70-persistent-net.rules to update your MAC address
you just need to exchange the eth0 with the eth1 and eth1 to eth0

Thursday, July 12, 2012

EXSI SSH Keygen path

The SSH keygen folder in EXSi was located in /.ssh/
You can scp the public key from other server and cat id_rsa.pub » /.ssh/authorized_keys

Minimum HDD size for Centos 6

the minimum hdd space needed for Centos 6 without any package is 4GB:

100MB   -> /boot
2000MB -> /
300MB   -> Swap
200MB   -> /home
500MB   -> /tmp
remain     -> /var


but if you want the minimum hdd space for Centos 6 with base package, it is 5GB:


100MB   -> /boot
3000MB -> /
300MB   -> Swap
200MB   -> /home
500MB   -> /tmp
remain     -> /var

Wednesday, November 23, 2011

Cacti - check memory

To use this script template, perform the following steps:
  1. Download cacti-netsnmp-memory.0.7.tar.gz to a temporary directory on the Cacti server machine.
  2. Expand the archive with the command tar -xvzf cacti-netsnmp-memory.0.7.tar.gz, and change to the cacti-netsnmp-memory directory that is created.
  3. Copy scripts/ss_netsnmp_memory.php to the <cacti>/scripts/ directory.
  4. Access the Cacti installation in a web browser, click on the "Import Templates" menu item on the left side of the Console screen, and import the template/Net-SNMP_memory_graph_template.xml file. Cacti should automatically create the required graph template, data input method, and data template objects.
  5. Click on the Devices menu item on the left side of the Console screen, select a *NIX host that is running Net-SNMP, and scroll down to the "Associated Graph Templates " table. Select "Host Memory - ucd/net - Memory Usage" in the "Add Graph Template " drop-down box, and click the "Add" button.
  6. After the Device screen reloads, verify that the "Host Memory - ucd/net - Memory Usage" graph template is now present, and then click the "Create Graphs for this Host" link at the top of the page.
  7. Locate the "Host Memory - ucd/net - Memory Usage" graph template, enable the checkbox to its right, and then scroll to the bottom of the page and click the "Create" button.
Note: these files are intended to be used with Cacti 0.8.6 and 0.8.7 and PHP 5.2, and may not operate as expected with other versions.

Reference URL http://www.eric-a-hall.com/software/cacti-netsnmp-memory/

Monday, November 21, 2011

yum useful info

Add the below line to /etc/yum.conf to enable list to show older versions of packages.
showdupesfromrepos=1
clean yum cache
# yum clean all

clean subscription as well if using RHEL
# subscription-manager clean

# yum list --noplugin

for those using RHEL,
it got function for download the rpm package to local disk and install later
below is example to download only for haproxy
# yum install --downloadonly --downloaddir=/opt/ haproxy

Monday, October 24, 2011

Nagios Customize Script

Since Nagios is only using check_nrpe to call / execute the shell script. We can use this command to execute our own write shell script.
Below is the example of script to check the public IP and give output to nagios
-------------------------------------------------------------------------------

#!/bin/sh

IP=`curl -s ifconfig.me`
LEASE=202.147.38.202 

if [ $IP == $LEASE ]; then

        echo $IP
        exit 0

else
        echo $IP
        exit 2

fi

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

According to nagios, it use exit code to determine the output to give what kind of response.
so below is the exit code


State OK = 0
State Warning = 1
State Critical = 2
State unknown = 3
State Dependent = 4

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

Now we will add this script to the client side and define the command to nagios

We will need to edit nrpe.cfg file and add this into it

command[check_lease]=/etc/nagios/check_lease

this command will allow nagios server to call this command
----------------------------------------------------------

Then we need to define this command at client side for the path of the script to execute at commands.cfg

define command{
     command_name    check_lease
     command_line    /bin/bash /etc/nagios/check_lease
     }

This will state check_lease is refer to which shell script
----------------------------------------------------------

The last part is add the check command to the server side


define service{
      use                             local-service
      host_name                       my-proxy
      service_description             lease
      check_command                   check_nrpe!check_lease
  }

Wednesday, October 12, 2011

check backup server

==== client side ====
we will make a script in each server to pump date into a file. so when we check at backup server, we will check if this file was backup to backup server since it will update the date everyday.\\

below is the script contain (/root/record)
----------------- Start ---------------------------
#! /bin/sh

echo `date` > /root/assessment

then use crontab -e to run this script everyday
0 12 * * * /root/record > /dev/null 2>&1

----------------- End ---------------------------

==== backup server side ====
at the server side, i had make a folder name assessment and put the script inside.\\
below is the script contain (check_assessment)

------------------- Start -------------------------------
#! /bin/sh

echo "assessment done on `date`" > /mnt/backup/assessment/assessment_result.txt -> this is to pump the date it run the script
echo " " >> /mnt/backup/assessment/assessment_result.txt -> give an empty space

for host in `cat /mnt/backup/assessment/list`    # -> this is to loop the server list
do
echo $host >> /mnt/backup/assessment/assessment_result.txt -> this is to pump the server name before it start check so we know the result is belong to which server

for n in {1..9} -> loop to check folder 01-09
do
FILE="/mnt/backup/$host/0$n/root/assessment"


if [ -f $FILE ];
then
cat $FILE >> /mnt/backup/assessment/assessment_result.txt -> if the file exist, copy the date to assessment_result.txt
else
echo "day $n didnt backup" >> /mnt/backup/assessment/assessment_result.txt -> if the file not exist, echo what day it didnt backup
fi

done


for n in {10..31} -> loop day 10-31
do
FILE="/mnt/backup/$HOST/$n/root/assessment"

if [ -f $FILE ];
then
cat $FILE >> /mnt/backup/assessment/assessment_result.txt
else
echo "day $n didnt backup" >> /mnt/backup/assessment/assessment_result.txt
fi

done

echo " " >> /mnt/backup/assessment/assessment_result.txt

done

uuencode /mnt/backup/assessment/assessment_result.txt /mnt/backup/assessment/assessment_result.txt | mail -s "[My-Backup] monthly check result" sat.support@my.offgamers.com -> this is to email the result to us as attachment

--------------------------- End -----------------------------------------

then put the server name you want this script to check into a file name list
example:-
my-domain
my-proxy
my-dns1
my-dns2

then use crontab -e to run this script every first day of the month