outsideit / firemotd Goto Github PK
View Code? Open in Web Editor NEW:fire: Fire Framework Linux MoTD Generator :fire:
Home Page: https://outsideit.net/firemotd
License: GNU General Public License v3.0
:fire: Fire Framework Linux MoTD Generator :fire:
Home Page: https://outsideit.net/firemotd
License: GNU General Public License v3.0
One initial action should be a test if the data file can be stored. See: https://community.openhab.org/t/oh2-raspi3-crash-and-lost-config/34916/12
Issue Type
Enhancement Request
Issue Detail
Looking to update from 7.11.170608 to the current 10.03.180725, I've noticed that executing firemotd using all the themes based on a theme file are slower.
On version 7.11.170608 every themes were included inside the firemotd script.
It would be nice to have better performances, it it is at least 2 times slower than before.
For info:
version | theme | theme location | time info |
---|---|---|---|
7.11.170608 | orange | internal | real: 0m1.761s, user: 0m0.303s, sys: 0m0.594s |
10.03.180725 | Original | internal | real: 0m2.024s, user: 0m0.547s, sys: 0m0.675s |
10.03.180725 | Invader | internal | real: 0m1.896s, user: 0m0.468s, sys: 0m0.586s |
10.03.180725 | Modern | external file | real: 0m3.712s, user: 0m1.484s, sys: 0m1.467s |
10.03.180725 | Blue | external file | real: 0m3.460s, user: 0m1.365s, sys: 0m1.313s |
Environment info
I'm user of VPS under OpenVZ.
Not sure if its related to specific virtualization options, but the route is not returning "via" part.
Basically it causes offset for awk arguments, so the f8 is empty string.
What it usually returns (excluding cache part):
192.168.0.1 via x.x.x.x dev interface0 src y.y.y.y
What it returns for my OpenVZ container:
192.168.0.1 dev interface0 src y.y.y.y
So the result is f6 instead of f8.
eth0 is expected line 70 in generate_motd.sh.
It should be at least a variable at the top of the file.
On all my CentOS7 VM, no eth0 but ens160 instead (vmware)
Getting this:
lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory
Debian 7 (Jessie)
OpenVZ
Currently digging on VPS, maybe its hidden by hypervisor.
Issue Type
Code Quality
Issue Detail
Latest versions are no longer 100 % Shellcheck compliant.
Expected Behavior
ShellCheck Passing
Actual Behavior
Shellcheck Failing
How to reproduce Behavior
Run ShellCheck
IP not displayed properly on Fedora 27
Enhancement Request
When using FireMotD on Fedora 27, the ip address is not displayed but instead the error message in the title. This appears to be due to a newer version of "ip", which on my machine shows uid at the end of line instead of the IP address, making it not match the criteria and hence it displays the error.
A change on line 221 of /usr/local/bin/FireMotD seems to fix that.
HostIp="$(${IpPath} route get 8.8.8.8 | head -1 | cut -d" " -f7)"
I've substituted -f7 in place of the -f8 in cut. After running FireMotD -S, it appears to work. I'm not sure if anyone wants to use this to make a Fedora 27 fork, but I don't have the knowledge or time right now. Just thought I'd share my solution. Thanks.
Expected Behavior: Display IP
Actual Behavior: Unable to parse ip. Please debug.
How to reproduce Behavior: Install on Fedora 27, run script
Current: FireMotD shows the whole allocated ram usage, which is not very useful, cause GNU/Linux systems usually allocate close to the whole available ram.
Proposed: show only the really used memory, from the "-/+ buffers/cache:" line of /usr/bin/free
Issue Type
Bug report
Issue Detail
Kibana Version cache hardcoded
FireMotD version: v11.04.190210
Fix:
KibanaRender="${PreKeyString}${KeyColor}${InfoKey} ${SeparatorColor}${Separator} ${ValueColor}Version: **\**$(jq -r ".Kibana.Version" $ExportFile)"
Hey there, I'm bugged by two problems.
Platform string wrongly sed'ed:
dmesg | grep "Rasp"
[ 0.000000] Linux version 4.4.0-1-rpi ([email protected]) (gcc version 4.9.2 (Raspbian 4.9.2-10) ) #1 Debian 4.4.6-1+rpi14 (2016-05-05)
[ 0.000000] Machine model: Raspberry Pi Model B Plus Rev 1.2
As you can see, there are two matching lines for Rasp="$(echo "$Dmesg" | grep "Rasp")"
, producing a malformed Platform string.
The Platform string is presented with grep coloring:
(after changing to Rasp="$(echo "$Dmesg" | grep "Rasperry")"
)
Not sure about the reason of using camelcase instead of lowercase for firemotd. Lowercase - harder to make mistake and easier to type.
Is there some existing application with same name?
This is related to the last two commits. I'm currently just seeing
Sessions = pi@
I'll provide a PR as soon as I found the time to look into this.
Discovered a new bug with free on CentOS 6. Results is an error message at logon. I'll need to investigate further asap..
free: invalid option -- '-'
usage: free [-b|-k|-m|-g|-h] [-l] [-o] [-t] [-s delay] [-c count] [-V]
-b,-k,-m,-g show output in bytes, KB, MB, or GB
-h human readable output (automatic unit scaling)
-l show detailed low and high memory statistics
-o use old format (no -/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] times
-a show available memory if exported by kernel (>80 characters per line)
-V display version information and exit
Version:
free -V
procps version 3.2.8
Issue Type
Enhancement Request
Issue Detail
I'd love to add information about he Java type and version used, such as openjdk vs oracle jdk.
Shell Checker is not so happy with some of my commands. I'm planning a major rework, so I'm not getting shellcheck errors.
@ThomDietrich Could you please test if the apt related changes are not giving any issues (as I'm not using apt)
I still need to verify on SUSE.
Some php.ini files contain multiple memory_limit directives, as orchestration tools such as Chef etc just append changed directives at the end of the config file...
I'll need to extract the latest value and convert -1 to 'Unlimited'
Issue Type
Bug report
Issue Detail
Expected Behavior
FireMotD displays correct information on login
Actual Behavior
after logging it is shown
FireMotD: Info: No FireMotD ExportFile detected. Please generate with โsudo .\FireMotD -Sโ
Trying to run
sudo .\FireMotD -S
I get:
018-07-22 18:30:05,216: FireMotD: Error: Template basic does not exist. Try \'basic\' or \'all\'. jq: error: Could not open file /usr/share/firemotd/data/FireMotD.json: No such file or directory
How to reproduce Behavior
Just update to newest 9.16.180717. the only way to resolve this issue is to downgrade to previous v8.08.171007 then FireMotD works perfectly fine.
Issue Type
Bug report
Issue Detail
Orange theme not there anymore.
Was there in 7.11.170608.
It's currently documented as existing.
Expected Behavior
Working Orange / orange theme
Actual Behavior
[root@xxxxxxxx ~]# /root/FireMotD -t orange
2018-08-29 12:04:45,901: FireMotD: Error: You specified a non-existant theme:
[root@xxxxxxxx ~]# /root/FireMotD -t Orange
2018-08-29 12:04:51,848: FireMotD: Error: You specified a non-existant theme:
[root@xxxxxxxx ~]#
I'd love to one day implement a system where themes are loaded from json files. Could take some time...
Hello,
first an addition for your README to trigger the CountUpdates()
function after an apt upgrade/install/.. was executed:
echo "DPkg::Post-Invoke { \"if [ -x /opt/FireMotD/FireMotD ]; then echo -n 'Updating FireMotD available updates count... '; /opt/FireMotD/FireMotD -S; echo 'OK'; fi\"; };" > /etc/apt/apt.conf.d/15firemotd
And now a request regarding https://github.com/willemdh/FireMotD/blob/master/FireMotD#L83
UpdateCount=$(apt-get update > /dev/null; apt-get upgrade -u -s | grep -P "^Inst" | wc -l)
Could you please provide a parameter which will not execute apt update
? It's (most probably) pointless after an apt upgrade
and does take needlessly long in the above integration...
My suggestion: -S
with, -s
without apt update
Hey @willemdh and all,
I just realized that even though FireMotD presents a lot of useful information I actually never "check" it for irregularities, even though that is how we ideally should use it.
Therefore I suggest to introduce a threshold (max AND/OR min) for values. If outside of the thresholds, a value will be presented in a theme-specific warning highlighting style. Wdyt?
Here's a super professional draft:
Issue Type
Bug report
Issue Detail
Basically I can't install it anymore. It throws the following error:
"Makefile:42: *** missing separator (did you mean TAB instead of 8 spaces?). Stop."
Indeed at line 42 in Makefile there are 8 spaces instead of a tab. Switched to tab and it worked.
How to reproduce Behavior
Clone the git repo and run make install
... and simplify options (-Afl
) passed to ps
(down to just -A
) since we're just passing the output straight off to wc -l
anyways for a count.
-f
causes the command arguments to be printed.
user@host:~$ ps -f
UID PID PPID C STIME TTY TIME CMD
user 12572 1754 0 02:51 pts/5 00:00:00 -bash
user 13344 12572 0 02:58 pts/5 00:00:00 ps -f
-l
Long Format.
user@host:~$ ps
PID TTY TIME CMD
12572 pts/5 00:00:00 bash
13170 pts/5 00:00:00 ps
user@host:~$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 12572 1754 0 80 0 - 5329 wait pts/5 00:00:00 bash
0 R 1000 13173 12572 0 80 0 - 7290 - pts/5 00:00:00 ps
I prepared a pull request to fix it in #31 for convenience.
Yet another issue:
Runtime error (func=(main), adr=15): Divide by zero
Related to Swap if non available (not uncommon on a Raspberry Pi)
Issue Type
Bug report
Issue Detail
Expected Behavior
No compile error. ;-)
Actual Behavior
When I start /opt/FireMotD/FireMotD -S I see the following error:
jq: error: syntax error, unexpected IDENT, expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
.Release.Value = "PRETTY_NAME="Debian GNU/Linux 9 (stretch)""
jq: 1 compile error
The machine is a fresh installed Debian Stretch 9.3, I installed FireMOTD through openhabian-config on this machine.
Issue Type
Bug report
Issue Detail
Maybe I miss something, but the advanced info (Apache, MySQL, PHP, ...) only available through the 'Original' theme.
Expected Behavior
All the themes can produce the advanced info.
Actual Behavior
Only the theme Original produces the advanced info.
Issue Type
Enhancement Request
Issue Detail
hostname is stil hardcoded in cache
Expected Behavior
Hostname should be read fromp export file
Actual Behavior
Hostname is hardcoded
How to reproduce Behavior
Change hostname and run FireMotD. Regenerating cache is required..
I believe this script is Linux only right? (no BSD or Mac or anything else?).
Because I was wondering if it would be OK to use GNU getopts to parse the options/parameters. It is quite easy to implement and quite powerful to use. We would have many benefits, like being able to use the parameters in any order, better parameter validation, etc.
The only downside is that GNU getopts is not available in other *nixes than Linux (by default, but can be installed). I guess the real downside is to create a dependency on GNU getopts, but since this is Linux only and all linuxes have GNU getopts...
I know for sure this doesn't work on Macs (I tried), and all other BSDs are probably the same.
Of course, if you plan to expand this to other systems, this will require extra work. But I think it would be nicer to just create another script for the other systems (keep it small, keep it clean).
If it is OK for you I will implement parsing the options/parameters with GNU getopts and make a pull request.
EDIT: After some nightmare conflicts I was able to rebase my fork to yours and have already made some minor changes. But I will wait for your answer to make another pull request. I am still not sure on why I couldn't merge with upstream, since you seem to have pulled all my changes and then changed on top of them. Did you edit the file on the browser by any chance?
Cheers!
Gus
since upgrading to Stretch most functions no longer report correct values:
# Ip = Unknown
## Release = Unknown
## Kernel = Unknown
## Platform = Unknown
## Uptime = 2 day(s). 13:4:11
## Installed = Unknown
## CPU Usage = 4.33% avg over 4 cpu(s) (4 core(s) x 1 socket(s))
## CPU Load = 1m: 0.83, 5m: 0.25, 15m: 0.09
## Memory = Free: 0.06GB (7%), Used: 0.88GB (93%), Total: 0.94GB
## Swap = Free: 0.07GB (79%), Used: 0.02GB (21%), Total: 0.09GB
## Root = Free: 49.98GB (76%), Used: 15.13GB (24%), Total: 68.24GB
## Updates = Unknown Unknown updates available
## Sessions = 1 sessions
## Processes = 166 running processes of 32768 maximum processes
## Apache = Version: Unknown
## nginx = Version: Unknown
## MySQL = Version: Unknown Distribution: Unknown
## PostgreSQL = Version: Unknown
## PHP = Version: Unknown, Memory Limit: Unknown
Issue Type
Missing command to remove the cron job file.
Bug report / Enhancement Request
Issue Detail
FireMotD version:
branch: master
OS distribution:
OS version:
Expected Behavior
Actual Behavior
How to reproduce Behavior
Issue Type
Bug report
Issue Detail
FireMotD: The wrong variable is saved at line 541.
Expected Behavior
Variable "$PostgresVersion" is saved.
Actual Behavior
Variable "$NginxVersion" is saved.
How to reproduce Behavior
sudo /usr/local/bin/FireMotD -S -v
cat /usr/share/firemotd/data/FireMotD.json
As I've said a few times before, I would like to generate the information and write it to a .json document. Information that isn't necessary to load every logon, will be queried with a cronjob every X hours, which should result in faster FireMotD generation..
For this to work, there will be another package requirement, which is https://github.com/stedolan/jq
This is the best option for working with json on the commandline I think. See https://shapeshed.com/jq-json/
In CentOS it's installed with yum install jq
@ThomDietrich @dimon222 Can you guys verify if installing jq is possible on your operating systems. let me know if you see an issue with this implementation.
The config file would look more or less like this:
{
"HostName": {
"Generated": "@Logon",
"Value": "$HostName",
"LastRun": "$Date"
},
"HostIp": {
"Generated": "@Logon",
"Value": "$HostIp",
"LastRun": "$Date"
},
"Release": {
"Generated": "@Cron",
"Value": "$Release",
"LastRun": "$Date"
},
"Kernel": {
"Generated": "@Cron",
"Value": "$Kernel",
"LastRun": "$Date"
},
"Platform": {
"Generated": "@Cron",
"Value": "$Platform",
"LastRun": "$Date"
},
"Uptime": {
"Generated": "@Logon",
"Value": "$Uptime",
"LastRun": "$Date"
},
"Installed": {
"Generated": "@Never",
"Value": "$Installed",
"LastRun": "$Date"
},
"CpuUsage": {
"Generated": "@Logon",
"Value": "$CpuUsage",
"LastRun": "$Date"
},
"CpuLoad": {
"Generated": "@Logon",
"Value": "$CpuLoad",
"LastRun": "$Date"
}
}
Issue Type
Bug report
Issue Detail
Expected Behavior
The current release is not working correctly on raspberry pi - i am running FireMotD 6.13.170302 on one pi successfully and 7.05.170509 on another.
Neither successfully run v8
Actual Behavior
Return FireMotD results
How to reproduce Behavior
Install on Raspberry Pi
Issue Type
Enhancement Request
Issue Detail
Feature Request
I would like to add the CPU temperature to the printout.
I'm running openHABian on a Raspberry and tried the following command:
vcgencmd measure_temp
which is giving this output:
temp=45.1'C
After the latest change with b3e92aa FireMotD will get stuck on PhpMaxMemory=$(tac $PhpMaxMemory ...
if PhpMaxMemory was not previously defined (none of the two above conditions were met). On our system no php.ini exists, The check should be skipped in this case.
As it is right now, FireMotD will hinder the user from logging in:
https://community.openhab.org/t/openhabian-stuck-on-ssh-connection/28040
Possible fix:
if [ -n "$PhpMaxMemory" ] ; then
PhpMaxMemory=$(tac $PhpMaxMemory | grep -F -m 1 memory_limit | sed -n 's/.* = \([0-9]*\)/\1/p' | sed 's/; .*//g')
fi
A quick fix would be highly appreciated, especially as many of our users are currently updating their installation... https://community.openhab.org/t/notice-to-all-openhabian-users-please-apply-a-fix-asap/27908/1
Show installation date with command:
rpm -qi basesystem | grep "Install Date"
Works only for rpm based os though..
Hey @willemdh, just wanted to ask before I invest any effort. Would you consider merging openHAB specific statistics? (version, opstate, overall devices and rules defined... could be a oneliner)
Obviously that's pretty specific for one application and might exceed the scope and maintainability of the one FireMotD script file...
So I did some tests with the dev branch and made a pull request. Is it possible to give you push permissions on the dev branch only somehow? Should I make the master branch protected?
... or add "FireMotD"
Hey Willem, a few of my users mistake the FireMotD version number as the version number of the overall system. I see the two options above, I would prefer the first but that's of course up to you ;) What do you think?
Any ideas on why that happens?
Happened again now. This is what my Fork info says:
This branch is 34 commits ahead, 3 commits behind willemdh:master.
I should just be 3 commits ahead I think (added the possibility to get internet IP on Amazon EC2 instances, since the LAN IP is kind of useless on those instances).
You didn't commit anything after accepting the pull request, so I really don't get it.
I will have to branch again (to save my changes).. then hard-reset to upstream, then reapply my changes. I really don't understand why github does not consider my changes when you accept my pull request. We should just be on the same commit from there.
Last time it took me more than 2 hours to get it back to upstream.
I may create a dev-tav branch or something to send new pull requests from my fork. This way at least I keep my master branch clean for when I need to update it from upstream. Then I just delete the branch and recreate it. Not very optimal but better than what is going on now.
This is a bit annoying...
EDIT: I wonder if that has anything to do with the fact that your pull request show all my commits as one only (with a different commit ID).
Cheers!
Gus
This code is missing from the StartGrayTheme function.
LeftoverChars=$((MaxLeftOverChars - HostChars -10))
(( $LeftoverChars <= 0 )) && LeftoverChars=0
Otherwise results in a error:
head: invalid number of bytes: /dev/zero
I'm working in dev-willem on a way to integrate an official banner, which would show some legal information. I'm still thinking about how to implement it. So I'm giving you guys the chance to discuss this topic with me. I don't have very much time left to implement this (need it for work), but I can always change some things later.
So I have the following questions:
My goal is to show the banner in a color of choice.. An example banner I have now is:
This computer system including all related equipment, network devices (specifically including Internet access), are provided only for authorized use. All computer systems may be monitored for all lawful purposes, including to ensure that their use is authorized, for management of the system, to facilitate protection against unauthorized access, and to verify security procedures, survivability and operational security. Monitoring includes active attacks by authorized personnel and their entities to test or verify the security of the system. During monitoring, information may be examined, recorded, copied and used for authorized purposes. All information including personal information, placed on or sent over this system may be monitored. Uses of this system, authorized or unauthorized, constitutes consent to monitoring of this system. Unauthorized use may subject you to criminal prosecution. Evidence of any such unauthorized use collected during monitoring may be used for administrative, criminal or other adverse action. Use of this system constitutes consent to monitoring for these purposes.
Looking forward to some input!
Willem
I was thinking of adding an auto update option. Sth like
sudo ./FireMotD --Update
Issue Type
Slow
Bug report / Enhancement Request
Issue Detail
After I get upgrade from V.7.05.170509 to v10.03.180725, after around 2-3sec loading, it's show up line by line, each line about 0.8-1.x sec, On previous version, after loading, info will show all info immediately
Expected Behavior
I expect same as previous, after loading will show all info at once
Actual Behavior
Info show up line by line
How to reproduce Behavior
I test on 3 Rpi, 2 Rpi 3 and 1 Rpi 3+, 1xRpi3 on Jessie and 1xRpi3+ on Stretch behavior same, line by line,
1xRpi3 on Jessie with old version V.7.05.17 function normal
I don't know is this is on Design, if it is, is there any options to behavior as previous version?
Hey just wanted to say thanks for this, simple and really effective! Awesome job! ๐
Current: on a machine with a running nginx server, using FireMotD as root will show the version of nginx; when ran as a normal user, this information is not shown
If possible please make this info show up when running as a normal user also.
I know I have done some pull requests that at some point were breaking script on several VPS configs.
It would be good to have some Unit testing for current script, so it can be prevented in the future (or at least warned before it gets merged by accident).
So far it doesn't seem to be trivial at all, since we basically have one big bash script. I quite expect this issue to be opened for a while.
There are multiple things to be tested like regression test of performance, functionality on special cases (missing installs for some apps), text offsets and other things.
I do really like this Bats option. Not sure yet how we can implement it. Its quite possible that some reorganization of script will be required like more atomic functions.
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.