Code Monkey home page Code Monkey logo

motd-generator's Introduction

Message-of-the-Day Generator

Introduction

motd

This is a custom message of the day (MOTD) designed to be as practical and informative as possible. The truth is, no one actually reads the MOTD. As such, the MOTD should contain useful, yet minimal, information about the host system such that a quick glance at it when logging in may actually be worth a person's precious time. This way, any potential issues are noticed and not naively ignored. This MOTD generator scripts has the ability to output text in color. Using this feature, potential issues can be highlighted for easy identification.

Warnings that can be highlighted:

  • The login time if this is the first login since a reboot
  • The last login hostname if it differs from the current login hostname
  • CPU utilization if it exceeds a threshold
  • CPU load if it exceeds a threshold
  • RAM usage if it exceeds a threshold
  • Disk usage if it exceeds a threshold
  • Network load if it exceeds a threshold

Feel free to modify the scripts as you see fit!

Files

  • motd_gen.py: Script to generate informative MOTD display
  • motd_stat.py: Statistic gathering daemon for MOTD
  • motd_stat: Init.d script to start the motd_stat daemon

Installation

# Be root to install
su

# Download the archive
curl -L https://github.com/dsnet/motd-generator/archive/master.tar.gz | tar -zxv

# Move local copy
SRC_ROOT=/usr/local/motd_gen
mv motd-generator-master $SRC_ROOT

# Setup the daemon service
ln -s $SRC_ROOT/motd_stat /etc/init.d/motd-stat
update-rc.d motd-stat defaults
service motd-stat start

# Nuke old MOTD file
rm /etc/motd
touch /etc/motd

# Prevent other modules from printing redundant information
sed -i -e 's|\(PrintLastLog\s*\)yes|\1no|' /etc/ssh/sshd_config
sed -i -e 's|\(PrintMotd\s*\)yes|\1no|' /etc/ssh/sshd_config
sed -i -e 's|\(^\s*session.*pam_mail.so\)|#\1|' /etc/pam.d/*
sed -i -e 's|\(^\s*session.*pam_motd.so\)|#\1|' /etc/pam.d/*
sed -i -e 's|\(^\s*session.*pam_lastlog.so\)|#\1|' /etc/pam.d/*
/etc/init.d/ssh restart

# Print the custom MOTD upon every login
echo -e "
if [ -e $SRC_ROOT/motd_gen.py ]; then
\tif [ -x /usr/bin/dircolors ]; then
\t\t$SRC_ROOT/motd_gen.py --color --warn --border
\telse
\t\t$SRC_ROOT/motd_gen.py --border
\tfi
fi" >> /etc/profile

motd-generator's People

Contributors

dsnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

motd-generator's Issues

service motd-stat start wont work

Feedback from the journalctl -xeu motd-stat.service

For Debian 6.1.55-1 the Script is not working.
Is something missing?

Error-Output:

Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD systemd[1]: Starting motd-stat.service - LSB: Starts the MOTD statistics monitor...
░░ Subject: A start job for unit motd-stat.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit motd-stat.service has begun execution.
░░
░░ The job identifier is 21665.
Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD motd-stat[2554009]: Starting motd_stat:
Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD motd-stat[2554009]: motd_stat not started ... failed!
Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD systemd[1]: motd-stat.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ An ExecStart= process belonging to unit motd-stat.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD systemd[1]: motd-stat.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit motd-stat.service has entered the 'failed' state with result 'exit-code'.
Jan 27 02:14:44 VM-ITDA-DMZ-CLOUD systemd[1]: Failed to start motd-stat.service - LSB: Starts the MOTD statistics monitor.
░░ Subject: A start job for unit motd-stat.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit motd-stat.service has finished with a failure.
░░
░░ The job identifier is 21665 and the job result is failed.

Also after login in SSH the MOTD looks like this now:

Using username "root".
Last login: Sat Jan 27 02:47:24 2024 from x.x.x.x
/usr/bin/env: „python“: Datei oder Verzeichnis nicht gefunden "File or Folder is missing"
-bash: /root/.bashrc_motd: Datei oder Verzeichnis nicht gefunden "File or Folder is missing"
-bash: bash_motd: Kommando nicht gefunden. "not found"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.