yboetz / motd Goto Github PK
View Code? Open in Web Editor NEWCollection of 'message of the day' scripts
Collection of 'message of the day' scripts
I noticed that sometimes grep aborts its search through syslog when it thinks portions of the file are binary. This resulted in missing the "Previous self test" lines that 36-diskststus needs.
To see the problem, I removed the second grep to get the results of the first grep with:
tac /var/log/syslog /var/log/syslog.1 | grep -hiP 'smartd\[[[:digit:]]+\]:'
It results in:
My solution is to use add --text to grep to force grep to treat the entire file as text. The diff is:
diff --git a/36-diskstatus b/36-diskstatus
index 43bbbe9..2bc43bd 100755
--- a/36-diskstatus
+++ b/36-diskstatus
@@ -23,7 +23,7 @@ hddtemp_port=7634
logfiles='/var/log/syslog /var/log/syslog.1'
# get all lines with smartd entries from syslog
-lines=$(tac $logfiles | grep -hiP 'smartd\[[[:digit:]]+\]:' | grep -iP "previous self-test")
+lines=$(tac $logfiles | grep --text -hiP 'smartd\[[[:digit:]]+\]:' | grep --text -iP "previous self-test")
# use nc to query temps from hddtemp daemon
hddtemp=$(timeout 0.01 nc $hddtemp_host $hddtemp_port | sed 's/|//m' | sed 's/||/ \n/g')
The 40-services script doesn't properly detect lxd when it's running in an Ubuntu snap package. It improperly states the services is inactive. The 60-lxd script, using lxc commands, does properly detect running containers though.
$ systemctl is-active lxd
inactive
$ snap services lxd
Service Startup Current
lxd.daemon enabled active
Running ubuntu 20.04 server, all required packages are install, script files have the same permissions as the default scripts, sshd has printmotd set to yes. Any advice?
update-motd: /usr/sbin/update-motd /etc/update-motd.d /usr/share/man/man5/update-motd.5.gz /usr/share/man/man8/update-motd.8.gz
figlet: /usr/bin/figlet /usr/share/figlet /usr/share/man/man6/figlet.6.gz
lolcat: /snap/bin/lolcat
hddtemp: /usr/sbin/hddtemp /etc/hddtemp.db /usr/share/man/man8/hddtemp.8.gz
~$ ls -la /etc/update-motd.d/
total 44
drwxr-xr-x 2 root root 4096 Feb 27 09:20 .
drwxr-xr-x 128 root root 12288 Feb 27 09:03 ..
-rwxr-xr-x 1 root root 72 Jul 12 2020 00-hostname-color
-rwxr-xr-x 1 root root 1246 Jul 12 2020 20-sysinfo
-rwxr-xr-x 1 root root 1074 Jul 12 2020 30-zpool-bar
-rwxr-xr-x 1 root root 1084 Jul 12 2020 35-diskspace
-rwxr-xr-x 1 root root 1810 Jul 12 2020 36-diskstatus
-rwxr-xr-x 1 root root 883 Jul 12 2020 40-services
-rw-r--r-- 1 root root 998 Jul 12 2020 README.md```
You can use this as example:
printf "\ncontainers:\n"
docker ps --format 'table {{.Names}}\t{{.Status}}' | tr '[A-Z]' '[a-z]' | column -ts $',' | sed -e 's/^/ /'
Thanks!
System information: Raspberry Pi 2B running Raspbian 9, fresh install.
After running sudo run-parts /etc/update-motd.d
containing working scripts and 35-diskspace
, the output looks as follows:
### OTHER SCRIPT OUTPUT ###
run-parts: failed to exec /etc/update-motd.d//35-diskspace: Exec format error
run-parts: /etc/update-motd.d//35-diskspace exited with return code 1
When runnning 35-diskspace on its own, it generates output and, strangely enough, has exit code 1.
sff@raspberrypi:/etc/update-motd.d $ ./35-diskspace
disk usage:
./35-diskspace: line 19: [: : integer expression expected
/ 4% used out of 32G
[==================================================]
./35-diskspace: line 19: [: : integer expression expected
/boot 51% used out of 46M
[==================================================]
sff@raspberrypi:/etc/update-motd.d $ echo $?
0
Looking at the file itself on line 19, it uses a variable max_usage
that is never set, maybe it's related to that? Note: I tried setting max_usage
to 100, just to test it out but that didn't seem to fix the issue.
Not an issue, but a question. For the services status, do you have a way to identify docker containers and if any have any errors?
Instead using update-motd, you can just modify the ~/.bash_profile
to run the scripts at login, adding the script location at the end of the ~/.bash_profile
file:
~/bin/sysinfo
~/bin/services
~/bin/dockerstatus
~/bin/zpool-bar
...
I can't get your smartd script running on my server, and it seems my smartd logs are a different format to yours. My log lines look like this
Dec 6 11:21:43 onora smartd[1108]: Device: /dev/sdb [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 114 to 113
(the actual temperature is 34C, I checked with hddtemp
after seeing that)
They don't contain a UUID like it seems to suggest in the script. Would you be able to post an example of your syslog lines to help me get the script working on my system?
I looked at issue #8 and it looks like this might be the same issue. All my disks are reported to have the same temperature, although it changes occasionally, it's always the same.
I added the relevant lines to my /etc/smartd.conf
maybe this fixes this also?
Another minor issue I have with the script is it takes 0.8-0.9 seconds to run on my machine. Searching the syslog might be an inefficient way to get the temperature. Caching the output would also work.
I am working on the script now to try to get it to work for me.
Hi!
I am wondering if this needs some dependencies? I am using debian 9.
I just added this repos file to /etc/update-motd.d/ but nothing seems to have changed.
Love the scripts! Is there a way to exclude a directory/path from the disk usage script?
I don't want to show the docker mnts:
/var/lib/docker/aufs/mnt/
I can see that you've done a few locations with the '-x', doesn't appear to work with /var or just var etc.
Ideally just want to ignore from /var onwards.
Thanks
How are you getting access to run the syslog and fail2ban greps without access to the log files? Are you giving log files read access to others? Just curious if there's another way for those items to work!
On my Ubuntu 22.04 install, I had to specify the full path for lolcat to function. Otherwise 10-hostname-color did not display at all on the MOTD.
Full path: /usr/games/lolcat
/usr/bin/env figlet "$(hostname)" | /usr/bin/env lolcat -f
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.