/usr/lib/python2.7/dist-packages/ltsp/status.py is in python-ltsp 0.2-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ##
## LTSP server status
##
## Copyright (C) 2007 Canonical Ltd.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
"""
status offers simple functions to check the different
server processes used by ltsp servers.
Copyright 2007, Canonical Ltd.
"""
import os
def check_server(binary_name):
"""
checks if binary_name is currently running and returns True/False
binary_name: name of a server bianry to look for in the processlist (i.e. nfsd)
"""
status=os.popen('ps -C '+binary_name+' --no-headers')
for line in status:
if line:
return True
return False
def check_inetd(service):
"""
checks if service is enabled in /etc/inetd.conf and checks if inetd is
running. returns True/False
service: service name (i.e. tftp) or a portnumber
"""
status=os.popen('grep ^'+service+' /etc/inetd.conf')
if status.read():
return check_server('inetd')
return False
def tftp():
"""
returns True if tftp service is ok
"""
return check_inetd('tftp')
def ldminfo():
"""
returns True if ldminfo service is ok
"""
return check_inetd('9571')
def nbdswap():
"""
returns True if nbdswap service is ok
"""
return check_inetd('9572')
def dhcp():
"""
returns True if dhcp service is ok
"""
return check_server('dhcpd3')
def nfs():
"""
returns True if nfs service is ok
"""
return check_server('nfsd')
|