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 - graeChris

#16
General Support / Re: NetXMS Grafana Plugin
June 09, 2023, 04:18:58 PM
Just wanted to follow up on this. I discovered the deprecation when I was attempting to figure out how to use dashboard variables with the plugin. It doesn't appear that that plugin supports dashboard variables. 
#17
Sorry for the delay! I've been in the hospital, but I'm all better now. 

We restarted the server shortly after this happened but only because it stopped returning the correct parameters to grafana SQL calls and we realized the disk space was low. 
#18
I haven't been able to duplicate this issue, but I think I discovered what caused the problem. Our server needed to be restarted as it was utilizing too much of the allocated resources. I believe this was causing the unexpected behavior as the database was also not updating values that were set for the object_properties.name field.
For the sequence of events. 

1.) Agent Disabled on endpoint for alarm creation -> Alarm created via EPP {status=0}
      1.1) Alert is created in OpsGenie
2.) Alarm marked as acknowledged by user -> HOOK:AlarmStateChange is executed -Confirmed via trace()- {status=1}
      2.1) Event is processed and opsgenie alert is acknowledged via cUrl
3.) Alarm Enabled on endpoint -> Alarm terminated via EPP  -> HOOK:AlarmStateChange is executed -Confirmed via trace()- {status=3}
      3.1) Alert is closed in OpsGenie
4.) Agent Disabled on endpoint again for alarm creation -> Alarm created via EPP {status=0} -> Log shows that HOOK:AlarmStateChange has executed via trace and Alarm has {status=3}
      4.1) Alert is created in Opsgenie via cUrl
      4.2) Alert is marked as closed in opsgenie via cUrl

I think this is more of a server related problem as we were running low on disk space at the time.

#19
General Support / NetXMS Grafana Plugin
May 23, 2023, 10:17:06 PM
Is there any development currently happening on the Grafana plugin? I checked github and noticed an issue was posted that AngularJS has been deprecated by Grafana in favor of React. 

https://github.com/netxms/grafana/issues/24

https://grafana.com/docs/grafana/latest/developers/angular_deprecation/#why-are-we-deprecating-angular-support

https://grafana.com/docs/grafana/latest/developers/angular_deprecation/angular-plugins/#netxmshttpsgrafanacomgrafanapluginsradensolutions-netxms-datasource

According to Grafana:
"For data source plugins the query editor and config options will likely need a total rewrite."
#20
I was able to get the external alerting to work with OpsGenie finally and I think I discovered a bug in the Alarm generation.

I am using the following code inside HOOK:AlarmStateChange 

sub main()
{
    eventserver = FindNodeObject($node, 100);
    global alarmstate = $alarm->state;
    global eventname = $alarm->eventName;
    global sourceobj = FindObject($alarm->sourceObject);
    global nameobj = sourceobj->guid;   
   
    trace(0, "Alarm State" . alarmstate . " Alarm:" . eventname . nameobj);
    switch(alarmstate)   
    {
/* Alarm State is Outstanding */
        case "0":
            break;
/* Alarm State is Acknowledged */
        case "1":
            PostEvent(eventserver, "Xms_Alarm_Ack","ACKALARM", eventname . nameobj);
            break;
/* Alarm State is Resolved */
        case "2":
            PostEvent(eventserver, "Xms_Alarm_Resolve","RSLVALARM", eventname . nameobj);
            break;
/* Alarm State is Sticky Acknowledged */
        case "17":
            PostEvent(eventserver, "Xms_Alarm_StickyAck","SACKALARM", eventname . nameobj);
            break;       
    }
}

I originally had code for state 3 ( terminated ). This is where the bug seems to occur.
When the Alarm is created HOOK:AlarmStateChange runs. This is not a big deal as that allows us to call scripts when an event is created as it should have a state of 0. I noticed via the trace() function that some of the alarms were being created with a state of 3 instead of a state of 0.

Currently we have an EPP that uses a server action to send a CURL request to the OpsGenie API for alert generation. We have Opsgenie integrated directly with Teams, and Jira for ticket management. I would be happy to post a guide on how to do this if anybody else wants to know how we implemented it.

The code for state 3 ( terminated ) created an event "Xms_Alarm_Term". This event would be processed by the EPP and use a server action to send a CURL request to OpsGenie to close the alert. The practical implications of the alarm being created with a state of 3 is that the alert is created in OpsGenie and Closed in Opsgenie at exactly the same moment.

I suspect the problem is in alarm.cpp -> Copy constructor.

https://github.com/netxms/netxms/blob/master/src/server/core/alarm.cpp#L378

I could be wrong, but it appears that code is part of the alarm constructor that duplicates alarms if the event occurs again. I believe the reason this happens is the line (378 )
m_state = src->m_state;
That code appears to set the new alarm state as the state of the source alarm. This is only an issue if the source alarm is terminated as it creates a new copy of the alarm with a state of 3.

I could very well be wrong about this, but it makes sense in my head.
#21
Hi Filipp,

Thank you for your help! I was able to call postevent() during the hook using the following:

sub main()
{
    eventserver = FindNodeObject($node, 100);
    global alarmstate = $alarm->state;
    switch(alarmstate)
    {
/* Alarm State is Outstanding */
        case "0":
            break;
/* Alarm State is Acknowledged */
        case "1":
            PostEvent(eventserver, "Xms_Alarm_Ack");
            break;
/* Alarm State is Resolved */
        case "2":
            PostEvent(eventserver, "Xms_Alarm_Resolve");
            break;
/* Alarm State is Sticky Acknowledged */
        case "17":
            PostEvent(eventserver, "Xms_Alarm_StickyAck");
            break;
    }
}


I then created the following webservice with the following parameters:

URL: https://api.opsgenie.com/v2/alerts/%[OGAckAlarmID]/acknowledge?identifierType=alias
HTTP request method: POST
Request data:
[
{
"user": "netXMS Admin",
"source\\": "netXMS",
"note": "Acknowledged via Alert API from netXMS - Time: %t"
}
]

I added the Authentication and the Content-Type:application/json in the Headers.

Now the problem I am running into- The EPP script does not want to run the Webservice without the data argument being passed. I tried to use a variety of Macro schemes to pull the data from the webservice configuration data field but I keep coming up empty. using trace() provided no information either.

Here are my questions:
  • Can I call a script inside the url field of the webservice configuration?
  • How do I reference the "Request Data" field in the webservice configuration when calling the post function?

I am attempting to call the post() function found here: https://www.netxms.org/documentation/nxsl-latest/#class-webservice
#23
That shouldn't be a problem. 
#24
I'm trying to build a series of scripts that send curl requests via command line to an external API. I've gone through the Docs multiple times but I haven't been able to find any documentation on how to use NSXL to send a curl command. I was able to get it to work under Actions Configuration, but I need this to occur during Hook::AlarmStateChange. 

For Curl to work via Actions I had to specify C:\\Windows\\System32\\curl.exe

Is it possible to call this using NSXL?
If it is not possible, should we be calling the server action instead?