Perl Tricks

In my environment there are some commands I need to run as “true root”, which means I have to login to the server as root… no su or sesu. We have all of our Unix/Linux servers locked down for root access via SSH, so every now and then I need to open root temporarily in order to login as root to run some commands. I got tired of manually editing sshd_config and restarting the service just to re-do every change I just made. Here is a couple of Perl one-liners that will do the job for me.

Linux, Perl Scripts Read More

Nagios Perl Script to add Hosts and Escalations

A couple of perl scripts to help add Hosts and Host Escalations into Nagios config files. 

DIRECTIONS: Edit .list file for script to read
FOR: addHost.pl edit host.list to include tab seperated parameter (5)options
use     host_name       alias   address host_groups

FOR: addEscalation.pl edit Escalation.list to include tab seperated parameter (2)options
host_name       contact_groups

Here is addHost.pl script

Linux, Network Security, Perl Scripts, Tutorials/Whitepapers Read More

Verify reboot and oracle process with Perl Script

Here is a script I wrote that I will run in cron on the days that we have autosys reboot schedules. The script will check if the server has been rebooted in the last 2 hours and if it’s rebooted in the last 24 hours. It also checks to see if Oracle processes are running. In the case that either the reboot failed or the Oracle processes did restart or aren’t running it will send an e-mail notification to whoever is specified in the @to array variable.

Linux, Perl Scripts, Tutorials/Whitepapers Read More

A Perl script called logHunter.pl

Ok here is a perl script that is pretty much useless in Linux, becuase linux has the grep command, but I’m a geek so I wrote it anyways. Hey, it could be usefull in windows…lol. So if you haven’t figured it out yet, this script will look thru a file for keywords and only print out the lines that contain the keyword. Of course you could also just output the results to a new file.

Linux, Perl Scripts, Tutorials/Whitepapers, Windows Read More

Monitor processes in Linux using Perl script

This is another perl script I wrote to monitor critical processes in Linux and report status to log. This script is alot like the earlier script I wrote to check mount points in that it opens a command and write it to a file in order to use regular expressions to check if something is true or not. Also this script can be edited to monitor any number of process and report it any number of ways including syslog, Nagios, or just system mail.

Linux, Perl Scripts, Tutorials/Whitepapers Read More