Perl script to monitor memory usage on unix box

2010-02-08 Thread Dave Tang
Hi everybody, I want to write a script that checks memory usage of my RHEL box, and ran as a cron job say every 10 minutes. I could write the Perl script to run a system command like ps aux, parse that information and kill a job if 90% of the total system memory (and I realise most of

Re: Perl script to monitor memory usage on unix box

2010-02-08 Thread Shawn H Corey
Dave Tang wrote: Hi everybody, I want to write a script that checks memory usage of my RHEL box, and ran as a cron job say every 10 minutes. I could write the Perl script to run a system command like ps aux, parse that information and kill a job if 90% of the total system memory (and I

Re: Perl script to monitor memory usage on unix box

2010-02-08 Thread Dave Tang
On Mon, 08 Feb 2010 22:52:37 +1000, Shawn H Corey shawnhco...@gmail.com wrote: Dave Tang wrote: Hi everybody, I want to write a script that checks memory usage of my RHEL box, and ran as a cron job say every 10 minutes. I could write the Perl script to run a system command like ps aux,

Re: Perl script to monitor memory usage on unix box

2010-02-08 Thread Shawn H Corey
Dave Tang wrote: Very recently a user wrote a script that crashed the server, by using all the memory. So also I wanted to capture the process information too. Is this information available in the /proc directory? Yes, google linux proc. -- Just my 0.0002 million dollars worth, Shawn

Re: piddle in hash

2010-02-08 Thread Patrick Dupre
On Sun, 7 Feb 2010, Patrick Dupre wrote: Hello, I have been unsuccessful in getting the piddle values when I store them in a hash so, I am asking to the list. This works OK: test_pdl (array) pdl *array CODE: PDL - converttype (array, PDL_D, 1) ; Sorry, I finally I know how to do it. I

Re: Perl script to monitor memory usage on unix box

2010-02-08 Thread Yue Chen
Hi Dave Have you ever tried module Proc-ProcessTable? It is a wonderful tool to collect process information such as PID, cmdline, CPU usage and Mem usage. Hi everybody, I want to write a script that checks memory usage of my RHEL box, and ran as a cron job say every 10 minutes. I could

Re: Basic Perl Questions

2010-02-08 Thread PolyPusher
On Feb 3, 2:26 pm, jwkr...@shaw.ca (John W. Krahn) wrote: PolyPusher wrote: Hi All, Hello, I have some Perl experience but has been awhile.   I mainly write SKILL lisp programs for Cadence CAD for a layout group(we are a IC design center). I have a CBR(describes circuit) file and

sequential value check

2010-02-08 Thread Curt Shaffer
I'm trying to figure out a way to compare a couple values to see if they are sequential or not. I'm running a for loop and grabbing a value and setting a variable through each iteration. At the end I would like to examine the results and see if they are sequential or not. If the values are

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS I'm trying to figure out a way to compare a couple values to see CS if they are sequential or not. I'm running a for loop and CS grabbing a value and setting a variable through each iteration. At CS the end I would like to examine the

Re: sequential value check

2010-02-08 Thread Curt Shaffer
OK. So I have tried some things. I guess the largest issue that I can't find an answer for elsewhere is how to evaluate variables to be , = or 100 in one evaluation. Before I get there, obviously I need to get the variables. Here is what I am trying to do for that: @hping_array = (); $hcount

Re: sequential value check

2010-02-08 Thread Jim Gibson
On 2/8/10 Mon Feb 8, 2010 3:55 PM, Curt Shaffer cshaf...@gmail.com scribbled: OK. So I have tried some things. I guess the largest issue that I can't find an answer for elsewhere is how to evaluate variables to be , = or 100 in one evaluation. Before I get there, obviously I need to get

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS OK. So I have tried some things. I guess the largest issue that I CS can't find an answer for elsewhere is how to evaluate variables to CS be , = or 100 in one evaluation. Before I get there, obviously CS I need to get the variables.

Syntax for if

2010-02-08 Thread Chris Coggins
What is the proper syntax for a comparison at the end of a subroutine to stop the script if a certain variable is 0 or ''? sub routine{ (get data and process it) if $varA = '' || $varA = 0 { (stop script, print error message to user) } else{ (continue with script) } -- To unsubscribe, e-mail:

Re: Syntax for if

2010-02-08 Thread Jim Gibson
On 2/8/10 Mon Feb 8, 2010 4:56 PM, Chris Coggins cacogg...@cox.net scribbled: What is the proper syntax for a comparison at the end of a subroutine to stop the script if a certain variable is 0 or ''? sub routine{ (get data and process it) if $varA = '' || $varA = 0 { (stop script,

Re: Syntax for if

2010-02-08 Thread 7
On 2/8/10, Chris Coggins cacogg...@cox.net wrote: What is the proper syntax for a comparison at the end of a subroutine to stop the script if a certain variable is 0 or ''? sub routine{ (get data and process it) if $varA = '' || $varA = 0 { (stop script, print error message to user) }

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Thanks Jim. I see my error now. I didn't realize you could just backtick in a for like that. On Feb 8, 2010, at 7:06 PM, Jim Gibson wrote: On 2/8/10 Mon Feb 8, 2010 3:55 PM, Curt Shaffer cshaf...@gmail.com scribbled: OK. So I have tried some things. I guess the largest issue that I

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Thanks for the clue. I have narrowed some things down. The counter is much nicer. I just need to get a better split I think as I'm not getting the grouping I would like. On Feb 8, 2010, at 7:19 PM, Uri Guttman wrote: CS == Curt Shaffer cshaf...@gmail.com writes: CS OK. So I have tried

Re: Syntax for if

2010-02-08 Thread 7
On 2/8/10, 7 7stud.7s...@gmail.com wrote: On 2/8/10, Chris Coggins cacogg...@cox.net wrote: What is the proper syntax for a comparison at the end of a subroutine to stop the script if a certain variable is 0 or ''? sub routine{ (get data and process it) if $varA = '' || $varA = 0 { (stop

Re: Syntax for if

2010-02-08 Thread 7
On 2/8/10, 7 7stud.7s...@gmail.com wrote: On 2/8/10, 7 7stud.7s...@gmail.com wrote: On 2/8/10, Chris Coggins cacogg...@cox.net wrote: What is the proper syntax for a comparison at the end of a subroutine to stop the script if a certain variable is 0 or ''? sub routine{ (get data and process

Re: Syntax for if

2010-02-08 Thread Uri Guttman
7 == 7 7stud.7s...@gmail.com writes: 7 if (defined $var ($var eq '' || $var eq '0')) { 7 #code 7 } 7 to handle cases where $var = undef. undef acts like it is a blank 7 string when used as a string. blah.. unless( $var ) { is all you need for that situation. you

Re: Syntax for if

2010-02-08 Thread Chris Coggins
Thanks Jim. I used exit(0) unless $varA; and it worked good from command line. When I try the script through a browser pointing to the file like so http://domain.com/cgi-bin/script.pl?varA=10 the script executes as it should. But when I try to send 0 as the value (?varA=0), I get a code

Re: Syntax for if

2010-02-08 Thread Jim Gibson
On 2/8/10 Mon Feb 8, 2010 5:45 PM, Chris Coggins cacogg...@cox.net scribbled: Thanks Jim. I used exit(0) unless $varA; and it worked good from command line. When I try the script through a browser pointing to the file like so http://domain.com/cgi-bin/script.pl?varA=10 the script

Re: Syntax for if

2010-02-08 Thread Chris Coggins
Chris Coggins wrote: I'm adding this exit step into the script to keep people from trying to execute it outside of the normal web interface. The script and browser communicate normally if the script is executed through its original form. What I'm trying to prevent is someone trying to

Re: Syntax for if

2010-02-08 Thread Jim Gibson
On 2/8/10 Mon Feb 8, 2010 6:07 PM, Chris Coggins cacogg...@cox.net scribbled: Chris Coggins wrote: I'm adding this exit step into the script to keep people from trying to execute it outside of the normal web interface. The script and browser communicate normally if the script is

Re: Syntax for if

2010-02-08 Thread Chris Coggins
Jim Gibson wrote: On 2/8/10 Mon Feb 8, 2010 6:07 PM, Chris Coggins cacogg...@cox.net scribbled: Chris Coggins wrote: I'm adding this exit step into the script to keep people from trying to execute it outside of the normal web interface. The script and browser communicate normally

Re: sequential value check

2010-02-08 Thread Curt Shaffer
Ok. So again, thanks for getting me on the right track. I am now at my compare routine. This is where I cannot figure out how to compare within 100. My first instinct is to write something like the following: #!/usr/bin/perl -w for (1 .. 5){ my $hping = `sudo hping3 www.microsoft.com

Re: Perl script to monitor memory usage on unix box

2010-02-08 Thread 蔡超
Hi Dave, There is a tool sysusage which is a open source coded in perl. It might be worth to have a look. 2010/2/8 Dave Tang d.t...@imb.uq.edu.au: Hi everybody, I want to write a script that checks memory usage of my RHEL box, and ran as a cron job say every 10 minutes. I could write the

Re: sequential value check

2010-02-08 Thread Jim Gibson
At 9:17 PM -0500 2/8/10, Curt Shaffer wrote: Ok. So again, thanks for getting me on the right track. I am now at my compare routine. This is where I cannot figure out how to compare within 100. My first instinct is to write something like the following: #!/usr/bin/perl -w for (1 .. 5){ I

Re: Syntax for if

2010-02-08 Thread 7
On Mon, Feb 8, 2010 at 6:19 PM, Uri Guttman u...@stemsystems.com wrote: 7 == 7 7stud.7s...@gmail.com writes: 7 if (defined $var ($var eq '' || $var eq '0')) { 7 #code 7 } 7 to handle cases where $var = undef. undef acts like it is a blank 7 string when used as a string.

Re: Syntax for if

2010-02-08 Thread 7
On Mon, Feb 8, 2010 at 9:00 PM, 7 7stud.7s...@gmail.com wrote: On Mon, Feb 8, 2010 at 6:19 PM, Uri Guttman u...@stemsystems.com wrote: 7 == 7 7stud.7s...@gmail.com writes: 7 if (defined $var ($var eq '' || $var eq '0')) { 7 #code 7 } 7 to handle cases where $var = undef.

Re: Syntax for if

2010-02-08 Thread 7
On Mon, Feb 8, 2010 at 6:45 PM, Chris Coggins cacogg...@cox.net wrote: Thanks Jim. I used exit(0) unless $varA; That form of unless is especially poor style.

Re: sequential value check

2010-02-08 Thread Uri Guttman
CS == Curt Shaffer cshaf...@gmail.com writes: CS #!/usr/bin/perl -w still no warnings and strict. USE THEM. do it now. add them and declare all your variables. it will save your ass. CS for (1 .. 5){ CS my $hping = `sudo hping3 www.microsoft.com -S -p 80 -c 1`; CS

Re: Syntax for if

2010-02-08 Thread Uri Guttman
7 == 7 7stud.7s...@gmail.com writes: 7 Because unless and until statements are harder to maintain, NO ONE should 7 use them--least of all beginners. 7  Because unless and until statements are harder to *read and maintain*, NO ONE 7 should use them--least of all beginners.

Re: Syntax for if

2010-02-08 Thread 7
On Mon, Feb 8, 2010 at 9:33 PM, Uri Guttman u...@stemsystems.com wrote: 7 == 7 7stud.7s...@gmail.com writes: they both read fine in english which is why they we included by larry. They don't both read fine. To many people, unless is a confusing construct. Larry has made plenty of

Re: Syntax for if

2010-02-08 Thread Uri Guttman
7 == 7 7stud.7s...@gmail.com writes: 7 On Mon, Feb 8, 2010 at 9:33 PM, Uri Guttman u...@stemsystems.com wrote: 7 == 7 7stud.7s...@gmail.com writes: 7 they both read fine in english which is why they we included by larry. 7 They don't both read fine. To many people, unless