Perl – Get the md5 hash for a file Get the MD5 hash for a file on the command line, using Digest::MD5 usage: ./md5sum.pl [filename] [-f] -f do not display filename [perl] use warnings; use strict; use Digest::MD5; sub md5sum { my $file = shift; my $digest = “”; eval{ open(FILE, $file) or die “Can’t […]
Server Port Check – Net::Telnet, check remote mail server is up and online This is pretty useful for checking that a server is accepting requests on a specific port. In this case, i am checking port 25, but can be used for others. ./smtp_check.pl <host> <host> <host> [perl] use Data::Dumper; use Net::SMTP; my @all_emails = […]
Get HTTP Code Response – Perl Pass the script many hosts and obtain the HTTP response codes for the pages. [bash] ./http_check.pl … [/bash] [perl] use LWP::UserAgent; print get_url($url); sub get_url ($) { my $url = shift; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); my $res = $ua->request($req); return $res->code; } ##Some […]
Select the next available value in a table Let’s say I have a table like this: ID Value ———————- 100 val1 101 val2 104 val3 105 val4 107 val5 [sql] SELECT Min(r1.uid) + 1 AS next_available_uid FROM unixuid AS r1 LEFT OUTER JOIN unixuid AS r2 ON r2.uid = r1.uid + 1 WHERE r1.uid > […]
Datacentre – classifications Tier Level Requirements 1 Single non-redundant distribution path serving the IT equipment Non-redundant capacity components Basic site infrastructure guaranteeing 99.671% availability 2 Fulfils all Tier 1 requirements Redundant site infrastructure capacity components guaranteeing 99.741% availability 3 Fulfils all Tier 1 & Tier 2 requirements Multiple independent distribution paths serving the IT equipment […]
Copying a filesystem with Veritas This procedure is to create an exact copy of a Veritas filesystem. You will need enough spare disks in your volume group, and ideally anything using the filesystem should be killed. create a mirror # vxassist -g tier3dg mirror tier3fs # vxprint tier3fs Disk group: tier3dg TY NAME ASSOC KSTATE […]
Volume Management Add a volume (Normal UFS mounted filesystem) # # vxassist -g datadg maxsize # # iostat -En > /tmp/iostat_en_<date> # # devfsadm # # iostat -En > /tmp/iostat_en_<date>.NEW # # luxadm probe # If no disk appears add disk manually ## # vxdmpadm listctlr all ## # cfgadm -c configure c2 ## # […]
Shell – Finding Large Files – UNIX [bash] find / -size +2000 -exec ls -s {} \; | sort -nr | more [/bash] [bash] du -sk * | sort -nk 1 [/bash]
Screen – /usr/bin/screen Useful commands: Screen ^AC – create new session ^AA – swap to previous session (flip back/forth) ^AN – go to next session ^AP – go to previous session ^AD – disconnect ^AK – kill current session