Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG, Page 229 of 801  Not logged in ELOG logo
ID Date Icon Author Author Email Category OS ELOG Version Subjectdown
  67767   Mon Jan 26 15:56:41 2015 Reply Andreas Luedekeandreas.luedeke@psi.chQuestionAll3.3Re: calculate the value of one attribute depending upon the value of other attribute.

If you have the following elogd.cfg:

Attributes = START, END, DURATION
subst DURATION = $shell( /usr/local/elog/diff.sh \"$START\" \"$END\")
Show Attributes Edit = START, END

And the shell script /usr/local/elog/diff.sh is:

#!/bin/sh
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/3600"|bc -lq)
printf "%.0f hours" $d

Then DURATION is calculated from START and END in full hours.

It appears that if you define START and END as "datetime", then only the date part would be passed to the script. This may is a bug of elogd: Stefan, have you ever tried?

dev wrote:

I HAVE A LOGBOOK WHICH KEEPS THE RECORD OF ALL FAULT BOOKED BY DIFFERENT SUBSCRIBER.THIS LOGBOOK HAS THREE ATTRIBUTE DOWNTIME,UPTIME & TOTAL DURATION (DATE &TIME FORMAT) . I WANT TO CALCULATE THE TOTAL DURATION AUTOMATICALLY WHENEVR UPTIME VALUE IS GIVEN AND IF THE UPTIME IS NOT GIVEN IT SHOULD CALCULATE DEPENDING UPON THE SYSTEM PRESENT TIME.PLEAS EXPLAIN IT WITH EXAMPLE.

PS: Please do NOT write all capital text in a forum. Thank you!

  67768   Mon Jan 26 19:24:02 2015 Reply devjoshi868b@gmail.comQuestionAll3.3Re: calculate the value of one attribute depending upon the value of other attribute.

I tried that It is not calculating  and it is giving the error "Shell execution not enabled via -x flag ".I started elogd -x from command prompt  it still gives the same error.

Andreas Luedeke wrote:

If you have the following elogd.cfg:

Attributes = START, END, DURATION
subst DURATION = $shell( /usr/local/elog/diff.sh \"$START\" \"$END\")
Show Attributes Edit = START, END

And the shell script /usr/local/elog/diff.sh is:

#!/bin/sh
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/3600"|bc -lq)
printf "%.0f hours" $d

Then DURATION is calculated from START and END in full hours.

It appears that if you define START and END as "datetime", then only the date part would be passed to the script. This may is a bug of elogd: Stefan, have you ever tried?

dev wrote:

I HAVE A LOGBOOK WHICH KEEPS THE RECORD OF ALL FAULT BOOKED BY DIFFERENT SUBSCRIBER.THIS LOGBOOK HAS THREE ATTRIBUTE DOWNTIME,UPTIME & TOTAL DURATION (DATE &TIME FORMAT) . I WANT TO CALCULATE THE TOTAL DURATION AUTOMATICALLY WHENEVR UPTIME VALUE IS GIVEN AND IF THE UPTIME IS NOT GIVEN IT SHOULD CALCULATE DEPENDING UPON THE SYSTEM PRESENT TIME.PLEAS EXPLAIN IT WITH EXAMPLE.

PS: Please do NOT write all capital text in a forum. Thank you!

 

  67770   Tue Jan 27 15:59:59 2015 Reply Andreas Luedekeandreas.luedeke@psi.chQuestionAll3.3Re: calculate the value of one attribute depending upon the value of other attribute.

Yes, I forgot to mention that you need to enable shell script execution by starting the server with "elogd -x".

Before you start elogd from the command line you need to shutdown any running elogd; otherwise the port is blocked and the command line elogd cannot start: "sudo /sbin/service elogd stop"

From Linux you can edit instead /etc/init.d/elogd and add there the option "-x" to the line where "elogd" is started and then restart the service: "sudo /sbin/service elogd restart".

dev wrote:

I tried that It is not calculating  and it is giving the error "Shell execution not enabled via -x flag ".I started elogd -x from command prompt  it still gives the same error.

Andreas Luedeke wrote:

If you have the following elogd.cfg:

Attributes = START, END, DURATION
subst DURATION = $shell( /usr/local/elog/diff.sh \"$START\" \"$END\")
Show Attributes Edit = START, END

And the shell script /usr/local/elog/diff.sh is:

#!/bin/sh
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/3600"|bc -lq)
printf "%.0f hours" $d

Then DURATION is calculated from START and END in full hours.

It appears that if you define START and END as "datetime", then only the date part would be passed to the script. This may is a bug of elogd: Stefan, have you ever tried?

dev wrote:

I HAVE A LOGBOOK WHICH KEEPS THE RECORD OF ALL FAULT BOOKED BY DIFFERENT SUBSCRIBER.THIS LOGBOOK HAS THREE ATTRIBUTE DOWNTIME,UPTIME & TOTAL DURATION (DATE &TIME FORMAT) . I WANT TO CALCULATE THE TOTAL DURATION AUTOMATICALLY WHENEVR UPTIME VALUE IS GIVEN AND IF THE UPTIME IS NOT GIVEN IT SHOULD CALCULATE DEPENDING UPON THE SYSTEM PRESENT TIME.PLEAS EXPLAIN IT WITH EXAMPLE.

PS: Please do NOT write all capital text in a forum. Thank you!

 

 

  67773   Tue Jan 27 17:18:17 2015 Reply devjoshi868b@gmail.comQuestionAll3.3Re: calculate the value of one attribute depending upon the value of other attribute.

I am working in window system.Itries using elogd  stop and start  command  but it is always showing it is running.Kindly help  me  thanking you.

Andreas Luedeke wrote:

Yes, I forgot to mention that you need to enable shell script execution by starting the server with "elogd -x".

Before you start elogd from the command line you need to shutdown any running elogd; otherwise the port is blocked and the command line elogd cannot start: "sudo /sbin/service elogd stop"

From Linux you can edit instead /etc/init.d/elogd and add there the option "-x" to the line where "elogd" is started and then restart the service: "sudo /sbin/service elogd restart".

dev wrote:

I tried that It is not calculating  and it is giving the error "Shell execution not enabled via -x flag ".I started elogd -x from command prompt  it still gives the same error.

Andreas Luedeke wrote:

If you have the following elogd.cfg:

Attributes = START, END, DURATION
subst DURATION = $shell( /usr/local/elog/diff.sh \"$START\" \"$END\")
Show Attributes Edit = START, END

And the shell script /usr/local/elog/diff.sh is:

#!/bin/sh
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/3600"|bc -lq)
printf "%.0f hours" $d

Then DURATION is calculated from START and END in full hours.

It appears that if you define START and END as "datetime", then only the date part would be passed to the script. This may is a bug of elogd: Stefan, have you ever tried?

dev wrote:

I HAVE A LOGBOOK WHICH KEEPS THE RECORD OF ALL FAULT BOOKED BY DIFFERENT SUBSCRIBER.THIS LOGBOOK HAS THREE ATTRIBUTE DOWNTIME,UPTIME & TOTAL DURATION (DATE &TIME FORMAT) . I WANT TO CALCULATE THE TOTAL DURATION AUTOMATICALLY WHENEVR UPTIME VALUE IS GIVEN AND IF THE UPTIME IS NOT GIVEN IT SHOULD CALCULATE DEPENDING UPON THE SYSTEM PRESENT TIME.PLEAS EXPLAIN IT WITH EXAMPLE.

PS: Please do NOT write all capital text in a forum. Thank you!

 

 

 

  67774   Wed Jan 28 09:57:11 2015 Reply Andreas Luedekeandreas.luedeke@psi.chQuestionAll3.3Re: calculate the value of one attribute depending upon the value of other attribute.

Unfortunately I cannot help you with Windows. But you must have started the service somehow in the first place: that is where I would expect you can stop it as well.

dev wrote:

I am working in window system.Itries using elogd  stop and start  command  but it is always showing it is running.Kindly help  me  thanking you.

Andreas Luedeke wrote:

Yes, I forgot to mention that you need to enable shell script execution by starting the server with "elogd -x".

Before you start elogd from the command line you need to shutdown any running elogd; otherwise the port is blocked and the command line elogd cannot start: "sudo /sbin/service elogd stop"

From Linux you can edit instead /etc/init.d/elogd and add there the option "-x" to the line where "elogd" is started and then restart the service: "sudo /sbin/service elogd restart".

dev wrote:

I tried that It is not calculating  and it is giving the error "Shell execution not enabled via -x flag ".I started elogd -x from command prompt  it still gives the same error.

Andreas Luedeke wrote:

If you have the following elogd.cfg:

Attributes = START, END, DURATION
subst DURATION = $shell( /usr/local/elog/diff.sh \"$START\" \"$END\")
Show Attributes Edit = START, END

And the shell script /usr/local/elog/diff.sh is:

#!/bin/sh
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/3600"|bc -lq)
printf "%.0f hours" $d

Then DURATION is calculated from START and END in full hours.

It appears that if you define START and END as "datetime", then only the date part would be passed to the script. This may is a bug of elogd: Stefan, have you ever tried?

dev wrote:

I HAVE A LOGBOOK WHICH KEEPS THE RECORD OF ALL FAULT BOOKED BY DIFFERENT SUBSCRIBER.THIS LOGBOOK HAS THREE ATTRIBUTE DOWNTIME,UPTIME & TOTAL DURATION (DATE &TIME FORMAT) . I WANT TO CALCULATE THE TOTAL DURATION AUTOMATICALLY WHENEVR UPTIME VALUE IS GIVEN AND IF THE UPTIME IS NOT GIVEN IT SHOULD CALCULATE DEPENDING UPON THE SYSTEM PRESENT TIME.PLEAS EXPLAIN IT WITH EXAMPLE.

PS: Please do NOT write all capital text in a forum. Thank you!

 

 

 

 

  68435   Fri Sep 30 11:21:44 2016 Reply Alex Kühnelalexander.kuehnel@gmail.comQuestionLinux3.1.2Re: calculate diff of 2 date(s)

I found the solution in the forum :-)

subst Einsatzzeit = $shell(/usr/local/elog/diff.sh \"$Einsatzbeginn\" \"$Einsatzende\")

and diff.sh is

#!/bin/sh
#set -x
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/60"|bc -lq)
printf "%.0f Minuten" $d
 

 

 

Alex Kühnel wrote:

hi

I have an elogsystem for documenting emergency services. I have a starttime and an endtime. Is it possible to calculate the diff between the 2 timestamps and convert it to minutes?

 

Attributes = Bereitschafts Kalender Woche, Bereitschafts Woche, Einsatzbeginn, Einsatzende, Einsatzzeit, Telefon Nummer, Station, Status, Problem 
Options Status= Offen{1}, Erledigt{2}, Geschlossen{3}

......

Type Einsatzbeginn = datetime
Type Einsatzende = datetime

....

Subst Einsatzzeit  = $shell(Einsatzende - Einsatzbeginn) 

 

regards

/alex

 

  68436   Fri Sep 30 11:25:08 2016 Reply Alex Kühnelalexander.kuehnel@gmail.comQuestionLinux3.1.2Re: calculate diff of 2 date(s)

is ist possible that subst only works for the initial create of a logbook entry? when I change/edit one of the parameter "Einsatzbegin" or "Einsatzende" the "Einsatzzeit" is not changed.

regards

/alex

Alex Kühnel wrote:

I found the solution in the forum :-)

subst Einsatzzeit = $shell(/usr/local/elog/diff.sh \"$Einsatzbeginn\" \"$Einsatzende\")

and diff.sh is

#!/bin/sh
#set -x
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/60"|bc -lq)
printf "%.0f Minuten" $d
 

 

 

Alex Kühnel wrote:

hi

I have an elogsystem for documenting emergency services. I have a starttime and an endtime. Is it possible to calculate the diff between the 2 timestamps and convert it to minutes?

 

Attributes = Bereitschafts Kalender Woche, Bereitschafts Woche, Einsatzbeginn, Einsatzende, Einsatzzeit, Telefon Nummer, Station, Status, Problem 
Options Status= Offen{1}, Erledigt{2}, Geschlossen{3}

......

Type Einsatzbeginn = datetime
Type Einsatzende = datetime

....

Subst Einsatzzeit  = $shell(Einsatzende - Einsatzbeginn) 

 

regards

/alex

 

 

  68437   Fri Sep 30 12:33:38 2016 Reply Stefan Rittstefan.ritt@psi.chQuestionLinux3.1.2Re: calculate diff of 2 date(s)

There is the "subst on edit = ..." option you should use in addition.

Stefan

Alex Kühnel wrote:

is ist possible that subst only works for the initial create of a logbook entry? when I change/edit one of the parameter "Einsatzbegin" or "Einsatzende" the "Einsatzzeit" is not changed.

regards

/alex

Alex Kühnel wrote:

I found the solution in the forum :-)

subst Einsatzzeit = $shell(/usr/local/elog/diff.sh \"$Einsatzbeginn\" \"$Einsatzende\")

and diff.sh is

#!/bin/sh
#set -x
s1=$(date -d "$1" +%s)
s2=$(date -d "$2" +%s)
d=$(echo "($s2-$s1)/60"|bc -lq)
printf "%.0f Minuten" $d
 

 

 

Alex Kühnel wrote:

hi

I have an elogsystem for documenting emergency services. I have a starttime and an endtime. Is it possible to calculate the diff between the 2 timestamps and convert it to minutes?

 

Attributes = Bereitschafts Kalender Woche, Bereitschafts Woche, Einsatzbeginn, Einsatzende, Einsatzzeit, Telefon Nummer, Station, Status, Problem 
Options Status= Offen{1}, Erledigt{2}, Geschlossen{3}

......

Type Einsatzbeginn = datetime
Type Einsatzende = datetime

....

Subst Einsatzzeit  = $shell(Einsatzende - Einsatzbeginn) 

 

regards

/alex

 

 

 

ELOG V3.1.5-3fb85fa6