Can anyone help convert time in a simple script?

Hi, i have the following 2 scripts running on my Mikrotik RB750up on a solar site to monitor battery levels.
I basically copy and modified them from the internet for my needs as i’m not really a script writer.
But the issue i have is that i need the info sent through 7am each morning, not 11pm each night.
This is so i can see if my wind generator did anything over-night, as i know my solar wouldn’t have contributed overnight!
So if anyone could help me change these, that would be awesome :slight_smile:
[OR even better, set a “variable??” where i can set the hour, if that’s possible??]

VOLTMONITOR

#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 112
:global earlyvoltwarn 114
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:local thisbox [/system identity get name]
:global voltage [/system health get voltage]
:local thistime [/system clock get time]
:local thisdate [/system clock get date]
:local thishour [:pick $thistime 0 2]
:local emessage ($thisbox . " voltage is " . [:pick $voltage 0 2] . “.” . [:pick $voltage 2 3] ." // " . [:pick $voltage 0 2] . “.” . [:pick $voltage 2 3]+5)
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}

set your email address in the next line

:if ($thishour >= “17” and $voltage = $earlyvoltwarn) do={/tool e-mail send to=“emailaddress” subject=“!-EARLY LOW VOLT WARN-! $thishour pm $emessage” body=$emessage from=RB750UP start-tls=yes}
:if ($voltage <= $lowvoltalarm) do={/tool e-mail send to=“emailaddress” subject=“!-LOW VOLT NOW-! $emessage” body=$emessage from=RB750UP start-tls=yes}
:if ($voltage > $highvolt) do={:set highvolt $voltage; :set hivolttime ($thistime . " " . $thisdate)}
:if ($voltage < $lowvolt) do={:set lowvolt $voltage; :set lovolttime ($thistime . " " . $thisdate)}
:if ([:len $vh] > 0) do={:set vh ([:toarray $voltage] + $vh)} else={:set vh [:toarray $voltage]}
:if ([:len $starttime] < 1) do={:set starttime ($thistime . " " . $thisdate)}
:if ($thishour = “23”) do={:execute voltreport}

VOLTREPORT

:global highvolt
:global lowvolt
:global hivolttime
:global lovolttime
:global starttime
:global vh
:local tvolt
:local thisbox [/system identity get name]
:local thisdate [/system clock get date]
:local thishour
:local emessage “Voltage report for $thisbox on $thisdate\n\n”
:if ([:len $vh] > 0) do={
:for x from=0 to=([:len $vh]-1) step=1 do={
:set tvolt [:tostr [:pick $vh $x]]
:set thishour [:tostr (23 - $x)]
:while ([:len $thishour] < 2) do={:set thishour (“0” . $thishour)}
:set emessage ($emessage . $thishour . ":00 = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . “\n”)
}
:set emessage ($emessage . "\nSince voltmonitor started on " . $starttime . “\n”)
:set tvolt [:tostr $highvolt]
:set emessage ($emessage . "Maximum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $hivolttime . “\n”)
:set tvolt [:tostr $lowvolt]
:set emessage ($emessage . "Minimum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $lovolttime . “\n”)

set email address in next line

/tool e-mail send to=“emailaddress” subject=“$thisbox Voltage Report” body=$emessage from=emailaddress start-tls=yes
}

remark out the next line for testing to avoid resetting the voltage array

:set vh

I do use script to send out using syslog, voltage/temperature and other option.
You can change the scheduler to send out at what hour you like, I do send info every 5 min.
Then I do use Splunk to graph everything.

Look at link in my signature to see how to use Mikrotik->Syslog->Splunk

Example on graph showing voltage and temperature.

Thank you. I may try that if i get some time to set it up.
Graphing it would make life easier than reading back though my emails! lol.

I’d still appreciate some help with my script above for now, as it turns out that i used Splunk about 5yrs ago, and now i can’t login anymore.
I can’t even register again, as my email and username are “unavailable” for use!

And they are a very difficult business to email… can only find phone numbers for other countries…

5 years old Splunk is very old. Uninstall and Install it with new user/password.

No, i don’t have it installed any more. From your link, it seems I must have an account to download and install the new one, but i can’t register with the company.
That’s my problem, i need an account reset from them, to let me use my account again or release my email address so i can create a new account.

Creating an account on Splunk is 100% free. Download is free and using it for the first 30 day is free.
Before 30 day, set Splunk lisens to free and you are good to go for 500MB of log every day, free.

So you could just use another email and create a new account.
Eks if you do not have more email account:
https://protonmail.com/
Free to create email account, no SMS verification, no other email verification.

You can try going about it via this route (that’s how I do it):
SNMPv3 ↔ Nagios/Icinga2 ↔ Graphite ↔ Grafana

All of the aforementioned software is available for free, given that you’re comfortable with Linux.

Well the simple answer is to change the execution time for the VOLTREPORT from 11PM to 7AM. Last line of the VOLTMONITOR script is as follows:

:if ($thishour = "23") do={:execute voltreport}

Change the ‘23’ (11 PM) to ‘07’ (7AM)

I notice in the VOLTREPORT script the logic is refering to ‘23’ again for the hour. I think the design of the script might not work as you want by changing to 7AM. Try it and see.