Tag Archives: perl

List disks on linux server for nagios.

I wrote this simple script that I named list_disks.pl to help me configure my hosts. I use it as a NRPE check to query a server for all of its available disks, and parse the output to write configuration files. It is useful for automating host configuration files when the hosts don’t have consistent naming [...]
Posted in Nagios | Also tagged , , | Leave a comment

Get alexa rank from alexa.com with perl.

This is just a little code snippet to return the alexa rank of a given site from http://alexa.com. The script should be easily adaptable to whatever you’re using it for, but let me know if you have any questions. #!/usr/bin/perl use strict; use LWP::Simple; use URI::URL; my $need_alexa_rank = $ARGV[0]; my $url = url("http://alexa.com/siteinfo/$need_alexa_rank"); my [...]
Posted in Programming, Webhosting | Tagged | Leave a comment

Check if file exists with perl.

Take a command line filename and check if the file exists. I think this is a bashy way of doing this, but its useful nonetheless: #!/usr/bin/perl use strict; die "usage: exist.pl file\n" unless defined($ARGV[0]);   if (-e $ARGV[0]) { print "File exists!\n"; } else { print "File does not exist!\n"; } The opposite can also [...]
Posted in Programming, Webhosting | Tagged | Leave a comment