nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Want a good forume about Perl

This is a discussion on Want a good forume about Perl within the Coding in General forums, part of the Development/Scripting category; Hi Vivek/nixcraft/jay, I want to start scripting in perl (as of now only related to linux administration). Please suggest some ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Development/Scripting > Coding in General

Linux answers from nixCraft.


Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-29-2009, 04:02 PM
kumarat9pm's Avatar
Senior Member
User
 
Join Date: Jun 2007
Location: Pune,MH,India
OS: RHEL,UBUNTU..
Posts: 335
Thanks: 12
Thanked 13 Times in 11 Posts
Rep Power: 4
kumarat9pm has a spectacular aura about kumarat9pm has a spectacular aura about
Send a message via Yahoo to kumarat9pm Send a message via Skype™ to kumarat9pm
Default Want a good forume about Perl

Hi Vivek/nixcraft/jay,

I want to start scripting in perl (as of now only related to linux administration). Please suggest some admin tasks in Linux administration which can be automated by using perl (just i want to know what things can be automated by using this good lang).. And can you guys suggest me some perl forum dealing mostly about linux administration activity(i want a live/dynamic forum like nixcraft)?

please share your exp what we can do with perl in day to day activity's in admin world.
__________________
Thanks,
Surendra Kumar Anne
Ubuntu: Simple, Stylish and Striking..!
Linux: Fast, friendly, flexible and .... free!
Support Open source.

Last edited by kumarat9pm; 10-29-2009 at 04:04 PM.
Reply With Quote
  #2 (permalink)  
Old 10-29-2009, 07:15 PM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 525
Thanks: 54
Thanked 66 Times in 59 Posts
Rep Power: 8
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default

Hey kumarat9pm,


That question has come across my mind many times. I have noticed that there is really not that much forums for perl. However I have been using the following for my perl learning.

PerlMonks - The Monastery Gates

This is the most helpful site.

perldoc - perldoc.perl.org


As for using perl in my daily admin activities, I am currently working on a perl / bash shell script to locate php processes on a redhat server that cause the load to exceed 10. Once that load has been breached I am grepping for the process that caused it and attempting to terminate them. This is similar to another script that I have posted. You can see that I am still learning PERL. Most of this script is bash orientated.


Here is what I have so far. Feel free to modify and use. I have been receiving guidance from my senior admin along the way. Thanks "ARUP" hehe



PHP Code:
#!/usr/bin/perl 
# Created for killing php processes which are running  #
# for a long time and causing the server load to get   #
# high.                                                #

$lockfile"/var/log/pkill.lock";
$pklog "/var/log/pkill.log";
$kpid "0";

if ( -
f $lockfile)
 {
 die;
 }
`
touch $lockfile`;

$loadavg=`uptime |cut -d , -f 4|cut -d : -f 2`;

while ( 
$loadavg "10" )
  {
        
$kpid=`ps -eo pid,pcpu,%mem,time,cmd|grep /usr/local/bin/php |grep -v grep |sort -k4 -r |sed -e 's/^[ \t]*//' |sed -n 1p |cut -d " " -f1`;
        if (
$kpid) {
            
$pdtl =`ps auxfww |grep -v grep |grep $kpid`;
            
open(LOGFL,">>$pklog");
            print 
LOGFL $pdtl;
            
close(LOGFL);
            
system("kill -1 $kpid");
            
sleep(20);
            
$loadavg=`uptime |cut -d , -f 4|cut -d : -f 2`;
                   } else
                   {
            `
echo "Load is not for PHP Scripts. No PHP Scripts are running currently" >>$pklog`;
            
$loadavg="0";
            
next;
                   }
  }
if ( -
f $pklog)
 {
$SUBJECT="SERVER LOAD HAS REACHED 10.00 - FEW PHP PROCESSES AUTOMATECALLY KILLED";
$TO="machines\@company.com";
$MESSAGE="/usr/local/bin/messages/kill.txt";
`
echo "The Server has been issued a kill to the following processes.  This occured cause the system load has reached a 10.00 set threshold" >> $MESSAGE`;
`
echo "  " >> $MESSAGE`;
`
echo " KILLED PROCESSES LIST" >> $MESSAGE`;
`
echo "   " >> $MESSAGE`;
`
cat $pklog >> $MESSAGE`;
`
mail -s "$SUBJECT" "$TO" < $MESSAGE`;
 }
unlink $pklog;
unlink $MESSAGE;
unlink $lockfile
__________________
Give a man a fish, feed him for today.
Teach a man to fish, he will feed himself from now on.

Last edited by jaysunn; 10-29-2009 at 07:17 PM. Reason: Gave credit to Arup my senior admin
Reply With Quote
The Following User Says Thank You to jaysunn For This Useful Post:
kumarat9pm (10-29-2009)
  #3 (permalink)  
Old 10-29-2009, 08:55 PM
kumarat9pm's Avatar
Senior Member
User
 
Join Date: Jun 2007
Location: Pune,MH,India
OS: RHEL,UBUNTU..
Posts: 335
Thanks: 12
Thanked 13 Times in 11 Posts
Rep Power: 4
kumarat9pm has a spectacular aura about kumarat9pm has a spectacular aura about
Send a message via Yahoo to kumarat9pm Send a message via Skype™ to kumarat9pm
Default Thanks for the links jay,

I will go through them.. and mean time i found some other official/unofficial sites/forums for perl ref. Many of you know them just want to provide a link..

perl.org
perlguru.com
cpan.perl.org

and frankly to say in order to learn that script it will take time for me
lets see how many days/weeks it will take for me to get the basics of Perl.
__________________
Thanks,
Surendra Kumar Anne
Ubuntu: Simple, Stylish and Striking..!
Linux: Fast, friendly, flexible and .... free!
Support Open source.
Reply With Quote
  #4 (permalink)  
Old 10-30-2009, 12:18 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,452
Thanks: 11
Thanked 189 Times in 139 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Seriously, get a good book. I recommend Teach Yourself Perl in 21 Days and Perl for sysadmins. Forum is good to get help and hints about specific problem but you will not find any tutorial.

Good luck!
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Is Fedora good on a server chinalinix CentOS / RHEL / Fedora 3 08-13-2009 05:56 PM
How good is New Windows XP Firewall to protect my computer? toor Windows Xp/2000/2003 server administration 4 08-06-2009 12:55 AM
which daemon is good to go through sathiya Ubuntu / Debian 0 05-10-2008 01:47 PM
is any one good in c program ? oronno Shell scripting 0 09-19-2007 02:04 PM
looking for good shell scripting tutorial.... milonix Shell scripting 4 04-24-2007 07:44 AM


All times are GMT +5.5. The time now is 06:30 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38