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. Read more »
Perl Tricks
Posted in Linux, Perl Scripts with tags Perl, one-liner, ssh on November 3, 2009 by trizCheck Mount Points with Perl Script New
Posted in Linux, Perl Scripts on March 24, 2009 by trizI wanted to make a more flexible mount point script to use since our environment consists of several different architects with different mount points. This works good by reading the fstab file and mounting accordingly. I just need a flexible way to omit the common mount points like / and /opt…
#!/usr/bin/perl -w
#
# Name: mountCheck.pl
# Written by: brandon.thompson EMC Mortgage
# Usage: ./mountcheck.pl 'mount point 1' 'mount point 2'... or no argsv for defaults
# This script is put in cron on these boxes for monitoring purposes
#
use strict;
my $alert_email='brandon.w.thompson\@jpmorgan.com';
chomp(my $host=`/bin/hostname`);
open(FSTAB,"awk '{print\$2}' /etc/fstab |") or die "Failed: $!\n";
our @mounts=;
close(FSTAB);
foreach my $mount(@mounts){
my $status=`df -hT | egrep -i $mount`;
if(!$status){
`mount $mount`;
system("/bin/logger", "-p", "warn", "Mount Point: $host: $mount is NOT mounted on ". scalar(localtime())."!\n")==0
or die "Can't complete cmd: $!\n";
my $alert=system("/usr/bin/mailx -s 'ALERT! $host: $mount is NOT mounted!' $alert_email /dev/null")==0
or die "Can't complete cmd: $!\n";
# Attempt to mount
}
}
Nagios Perl Script to add Hosts and Escalations
Posted in Linux, Network Security, Perl Scripts, Tutorials/Whitepapers with tags nagios perl hosts linux monitor on October 24, 2008 by trizA 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 Read more »
Native Windows Command
Posted in Windows with tags CMD command windows on August 26, 2008 by trizSome of you may already know about this native windows command, but I didn’t… so here it is if anyone is interested
forfiles -pc:\act -m*.zip -d-7 -c”CMD /C del @FILE”
The above command will delete zip files from “c:\act” that are older then 7 days. This would be beneficial when having to delete files that are automatically created but only need to be retained for a certain amount of days.
Busted 6000 hits today…
Posted in Site Info, Uncategorized with tags hits uptime on June 26, 2008 by triz/me pats self on back…..
Verify reboot and oracle process with Perl Script
Posted in Linux, Perl Scripts, Tutorials/Whitepapers with tags autosys, oracle, Perl, reboot, script on May 22, 2008 by trizHere 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. Read more »
Change ownership of files and directories with Perl script
Posted in Linux, Perl Scripts, Tutorials/Whitepapers, Windows with tags Perl script chown ownershipt username group on May 12, 2008 by trizI came across this method of changing the ownership of files when working on a DataStage startup/shutdown script and changing the permissions on the logfiles the script creates. So I wrote a simple script that takes a username from input and a file name or multiple names from input and changes the owner and group of that directory. Read more »
A Perl script called logHunter.pl
Posted in Linux, Perl Scripts, Tutorials/Whitepapers, Windows with tags script perl search log find keyword linux windows on May 12, 2008 by trizOk 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. Read more »
Monitor processes in Linux using Perl script
Posted in Linux, Perl Scripts, Tutorials/Whitepapers with tags monitor process script perl linux ps on May 12, 2008 by trizThis 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. Read more »
Check mount points with Perl script
Posted in Linux, Perl Scripts, Tutorials/Whitepapers with tags perl script mount point on May 3, 2008 by trizHere is my script I wrote to possibly add to the cron job to check and mount… mount points.
#!/usr/bin/perl -w
#
# Name: chkMounts.pl
# written by trizsolo
# Usage: ./chkMounts.pl args args args
#you can check as many mount points as needed
#with arguments or use defaults
################################### Read more »