#!/usr/bin/perl
use IO::Socket;
@servers = ( 'one', 'two', 'three');
foreach (@servers) {
$socket = IO::Socket::INET->new( PeerAddr => $_, PeerPort => '22', Proto => 'tcp'); if ($socket) { #print $_ . ” SSH is UP” . “\n”; } else { open(MAIL, “| /usr/sbin/sendmail -oi -n -t”); print MAIL << EMAIL_TO_USER; To: unix\@whoever.com, unixunix\@whoever.com From: mon\@whoever.com Subject: MON Alert - SSH on $_ is DOWN Issue: SSH Port on $_ is DOWN. Business Impact: Cannot remote login into $_. Historical Fixes: Restart SSH via svcadm refresh ssh or service sshd restart EMAIL_TO_USER close MAIL; print $_ . " SSH is DOWN" . "\n"; } };
Posted: July 31st, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
#!/usr/bin/perl use Net::Ping; @servers = ( 'one', 'two', 'three'); foreach (@servers) { $p = Net::Ping->new(); if ($p->ping($_)) { #print $_ . " is alive" . "\n"; $p->close(); } else { open(MAIL, "| /usr/sbin/sendmail -oi -n -t"); print MAIL << EMAIL_TO_USER; To: unix\@whoever.com, unixunix\@whoever.com, From: mon\@whoever.com Subject: MON Alert - Cannot Ping $_ Issue: Cannot Ping $_. Business Impact: $_ may be down and unreachable. Historical Fixes: Console into the server. EMAIL_TO_USER close MAIL; print "Cannont Ping " . $_ . "\n"; } };
Posted: July 31st, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
#!/usr/bin/perl $hostname = (`hostname`); @diskinfo = (`df -hl | grep -v named`); foreach (@diskinfo) { @lines = split (/\s+/, $_); $mount = $lines[5]; $percent = $lines[4]; chop $percent; if ( $percent > 50 ) { #print "Sending Alert for " . $mount . "\n"; open(MAIL, "| /usr/sbin/sendmail -oi -n -t"); print MAIL << EMAIL_TO_USER; To: me\@me.com From: me\@me.com Subject: $hostname - $mount is at $percent percent. Issue: $hostname - $mount is at $percent percent. Resolution: Please clean up unneeded files. EMAIL_TO_USER close MAIL; } }
Posted: July 24th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
#!/usr/bin/perl open ( FILE, "< /etc/hosts" ) or die "Cannot open file \n" ; while ( ) { if (/10.0.1/) { @lines = split(/\s+/, $_); print $lines[1] . "\n"; } } close FILE;
Posted: July 24th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
#!/usr/bin/perl $filenumber = 100; while ($filenumber <= 200){ print "$filenumber" . "\n"; # Linux and Solaris #system("wget http://website/images/file_$filenumber.JPG"); # MacOS X system("curl -LO http://website/images/file_$filenumber.JPG"); $filenumber++; }
Posted: July 18th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
Add the following into your .bash_profile:
alias wget="echo 'using curl -LO'; curl -LO $1"
Posted: July 16th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
Example:
AuthType Basic AuthName "Password Required" AuthUserFile /etc/htpasswd require valid-user
Posted: July 16th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.
Add terminal colors by adding the following lines into your .bash_profile.
export CLICOLOR=1 export LSCOLORS=ExFxCxDxBxegedabagacad
Posted: July 16th, 2007
Categories: Uncategorized
Tags:
Comments:
No Comments.