<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how generate an event  when only an interface become down after N minutes ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822216#M84033</link>
    <description>Jul 18, 2006 12:23:14 GMT    N/A: Question Author   &lt;BR /&gt;&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;i have created thoses two scripts&lt;BR /&gt;the first one is executed when for exemple an interface goes down and the seconde when it become up:&lt;BR /&gt;&lt;BR /&gt;=================================================&lt;BR /&gt;when interface goes down this script is executed&lt;BR /&gt;================================================&lt;BR /&gt;#!/opt/OV/bin/Perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my $arg = $ARGV[0];&lt;BR /&gt;my @indexe = (2, 3, 9, 10, 11, 25);&lt;BR /&gt;Hm,&lt;BR /&gt;assigning points to all responds will be nice...&lt;BR /&gt;From your code it looks like if the argument to the script is "2"; then create the file ; then check if the file exists (of course it will exist -you created it); then send e-mail.&lt;BR /&gt;&lt;BR /&gt;if($arg == $index[0])&lt;BR /&gt;{&lt;BR /&gt;system("touch lockfile");&lt;BR /&gt;sleep 10;&lt;BR /&gt;$file = 'lockfile';&lt;BR /&gt;if(-e $file)&lt;BR /&gt;{&lt;BR /&gt;#if file existe send mail to toto&lt;BR /&gt;system "/opt/OV/bin/sendmail 'inteface is Down' toto@";&lt;BR /&gt;exec "rm lockfile";&lt;BR /&gt;}&lt;BR /&gt;} &lt;BR /&gt;</description>
    <pubDate>Tue, 18 Jul 2006 07:58:47 GMT</pubDate>
    <dc:creator>Alexander Chuzhoy</dc:creator>
    <dc:date>2006-07-18T07:58:47Z</dc:date>
    <item>
      <title>how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822210#M84027</link>
      <description>I have configured perl script that send me an email event whenever a stat of a managed  router  interface become DOWN or UP.&lt;BR /&gt;to avoide receiving a lot of email alert due interface reset. &lt;BR /&gt;how to make the event generated only when an interface is down for exemple at least for 3 minutes?&lt;BR /&gt;&lt;BR /&gt;many Thanks</description>
      <pubDate>Wed, 12 Jul 2006 10:24:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822210#M84027</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-12T10:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822211#M84028</link>
      <description>You could create a "lock" file to identify that the mail already was sent. for example:&lt;BR /&gt;&lt;BR /&gt;if interface down then&lt;BR /&gt;  check if lock file exists&lt;BR /&gt;  if lock file does not exists&lt;BR /&gt;    create lock file&lt;BR /&gt;    send email alert&lt;BR /&gt;  if lock file exists&lt;BR /&gt;    do nothing&lt;BR /&gt;  fi&lt;BR /&gt;fi&lt;BR /&gt;if interface up then&lt;BR /&gt;  remove lock file&lt;BR /&gt;  send email notification&lt;BR /&gt;fi</description>
      <pubDate>Wed, 12 Jul 2006 12:14:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822211#M84028</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2006-07-12T12:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822212#M84029</link>
      <description>You can use "threads" functionality.&lt;BR /&gt;So as soon as your interface goes down.&lt;BR /&gt;Another thread starts and counts the time (3 minutes in your example).&lt;BR /&gt;Upon this thread's closure-the parent will generate an email...&lt;BR /&gt;Hope it helps.&lt;BR /&gt;&lt;BR /&gt;P.S.&lt;BR /&gt;How do you monitor the router's interface - just curious.</description>
      <pubDate>Thu, 13 Jul 2006 06:01:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822212#M84029</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2006-07-13T06:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822213#M84030</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;I have made a script tha combine the two suggestions &lt;BR /&gt;lockfile and sleep fonction&lt;BR /&gt;&lt;BR /&gt;it work now :-)&lt;BR /&gt;&lt;BR /&gt;thank you&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jul 2006 06:11:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822213#M84030</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-13T06:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822214#M84031</link>
      <description>Good marouanej and welcome to the forum.&lt;BR /&gt;&lt;BR /&gt;Please see also:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;</description>
      <pubDate>Thu, 13 Jul 2006 09:02:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822214#M84031</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2006-07-13T09:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822215#M84032</link>
      <description>i have created thoses two scripts&lt;BR /&gt;the first one is executed when for exemple an interface goes down and the seconde when it become up:&lt;BR /&gt;&lt;BR /&gt;=================================================&lt;BR /&gt;when interface goes down this script is executed&lt;BR /&gt;================================================&lt;BR /&gt;#!/opt/OV/bin/Perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my $arg = $ARGV[0];&lt;BR /&gt;my @indexe = (2, 3, 9, 10, 11, 25);&lt;BR /&gt;&lt;BR /&gt;if($arg == $indexe[0])&lt;BR /&gt;{&lt;BR /&gt;system("touch lockfile");&lt;BR /&gt;sleep 10;&lt;BR /&gt;$file = 'lockfile';&lt;BR /&gt;if(-e $file)&lt;BR /&gt;{&lt;BR /&gt;#if file existe send mail to toto&lt;BR /&gt;system "/opt/OV/bin/sendmail 'inteface is Down'  toto@";&lt;BR /&gt;exec "rm lockfile";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;==============================================&lt;BR /&gt;when interface become up this script is executed&lt;BR /&gt;===============================================&lt;BR /&gt;&lt;BR /&gt;#!/opt/OV/bin/Perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my $arg = $ARGV[0];&lt;BR /&gt;my @indexe = (2, 3, 9, 10, 11, 25);&lt;BR /&gt;&lt;BR /&gt;if($arg == $indexe[0])&lt;BR /&gt;{&lt;BR /&gt;$file = 'lockfile';&lt;BR /&gt;if(-e $file)&lt;BR /&gt;{&lt;BR /&gt;exec "rm lockfile";&lt;BR /&gt;}&lt;BR /&gt;else{&lt;BR /&gt;system("/opt/OV/bin/sendmail 'interface is up'  toto@");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;===============================&lt;BR /&gt;when i execute the script at the unix command line the lockfile is created . but when i shutdown the interface evenif the lockfile is not created i receive   "interface is down "email notification.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;many thanks</description>
      <pubDate>Tue, 18 Jul 2006 07:23:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822215#M84032</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-18T07:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822216#M84033</link>
      <description>Jul 18, 2006 12:23:14 GMT    N/A: Question Author   &lt;BR /&gt;&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;i have created thoses two scripts&lt;BR /&gt;the first one is executed when for exemple an interface goes down and the seconde when it become up:&lt;BR /&gt;&lt;BR /&gt;=================================================&lt;BR /&gt;when interface goes down this script is executed&lt;BR /&gt;================================================&lt;BR /&gt;#!/opt/OV/bin/Perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my $arg = $ARGV[0];&lt;BR /&gt;my @indexe = (2, 3, 9, 10, 11, 25);&lt;BR /&gt;Hm,&lt;BR /&gt;assigning points to all responds will be nice...&lt;BR /&gt;From your code it looks like if the argument to the script is "2"; then create the file ; then check if the file exists (of course it will exist -you created it); then send e-mail.&lt;BR /&gt;&lt;BR /&gt;if($arg == $index[0])&lt;BR /&gt;{&lt;BR /&gt;system("touch lockfile");&lt;BR /&gt;sleep 10;&lt;BR /&gt;$file = 'lockfile';&lt;BR /&gt;if(-e $file)&lt;BR /&gt;{&lt;BR /&gt;#if file existe send mail to toto&lt;BR /&gt;system "/opt/OV/bin/sendmail 'inteface is Down' toto@";&lt;BR /&gt;exec "rm lockfile";&lt;BR /&gt;}&lt;BR /&gt;} &lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 07:58:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822216#M84033</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2006-07-18T07:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822217#M84034</link>
      <description>1. check if rm is alias to rm -i&lt;BR /&gt;2. try to increase the sleep time from 10 to 30 (for test purposes).</description>
      <pubDate>Tue, 18 Jul 2006 08:04:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822217#M84034</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2006-07-18T08:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822218#M84035</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;how to specify the path for the created lockfile ?&lt;BR /&gt;or&lt;BR /&gt;without specifying the path where the lockfile is created?</description>
      <pubDate>Tue, 18 Jul 2006 09:09:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822218#M84035</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-18T09:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822219#M84036</link>
      <description>without specifying the path the lockfile is created in the current directory.&lt;BR /&gt;Specifying lockfile with path is very simple:&lt;BR /&gt;&lt;BR /&gt;$lockfile="/tmp/lockfile";&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 09:27:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822219#M84036</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2006-07-18T09:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822220#M84037</link>
      <description>can I test the lockfile with the path?&lt;BR /&gt;&lt;BR /&gt;..&lt;BR /&gt;$lockfile="/opt/OV/bin/lockfile";&lt;BR /&gt;system "touch $lockfile";&lt;BR /&gt;sleep 30;&lt;BR /&gt;if(-e $file)&lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 10:18:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822220#M84037</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-18T10:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822221#M84038</link>
      <description>in your last example $lockfile was the variable name, so it should be:&lt;BR /&gt;if ( -e $lockfile) {&lt;BR /&gt;     "some expression";&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 11:30:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822221#M84038</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2006-07-18T11:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: how generate an event  when only an interface become down after N minutes ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822222#M84039</link>
      <description>excuse me for been late to response you.&lt;BR /&gt;but the problem remain:&lt;BR /&gt;the first script create the file but the seconde doesn't delete the created file:&lt;BR /&gt;i'm sure that the first script is executed first but the second script wait until the first script terminate.&lt;BR /&gt;evenif the the time between the two stats (Down &amp;amp;UP) is enough lower than 160second.&lt;BR /&gt;logup*(see the script) containe always this error:&lt;BR /&gt;rm: /opt/OV/bin/lockfile non-existent&lt;BR /&gt;-------&lt;BR /&gt;_______________________________________&lt;BR /&gt;Script_DOWN&lt;BR /&gt;_______________________________________&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;if($arg == $indexe[0])&lt;BR /&gt;{&lt;BR /&gt;$lockfile="/opt/OV/bin/lockfile";&lt;BR /&gt;system "touch $lockfile";&lt;BR /&gt;sleep 150;&lt;BR /&gt;if(-e $lockfile)&lt;BR /&gt;{&lt;BR /&gt;system "/opt/OV/bin/sendmail 'Interface Down'  toto@st.com";&lt;BR /&gt;exec "rm $lockfile &amp;gt; /opt/OV/bin/lockdown 2&amp;gt;&amp;amp;1";&lt;BR /&gt;}else&lt;BR /&gt;}&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;_________________________________________&lt;BR /&gt;Script_UP&lt;BR /&gt;_______________________________________&lt;BR /&gt;&lt;BR /&gt;#!/opt/OV/bin/Perl/bin/perl&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;if($arg == $indexe[0])&lt;BR /&gt;{&lt;BR /&gt;$lockfile="/opt/OV/bin/lockfile";&lt;BR /&gt;if(-e $lockfile){&lt;BR /&gt;exec "rm $lockfile &amp;gt; /opt/OV/bin/lockup 2&amp;gt;&amp;amp;1";&lt;BR /&gt;}&lt;BR /&gt;else{&lt;BR /&gt;system "/opt/OV/bin/sendmail 'Interface Down'  toto@st.com";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{}&lt;BR /&gt;.&lt;BR /&gt;.</description>
      <pubDate>Wed, 26 Jul 2006 13:17:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-generate-an-event-when-only-an-interface-become-down-after-n/m-p/3822222#M84039</guid>
      <dc:creator>marouanej</dc:creator>
      <dc:date>2006-07-26T13:17:01Z</dc:date>
    </item>
  </channel>
</rss>

