Comments (2)
Hello Martin,
Thanks for present your case, it's always interesting to know the different ways of using Tuptime.
The requirement proposed falls into a type of filtering that could be called "advance filtering", because it is possible to normalize it to the point of reaching a register ID or a timestamp, any of them already covered by existing arguments, like --until
, --since
, --at
, --exclude
, --tsince
, --tuntil
, --tat
.
Please, let me summarize, plus yours, a few other examples that I've know:
- --since-non-graceful - Since the startup following the most recent non-graceful shutdown.
- --skip-bad-shutdown - All startups with a clean shutdown.
- --only-bad-shutdown - All startups with a bad shutdown.
- --last-bad-shutdown - Indentify only the last register when the system had a non-graceul shutdown.
And also with time:
- --since-last [month|week|day] - Report usual time ranges.
In some environments, like yours, they offer the key to use Tuptime, but they are like shortcuts. Tuptime offers strong and reliable primitives to construct basic filtering, allowing users to narrow down the range in any way they imagine.
If it offers one of these options, why not other that could be essential in other environment? At the end, the proyect would move away the good design trends, like Unix Philosophy and Suckless Philosophy
Anyway, to offer an alternative, if you put this little script in a folder listed in your $PATH before "/usr/bin", for example "/usr/local/bin" you'll have the expected behaviour.
#!/bin/bash
EXE='/usr/bin/tuptime'
# Process new argument if it exists
if [[ "$1" == "--since-non-graceful" ]]; then
# Remove it from argument list
set -- "${@/--since-non-graceful/}"
# Set argument value:
# - Order table by 'e'nd status
# - Grep last BAD register
# - Increase in 1 their No.
VAL1=`$EXE --table --order e | grep BAD | tail -1 | awk '{print $1 + 1}'`
# Set new behaviour
if [ -n "$VAL1" ]; then
set -- "$@" "--since" "$VAL1"
fi
fi
# Call with arguments
$EXE $@
Also, I slighly improve your filter using --order e
to avoid one pipe step.
Now, executing it with the new argument will produce the expected result:
$ tuptime --since-non-graceful
from tuptime.
Thanks for your feedback!
My request is totally not in the --last-year
class, because this seems to be flawlessly covered by --tsince
and --tuntil
, but now that you outlined a few additional use cases, --since-previous-graceful-until-previous-non-graceful
would be something I could see myself also being interested in. ;-)
I'll test a shell function that does the filtering. :-)
function tuptime-graceful () {
local tuptime_since=1
local temp_array
while read -r line
do
if [[ "${line}" =~ ' BAD ' ]]
then
read -r -a temp_array <<< "${line}"
tuptime_since=$(( temp_array[0] + 1 ))
break
fi
done < <(tuptime --table --order e --reverse)
tuptime --since "${tuptime_since}"
}
from tuptime.
Related Issues (20)
- Extra uptime entry generated for one reboot (power loss) HOT 1
- Any tips on fixing this error? HOT 6
- tuptime-plot1.py got IndexError HOT 6
- tuptime on AUR out of date and doesn't work HOT 15
- RPM %check section? HOT 7
- Replace sys.exit(-1) by sys.exit(1) HOT 2
- -g option should not really be needed HOT 5
- Need help in excluding certain date from tuptime HOT 11
- tuptime shows wrong donwtime HOT 10
- Retention about tuptime data HOT 2
- Convert to f-strings HOT 2
- Question: What happened to largest/shortest times? HOT 2
- How to uninstall the tuptime installed by script? HOT 4
- Error on line 72 of dbcheck HOT 2
- Incorrect uptime with previous downtime equal to 0 HOT 1
- systemd tmpfiles.d HOT 4
- hm HOT 2
- systemd-sysusers and Fedora/RHEL HOT 6
- Mismatch between "Shutdown time" reported by the tool and actual shutdown time. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tuptime.