techrobatics.com

Sysadmin Ex Machina

Browsing Posts tagged linux

The following script is a rudimentary attempt at ( 1 ) understanding the BOTO API kit for Amazon S3, and ( 2 ) ending up with something functionally useful for the average web system administrator. I’ll be using what I’ve learned from this, as the framework for a complete backup tool for DIY bloggers/web types. [...]

This, I got from pixelbeat.org. I’m reposting it here, so that I never ever lose it. #!/usr/bin/env python # Try to determine how much RAM is currently being used per program. # Note per _program_, not per process. So for example this script # will report RAM used by all httpd process together. In detail [...]

This bit of bash script tells me when the swap file on my servers exceeds a set maximum. I use it to let me know when storage becomes an issue on my site: #!/bin/bash # Notify me one time if my swap is over MAXSWAP and log the # swap usage as well in SWAPLOG. [...]

For those of you stuck behind a corporate intranet firewall, here’s a few python functions that might come in handy: #!/usr/bin/env python #iptools.py import socket import urllib2 def get_intranet_ip: “”"Relies upon your company’s intranet web site being available”"” s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((“www.myintranethost.net”, 80)) ipaddr, port = s.getsockname() return ipaddr def get_internet_ip: “”"Relies upon external [...]

For you python enthusiasts, here is a script that will recurse through directories, from the location where you run this, and show you the top disk space consumers. It’s handy for finding a runaway process, or indulgent user… #!/usr/bin/env python #dutop.py import os import sys import operator cutoff_percentage=5 #The following matches “du -h” output def [...]