Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - MarcusH

#31
General Support / Re: AgentExecuteAction
October 27, 2022, 12:06:09 PM
Checked source and tested, in 4.1.420 it was AgentExecuteAction and in 4.2.395 it is AgentExecuteCommand
#32
General Support / AgentExecuteAction
October 27, 2022, 08:44:38 AM
Hi,

Updated to 4.2.395 and now when script runs AgentExecuteAction i get Function not found?

Is this a bug can't see any notes in scripting docs that this is deprecated
#33
General Support / Re: JSON NXSL
September 12, 2022, 03:08:25 PM
Agent is running on Windows, installed with official package
#34
General Support / Re: JSON NXSL
September 05, 2022, 02:41:31 PM
If use Bearer auth i get "OAuth 2.0 Bearer Access Token not implemented" in web service errorMessage.

For info running 4.1.420 on both server and agent
#35
General Support / Re: JSON NXSL
August 31, 2022, 12:09:31 PM
Wonderful, looking forward to the release.

On a sidenote is support for Bearer authentication with token planned for implementation soon on webservice?
#36
General Support / Re: JSON NXSL
August 26, 2022, 04:42:52 PM
Almost always when you post a question you find an answer shortly after. I Solved my counting issue by using ->replace("[", "")->replace("]", "")->split(",")
With that i get an array with a JSON in each that i can loop through.
#37
General Support / JSON NXSL
August 26, 2022, 04:16:54 PM
Hi,

Working on integration NetXMS with GLPI using RestAPI and web service definitions. Everything is working except i can not get a handle arround the JSON response.

Is there no support for JSON arrays in NXSL functions?

For example i have this response and i want to loop these values and count total


[
   {
      "id": 178
   },
   {
      "id": 179
   },
   {
      "id": 181
   }
]
#38
General Support / Re: Script DCI
May 12, 2022, 09:12:32 AM
$dci works

Here exemple on what i have done.

CheckDownStatus(container objectid) loops all nodes in the container and gets latest value from DCI named Down, if any node has been down over 80 seconds it returns 80 else 0.

All below is run on same node named PushNode, this node is trusted on all nodes since i have trusted nodes active.

This version is run by a script DCI and pushes down value to a DCI with origin Push on PushNode

sub CheckDownStatus(obj)
{
  foreach(o : obj->children) {
  if(!o->isInMaintenanceMode)
  {
    downsince = GetDCIRawValue(o, FindDCIByName(o, "Down"));
    if(downsince > 80)
    {
    return 80;
    }
    }
  }
  return 0;
}

// AP Zone 1
PushDCIData($node, 3115, CheckDownStatus(FindObject("9347", $node)));
// AP Zone 2
PushDCIData($node, 3117, CheckDownStatus(FindObject("12216", $node)));


This version returns value to the same DCI that runs it, and as stated above only works from version 4.1.283

sub CheckDownStatus(obj)
{
  foreach(o : obj->children) {
  if(!o->isInMaintenanceMode)
  {
    downsince = GetDCIRawValue(o, FindDCIByName(o, "Down"));
    if(downsince > 80)
    {
    return 80;
    }
    }
  }
  return 0;
}

test = $dci->id;

// AP Zone 1
if(test = "3115"){ return CheckDownStatus(FindObject("9347", $node));}
// AP Zone 2
if(test = "3117"){ return CheckDownStatus(FindObject("12216", $node));}


My reason for these is that now i have one DCI that i can monitor if any node goes down in that group. I also like having things in scripts gives me more freedom, in some cases we call action on agents like the agent that is on the PC that runs the grafana screens has an action for text2speech and that is speaking some alarms with values that needs immediate action.

#39
General Support / Re: Script DCI
May 11, 2022, 11:52:57 AM
Changed approach, one DCI that runs script and script then push return to different push DCI
#40
General Support / Script DCI
May 11, 2022, 10:42:34 AM
Hi,

Is there any way to in a script that runs as DCI identify which DCI that started the script?
I am trying to make one script for multiple DCI
#41
General Support / Re: Trusted Nodes
May 11, 2022, 10:38:49 AM
Indeed i was deep in loops of trial and error to get it to work and i just tested it and it worked and just as i saw your reply i got how simple it was and how unnecessary advanced i made it :)
#42
General Support / Re: Trusted Nodes
May 11, 2022, 10:25:12 AM
Ah i got it working with trustednodes = [session.findObjectById(objectID).getObjectId()] but data.setTrustedNodes([trustedNodeId]) is cleaner
#43
General Support / Re: Trusted Nodes
May 11, 2022, 09:44:23 AM
Here is the entire code i am trying to get working, i get TypeError: setTrustedNodes(): 1st arg can't be coerced to java.lang.Long[]

# Add trusted nodes to list
trustednodes = [session.findObjectById(objectID)]

# Container to add trusted nodes to
container = session.findObjectById(objectID)

# Loop nodes in container
for node in container.getAllChildren(objects.GenericObject.OBJECT_NODE):
print node.getObjectName()
data = NXCObjectModificationData(node.getObjectId())
data.setTrustedNodes(trustednodes)
session.modifyObject(data)
#44
General Support / Re: Trusted Nodes
May 11, 2022, 08:39:11 AM
Got a script working that loops all nodes in a container but i cannot get setTrustedNodes to work, i think i have it down to NXCObjectModificationData not working in my case, happy for any pointers :)

Tried this simple code for verification and it does not work only get NoneType from data.

print node.getObjectId()
data = NXCObjectModificationData(node.getObjectId())
print data.getName()
#45
General Support / Re: Maleformed eMail
May 11, 2022, 08:16:23 AM
Hi,

We have the same issue on 4.1.283 and FromName= is correct.