you’re welcome!
-
System Uptime shellsensor device
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Hey guy’s,
Sometimes I get only 0 back from this script:
#!/bin/bash # uptime.sh # get uptime from /proc/uptime uptime=$(ps -eo etimes,cmd|grep -v grep|grep -i pimatic|awk '{print $1}' OFMT='%3.1f'|head -n 1) #uptime=$(ps -eo etimes,cmd|grep -v grep|grep -i pimatic|awk '{print $1}' OFMT='%3.1f'|head -n 0) #echo x$uptime x #seconds=$(( uptime%60 )) minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) days=$(( uptime/60/60/24 )) echo "$days Tage $hours Stunden $minutes Minuten"
I think leader is the builder of it
Any ideas?
pimatic + MySensors + Homeduino + z-way
https://github.com/n3roGit/MySensors_n3ro -
@n3ro
check the first post here. the script differs.
maybe this helps.pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Actually there’s a new version of the sysinfo plugin that has a device for uptime included
you can use it like that :
{ "class": "SystemSensor", "id": "uptime", "name": "System Uptime", "attributes": [ { "name": "uptime", "interval": 60000 } ] }
maybe there’s a possibility to format the time somehow like my above script does?
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
The Sparkline for this attribute is a little bit useless. Or our pi´s can travel trough time
pimatic rocks!!!
-
@Icesory
sure, pimatic can also control time machines (let’s go and invent …)
maybe the sparkline could be disabled by default via the plugin itself ?otherwise just use the xAttributeOptions for hiding the sparkline like that :
{ "class": "SystemSensor", "id": "uptime", "name": "System Uptime", "attributes": [ { "name": "uptime", "interval": 60000 } ], "xAttributeOptions": [ { "name": "uptime", "displaySparkline": false } ] }
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
@leader21 Actually, it does already (thanks to the human-format package used by pimatic to render attribute values)
@Icesory agree. Would make sense to deactivate sparkline for uptime by default
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig
hm … my uptime from the sysinfo plugin is in hours though - 556 hours is ~ 23 days like my shellsensor script displays :
and here’s the same info from the sysinfo uptime device - some ideas what went wrong?
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
I like this this script!
I use a similar one for monitoring the Pimatic-Service-Uptime.
But sometimes i get ‘0’ back…
#!/bin/bash #set -x # uptime.sh # get uptime from /proc/uptime uptime=$(ps -eo etimes,cmd|grep -v grep|grep -i pimatic|awk '{print $1}' OFMT='%3.1f'|head -n 1) #echo $(ps -eo etimes,cmd|grep -v grep|grep -i pimatic|awk '{print $1}' OFMT='%3.1f'|head -n 1) #seconds=$(( uptime%60 )) minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) days=$(( uptime/60/60/24 )) echo "$days Tage $hours Stunden $minutes Minuten"
Any Ideas?
pimatic + MySensors + Homeduino + z-way
https://github.com/n3roGit/MySensors_n3ro -
actually i switched from the uptime.sh script to the syssensor uptime. But the uptime over 24 hour is shown like this:
407:08:41
it would be nice if someone could change it to
16 T 08:41
thx !
-
Well, the conversion of the uptime is done in mobile-frontend by a helper function called toHHMMSS(seconds) based on the unit (s) given by the plugin.
I’m unsure of the best practice on where to change the behaviour. @developer
- change the frontend and extend the helper function to calculate also days or
- change the plugin to do the conversion on its own, without relying on the automated conversion by mobile-frontend
I would say a time period should always be able to show also days, so I would vote for 1)
-
@Markus-Plessing said:
I’m unsure of the best practice on where to change the behaviour
Best bractice would be to extend the “human-format” package used for rending human readble number formats. I have raised a question on how to do it a couple of months ago but I have not looked into this in detail yet. An alternative approach may be to use moment.js for rendering time/date values
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig said:
@Markus-Plessing said:
I’m unsure of the best practice on where to change the behaviour
Best bractice would be to extend the “human-format” package used for rending human readble number formats. I have raised a question on how to do it a couple of months ago but I have not looked into this in detail yet. An alternative approach may be to use moment.js for rendering time/date values
Ah ok. Thanks for the clarification.
It looks to me like a simple helper function inside helper.coffee of the pimatic-mobile-frontend.Maybe we should go for a quick fix, if the best practice is this complicated
-
@Markus-Plessing said:
It looks to me like a simple helper function inside helper.coffee of the pimatic-mobile-frontend.
Agree. Using moment.js it is really easy to implement. Extending human-format is not so easy at a first glance.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
Just had a look at moment.js. Surprisingly, the formatting options for durations are minimal, but there are some good plugins like preciseDiff available to fill the gaps.
The question now is, how the duration should be rendered? Personally I would prefer the the BSD/SUS format used by the uptime command which is
days HH:MM
. The alternative would be to use “preciseDiff” which provides the exact uptime in seconds using the human readble form, e.g1 month 2 days 3 hours 4 minutes 5 seconds
."It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig I also would prefer the
days HH:MM
format. Think that the second one is way too long. -
@jensebub and @leader21 : With regard to your differences in the uptime and sed, awk etc.
That is due to the fact that bananapi (on bananian) uses by default the zsh shell where debian on RPi uses the bash shell.
Please try on a command promptecho $SHELL
and you will (most probably) see.
To get the same output you need to switch to the bash shell on bananapi. That’s also why it works when using a script where you put the#!/bin/bash
as shebang in the top line: it will use the bash shell.This thread was more than a year old, but “woken from the dead”. That’s why I was triggered.
-
Thx harry for the info on bananaPi!
The uptime script in post no.1 works on both. Actually there are efforts to get the uptime from the systemsensor device into a better format.pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Hello, I apologize for the whole old themes.
But I have here also a mistake with “/”thats my uptime.sh
#!/bin/bash # uptime.sh # get uptime from /proc/uptime uptime=$(</proc/uptime) uptime=${uptime%%.*} seconds=$(( uptime%60 )) minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) days=$(( uptime/60/60/24 )) echo "$days Tage $hours Stunden $minutes Minuten $seconds Seconds" error [pimatic-shell-execute]: [ShellSensor#system-uptime] Error: Error getting attribute value for Uptime: /home/pi/uptime.sh: Zeile 4: $'\r': Kommando nicht gefunden. /home/pi/uptime.sh: Zeile 7: $'\r': Kommando nicht gefunden. /home/pi/uptime.sh: Zeile 8: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 9: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 10: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 11: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 12: $'\r': Kommando nicht gefunden.