sed and awk

Remove multiple spaces
= = = = = = = = = = = = =

Remove leading space and number in history command output
 
history | sed 's/^ *[0-9][0-9]* *//'


root@vm2:~# cat hello 
#ab 12
cd      99
   zz    te
#ef
    test
      #tellso

root@vm2:~# cat hello  | sed 's/^\s\+//g'

#ab 12
cd      99
zz    te
#ef
test
#tellso

Combinig sed expression
root@vm2:~# cat hello  | sed 's/^\s\+//g;s/\s\+/ /g'
#ab 12
cd 99
zz te
#ef
test
#tellso


sed 'p' passwd  #prints file content but double content
sed -n '1p' file.txt  #print 1st line
sed -n  '2p' file.txt  #print 2nd line
sed -n 4,13p file.txt #print 4 to 14 line
sed -n '$p'  file.txt  #print last
sed -n '1!p' file.txt  #print all except line 1
sed -n '1,3!p' file.txt #print all except line 1 to 3


=======================using regular expression=======================
we use '-e' option when we use expression

sed -n -e '/2011/p' file.txt     # print line containing 2011
sed -n -e '/^root/p' passwd      # print lines starting with word 'root'
sed -n -e '/root$/p' passwd      # print lines Ending with word 'root'
sed -n -e '/^harke101$/p' passwd
sed -n -e '/^harke101.*$/p' passwd     # print lines Starting and Ending with word 'root'
sed -n -e '/[0-9]/p' firewall.txt     # print lines containing number 0-9
sed -n -e '/^[0-9][0-9][0-9]$/p'  firewall.txt #print beginning and ending with 3 char number
sed -n -e '/[0-9]\{3\}/p' firewall.txt # print beginning and ending with 3 char number
sed -n -e '/^[0-9]\{3\}$/p' firewall.txt # print beginning and ending with 3 char number



Find sumtotal of column

ps aux | grep apache | awk '{ sum += $6 } END { print sum }'
ls -lh php*; ls -l php* | awk '{ SUM += $5} END { print SUM/1024/1024 }'
===========================================================================



echo 'its a trap' | sed s/ra/zzz/        ##replace the word ra with zzz, matches only first occurance of Reg Ex
its a tzzzp

echo "how now brown cow" | sed s/ow/YY/  
hYY now brown cow

echo "how now brown cow" | sed s/ow/YY/g
hYY nYY brYYn cYY

sed -ie 's/ow/aagh/g' ~/temp.txt   #Make changes to the file itself

sed '11,$ d' ~/temp.txt  #delete line 11 and latter lines of file

sed '/#.*/ d'  file.txt   #delete line starting with '#'

Remove empty lines and comments {#  and ;}

 cat taste | sed '/^[#;]/d' | sed '/^$/d'      =>[#;] means lines starting with semicolon ";"  or hash " # " 


Tr command in linux
= = = = = = =  = = =  = =

Replace newline[\n]with    '  '  <space>

echo "$string" | tr '\n' ' '

Translate white-space to tabs

$ echo "This is for testing" | tr [:space:] '\t'
This is for testing

We can use -s option to squeeze the repetition of characters.

$ echo "This   is   for testing" | tr -s [:space:] '\t'
This is for testing

# Replace multiple newline with single new line


cat -s filename

cat -s 10-master.conf | grep -v "#" | cat -s

# with sed

cat filename | sed '/^$/d'

# with tr to replace multiple newline to one
cat file name | tr -s '\n'

mailscanner clamd spamassassin- Integrating mailscanner part 3

====Integrating MailScannner=====
1. Edit the file /etc/postfix/main.cf and remove the # in front of the line below

header_checks = regexp:/etc/postfix/header_checks

2. Edit the file /etc/postfix/header_checks and add the line below to the bottom of the file

/^Received:/ HOLD

3. MailScanner should now be the one to start the Postfix service. Stop the Postfix service and start the Clamd and MailScanner service in that order. Use the commands below to accomplish these.

chkconfig postfix off
chkconfig clamd on
chkconfig MailScanner on
service postfix stop
service clamd start
service MailScanner start
= = = = = clean mailscanner quarantine emails as the size increase gradually by time = = =
 # cd /etc/cron.daily/
# vim  clean.quarantine
$disabled = 0;    #uncomment
$days_to_keep   = 3;    # set value according to your needs

#./clean.quarantine       ; #to run now by hand


= = = = = clamd  may stop ,, dirty fix by periodically restarting clamd = = = = =  =
[root@mx12 xinetd.d]# crontab -l
*/3 * * * * /opt/checkclam.sh

# cat /opt/checkclam.sh
#!/bin/bash
if ! pgrep clamd > /dev/null;
then
/etc/init.d/clamd restart > /dev/null;
else
echo "OK `date +%T\ %F`" >> /program.log; #'\ ' is for space use %t for tab
fi

 = = = = = = = = = = = = = = =  = = = = = =

Perform header checks  with /etc/postfix/header_checks   file :

/^Received:/ HOLD
#                                                               HEADER_CHECKS
#
/^Subject:.*Info..P..E N I_S..--..E-N-L..A R-G-E M_E..N T-___P_I L..L_S-*/ HOLD
/^Subject:.*skinny/ HOLD
/^Subject:.*      / HOLD
/^Subject:.*Easy*/ HOLD
/^From:.*medch*/ HOLD
/^From: "expediti/ HOLD
/^From:.*newsfilm@ds02.01cloud.com/ HOLD
/^From:.*no-reply@answers.medchrome.com*/ HOLD
/^From:.*expediti/ HOLD
/^From:.*tejecraft.com.np*/ HOLD

[root@mx12 postfix]# cat check_sender
gmail.com   REJECT
hotmail.com    REJECT
yahoo.com      REJECT
medch@ds02.01cloud.com  REJECT
expediti@ds01.01cloud.com REJECT
info@tejecraft.com.np REJECT
newsfilm@ds02.01cloud.com REJECT
no-reply@answers.medchrome.com REJECT
info@wexnepal.com REJECT


[]#postmap check_sender
]#vim main.cf

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/check_sender

mailscanner clamd spamassassin-- mailscanner.conf configuratoin part 2

yum install spamassassin

Configuring MailScanner
#check below lines match
vim  /etc/MailScanner/virus.scanners.conf
clamav          /usr/lib/MailScanner/clamav-wrapper     /usr/local
clamd           /bin/false                              /usr/sbin



vim /etc/MailScanner/MailScanner.conf
# **** RULE: It must not contain any spaces! ****
%org-name% = mx12  #give your servername
%org-long-name% =          #your organization full name optional
%web-site% =   #optional
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
Quarantine Dir = /var/spool/MailScanner/quarantine
PID file = /var/run/MailScanner.pid
MTA  = postfix
Incoming Work User =
Incoming Work Group = clam
Incoming Work Permissions = 0640

Virus Scanners = clamd
Clamd Port = 3310
Clamd Lock File =
Clamd Use Threads = no  #just check leave defaults
Clamd Socket = /var/run/clamav/clamd.sock
Use SpamAssassin = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin


===SETUP NECESSARY DIRECTORIES===
cd /var/spool/MailScanner/
mkdir spamassassin
chown -R postfix.clam *
chmod -R 750 *


[root@mx12 MailScanner]# ls -l
total 12
drwxr-x---  9 postfix clam   4096 Aug 21 02:27 incoming
drwxr-x--- 26 postfix apache 4096 Aug 21 00:01 quarantine
drwxr-x---  2 postfix clam   4096 Aug 21 02:17 spamassassin

mailscanner clamd spamassassin- installing clamd and mailscanner part 1

=====install  clamd and mailscanner=====

 first add epel

 yum install clamd
 3. To test ClamAV AntiVirus, type in the command clamscan in a terminal window.
 4. To update the virus database, type in the command freshclam in a terminal window.
 yum install
perl-Archive-Zip
perl-DBI
perl-DBD-SQLite
perl-Filesys-Df
perl-Net-CIDR
perl-OLE-Storage_Lite
perl-Sys-Hostname-Long
perl-Sys-SigAction
perl-MIME-tools

3. Download the latest stable version of MailScanner for RedHat, Fedora and Mandrake Linux at http://www.mailscanner.info/downloads.html.

4. Extract MailScanner using the command below.

tar -xvzf ~/Desktop/MailScanner*.gz

Replace ~/Desktop with the path of your downloaded file

5. Finally, type in the command below to install MailScanner.

cd MailScanner-4.83.5-1
yum install --nogpgcheck mailscanner* tnef*

Replace MailScanner-4.83.5-1 with the path of the extracted MailScanner archive file.

6. To test MailScanner, use the command below.

MailScanner

Errors related to configuration files are ok. Errors saying “Can’t locate xxx.pm” are perl module dependency problems so repeat step 2.

automysql backup auto mysql backup

################### Shell Bash style NO 1###############################
#!/bin/bash
#Script to make a regular copy of a mysql database and gzip it into the SAVEDIR.

USER="authorized_user"
PASSWORD="the_password"
DATABASE="database_name"
SAVEDIR="/backup"

/usr/bin/nice -n 19 /usr/bin/mysqldump -u $USER --password=$PASSWORD --default-character-set=utf8 $DATABASE -c | /usr/bin/nice -n 19 /bin/gzip -9 > $SAVEDIR/$DATABASE-$(date '+%Y%m%d-%H').sql.gz

################### Shell Bash style NO 2###############################
 #!/bin/bash
mysqldump  -u  root  -pyourP@ssword cloud | gzip > /mysqldump/cloud_db_`date '+%m-%d-%Y'`.sql.gz

##############################################################################
AutoMySQLBackup is a clever script that takes the pain out of setting up automated incremental daily, weekly, and monthly backups of MySQL databases. Its only dependency is the mysqldumpcommand, which comes with mysql-client. AutoMySQLBackup dumps your databases at whatever intervals you desire, and rolls them up into compressed tarballs. Then you can copy the tarballs to other media, and encrypt them if you wish.

Getting AutoMySQLBackup

Download AutoMySQLBackup from Sourceforge, and then unpack the tarball:
$ tar zxvf automysqlbackup-v3.0_rc6.tar.gz
Now you should have the automysqlbackup-v3.0_rc6 directory with six files in it: automysqlbackup, automysqlbackup.conf, CHANGELOG, install.sh, LICENSE, and README.
Next, read the README because it contains installation instructions and other useful information. It may not tell you everything you need to know, so hopefully this article will fill the gaps. Then your next step is to run install.sh, and this requires root privileges. If the installation script fails you can easily install AutoMySQLBackup manually by following these steps. These are run from the directory where you unpacked the tarball:
# chown root:root automysqlbackup
# chmod 0700 automysqlbackup
# cp automysqlbackup /usr/local/bin/
# mkdir /etc/automysqlbackup
# cp automysqlbackup.conf /etc/automysqlbackup/automysqlbackup.conf
# cd /etc/automysqlbackup
# cp automysqlbackup.conf servername.conf
Replace "servername.conf" with whatever you want to name your configuration file. Then you will have a copy of the original for reference, and your working configuration file.

Configuration Options

The configuration file is large and well-commented, and you need to change only a few things to start making and testing your backups. First you need to select a MySQL user that has, at a minimum, SELECT privileges, and then enter that user and user's password:
# Username to access the MySQL server e.g. dbuser
CONFIG_mysql_dump_username='db_user'
# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password='sekkritpassword'
There is a complication if you are using Parallels Plesk 10.2 or newer on your server, and you want to authenticate with the admin user. It is better to use a different MySQL user, like one you have created with minimal privileges just for AutoMySQLBackup, but if that is not possible then you can't use the plain-text admin password. Starting with version 10.2 the Plesk admin password is encrypted in /etc/psa/.psa.shadow. You can dump this password in plain text with this command if you need to recover it:
# /usr/local/psa/bin/admin --show-password
But you can't use the plain text password in your AutoMySQLBackup configuration. Instead, use the encrypted password:
# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password=`cat /etc/psa/.psa.shadow`
Your server is localhost, and you need to create or choose a directory to store your backups in:
# Host name (or IP address) of MySQL server e.g localhost
CONFIG_mysql_dump_host='localhost'
# Backup directory location e.g /backups
CONFIG_backup_dir='/home/mysqlbackups'
You have a lot of control over which databases are backed up. If you have a lot of them, then leaving CONFIG_db_names=() empty copies all of them. Then if there are any you want to exclude, just create an exclude list. One of my servers hosts over 150 virtual Web hosts, and each one has its own MySQL database, so this is a huge timesaver for me:
# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_names=()
# List of databases for Monthly Backups.
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_month_names=()
# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ().
CONFIG_db_exclude=('information_schema' 'test_db' 'demo_db' )
Rotation settings are straightforward. This example performs monthly backups on the 3rd of every month, weekly backups on Saturdays, daily backups are kept for 7 days, weekly backups are kept for 14 days, and monthly backups for 30 days.
# Which day do you want monthly backups? (01 to 31)
# If the chosen day is greater than the last day of the month, it will be done
# on the last day of the month.
# Set to 0 to disable monthly backups.
CONFIG_do_monthly="03"
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
# Set to 0 to disable weekly backups.
CONFIG_do_weekly="6"
# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
CONFIG_rotation_daily=7
# Set rotation for weekly backups. VALUE*24hours
CONFIG_rotation_weekly=14
# Set rotation for monthly backups. VALUE*24hours
CONFIG_rotation_monthly=30
There are two items that control notifications. I like to see the logfiles after every run, as this example shows:
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
CONFIG_mailcontent='log'
# Email Address to send mail to? (
 user@domain.com)CONFIG_mail_address='
 carla@tuxcomputing.com'

First Run

For the first few runs, while you're getting familiar with AutoMySQLBackup, I recommend backing up just one or two small databases. It's safe and can't hurt your databases, but the larger your databases the longer it takes to try different configuration tweaks. Run it from the command line like this:
# automysqlbackup /etc/automysqlbackup/servername.conf
Then you can check your backup directory to see if it worked. It should have created all the necessary directories:
# ls /home/mysqlbackups/
daily/  
fullschema/  
latest/  
monthly/  
status/  
tmp/  
weekly/
And made entries like this, for each database you backed up, in the daily/ directory:
-rw-r--r-- 1 root root 66428 Oct 25 00:12 daily_db_name_2012-10-22_00h05m_Monday.sql.gz
AutoMySQLBackup generates a detailed log file, so there will be no mysteries about what happened if anything goes wrong.
The README offers a simple backup script:
#!/bin/sh
/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
chown root.root /var/backup/db* -R
find /var/backup/db* -type f -exec chmod 400 {} \;
find /var/backup/db* -type d -exec chmod 700 {} \;
You'll need to change myserver.conf to your configuration file name, and /var/backup/ to your own backup directory. This script ensures that the backup files owner is root, and that they are read-only, which are simple precautions against accidental changes. Don't forget to make it executable.

Scheduled Backups

Good old cron is still champ for scheduling backups. This example runs the backup script every morning at 12:05AM:
5 0 * * *  /usr/local/bin/backupscript 

Offsite Backups

Now that you have these nice database backups, what do you do with them? I use Horcrux, which we learned about last week, to encrypt and copy them to an offsite backup. So all I have to do to add my database backups to my Horcrux backup is to add this line to my Horcrux configuration:
+ /home/mysqlbackups/
Because these are compressed tarballs, you can manage them like any ordinary files and copy them to whatever backup media you want.
What about restoring from backup? AutoMySQLBackup doesn't offer any special tools for making that any easier, so you'll have to do it manually by first unzipping the backup file, and then using the mysql client to restore your database or databases. The README and forums are helpful, but what will help the most is knowing how to administer MySQL databases.

grep command GREP command

ls -l | grep -i python  # -i  = case insensitive search

ls -l | grep -v "python"   # -v = invert the search , not matching element will be printed

# find . –name "*.mp3" | grep –i JayZ | grep –vi "remix" 

ps -ef | grep -c [h]ttpd  #count number of matching line

cat myfile.txt | grep -n "major12"  # print line number of matching line

cat myfile.txt | grep -w "NepalKTM"  #returns only "NepalKTM" match entire word only
 
cat apache.conf | grep -v "^#"  

check process status and start if it is not running using cron bash

[root@mx12 /]# cat /opt/checkclam.sh
#!/bin/bash
if ! pgrep clamd > /dev/null;
then
/etc/init.d/clamd restart > /dev/null;
else
echo "OK `date +%T\ %F`" >> /program.log; #'\ ' is for space use %t for tab
fi


[root@mx12 /]# crontab -l
*/3 * * * * /opt/checkclam.sh 


== == =====  ===== = =  =  === === ====    == =  ========= =
#!/bin/bash

# Check if gedit is running
if ps aux | grep "[h]ttdp" > /dev/null
then
    echo "Running"
else
    echo "Stopped"
fi
 
This script is just checking to see if the program "httpd" is running.
The square brackets are useful to avoid the output of the grep command. Without this the conditional will always return true, because the grep command start a process with the same content of the searched string.
 = = = =  = = = = = = = = =Check SELINUX and turn it to permissive  = = = = = = = = = = = = = =
#!/bin/bash
var1=`getenforce`
if [ "$var1" == "Permissive" ]
then
    :                             # the " : " colon will do nothing or NO operation
else
/usr/sbin/setenforce 0
fi
 
 
============
 
[root@mailvm /]# cat selinuxcheck 
#!/bin/bash
var1=`getenforce`
#if [ "$var1" == "Permissive" ] 
#then  
#    :
#else 
#/usr/sbin/setenforce 0 
#fi
if [ "$var1" == "Enforcing" ]
then
echo "enforced mode"
printf "Now changing to Permissive"
sleep 1
printf "."
sleep 1
printf "."
/usr/sbin/setenforce 0
else
echo "permissive mode [OK]"  
fi
echo
 
============================================================================= 

ICINGA check postfix mailq in icinga part 3

#icinga  #icinga

#vim /etc/nagios/nrpe.cfg

allowed_hosts=198.50.155.195,  127.0.0.1
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w 300 -c 500

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
root@vps:/usr/lib/nagios/plugins# ls -l /usr/lib/nagios/plugins/check_mailq
-rwxr-xr-x 1 root root 916 Aug 15 16:34 /usr/lib/nagios/plugins/check_mailq*


#cat /usr/lib64/nagios/plugins/check_mailq

#!/bin/bash
#
# 19-07-2010
# Author: Cherwin Nooitmeer <cherwin@gmail.com>
#

# exit codes
e_ok=0
e_warning=1
e_critical=2
e_unknown=3



# regular expression that matches queue IDs (e.g. D71EF7AC80F8)
queue_id='^[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]'

usage="Invalid command line usage"

if [ -z $1 ]; then
    echo $usage
    exit $e_unknown
fi

while getopts ":w:c:" options
do
    case $options in
        w ) warning=$OPTARG ;;
        c ) critical=$OPTARG ;;
        * ) echo $usage
            exit $e_unknown ;;
    esac
done

# determine queue size
qsize=$(mailq | egrep -c $queue_id)
if [ -z $qsize ]
then
    exit $e_unknown
fi

if [ $qsize -ge $critical ]; then
    retval=$e_critical
elif [ $qsize -ge $warning ]; then
    retval=$e_warning
elif [ $qsize -lt $warning ]; then
    retval=$e_ok
fi

echo "$qsize mail(s) in queue | mail_queue=$qsize"
exit $retval




===========@ In ICINGA server -===============
#no need to add nrpe user in sudoer file

# /usr/local/icinga/libexec/check_nrpe -H 5.9.240.227 -c check_mailq
 358 mail(s) in queue | mail_queue=358

ICINGA EXIM mailq script for icinga part 2

========================================================================
check mailq EXIM
 ========================================================================
At client side:-
#rpm -qf utils.pm                                  //tofind the package name of file
#yum install nagios-plugins-perl
do this if you face the"utils.sh not found error". make dir's as needed
#ln -s /usr/lib64/nagios/plugins/utils.sh  /usr/local/nagios/libexec/utils.sh
#visudo
   Comment out    

#Defaults    requiretty             <<<= = =

#add nrpe user like below line
root    ALL=(ALL)       ALL
nrpe ALL=NOPASSWD:/usr/sbin/exim                             
Save/exit
 ***************************************
copybelow script in file name  "check_eximmailqueue"
#ls -l  /usr/lib64/nagios/plugins/check_eximmailqueue
-rwxr-xr-x 1 root root   3285 Jul 27 06:25 check_eximmailqueue*
-rwxr-xr-x 1 root root 172880 Oct 17  2013 check_http*
-rwxr-xr-x 1 root root  40944 Oct 17  2013 check_load*
-rwxr-xr-x 1 root root  22256 Apr 30 21:28 check_nrpe*
-rwxr-xr-x 1 root root  36080 Oct 17  2013 check_users*
-rwxr-xr-x 1 root root  38696 Oct 17  2013 negate*
-rwxr-xr-x 1 root root  36104 Oct 17  2013 urlize*
-rw-r--r-- 1 root root   2091 Oct 17  2013 utils.pm
-rwxr-xr-x 1 root root   2728 Oct 17  2013 utils.sh*
cat /usr/lib64/nagios/plugins/check_eximmailqueue
#!/bin/sh
###############################################
#
# Nagios script to check Exim mail queue status
#
# Copyright 2007, 2008 Ian Yates
#
# NOTE: Depending on your config, the nagios user will probably be
#       needed to be added to the exim group for this script to function correctly
#
# See usage for command line switches
#

. /usr/local/nagios/libexec/utils.sh


VERSION="1.3"

EXIM=$(which exim)
SUDO=/usr/bin/sudo

FLAG_VERBOSE=FALSE
LEVEL_WARN=""
LEVEL_CRIT=""
RESULT=""
EXIT_STATUS=$STATE_OK


###############################################
#
## FUNCTIONS
#

## Print usage
usage() {
    echo " check_eximailqueue $VERSION - Nagios Exim mail queue check script"
    echo ""
    echo " Usage: check_eximailqueue -w <warning queue size> -c <critical queue size> [ -v ] [ -h ]"
    echo ""
    echo "         -w  Queue size at which a warning is triggered"
    echo "         -c  Queue size at which a critical is triggered"
    echo "         -v  Verbose output (ignored for now)"
    echo "         -h  Show this page"
    echo ""
}

## Process command line options
doopts() {
    if ( `test 0 -lt $#` )
    then
        while getopts w:c:vh myarg "$@"
        do
            case $myarg in
                h|\?)
                    usage
                    exit;;
                w)
                    LEVEL_WARN=$OPTARG;;
                c)
                    LEVEL_CRIT=$OPTARG;;
                v)
                    FLAG_VERBOSE=TRUE;;
                *)    # Default
                    usage
                    exit;;
            esac
        done
    else
        usage
        exit
    fi
}


# Write output and return result
theend() {
    echo $RESULT
    exit $EXIT_STATUS
}


#
## END FUNCTIONS
#

#############################################
#
## MAIN
#


# Handle command line options
doopts $@

# Do the do
OUTPUT=`$SUDO -u root $EXIM -bpc`
if test -z "$OUTPUT" ; then
    RESULT="Mailqueue WARNING - query returned no output!"
    EXIT_STATUS=$STATE_WARNING
else
    if test "$OUTPUT" -lt "$LEVEL_WARN" ; then
        RESULT="Mailqueue OK - $OUTPUT messages on queue"
        EXIT_STATUS=$STATE_OK
    else
        if test "$OUTPUT" -ge "$LEVEL_CRIT" ; then
            RESULT="Mailqueue CRITICAL - $OUTPUT messages on queue"
            EXIT_STATUS=$STATE_CRITICAL
        else
            if test "$OUTPUT" -ge "$LEVEL_WARN" ; then
                RESULT="Mailqueue WARNING - $OUTPUT messages on queue"
                EXIT_STATUS=$STATE_WARNING
            fi
        fi
    fi
fi

# Quit and return information and exit status
theend

delete file with inode

ls -il   #list file inode


stat  filename  

SYNTAX-  find . -inum [inode-number] -exec rm -i {} \;

Example:-
 
find . -inum 782263 -exec rm -i {} \;

(a) Create a hard to delete file name:
$ cd /tmp
$ touch "\+Xy \+\8"
$ ls

(b) Try to remove this file with rm command:
$ rm \+Xy \+\8

(c) Remove file by an inode number, but first find out the file inode number:
$ ls -ilOutput:
781956 drwx------  3 viv viv 4096 2006-01-27 15:05 gconfd-viv
781964 drwx------  2 viv viv 4096 2006-01-27 15:05 keyring-pKracm
782049 srwxr-xr-x  1 viv viv    0 2006-01-27 15:05 mapping-viv
781939 drwx------  2 viv viv 4096 2006-01-27 15:31 orbit-viv
781922 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-cnaOtj4013
781882 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-SsCkUW4013
782263 -rw-r--r--  1 viv viv    0 2006-01-27 15:49 \+Xy \+\8
Note: 782263 is inode number.
(d) Use find command to delete file by inode:
Find and remove file using find command, type the command as follows:
$ find . -inum 782263 -exec rm -i {} \;