Skip to main content

Python classes to allow for tailing of multiple files via SSH.

Project description

A simple set of Python classes to facilitate tailing of one or more files via SSH. At the moment it only supports key-based SSH’ing.

Quick installation

Install from PyPI:

> easy_install -U python-sshtail

Tailing a single file

from sshtail import SSHTailer
from time import sleep

# "1.2.3.4" is the IP address or host name you want to access
tailer = SSHTailer('1.2.3.4', '/var/log/path/to/my/logfile.log')

try:
    while 1:
        for line in tailer.tail():
            print line

        # wait a bit
        time.sleep(1)

except:
    tailer.disconnect()

Tailing multiple files

from sshtail import SSHMultiTailer

tailer = SSHMultiTailer({
    '1.2.3.4': ['/path/to/log1.log', '/path/to/log2.log'],
    '4.3.2.1': ['/path/to/log3.log'],
})

# will run until it receives SIGINT, after which it will
# automatically catch the exception, disconnect from the
# remote hosts and perform cleanup

for host, filename, line in tailer.tail():
    print "%s:%s - %s" % (host, filename, line)

Using a custom private key

from sshtail import SSHMultiTailer, load_dss_key

# if no path's specified for the private key file name,
# it automatically prepends /home/<current_user>/.ssh/
# and for RSA keys, import load_rsa_key instead.

tailer = SSHMultiTailer({
        '1.2.3.4': ['/path/to/log1.log', '/path/to/log2.log'],
        '4.3.2.1': ['/path/to/log3.log'],
    },
    private_key=load_dss_key('identity'))

for host, filename, line in tailer.tail():
    print "%s:%s - %s" % (host, filename, line)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-sshtail-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

python_sshtail-0.0.2-py2.7.egg (7.2 kB view details)

Uploaded Source

File details

Details for the file python-sshtail-0.0.2.tar.gz.

File metadata

File hashes

Hashes for python-sshtail-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a7a45a4f5bbbdf8c1802099ea9d249261cec389046f3534770c476cf594e3e55
MD5 3a0fdc5b36493eeb19feb61206988ca2
BLAKE2b-256 954ba205df9c88d9a1653cdee0fbe886fe162a2482d23def972d8cb7046a6257

See more details on using hashes here.

File details

Details for the file python_sshtail-0.0.2-py2.7.egg.

File metadata

File hashes

Hashes for python_sshtail-0.0.2-py2.7.egg
Algorithm Hash digest
SHA256 b3ad4e56c9eb5d7db03c0d857fad6390c0b83c3cc9b40e58aa1ed1a982037ea7
MD5 6114f76c4ed2954455ef0e9d7c019e49
BLAKE2b-256 9d381509b123e3b5d9f4f1afa83ed364a1d7163d4ae97257ecdabdbbe99a6cdd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page