Get status of your servers with perl script.

2014-07-14 1 min read Perl

Monitoring the servers could be well – “not difficult” but boring and monotonous. And since this is something that you should ideally do on daily basis, so why not have a script for the same.

You can’t possibly copy your ssh-keys to all the servers that you are monitoring, better if you can, then you need to do ssh to server with password. So, here is link to my github repo for monitoring servers with perl script. Preety straight forward script and you can schedule this in cron to get a daily mail.

Continue reading

Manage your servers the easy way with perl script over ssh with no remote client.

2013-05-06 8 min read Linux Perl

For a long time I have not posted any script. So, its not that I have not written anything new, but just that did not put them here in lack of time. So, here is one interesting one. The original idea came from one posted in one of the interesting blog here. But the problem with this one was that for every time, it ran in the cron, it would make multiple entries in the “last” output (about 10 or more with my modifications for differentiating between solaris and Linux). This is something which is not quite desirable. Hence I came up with this script which is based on html template and hence the output is also easier to manipulate. BTW, just the below script will not help, you would need to download the template files as well. In the list.txt file, you will have to put the usename, password and the server IP to monitor. The server could be any Linux or Solaris host.

Continue reading

perl is faster than bash in some cases.

2011-01-11 3 min read Bash Fedora Linux Perl

Some days back, I had to generate some data to be uploaded to a database. As usual I assumed that bash should be faster and hence wrote the script to create the files in bash. But I found that even after 5 hours I was only 10% done with the data generation. Now that would mean that it would take around 50 hours to complete the data generation. Something did not look correct to me and I asked one of my colleague. He suggested I do a strace.

Continue reading

Building a Finite State Machine Using DFA::Simple

2010-12-15 11 min read Perl

http://www.perl.com/pub/2004/09/23/fsms.html

Building a Finite State Machine Using DFA::Simple By Bill Ruppert on September 23, 2004 12:00 AM I am converting some articles from MS Word to HTML by hand. I often use bulleted outlines so I face a lot of work creating lists with nested sub-lists. It didn’t take opening and closing many

and

  • tags to realize I wanted to automate the task. It’s very easy to use filters with my text editor and I’ve written several in Perl to speed up my HTML formatting. I decided to create a filter to handle this annoying chore. After a little thought I decided the logic involved was just tricky enough to use a finite state machine (FSM) to keep things straight.

    Continue reading

String and Array Creation

2010-04-28 0 min read Learning Linux Perl
\"Perl\"
Image via Wikipedia

<img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/perl-one-liners.jpg" alt="Perl One Liners" align="bottom" />This is the fourth part of a nine-part article on famous <a class="zem_slink freebase/en/perl" title="Perl" rel="homepage" href="http://www.perl.org/">Perl one-liners. In this part I will create various one-liners for string and array creation. See <a href="http://www.catonmat.net/blog/perl-one-liners-explained-part-one/">part one for introduction of the series.

Famous Perl one-liners is my attempt to create “perl1line.txt” that is similar to “<a href="http://www.catonmat.net/blog/awk-one-liners-explained-part-one/">awk1line.txt” and “<a href="http://www.catonmat.net/blog/sed-one-liners-explained-part-one/">sed1line.txt” that have been so popular among Awk and Sed programmers.

Continue reading

Script to get the number of events from the logs.

2010-04-11 2 min read Learning Linux Perl

<a id="aptureLink_4P0PJ73NaG" style="margin: 0pt auto; padding: 0px 6px; text-align: center; display: block;" href="http://en.wikipedia.org/wiki/Log%20analysis"><img style="border: 0px none;" title="Log analysis" src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/360x320_WikipediaArticle" alt="" width="360px" height="320px" />

I was trying to do some <a class="zem_slink freebase/en/log_analysis" title="Log analysis" rel="wikipedia" href="http://en.wikipedia.org/wiki/Log_analysis">log analysis and finding the events in the logs. For this the logs had the Events logged as &#8221;|+Event name|&#8221; or with sending and receiving. So I wrote this little script to take care of my requirements.

Continue reading

Perl script to create csv files with a pattern – Generic script.

2010-01-19 1 min read Learning Linux Perl

I was having a really bad day and needed a quick solution to create some csv files. And this I needed to do for multiple data kinds and patterns, so I created this small script to do the job for me…

#Number of rows required in the output.

$rows = 100;

#The config and the output file

open (CF_FILE, &#8221;<Config.test&#8221;);
open (OUT_FILE, &#8221;>test.csv&#8221;);

#—————————————————————————
# No need to change anything below this.
#—————————————————————————

Continue reading