Simple question - variable which holds result of icmp when doing status polls
-
I have my nodeUpDown custom variable auto binding and unbinding working - except for the last piece - updating this custom variable when status polling.
I do NOT want to just use the event and do it via event processing - Event Policy processing can get behind so this way avoids waiting - it updates what we look at immediately.
I want to add to the Status hook the setting of the nodeUpDown based on the ICMP ping response.
If I can ping the device - set it to up. If I cannot ping it, set it to down.Something like this below added to the status polling hook script - once I know the variable that holds the ICMP response.
if (($node->icmpresponse == "no")) { newstate = "Down"; oldstate = GetCustomAttribute($node, "nodeUpDown"); if (newstate != null) { if ((newstate imatch "Down")) { BindObject(FindObject("AllDown"), $node); SetCustomAttribute($node, "nodeUpDown", newstate); } } if (($node->icmpresponse = "yes")) { newstate = "Up"; oldstate = GetCustomAttribute($node, "nodeUpDown"); if (newstate != null) { if ((newstate imatch "Up")) { SetCustomAttribute($node, "nodeUpDown", newstate); UnbindObject(FindObject("AllDown"), $node); } } } -
I recommend using runtimeFlags field to determine that node is completely unreachable, like this:
if (($node->icmpresponse & 4) != 0) // state is "down"Also few comments on script itself - purely style/clarity, not functionality:
- You may use direct comparison instead of regexp match if you are loking for exact match, i.e.
(newstate == "Down")
instead of
(newstate imatch "Down")
- No need for checking status twice, just can just use else:
if ($node->icmpresponse == "no") { } else { }Best regards,
Victor -
Fantastic - thanks Victor.
Coding style - mine is mostly a hack and slash approach to something else I have seen as an example or that I know works. Once it works, rather than go back and clean it up - more trial and error - I move onto the next highest priority task.
The more I do with NetXMS, the better I will get.
Between this and the runtime flag for unreachable - very, very happy person I am today

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login