You are here
Alex Whatley - Sun, 2012/10/07 - 21:48
Hey,
I have recently installed Turnkey Domain controller to run in my network. I would like to set up the MOTD on ssh login to show more then just the free space on "/". I cannot figure out how to change it. I have tried adding a line to the file /usr/bin/turnkey-sysinfo but it will only replace the disk usage and not add another one to it.
Any help would be great.
Alex
Forum:
Tags:
I'm not familiar with customising the MOTD
But Debian has a wiki page on it (TKL v12.x is based on Debian 6/Squeeze).
Its not the MOTD itself
Hey,
Its the turnkey-sysinfo that i am having issues, the MOTD pulls info from that file, and I cannot seem to figure it out.
HowTo edit turnkey-sysinfo for MOTD
Ok so I added a separate data volume to separate file shares from system volume, and I also wanted to know disk space of the volume supporting the file shares on login.
Here's what my current MOTD looks like:
I edited the file with vi /usr/lib/turnkey-sysinfo/turnkey-sysinfo.py
Use pico if vi confuses you.
Under def_main(): I added a new disk.usage variable (disk_usage1) right after the first one referencing where I mounted the second disk,
disk_usage = "Usage of /: " + disk.usage("/")
disk_usage1 = "Usage of /data/: " + disk.usage("/srv/storage/data")
then added a "row" with rows.append((disk_usage1,'')) in front of the print statements which pull everything together.
for nic in nics[1:]:
rows.append(('', nic))
rows.append((disk_usage1,''))
Hope this helps.
Best regards,
Jeff
--
Re: HowTo edit turnkey-sysinfo for MOTD
Hi Jeff,
I followed your instructions but I still cannot get the second mounted drive to show up.
I have a partition mounted at /srv/storage. This is what
turnkey-sysinfo.py looks like:
# turnkey-sysinfo is open source 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 3 of the
# License, or (at your option) any later version.
#
import os
import re
import disk
from memstats import MemoryStats
from datetime import datetime
import netinfo
import commands
NIC_BLACKLIST = ('lo')
def get_nics():
nics = []
for ifname in netinfo.get_ifnames():
if ifname in NIC_BLACKLIST:
continue
nic = netinfo.InterfaceInfo(ifname)
if nic.is_up and nic.address:
nics.append((ifname, nic.address))
nics.sort(lambda a,b: cmp(a[0], b[0]))
return nics
def get_loadavg():
return os.getloadavg()[0]
def get_pids():
return [ int(dentry) for dentry in os.listdir("/proc")
if re.match(r'\d+$', dentry) ]
def main():
system_load = "System load: %.2f" % get_loadavg()
processes = "Processes: %d" % len(get_pids())
disk_usage = "Usage of /: " + disk.usage("/")
disk_usage1 = "Usage of /srv/storage: " + disk.usage("/srv/storage") (this was added by me)
memstats = MemoryStats()
memory_usage = "Memory usage: %d%%" % memstats.used_memory_percentage
swap_usage = "Swap usage: %d%%" % memstats.used_swap_percentage
rows = []
rows.append((system_load, memory_usage))
rows.append((processes, swap_usage))
nics = [ "IP address for %s: %s" % (nic, address)
for nic, address in get_nics() ]
column = [disk_usage]
if nics:
column.append(nics[0])
rows.append(column)
for nic in nics[1:]:
rows.append(('', nic))
rows.append((disk_usage1,")) (this was added by me)
print "System information (as of %s)" % datetime.now().strftime("%a %b %d %H:%M:%S %Y")
print
max_col = max([ len(row[0]) for row in rows ])
tpl = " %%-%ds %%s" % max_col
for row in rows:
print tpl % (row[0], row[1])
if os.geteuid() == 0:
error, output = commands.getstatusoutput("tklbam-status")
error_nosuchcommand = (os.WEXITSTATUS(error) == 127)
if not error_nosuchcommand:
print
print output,
if __name__=="__main__":
main()
I dont know where im going wrong. I would like to eventually have my 4 different partitions listed here espically when I ssh in from my phone. Please let me know what I am doing wrong.
Add new comment