Page 1 of 1

Domoticz uptime on the dashboard.

Posted: Tuesday 03 November 2015 20:38
by EddyG
It would be nice to have a Domoticz "uptime" on the dashboard.
If there is a problem with Domoticz I use monit to restart Domoticz.
By the "uptime" I could figure out if that happened recently and have to investigate why the restart took place.

Re: Domoticz uptime on the dashboard.

Posted: Tuesday 03 November 2015 21:16
by SweetPants
Uptime will only show you how long ago domoticz was restarted for the last time. What if this happend more times?
You can get more information from the monit log file /var/log/monit.log

Re: Domoticz uptime on the dashboard.

Posted: Wednesday 04 November 2015 6:22
by EddyG
I use the HTML interface daily and Domoticz is running fine for days or even weeks.
I would like to see on the interface if there was a restart.
If I see a recent restart then I could investigate monit.log and others for the reason of the restart.
Now I have to check monit.log every once in a while (or daily) and find out there there where a lot of restarts 5 days ago.

Re: Domoticz uptime on the dashboard.

Posted: Wednesday 04 November 2015 8:00
by safi78
Or have monit send you a message with Pushover? There's a very easy script for that (just google monit and pushover).

Works like a charm for me :)

Re: Domoticz uptime on the dashboard.

Posted: Wednesday 04 November 2015 8:28
by jackslayter
hi, add a new text dummy and this script

Code: Select all

#!/bin/sh
#uptime.sh

pid=`ps -ef |grep 'domoticz -daemon' |grep -v grep |awk '{print $2}'`
updz=`ps -p $pid -o %t | tail -1 | sed -e 's/^[ \t]*//;s/[ \t]*$//' | awk 'sub( "...$", "" )'`

itime=`uptime | awk '{print $1}' | awk 'sub( "...$", "" )'`

min=$(uptime | grep -ci min)
day=$(uptime | grep -ci day)
if  [ $min -eq 1 ] ; then
uptime=`uptime | awk '{print $3}'`
uptime2=`uptime | awk '{print $4}'`
elif [ $day -eq 1 ] ; then
uptime=`uptime | awk '{print $3}'`
uptime3=`uptime | awk '{print $5}'`
else
uptime=`uptime | awk '{print $3}'`
fi

curl "http://IPADRESS:PORT/json.htm?type=command&param=udevice&idx=TEXTIDX&nvalue=0&svalue="$itime"%2c%20up%20"$uptime"%20"$uptime2"-"$uptime3"%20Dz%20"$updz""
and chmod +x uptime.sh
jhdhj.png
jhdhj.png (4.09 KiB) Viewed 5826 times

Re: Domoticz uptime on the dashboard.

Posted: Wednesday 04 November 2015 8:31
by EddyG
I use telegram, and thats works perfectly. I know.
BUT. recently Domoticz was restarted frequently so I got a lot of alerts.
So thats why I suggest an "uptime" on the dashbord.

In my opinion it does not hurt anybody to add such a feature.

EDIT:
The above script is a good solution too (thanks), but takes up the place of a button on the dashboard.

Re: Domoticz uptime on the dashboard.

Posted: Friday 06 November 2015 3:25
by pluggin
this is my script for uptime

#!/bin/bash
pid=`ps -ef |grep "domoticz -daemon -www"|grep -v grep |awk '{print $2}'`
updz=`ps -p $pid -o %t | tail -1 | sed -e 's/^[ \t]*//;s/[ \t]*$//'`
val=$(echo ${updz/-/day(s)%20})
curl -s "http://IP:PORT/json.htm?type=command&param=udevice&idx=100&nvalue=3&svalue=$val" > /dev/null

I use a TEXT sensor for display the value

Re: Domoticz uptime on the dashboard.

Posted: Friday 06 November 2015 6:13
by EddyG
Hi,
Tnx, for the sensor script.
Found it in Setup -> About.
Thats good for me too.
Was it always there?

Re: Domoticz uptime on the dashboard.

Posted: Saturday 07 November 2015 10:27
by gizmocuz
No, it was added a few days ago (did not know about this thread... so it was a coincidence ;)

Re: Domoticz uptime on the dashboard.

Posted: Saturday 07 November 2015 17:01
by EddyG
Tnx. :D :D :D

Re: Domoticz uptime on the dashboard.

Posted: Saturday 07 November 2015 19:29
by stlaha2007
The Setup/About is strange.
Running domotics for more dan 16000 days.. Started begin of July ;-)
Guess it reads a wrong value...

The script of Pluggin seems correctly reading current pid and runtime of it. As Domoticz will change pid when a restart accurred.


Sent from my D6503 using Tapatalk

Re: Domoticz uptime on the dashboard.

Posted: Monday 16 November 2015 20:52
by stlaha2007
gizmocuz wrote:No, it was added a few days ago (did not know about this thread... so it was a coincidence ;)
Found it and checked it... However this is what About says:

Code: Select all

 About Domoticz

Version: 2.3530
Build Hash: 9eef872
Compile Date: 2015-11-01 11:41:18

Uptime: 16755 Dagen, 19 Uren, 39 Minuten, 55 Seconden 
Last reboot was Nov 7, 2015.
Seems that the format isn't correct or using some other timecode/timesource.

According to uptime:
Time 20:48:40 up 9 days 7:29, 3 users...
9 days 7 hours 29 minutes comes close to restart around 14.00h.




Sent from my D6503 using Tapatalk

Re: Domoticz uptime on the dashboard.

Posted: Tuesday 12 January 2016 10:57
by proohu01
Is there a way to use this uptime value into a LUA script variable?

I have a couple of switches that send me a picture using Telegram. I alway get a lot of messages when the system is rebooted or when I update (restart) Domoticz. I would like to be able to change my LUA scripts so it doesn't do anything if the uptime is less than a minute.

Re: Domoticz uptime on the dashboard.

Posted: Wednesday 13 January 2016 14:56
by Kjakan
I want to know about this to.

UptimeInMinutes or similar would be a nice feature.

Re: Domoticz uptime on the dashboard.

Posted: Friday 15 January 2016 10:24
by proohu01
A standard method would be a very nice addition indeed? Any chance of getting this into Domoticz as a feature? UptimeInMinutes sound good to me.

In the meantime, I cooked up some lua code that works for me now...

Code: Select all

commandArray = {}

	n = os.tmpname ()
	os.execute ("var=$(ps -eo pid,args |grep 'domoticz -daemon' | grep -v grep |awk '{print $1}') && echo $(($(cut -d '.' -f1 /proc/uptime) - $(($(cut -d ' ' -f22 /proc/$var/stat)/100)))) > " .. n)
	for line in io.lines (n) do
		UptimeInSeconds = line
	end
	os.remove (n)

	UptimeInSeconds = tonumber(UptimeInSeconds);
	-- print('Domoticz has been running for '.. UptimeInSeconds .. ' seconds')
	if UptimeInSeconds < 90 then
	    print('Domoticz uptime is less than 90 seconds')
	    commandArray['SendNotification']='Domoticz uptime is less than 90 seconds'
    end

return commandArray

Re: Domoticz uptime on the dashboard.

Posted: Tuesday 09 February 2016 17:57
by MacJL
Hello,

Why not adding a counter device for uptime in motherboard sensors?
It would be quite simple, can be used with blocky/scripts, and would have an history :D .