Page 1 of 1

Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by misterleffe
Är det möjligt att se vilken upptid min Raspberry Pi har sedan sista omstart?


/misterleffe

Posted: Fri Mar 17, 2023 9:45 am
by magnus07
Prova med kommandot: uptime

Re:

Posted: Fri Mar 17, 2023 9:45 am
by KHolm
magnus07 wrote:Prova med kommandot: uptime
Bonuspoäng till den som klurar ut ett Regex för att plocka resultat från /usr/bin/uptime till en användbar datafetcher :D
/Marcus

Re: Re:

Posted: Fri Mar 17, 2023 9:45 am
by misterleffe
KHolm wrote:
magnus07 wrote:Prova med kommandot: uptime
Bonuspoäng till den som klurar ut ett Regex för att plocka resultat från /usr/bin/uptime till en användbar datafetcher :D
/Marcus
Låter som jag också kunde bidra med bonuspoäng till "projektet". Näpet att kunna se det i Remote!

Tack magnus07 för kommandot! Ingen fena på Linux -ännu!


/misterleffe

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by KHolm
To be used in a datafetcher:

Code: Select all

FetchType: Execute
ParserType: Line,Scanf
Executable: awk '{printf("%d:%02d:%02d:%02d",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime
Scanf: %s
Results in the following signal:

Code: Select all

datafetcher,3,Uptime,fetched:3:00:57:23 
This gives you days, hours, minutes and seconds that can be transformed into a single string or multiple integers using a Signal Transform - based on what you need.

Instead of using the very hard to parse /usr/sbin/uptime I use what is reported on /proc/uptime where the first argument is number of seconds the system has been up.

E.g.

Code: Select all

Pattern to match: datafetcher,3,Uptime,fetched:%i:%i:%i:%i
Parsed variable to store: 2
Variable to uptate: UptimeHours (integer)

Pattern to match: datafetcher,3,Uptime,fetched:%s
Parsed variable to store: 1
Variable to uptate: Uptime (String)
References:
http://en.wikipedia.org/wiki/Uptime#Usi ... c.2Fuptime
http://unix.stackexchange.com/questions ... ormat-date

/Marcus

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by misterleffe
Works like a charm! Think you got the bonuspoints Marcus!

Is it possible, maybe in the same way, to collect data from tempsensors and put it on the Web for showing graphs? I wanna collect data for statistics over time and present it monthly, weekly or daily. Yes I know there is plot function in Autmagically and it's fine if you only want to know the last 24 hours. Is it possible to do this in Automagically? Could it be possible to FTP the collected data and have the database "outside" the Raspberry? Otherwise the SD card will be filled up very soon?

I'm not so good in Linux, so therefore I ask the "Brains" in this Forum, kindly ...


/misterleffe

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by KHolm
Since Automagically now reports sensors to live, I guess tellmon.net may do what you want. Check out this post and try it out.
http://www.telldus.com/forum/viewtopic.php?f=11&t=4173

Or, a cron job usling tdtool -l with sed/awk will collect data for you to fetch/parse...

/Marcus

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by misterleffe
KHolm wrote:Since Automagically now reports sensors to live, I guess tellmon.net may do what you want. Check out this post and try it out.
http://www.telldus.com/forum/viewtopic.php?f=11&t=4173

Or, a cron job usling tdtool -l with sed/awk will collect data for you to fetch/parse...

/Marcus
I will have a look at tellmon.net and test it. In fact, I want to store and make graphs locally, but my skills in Linux is to poor for doing that kind of stuff. I've heard about the tdtool, but honestly, I don't know how to use it and for sure, not to fetch data and put it into a graph ... Is tdtool a plugin which works together with Automagically? Do I have to get it and install it "in to" Automagically?


/misterleffe

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by KHolm
misterleffe wrote:Is tdtool a plugin which works together with Automagically? Do I have to get it and install it "in to" Automagically?
tdtool is a command line tool from Telldus. It is installed in the Automagically image so nothing is needed to be done to get it up and running.

Login to your pi and run the command:

Code: Select all

$ tdtool -l
This should give you the status of all your devices (in /etc/tellstick.conf) and values of sensons discovered by Tellstick Duo.

To turn on a device (id=45):

Code: Select all

$ tdtool --on 45
A simple command to output the temperrature from a sensor (id 254) every 60 second.

Code: Select all

$ while sleep 60; do tdtool -l | grep fineoffset | grep 254 | awk '{print $4}';done
To append the output to a file (~/temp.log):

Code: Select all

$ while sleep 60; do tdtool -l | grep fineoffset | grep 254 | awk '{print $4}' >> ~/temp.log;done
You might want to put this into a shell script (xxx.sh) and start it at boot; a tutorial for init.d scripts can be found here:
http://www.cyberciti.biz/tips/linux-wri ... rvice.html
/Marcus

Re: Upptid för Raspberry Pi

Posted: Fri Mar 17, 2023 9:45 am
by KHolm
misterleffe wrote: Is it possible, maybe in the same way, to collect data from tempsensors and put it on the Web for showing graphs?
Now/Soon there is, see my recent post:
http://www.telldus.com/forum/viewtopic.php?f=25&t=4220
/Marcus