Sponsored Content
Top Forums Shell Programming and Scripting Perl script to calculate failure ratio Post 302871455 by infinitydon on Wednesday 6th of November 2013 08:29:25 AM
Old 11-06-2013
Perl script to calculate failure ratio

Hello geeks, Find below a Perl script am writing to calculate some failure rate in our GPRS network, am just starting to use perl for scripting.

Code:
#!/usr/bin/perl
#Script written to calculate the following:
#PDP activation failure rate for every 15 minutes interval
#Number of Active PDP Contexts
#Script makes use of expect script statement also.
#Script written  by Gbenga Adigun; email: adigun.gbenga@ercisson.com

use diagnostics;
use strict;
use warnings;

#### First Data Collection
sub pdpsub {
system ("expect /tmp/pdp \$1 > /tmp/\$\$pdp");

##ATTEMPTED ACTIVATIONS____WEB APN
my $attweb1=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 1`;

##COMPLETED ACTIVATIONS____WEB APN
my $compweb1=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 1`;

##ATTEMPTED ACTIVATIONS____BB APN
my $attbb1=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

##COMPLETED ACTIVATIONS____BB APN
my $compbb1=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;
system ("rm /tmp/\$\$pdp");

sleep 20;

##### Second Data Collection with the Number of Active PDP contexts
system ("expect /tmp/pdp \$1 > /tmp/\$\$pdp");
my $pdp=`cat /tmp/\$\$pdp | grep "pdp-active:" | head -n 1 | awk '{print \$2}'`;

##ATTEMPTED ACTIVATIONS____WEB APN
my $attweb2=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 1`;

##COMPLETED ACTIVATIONS____WEB APN
my $compweb2=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 1`;

##ATTEMPTED ACTIVATIONS____BB APN
my $attbb2=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

##COMPLETED ACTIVATIONS____BB APN
my $compbb2=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

####CALCULATION PART
my $attweb3 = $attweb2 - $attweb1;
my $compweb3 = $compweb2 - $compweb1;
my $attbb3 = $attbb2 - $attbb1;
my $compbb3 = $compbb2 - $compbb1;
my $failpdpweb = (($attweb3 - $compweb3)/$attweb3)*100;
my $failpdpbb = (($attbb3 - $compbb3)/$attbb3)*100;
print $failpdpweb;
print $failpdpbb;
print $pdp;
system ("rm /tmp/\$\$pdp");
}

&pdpsub 192.168.12.177;

But perl keeps giving the following error:
Code:
String found where operator expected at test.pl line 60, near "&pdpsub
        "192.168.12.177"" (#1)

syntax error at test.pl line 60, near "&pdpsub "192.168.12.177""

Uncaught exception from user code:
        syntax error at test.pl line 60, near "&pdpsub "192.168.12.177""
Execution of test.pl aborted due to compilation errors.

I will appreciate any feedback, i tried using bash scripting but the calculation part seems to be giving more problems.

Thanks!

Last edited by vbe; 11-06-2013 at 10:21 AM..
 

10 More Discussions You Might Find Interesting

1. Solaris

Fragmentation Ratio

All. How can i calculate the fragmentation ratio on a mounted disk, given that i have no root privilege and i cannot switch to single user mode. (0 Replies)
Discussion started by: Negm
0 Replies

2. UNIX for Dummies Questions & Answers

16:9 aspect ratio in X windows

How do I set X so that it has a 16:9 aspect ratio? I am trying to load it onto a display monitor, the bootloader and comand line run in 16:9 but when x starts it goes to a normal ratio. (0 Replies)
Discussion started by: Winzernotman
0 Replies

3. Shell Programming and Scripting

How can use the perl or other command line to calculate the length of the character?

For example, if I have the file whose content are: >HWI-EAS382_30FC7AAXX:7:1:927:1368 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >HWI-EAS382_30FC7AAXX:7:1:924:1373 ACGAACTTTAAAGCACCTCTTGGCTCGTATGCCGTC I want my output calculate the total length of nucleotide. So my output should look like this:... (1 Reply)
Discussion started by: patrick chia
1 Replies

4. UNIX for Dummies Questions & Answers

Write catch hit ratio

Dear friends, Does any one know about alert "write catch hit ratio" on Solaris 9? How to avoid???? (0 Replies)
Discussion started by: solaris5.10
0 Replies

5. Shell Programming and Scripting

using perl to calculate frequency and multiply

Suppose u have two input files FILE A and FILE B FILE A AACD ABBD ACBC FILE B s/ A B C D E A 1 -2 3 4 2 B 3 2 -1 2 1 C 2 3 1 2 3 D 3 4 -3 2 2 E 1 3 4 2 3 So in FILE A we have calculated frequency... (3 Replies)
Discussion started by: cdfd123
3 Replies

6. Programming

perl - calculate the number of lines from particular files

Hi, plz see the below code. here my aim is to calculate the number of lines in unprocessedData.out if this file contains 40 lines then lastly $linenum should print 40.(except blank lines) i have tried below code but it giving me the output only one. can anyone help me how to do ? ... (9 Replies)
Discussion started by: pspriyanka
9 Replies

7. Shell Programming and Scripting

Calculate average from CSV file using PERL script

Hi All I have this csv file and I need to calculate the average of FPS. FPS:27.7420, Interval:1314184238772 FPS:25.9798, Interval:1314184242646 FPS:27.4772, Interval:1314184246311 FPS:26.1623, Interval:1314184250159 FPS:26.4515, Interval:1314184253972 FPS:31.5896, Interval:1314184257163... (24 Replies)
Discussion started by: sayachop
24 Replies

8. Shell Programming and Scripting

AWK: calculate ratio of columns

Hi all, I have a tab-delimited text file in which i have a few columns which look like, X Y U V 2 3 4 5 4 5 3 4 6 4 3 2 For example, I want to calculate the ratio (X+Y)/(X+Y+U+V) for each row and print the output. X Y U V ... (3 Replies)
Discussion started by: mehar
3 Replies

9. Shell Programming and Scripting

Computing the ratio of similar columns in the two files using awk script

Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2". awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2 First can anyone explain that what is the purpose of assigning a =1? Second, the current script is printing out the matched columns between the... (4 Replies)
Discussion started by: coder83
4 Replies

10. Shell Programming and Scripting

Calculate time difference between pst and pdt dates in perl

Hi, how to calculate the time difference between PST date and PDT date in perl scripting. date1: Mon Dec 31 16:00:01 PST 2015 date2: Tue Mar 19 06:09:30 PDT 2013 and also difference between PST-PST and PDT-PDT need difference in months or days (months prefereble). (3 Replies)
Discussion started by: praveen265
3 Replies
BALLView(1)						      General Commands Manual						       BALLView(1)

NAME
BALLView - A free molecular modeling and molecular graphics tool SYNOPSIS
BALLView [Molecular-file] DESCRIPTION
BALLView BALLView provides fast OpenGL-based visualization of molecular structures, molecular mechanics methods (minimization, MD simula- tion using the AMBER and CHARMM force fields), calculation and visualization of electrostatic properties (FDPB). BALLView is based on BALL (Biochemical Algorithms Library) , which is currently being developed in the groups of Oliver Kohlbacher (Univer- sity of Tuebingen, Germany), Andreas Hildebrandt (Saarland University, Saarbruecken, Germany), and Hans-Peter Lenhof (Saarland University, Saarbruecken, Germany). BALL is an application framework in C++ that has been specifically designed for rapid software development in Molecular Modeling and Computational Molecular Biology. It provides an extensive set of data structures as well as classes for Molecular Mechanics, advanced solvation methods, comparison and analysis of protein structures, file import/export, and visualization. BALLView is available under the LGPL licence. Homepage: www.BALLView.org USAGE
To run BALLView, simply type: BALLView or BALLView file.pdp where file.pdb is your PDB file. BALLView also supports HIN, MOL, MOL2 and SD files. BALLView provides HTML documentation, that is available in the application itself (see Help menu). This package also includes Python example scripts, that can be run in BALLView. They can be found under /usr/share/BALL/PYTHON. AUTHOR
BALLView is copyright 1998-2009 by the BALL project group SEE ALSO
http://www.ballview.org 24 January 2009 BALLView(1)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy