Listing installed Perl Modules
Simple one line command for listing all installed Perl modules
-
perl -MExtUtils::Installed -e'my $inst = ExtUtils::Installed->new(); print $_, $/ for $inst->modules'
Listing installed Perl Modules
Simple one line command for listing all installed Perl modules
Another simple script I've written and use often (actually runs via cron every 5 minutes) to verify the contents of a particular page to determine of it has changed for any reason like a webserver cracked/hacked or if the dynamic content is not what is expected.
In this case it is specifically monitoring a page from a PeopleSoft application that I do not entirely trust, if the content doesn't match my checksum that generally means the Tuxedo application server is hosed and needs to be restarted.
Easily adapted to fit your particular needs, is use it on all of my public websites that are on shared hosting accounts etc...
Comments for bigger sections are thrown in to give you an idea of what to tweak for your needs, remember to update $file2 with a new copy of the markup if you modify the landing page you are monitoring!
Checking SSL Certificate expiration dates
Managing a lot of SSL certificates? Hate being surprised when they expire on you and break your web site? How about a simple process to notify you in advance?
All of the above sound about right? It does to me, I literally manage close to 100 web sites that require SSL encryption for sensitive data transfers, it seems almost impossible to get and keep them all lined up for expiration dates. Even when they were something new would come along and mess up the rotation, in short order it looks like a shotgun blast to a calendar was the deciding factor.
Here is an easy perl script I wrote to check the dates of existing SSL certs, it gets the URL list to check from certs.urls, compares the certificate expiration date to the current date and send emails at the specified intervals. Pretty simple, but like most, it's very effective when run daily via cron.
I've edited some of the partially confidential stuff out, but not enough to render the script unusable by any means, just set the email.sr to your local email faciltiy.
URLs are stored in cert.urls with no http:// prefix
You get the idea...
Happy hacking!
Finding large files on Linux/Unix
Depending on how you build your filesystem, locating large files such as logs or other output from scripts, programs, or daemons can be frustrating at best. Since I'm not a GUI kind of guy this little snippet for the shell can save tons of time. (tested with KSH and Bash shells, likely should work with most if not all)
This will search beginning at the root / directory for all files over 20M. To adapt it for your use simply change the / to represent any beginning path you wish and the 20000k to the minimum filesize you would like to find.
Hard to get any easier than this. A detailed description of the all powerful awk can be found by reading the associated man pages should you be so inclined.
Happy hacking!
Occasionally recurring jobs will get hung, especially with jobs fired off from cron that are scheduled to run every minute. In my case there is a job that runs every minute to pick up status files from numerous remote servers, the script gets the files, parses them, and then plugs them into a MySQL database. That data is later parsed on demand by a php page to display different status information about the remote servers. All in all it works quite well, until something gets hung, especially if the NFS mount for the database has a hiccup, once the first database connect hangs it tends to hang the subsequent jobs as well... quickly filling up the available memory and of course crashes or hangs any other web pages trying to access the database.
A quick and dirty way to right things without typing or copy/pasting a bazillion pids to a kill -9
Nothing magical about it, the for loop scans the output from the ps command for the process_name, awk parses out the pid #, the loop performs a kill -9 for each pid returned.
Like I mentioned, nothing magical about it, but a quick efficient method of killing what can be hundreds of processes.
Happy hacking!