The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help for a perl script - writing to a data file meghana Shell Programming and Scripting 2 02-04-2008 05:05 PM
Perl Unix Script Writing Dinkster UNIX for Dummies Questions & Answers 1 02-01-2008 04:09 PM
Writing CGI scripting using perl alma Shell Programming and Scripting 7 04-23-2007 09:46 PM
help for writing a script amodha UNIX for Dummies Questions & Answers 2 04-10-2006 06:21 AM
Writing perl module jo_aze Shell Programming and Scripting 4 08-06-2003 11:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-01-2008
eliraza6 eliraza6 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 56
yeah actually but I need it to be taken from the treshold file and not hardcoded as a text in the script you wrote...

thanks radoulov you are simply a saver...!
  #2 (permalink)  
Old 12-02-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
With some assumptions:

Code:
#! /usr/bin/env perl


use warnings;
use strict;

my ($Thresholds_f, $Queue) = 
  ('/users/tibprod/scripts/EMS_Queue_List_leaiprod.ls', 
   '/users/tibprod/scripts/ShowQueues_leaiprod.sh|');
my %Thresholds_h;

open TH, '<', $Thresholds_f  or die "$Thresholds_f: $!\n";
  
while (<TH>) {
  tr/"//d;
  my @Fields = split /\s{3,}/;
  $Thresholds_h{$Fields[0]} = [@Fields[1..4]];
  }

close TH;  


open QUEUE, $Queue or die "$Queue: $!\n";

while (<QUEUE>) {
  next unless /\w+\s+/;
  my $Flag = 0;
  my @Fields = split /\s+/;
  while (my($Key, $Ref) = each %Thresholds_h) {
    my @Values = @$Ref;
    if ($Fields[0] =~ /^$Key$/) {
      if ($Values[0] =~ s/^"*-//) {
        if ($Fields[1] < $Values[0]) {
        print "\n$Fields[0] ...".
        "\n\n\t--> task threshold exceeded: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      -", $Values[0], "\n\n";
        defined $Values[2] and print $Values[2], "\n\n";
        $Flag++
          }
        }
      elsif ($Fields[1] > $Values[0]) {
        printf "\n$Fields[0] ..." unless $Flag;
        print "\n\n\t--> task threshold exceeded: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      ", $Values[0], "\n\n";
        defined $Values[2] and print $Values[2], "\n\n";
        $Flag++
        }        
      if ($Values[1] =~ s/^"*-//) {
        if ($Fields[2] < $Values[1]) {
         printf "\n$Fields[0] ..." unless $Flag;
         print "\n\t--> listeners threshold exceeded: \n\n\tcurrent status: ",
        $Fields[2], "\n\tthreshold:      -", $Values[1], "\n\n";
        defined $Values[3] and print $Values[3], "\n\n";
        $Flag++
        }
      }
      elsif ($Fields[2] > $Values[1]) {
        printf "\n$Fields[0] ..." unless $Flag;
        print "\n\n\t--> listeners threshold exceeded: \n\n\tcurrent status: ",
        $Fields[2], "\n\tthreshold:      ", $Values[1], "\n\n",
        defined $Values[3] and print $Values[3], "\n\n";
      }      
    }
  }
}  
  
close QUEUE;
  #3 (permalink)  
Old 12-02-2008
eliraza6 eliraza6 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 56
well now i'm not getting any results as an output...

i think there is a problem with the split...

Code:
  my @Fields = split /\s{3,}/;

Last edited by eliraza6; 12-02-2008 at 09:57 AM..
  #4 (permalink)  
Old 12-02-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
What you have between "pl-it_prod.GW.Sync.reply.*" and "500"?
Space(s), tab(s)? How many?
  #5 (permalink)  
Old 12-02-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
Try changing this:

Code:
my @Fields = split /\s{3,}/;
to:

Code:
my @Fields = split /"\s+"/;
  #6 (permalink)  
Old 12-02-2008
eliraza6 eliraza6 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 56
I have tabs...

now i'm getting only the second word in the text:

Code:
[root@leaiprod1 scripts]# ./temp7.pl

pl-it_prod.GW.Sync.reply.SCPROD.Upd_Soc_List ...
        --> listeners threshold exceeded:

        current status: 2
        threshold:      -10

for
  #7 (permalink)  
Old 12-02-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
Quote:
Originally Posted by eliraza6 View Post
I have tabs...
[...]
Then it's easier:

Code:
my @Fields = split /\t/;
or (if more than one tab):

Code:
my @Fields = split /\t+/;
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0