Sponsored Content
Top Forums Shell Programming and Scripting Please help me to finish this scripts Post 302542744 by momo0617 on Thursday 28th of July 2011 12:30:51 PM
Old 07-28-2011
Please help me to finish this scripts

Hi All,

Can anyone help me to finish the scripts. this scripts is
this scripts will run on crontab in every 4 minutes to get the newest router interface status.

I would like to add a function to count the router interface flapping, if more than 2 times in 20 minutes (scripts run 5 times) then will sent out an email. But I know my programme knowledge is week. Can anyone help me to finish this. thanks.

Code:
dir=/testing
capturelog=$dir/capture.log
flapcountlog=$dir/flapcount.log
ovcmd=/opt/OV/bin/ovtopodump
$ovcmd | grep "Critical" > $capturelog
if [ -f $capturelog ]; then
        while read line
        do
        routername=`echo $line | awk '{print $3}'`
        interface=`echo $line | awk '{print $5}'`
        status=`echo $line | awk '{print $4}'`
        count=11111
 counter=`echo $count | cut -b 2-`
        
 if [ "$status" ]; then
  if [ -f $capturelog ]; then
   while read line
          do
   flaprouter=`echo $line | awk '{print $1}'`
          flapinterface=`echo $line | awk '{print $2}'`
   flapcount=`echo $line | awk '{print $4}'`
   if [ $routername -eq $flaprouter ]; then
    if [ $interface -eq $flapinterface ]; then
     $count=$flapcount
    else
     $count=$count
    fi
   else
    $count=$count
   fi
   done < $flapcountlog
  $count="$count0"
 else
  $count="$count1"
                fi
        echo $count
        echo $counter
 echo "$routername\t$interface\t$status\t$counter\n" > $flapcountlog
 
        done < $capturelog
else
        echo "missing"
fi
cat $flapcountlog
if [ -f $flapcountlog ]; then
        while read line
        do
 $count
 flapcount=`echo $count | awk '{ x=gsub("0",""); print x }'`
        if [ flapcount >= 2 ]; then
  echo "flapping"
  echo $flapcount
  mailx -s "$subject" "testing@email.com"
 else
  echo "normal"
  echo $flapcount
  mailx -s "$subject" "testing@email.com"
 fi
        done < $flapcountlog

Code:
#####################################
#XXXX IP ROUTERA.XXXX.com  Critical    192.168.1.1
#XXXX IP ROUTERB.XXXX.com Critical    192.168.1.2
#XXXX IP ROUTERC.XXXX.com Critical    192.168.1.3
#XXXX IP ROUTERD.XXXX.com  Critical    192.168.1.4
#XXXX IP ROUTERE.XXXX.com   Critical    192.168.1.5
#####################################


Last edited by pludi; 07-28-2011 at 05:36 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

jumpstart - finish scripts

hi, where i can find some help on how to write finish scripts for jump-start?? i tried sun-blueprints but i couldnt find it... (2 Replies)
Discussion started by: dorilevy
2 Replies

2. UNIX for Advanced & Expert Users

How can I wait for PID to finish in another shell

Have a need to schedule programs that can run after other programs are completed. Here's the catch: 1) The list of programs will not always be the same (kind of a plug-n-play deal) 2) The invoking shell may not be the same as the shell of the program being waited on In other words, I need... (2 Replies)
Discussion started by: superdelic
2 Replies

3. UNIX for Dummies Questions & Answers

how do i finish this last one..

i tried to build a command to replaces the word "include" with "exclude" in each *.h type of file in a certain directory and to display the lines in which the switch happened. i did a command and i dont know why its not working find /usr -name "*.h" -exec sed 's/include/exclude/g' {} \;... (2 Replies)
Discussion started by: newby2
2 Replies

4. UNIX for Advanced & Expert Users

commands do not finish

Hi, I have strange problem executing some command on solaris 5.9 ps command does not finish(hangs) and runs forever without any result. same with cc command too.Please suggest (1 Reply)
Discussion started by: Raom
1 Replies

5. Shell Programming and Scripting

How to make parent shell finish last?

Hi all, I have a shell that kicks off several sub-shells and make them run parallelly, like: shell1.sh & shell2.sh & shell2.sh & ... However, since all sub-shells run parallely, the parent shell finished right after it's submitted, like: $ parent.sh & $ + Done parant.sh & $ ... (2 Replies)
Discussion started by: visio2000
2 Replies

6. Shell Programming and Scripting

Finish script help

I am trying to add a finish script that can copy hosts, static routes and a few other files into relevant directories on a client system. These files would be mounted as nfs resource on the client as hosts.hostname, static_route.hostname etc. Script will compare the hostname of the client and copy... (0 Replies)
Discussion started by: c0kazaz
0 Replies

7. Shell Programming and Scripting

finish of file

Hello, I'm doing a script where I'm traveling a file, and moves down line by line, and is copied to another file, up to the line 100, then the smaller file passes to another format ... but the problem I have is that if there are 357 lines for example, file 1 2 i 3, converted correctly but the 4... (1 Reply)
Discussion started by: uri_crack
1 Replies

8. Shell Programming and Scripting

How to WAIT for jobs in each group to finish?

I have the shell script to call a Perl routine and pass the Informatica WorkFlow name to it. Jobs in each group executes in background do not seem to wait at all. How do I make it to WAIT for the prior group to complete before execute the next group of jobs? Sample of the jobs flow: { ... (6 Replies)
Discussion started by: lv99
6 Replies

9. Shell Programming and Scripting

Waiting a job to finish

Hello again, I am runnning a job on a cluster and I submit a job with the command qsub script.sh where script.sh is a script with the command i want o use. When i enter this command the cluster gives a huber like 123456 as the JOB ID. I want the job to run about 12 hours and when it... (5 Replies)
Discussion started by: lengolass
5 Replies

10. Shell Programming and Scripting

Who can finish this script?

Good morning dear friends, I want to write an UNIX script to do the following task: We have 6 directories, called (SMS_01, SMS_02 ....... SMS_06), some files are distributed across these directories, but the distribution process is not good, I mean when I check these directories I found the... (14 Replies)
Discussion started by: Mohannad
14 Replies
DH_INSTALLMODULES(1)						     Debhelper						      DH_INSTALLMODULES(1)

NAME
dh_installmodules - register kernel modules SYNOPSIS
dh_installmodules [debhelperoptions] [-n] [--name=name] DESCRIPTION
dh_installmodules is a debhelper program that is responsible for registering kernel modules. Kernel modules are searched for in the package build directory and if found, preinst, postinst and postrm commands are automatically generated to run depmod and register the modules when the package is installed. These commands are inserted into the maintainer scripts by dh_installdeb(1). FILES
debian/package.modprobe Installed to etc/modprobe.d/package.conf in the package build directory. OPTIONS
-n, --no-scripts Do not modify preinst/postinst/postrm scripts. --name=name When this parameter is used, dh_installmodules looks for and installs files named debian/package.name.modprobe instead of the usual debian/package.modprobe NOTES
Note that this command is not idempotent. dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_INSTALLMODULES(1)
All times are GMT -4. The time now is 06:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy