python


The package in wheezy backports dates from January 2014

saltstack_wheezy_backport

 

Advertisements

There are many choices for enterprise monitoring, you may already have server level monitoring in place.

Where an individual process requires inspection over time, a simple monitoring script is an option

One of the trade-offs that you must make when monitoring in detail is sample frequency.

Too frequent and you might cause more issues (large logs or other cruft).

Not frequent enough and you might miss the very thing you are trying to observe.

A basic Python script that logs every 2 minutes to sqlite can be found at the link shown next.

On a server with Python 2 available, and equipped with the process id you wish to monitor (from ps output), you might invoke the script as follows:

python ./pidmem_sample1.py 1234

(where 1234 is the process id of you long running process)

The script will run for 3 months or so, and samples at two minute intervals.

Killing the process being monitored will see the monitoring script exit also.

python -m unittest discover

…should work fine when you have set everything up with a bit of forethought

If you see response ‘Ran 0 tests’ then try

touch tests/__init__.py

If you fail to create an empty __init__.py in your tests folder, then Python (rightly) will not recognise it [ as a module ]

Rerun your discover command and if missing __init__.py was holding you up, then you should now be further along.

Along the way you have just learned a little about project structure, and Python requirements generally for modularised code.

Chkrootkit and other tools that scan for rootkits sometimes report a python related ‘.path’ file as suspect.

Example:

/usr/lib/pymodules/python2.6/.path

The script/binary responsible for creating that file is /usr/sbin/update-python-modules

from the Debian & Ubuntu package python-support

code extract from /usr/sbin/update-python-modules

There is no harm in understanding how to adapt chkrootkit or alternatives to ignore a list of locally recognised false positives, however some might consider this ‘false positive’ a bug.

Image

For this particular project the setup.py contained the following line:

      install_requires=['bottle','python-memcached>=1.45'],

Note: if you use ‘memcache’ or ‘memcached’ instead of what is written, you will probably get a message like:

Couldn’t find index page for ‘memcache’ (maybe misspelled?)

remote: Reading http://pypi.python.org/simple/
remote: No local packages or download links found for memcache>=1.45
remote: Best match: None

GNU/Linux systems now have a new major Kernel version – 3.

Best way to test / report kernel in Python?

Example script – hosted on Bitbucket:

The Python at the link above, will report what it knows about your running kernel.

Example output:

Example output for Linux kernel 3.x

Python reports Linux 3

It is always good to know how powerful a new cloud server is, when you take delivery.

There are a range of benchmarks available, however for pure cpu, I like to use some Mathematics.

Programs that tax a processor for several hours, often will be compiled from source.

( Makes sense as if the thing is cpu intensive,
then it really is important for it to be tailored more closely,
to the features available on the underlying host )

Benchmarking with fabric example – hosted on Bitbucket:

The fabric file at the link above, will download the code to your server and run the benchmark.

The image below (click to resize fullscreen) shows the preparatory steps in action as witnessed through the fabric call on the local machine.

benchmarking server from fabric

fabric to benchmark

The Mathematics will run for anywhere between 1 and 15 hours, depending on the raw (single core) processing power on the server being benchmarked.

Fabric availability as standard package

Because Fabric relies on Python 2.5 or newer, you will have to do your own thinking, for CentOS 5 and RedHat 5 (which have python 2.4 by default)

Here is a useful link for Python 2.5 and fabric on rpm based ‘5’ series systems.

Here is a fabric rpm in fedora that assumes a Python version 2.7 or newer.

Next Page »