Sunday, December 18, 2011
Mac 10.7, python-ldap, MySQL-python, homebrew
Wednesday, November 9, 2011
RHEL6 latency on Dell M610: C States
We ran into latency problems on Dell M610 servers using RHEL6 while RHEL5 performed perfectly. The RHEL6 stock kernel has a module called intel_idle which ignores Dell's BIOS settings to disable C-states. We've set the following in the tail of the boot line in /etc/grub.conf and so far so good.
intel_idle.max_cstate=0 processor.max_cstate=1When I started here six years ago we had a DNS server with a similar problem solved basically the same way; with a "acpi=off" to disable ACPI.
Update: The above seems to have helped servers connected to the SAN but not one which just uses the local disk. RedHat had some interesting tweaks to try with MegaCli, hdparm, and the scheduler as they think it's IO related:
Set policy to cache data:
# MegaCli64 -LDSetProp -Cached -LAll -aAllEnable disks' cache:
# MegaCli64 -LDSetProp EnDskCache -LAll -aAll # MegaCli64 -LDSetProp ADRA -LALL -aALLEnable write cache, but first verify if the controller is battery backed:
# MegaCli64 -AdpBbuCmd -GetBbuStatus -a0 | grep -e '^isSOHGood' -e '^Charger Status'If the above results display no BBU, do not proceed.
If we have a battery backed controller, enable write cache.
# MegaCli64 -LDSetProp WB -LALL -aALLIf battery fails or is discharged, disable write cache:
# MegaCli64 -LDSetProp NoCachedBadBBU -LALL -aALLVerify policy is Enabled:
# MegaCli64 -LDInfo -LAll -aAll |grep 'Disk Cache'Disk Cache Policy: Enabled
Disable local device caching:
# hdparm -W0 /dev/sda- Add the above to /etc/rc.local to persist reboots.
Edit /etc/fstab and modify the mount options, ie: /dev/mapper/vg_root-lv_root / ext4 defaults,nobarriers,data=writeback 1 1 ... ...The filesystem(s) would need be remounted for changes to take effect.
Next, we will change the scheduler to Deadline.
# echo 'deadline' > /sys/block/sda/queue/scheduler # echo 200 > /sys/block/sda/queue/iosched/read_expire # echo 500 > /sys/block/sda/queue/iosched/write_expire- Add the above commands to /etc/rc.local to persist reboots.
Monday, October 31, 2011
KVM PCI device assignment
Update: Turns out this was not a good idea since the VM would monopolize the device on the physical machine; e.g. the VM would get an HBA to the SAN.
Update 2: Using NPIV seems to be the right thing for this.
Monday, October 10, 2011
MySQL: replace into
Monday, September 26, 2011
web.py on Mac OS X 10.7
$ sudo easy_install web.py Password: Searching for web.py Reading http://pypi.python.org/simple/web.py/ Reading http://webpy.org/ Best match: web.py 0.36 Downloading http://pypi.python.org/packages/source/w/web.py/web.py-0.36.tar.gz#md5=3f9ee778c5c34357a0233c1f0e024d00 Processing web.py-0.36.tar.gz Running web.py-0.36/setup.py -q bdist_egg --dist-dir /tmp/easy_install-qC65Ak/web.py-0.36/egg-dist-tmp-CjDoLl zip_safe flag not set; analyzing archive contents... web.application: module references __file__ web.debugerror: module references __file__ Adding web.py 0.36 to easy-install.pth file Installed /Library/Python/2.7/site-packages/web.py-0.36-py2.7.egg Processing dependencies for web.py Finished processing dependencies for web.py $You might also be interested in Setting up PHP & MySQL on OS X 10.7 Lion to get it working with MySQL.
Friday, September 9, 2011
Claws Mail Client
- Quick response (Thunderbird was getting too slow)
- IMAP/SMTP over SSL
- Threaded View
- Emacs as my editor
- GPG Plugin
- Support for Zimbra tags
- Easy view of mail headers
- Some type of scripting support (Python and Perl)
On Fedora you can easily install it with its plugins:
yum install claws-mail claws-mail-plugins-smime claws-mail-plugins-pgp claws-mail-plugins-python
Tuesday, August 23, 2011
Wednesday, August 17, 2011
pychart & web.py
class pychart: def GET(self): # sample data, that will be passed as an argument (left for this demo) data = [(1, 6), # the first run took 6 days (2, 3), # the second run took 3 days (3, 1)] # the third run too import cStringIO from pychart import theme, axis, area, line_plot, line_style, tick_mark, canvas f = cStringIO.StringIO() can = canvas.init(f, format="png") theme.use_color = 1 theme.scale_factor = 2 theme.reinitialize() theme.get_options() xaxis = axis.X(format="/a-60/hL%d", tic_interval = 1, label="Runs") yaxis = axis.Y(tic_interval = 1, label="Days") ar = area.T(x_axis=xaxis, y_axis=yaxis, y_range=(0,None)) plot = line_plot.T(label="Time to run", data=data, line_style=line_style.red, ycol=1, tick_mark=tick_mark.square) ar.add_plot(plot) ar.draw(can) can.close() f.seek(0) web.header('Content-Type', 'image/png') return f
Friday, July 22, 2011
Aeolus todo
Wednesday, July 13, 2011
Pwn Plug Wireless
Tuesday, July 12, 2011
python configparser
Sunday, July 10, 2011
php:include "bar.php" 2 python:?
PHP programmers are used to having code in one file they can use in another file simply by calling include. Python's module system supports more than just including files, but if you want to just include a file the following code provides an example:
> ls foo.py mod/ > ls mod/ bar.py > > cat mod/bar.py def f(): print("I am bar") > > cat foo.py print("I am foo") import sys sys.path.append("mod/") import bar bar.f() > > python foo.py I am foo I am bar >
Thursday, July 7, 2011
Simple python inheritance example
Python's Classes documentation has a bag class. Since I'm writing a program in which I want to do inheritance but haven't done it in a while and need a refresh, I thought I'd extend bag into a wet paper bag; which looses things you put in it nearly half the time. I came up with this:
class Bag(object): def __init__(self): self.data = [] def add(self, x): self.data.append(x) def addtwice(self, x): self.add(x) self.add(x) class WetPaper(Bag): def __init__(self): super(WetPaper, self).__init__() def add(self, x): from random import randint if (randint(1,10) > 4): super(WetPaper, self).add(x) if __name__ == '__main__': bag = Bag() bag.addtwice(1) print "Bag:", bag.data wet = WetPaper() wet.addtwice(1) print "WetPaper:", wet.dataSince I'm extending Bag, defining the constructor was simplified and I didn't have to worry about how add() was implemented; I could just flip a coin with rand to see if the inherited add() should be called. I also didn't have to define addtwice() and it inherited the unreliable aspect of WetPaper's add().
When writing the above, the first thing I had to do was update the original Bag definition to a new style class descended from object. Until I did this I got a "TypeError: must be type, not classobj" error when I used super and I had to directly use the parent class name instead:
def __init__(self): Bag.__init__(self)While working on this I found Python's Super is nifty, but you can't use it. I also found out that in Python 3 self will become implicit in super calls so instead of:
super(WetPaper, self).__init__()I will just be able to do:
super().__init__()
Cloud Computing Definition
I read an article in the FSF Bulletin about Merlin. It contained a good definition of Cloud Computing, which I think is worth posting since there is a lot of confusion about what Cloud Computing is.
"Cloud Computing is about (a) aggregating server, network, and storage resources into a seemingly contiguous system ("the cloud"), (b) providing some kind of interface for the user to request or release these resources, and (c) making these resources network or location agnostic, so that the resources are accessible from anywhere, even in the face of system or network failures." -- Justin Baugh
Monday, July 4, 2011
Monday, June 27, 2011
Saturday, June 4, 2011
web.py, mod_wsgi , RHEL6
1. Install the packages that RHEL6 provides:
yum install httpd mod_ssl mod_wsgi mysql-devel MySQL-python
2. Insert web.py directly into RHEL's python2.6 site-packages:
cd /tmp wget http://pypi.python.org/packages/source/w/web.py/web.py-0.35.tar.gz tar xzf web.py-0.35.tar.gz cd /usr/lib/python2.6/site-packages mv /tmp/web.py-0.35/web .
3. Configure a place to host your application:
mkdir /var/www/myapp
4. Install some basic code in /var/www/myapp/code.py
import web urls = ( '/.*', 'hello', ) class hello: def GET(self): return "Hello World" application = web.application(urls, globals()).wsgifunc()
5. Configure mod_wsgi directives for Apache in /etc/httpd/conf.d/wsgi.conf:
LoadModule wsgi_module modules/mod_wsgi.so WSGIScriptAlias /myapp /var/www/myapp/code.py/ <Directory /var/www/tentacle/> Order allow,deny Allow from all </Directory>
When configuring the above I used the webpy.org cookbook as a reference. Note that my previous example was development only.
web.py
I like it because it's simple and I found it intuitive and easy to learn. You can set it up quickly on Fedora with:
yum install python-webpy yum install MySQL-pythonIt was straight forward to follow the tutorial, except it's not obvious in the tutorial how to specify a different DB server besides the default localhost. The keyword argument is 'host' just like in MySQLdb.connect(), which is provided by the Python package MySQLdb; i.e. the MySQL-python yum package. Here's the example from the tutorial in which an external DB server is declared:
db = web.database(dbn='mysql',\ user='user',\ pw='password',\ db='todo',\ host='mysql.example.com')Also, the PostgreSQL example translates into MySQL like this:
CREATE TABLE todo ( id serial primary key, title text, created timestamp default now(), `done` boolean default '0' );specifically boolean is an synonym for tinyint in MySQL so it uses not 'f' but '0' to represent false.
The output code from my tutorial is:
code.py:
#!/usr/bin/env python # Filename: code.py # Description: intro to web.py # Supported Langauge(s): Python 2.7.x # Time-stamp: <2011-06-04 18:15:06 someguy> # ------------------------------------------------------- import web # ------------------------------------------------------- render = web.template.render('templates/') urls = ( '/', 'index', '/add', 'add' ) app = web.application(urls, globals()) db = web.database(dbn='mysql',\ user='todo',\ pw='redacted',\ db='todo',\ host='mysql.example.com') # ------------------------------------------------------- class index: def GET(self): todos = db.select('todo') return render.index(todos) class add: def POST(self): i = web.input() n = db.insert('todo', title=i.title) raise web.seeother('/') # ------------------------------------------------------- if __name__ == "__main__": app.run()templates/index.html
$def with (todos) <ul> $for todo in todos: <li id="t$todo.id">$todo.title</li> </ul> <form method="post" action="add"> <p><input type="text" name="title" /> <input type="submit" value="Add" /></p> </form>
Monday, May 23, 2011
AI TouchBook
Sunday, May 15, 2011
goodbye openoffice, hello abiword
Monday, April 25, 2011
tried spice
sudo yum install spice-client spicec -h $server -p $port -w $passwd shift-ctrl-f12It really works. The image of my VM was less than 100M since it's stored in qcow2 format. This also allows images given to each user (one per port) to inherit software updates to the master image (requires qcow2 images to go offline).
Thursday, April 7, 2011
flymake & pyflakes
cd ~/elisp wget http://cvs.savannah.gnu.org/viewvc/*checkout*/emacs/emacs/lisp/progmodes/flymake.el?revision=1.2.4.41 mv flymake.el\?revision\=1.2.4.41 flymake.el easy_install pyflakes add the following to .emacs: (when (load "flymake" t) (defun flymake-pyflakes-init () (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "pyflakes" (list local-file)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pyflakes-init))) (add-hook 'find-file-hook 'flymake-find-file-hook)
Wednesday, March 30, 2011
todo: try Mongo GridFS
I've been thinking about traditional file systems mkfs'd on block devices vs distributed file systems and I would like to set some time aside to play with Mongo GridFS. It looks like given a sharded mongo installation you can use the API to save a large file and it will split it across multiple servers. This looks like a nice way to store a large data set across multiple machines as opposed to having a large file system attached to one server which requires an occasional file system check.
persistent connections within cisco firewall
[root@server ~]# tail -2 /etc/sysctl.conf # keep persistent connection (so firewall doesn't tear down) net.ipv4.tcp_keepalive_time = 900 [root@server ~]#
Tuesday, March 29, 2011
Monday, March 28, 2011
Saturday, March 26, 2011
Pylons
yum install python-sqlalchemy python-pylons paster create -t pylons HelloWorld cd HelloWorld paster serve --reload development.ini firefox4 http://127.0.0.1:5000and then I was able to directly go to the examples in Chapter 3 of Definitive Guide to Pylons.
firefox4
- firebug
- https-everywhere
- tree style tab
- vimperator
- web developer
Friday, March 25, 2011
Tuesday, February 22, 2011
Cisco Firewall Translation, RPC Portmapper, and NFS
I've posted before about problems using NFS with a Firewall which occur because of RPC. I think the correct way to solve the problem is to configure the NFS server so that RPC services like nlockmgr, rquotad, and mountd are hard coded. On a RedHat based system this comes down to uncommenting the following in /etc/sysconfig/nfs:
RQUOTAD_PORT=875 LOCKD_TCPPORT=32803 LOCKD_UDPPORT=32769 MOUNTD_PORT=892 STATD_PORT=662and then configuring your firewall to allow only the above ports through in addition to RPC:tcp/udp 111 and NFS:tcp/udp 2049, for NFS.
Today I learned that if you are using a Cisco firewall it is possible to not do the above but to enable inspect rpc so that when port mapper tells the client to use random ports for services like nlockmgr, rquotad, and mountd, that the firewall will then dynamically open the same random port exclusively between the NFS client and NFS server. This surprised me as it seems odd to imagine a server asking the firewall to open a port because it wants to use it. What also surprised me is that for FWSM versions older than 3.2, this won't work if you use xlate-bypass. So, if you thought along the lines of "I don't need NAT, let's turn off xlates" and enabled xlate-bypass then you will break sunrpc. I am personally in favor of not using xlates nor sunrpc.
Friday, February 18, 2011
Freedom Box Foundation
Thursday, February 10, 2011
RedHat Cloud Offerings: Update
I previously posted about RedHat Cloud Offerings and emphasized what my organization is lacking: Satellite, RHEV-M, and MRG Grid.
We're now running Satellite and will be registering all of our servers to use it. We've also been able to use Satellite alone to kickstart a VM on our KVM servers without touching the hypervisors. We're going to keep experimenting with Satellite and roll it into production very soon.
We're less interested in RHEV-H and RHEV-M since we are already happy with KVM running on RHEL and prefer to use our command line tools for management as opposed to the "vmware-like" RHEV-M GUI. We're also less interested in MRG Grid since HPC is not our focus.
We are interested in Deltacloud but in a development sense only. We don't expect it to be production-ready for a while. For now we're going to use a by-the-hour EC2 account with our development KVM cluster and see what it's like creating and migrating VMs between EC2 and our cluster (or private cloud (if you must)).