• phildunlap

    Hi ppaniceres, welcome to the forum!

    There's a simple example of writing to a file from a script within Mango in this thread: https://forum.infiniteautomation.com/topic/4208/creating-files-in-filestore-from-excel-post-process-script

    I would probably do this with a scripting data source on a cron like 0 * * * * ?

    posted in User help read more
  • phildunlap

    Hi Mista, welcome to the forum

    That has certainly been fixed in later versions to output more than null. I don't recall exactly what the issue there was, but you can perhaps check your browser's network tab and see what the response from the Dwr is, which may show the actual compilation results or error.

    posted in Mango Automation read more
  • phildunlap

    Hi YEZI,

    This would be in your log4j configuration, which in Mango would likely be located at either Mango/overrides/classes/log4j2.xml or Mango/classes/log4j2.xml

    You can reload the log4j settings at the /ui/administration/log4j-reset page from within Mango after you've modified the appropriate XML file's list of packages and log levels (near the bottom of the XML file)

    posted in BACnet4J general discussion read more
  • phildunlap

    In 3.6 security was added to scripts to ensure that only a script with superadmin permissions could invoke Java code. That's probably what you're seeing.

    posted in How-To read more
  • phildunlap

    Certainly!

    Do you mean that you tried it on the beta and it didn't work or you're saying that you're not using the beta and it still works? It should work for lots of older versions and still in future versions, as the post about the events email is a year and a half old at least.

    posted in How-To read more
  • phildunlap

    Hi Wingnut2.0,

    There is no event handler for "all" events, although that feature was implemented on a branch and not yet picked up.

    For now, I would advise polling with a script for events, using a script on a cron. It's not as responsive as being event driven (although you could poll with the script arbitrarily quickly), doing something like what occurs in this thread, but probably for a time period less than a day and more like a minute: https://forum.infiniteautomation.com/topic/3147/email-last-day-s-events

    In that script the eventList is a com.serotonin.m2m2.rt.event.EventInstance and have a method .getMessageString() that will return the translated message. https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/event/EventInstance.java

    posted in How-To read more
  • phildunlap

    Yes, it should be a couple years, and that would be with the unit powered off the whole time such that the battery was sustaining the clock. It's possible perhaps that in the journey from the factory to its current moment that the battery was dislodged by a firm smack or drop.

    posted in Mango Automation read more
  • phildunlap

    where would the event handler to create the Mango/RESTART file go?

    On the system startup event.

    posted in User help read more
  • phildunlap

    Hi Brian,

    I do not believe a fix for this observation is in that beta. I do believe it is our intention to make that fix. The timeline of the release is not firmly established. I will update you when a fix for the issue is in the code, and when it is released.

    posted in User help read more
  • phildunlap

    That is a kind sentiment to share, surely!

    posted in Mango feedback read more
  • phildunlap

    Hmm, it does sound like a battery issue, but it could also be that the hardware clock wasn't set somehow and for some reason in the normal course of production. You can try running, sudo hwclock -w after you've noticed date is producing the right output (so connect it to the internet and let ntp do its thing first). This would write to the hardware clock. If after you've observed that a hwclock -r produced the right date prior to a power cycle but not after, then it would surely be a battery issue. If however it retains time, it could have been an issue during the production of the units or it could be the batteries lost contact in transport, or something to that effect.

    posted in Mango Automation read more
  • phildunlap

    Hi Richard,

    I can only echo my words to @psysak : https://forum.infiniteautomation.com/topic/4238/thank-you-to-everyone-for-the-help/2 who oddly posted another new thread the next day!

    Personally, I'm not a fan of this sort of thread. Because,

    1. Say thanks when receiving the help and it doesn't need saying again.
    2. You leave the forum every time you close the browser, and you can come back whenever you wish. So, the "Goodbye" part of it also is to be taken as more final. As I told psysak, nothing is stopping you from using Mango in your personal life or your next position or whatever, and nobody said you had to leave the forum, so feel free to stick around....

    posted in Mango feedback read more
  • phildunlap

    Hi Johautt

    I ask if there is something bad with this format.

    There's nothing inherently wrong with epoch format. The worst mark against it would be its lack of human readability. During development Jared expressed a preference for the timezoned-human-readable format on the benefit of readability and therefore can be modified by hand. The first dates you provided have a Z to indicate their stamped in UTC time, but you could modify the Z to be something like from=2019-06-14T04:00:00.000-06:00 would be six hours less at the start of the period. It does mean daylight savings may affect your regions +/- amount. It's ISO 8601 format, so you should be able to convert any dates you have in a programming language to it fairly easily.

    posted in Mango Automation general Discussion read more
  • phildunlap

    Hi chio,

    Currently this option does not exist, but it would be pretty easy to use a JSON export and a python script to rewrite the file something like...

    import json
    
    configFile = open("/path/to/config.json", encoding='utf-8')
    config = json.load(configFile)
    configFile.close()
    
    csvData = open("/path/to/data.csv", "r")
    xidLine = csvData.readline()
    
    # Assume no commas, quotes or newlines in the XIDs
    xids = xidLine.replace("\r", "").replace("\n", "").replace("\"", "").split(",")[1:]
    #print(xids)
    
    xidMap = {}
    for dp in config["dataPoints"] :
        xidMap[dp["xid"]] = dp
    	
    newFirstLine = "\"timestamp\""
    for xid in xids :
    	newFirstLine += ",\"" + xidMap[xid]["deviceName"] + " - " + xidMap[xid]["name"] + "\""
    newFirstLine += "\n"	
    
    #print(newFirstLine)
    outputFile = open("/path/to/output.csv", "w+")
    outputFile.writelines(newFirstLine)
    outputFile.writelines(csvData.readlines())
    outputFile.close()
    csvData.close()
    

    Definitely we see what you're saying and that you've added weight in the discussion that the available formats could be more flexible. I think the original XIDs as headers was done in anticipation of providing a multicolumn data upload, but no such feature exists currently.

    I have created a git issue about it: https://github.com/infiniteautomation/ma-core-public/issues/1436

    posted in User help read more
  • phildunlap

    Hmm, that looks okay. I wonder if maybe there's another cron definition invoking the script? You could try commenting out the line that tries to invoke /usr/sbin/systemInfo/timeAlive in /usr/sbin/systemInfo/getAll to see if that error is what's getting there, but I have the same line in the device I'm looking at and it doesn't produce /var/mail/mail contents. That definitely looks a lot like what was happening when the output of the cron job was not being redirected to /dev/null

    posted in Mango Automation read more
  • phildunlap

    https://forum.infiniteautomation.com/topic/3044/can-you-relativise-an-excel-report-driven-by-watchlist-possibly

    ^ Has an example of a script that uses the watchlist's export to iterate over the XIDs that are in the watchlist. That's really more for static watchlists, but you could also get a watchlist's query string this way to pass to the RQL. There is a DataPointQuery.byXid("DP_12345") function as well to get a single DataPointWrapper.

    https://help.infiniteautomation.com/about-mango-java-script

    Has information about the various context objects available to assist in writing scripts. Note from the first link, though, that you can invoke Java directly, making the scripting environment extremely powerful and flexible.

    posted in How-To read more
  • phildunlap

    Hi andrewh,

    Can you share the output of tail -n 50 /var/mail/mail ?

    Also perhaps can you ensure the /etc/cron.d/system-info cron job is directing its stdout and stderr to /dev/null, > /dev/null 2>&1 ? This should have occurred in updating the MangoESConfiguration module to the versions Joel mentioned (or later versions).

    posted in Mango Automation read more
  • phildunlap

    Hi pyeager, welcome to the forum!

    If I could associate the script with a watchlist, that would seem to solve the problem, but I don't see a way to do that.

    Do you say this because you have a parameter in a watchlist you've created or something which you are selecting between? I do not understand how you're thinking of associate a script with a watchlist.

    Have you had a play with the DataPointQuery context object? You can use RQL just like the watchlist builder. DataPointQuery.query(rql); returns a list of DataPointWrapper objects, which are what you get from a context point when you call .getDataPointWrapper(); . Data point wrappers have a .getRuntime(); that will return the type of object manually added context points are, AbstractPointWrapper, or null if the point is disabled.

    posted in How-To read more
  • phildunlap

    Maybe I've to create a chron script that daily rsync backup directory on a remote server.

    Yes, that's a good way to do it.

    posted in Mango Automation general Discussion read more