tonydm / smokeping-OpenSSHMikrotikRouterOSPing

Smokeping SSH Probe for Mikrotik RouterOS
GNU General Public License v3.0
10 stars 2 forks source link

Feature Request - Ping Results to Multiple Nodes #5

Closed gabrielmangieri closed 3 years ago

gabrielmangieri commented 3 years ago

Hello,

Is there a way to configure this probe to allow a single probe to report on the results of multiple IPs? For instance, the probe connects to a MikroTik router, then runs and gets ping results from IPs x.x.x.x, x.x.x.y, x.x.x.z, and so forth?

Or can multiple probes be spawned to connect to the same router simultaneously to run these tests?

If either of these is possible, how would you format the SmokePing config file to accomplish this?

Thank you.

tonydm commented 3 years ago

@gabrielmangieri - Hello...

As you may already be aware, but as a refresher, the way Smokeping works is that it spawns an instance of a probe for each Target entry. So if you have 5 targets definitions configured to use the OpenSSHMikrotikRouterOSPing Probe, Smokeping will spawn 5 probe instances. And if those 5 target definitions are configured to use the same source IP/Router, Smokeping will also spawn 5 probe instances each connecting to that same source IP/Router.

To answer your first question "...then runs and gets ping results from IPs x.x.x.x, x.x.x.y, x.x.x.z, and so forth?": A defined target and the spawned probe results are associated with and written to that single target's RRD file. It is technically possible to code the probe to run multiple pings against multiple hosts as part of one spawned probe instance, but that would cause several issues. 1) it would break with Smokeping convention, 2) Smokeping wouldn't know how to update the target RRD file(s) for multiple host results. Smokeping expects one set of ping results for one host (target definition), not multiple hosts.

To to answer your second question, "can multiple probes be spawned to connect to the same router": Smokeping does by design, as described above. If you have multiple target entries that are configured to connect to the same source IP/Router then Smokeping will make multiple connections by virtue of the fact that each probe spawned with connect to that same source IP/Router. This isn't ideal though as it creates a new SSH connection for each probe instance spawned eating up router resources. When you only have a few targets defined to connect to the same source IP/Router, it's not a super huge impact on the Router's resource.

With all that said, this probe supports multiplexed connections. That is, once one connection is established to a source IP/Router, all additional connections made to the same source IP/Router will share the established SSH connection/socket. This looks like one connection made on the router IP/Firewall/Connections as well as the System/Users/Active Users. The benefit is that if you have 50 targets defined that use the OpenSSHMikrotikRouterOSPing probe which all are configured to connect to the same source IP/Router, you will see 50 spawned probes, but you won't have 50 SSH connections to your router, you'll have only one as all the probes will share/use the same SSH connection socket.

Here's some sample config you can use as a template. There are many ways to configure your targets. Please refer the main page for detail on configuration options as well as the Smokeping projects documentation for Target file definitions structure

I hope this help

Probes File

+ OpenSSHMikrotikRouterOSPing

forks = 5
offset = 50%
step = 300
timeout = 60
packetsize = 56
pings = 20
# interface = <interface name> # Not used by default
# ttl = 20 # Not used by default
# dscp_id = <id number> # Not used by default
# rtable = <routing table name> # Not used by default
# do_not_fragment = false # Not used by default
routerospass = <userpass>
routerosuser = <username>
# ssh_binary_path = /usr/bin/ssh
# multiplex_ssh = true # Default
# multiplex_control_persist_time = 10 # Default is 10 min.  A value of 0 will leave socket file indefinitely
# multiplex_control_file_path = ~/.libnet-openssh-perl # Default

Targets File

# Parent
+ Local_Edgerouter
# Define some defaults for this sections Targets 
probe = OpenSSHMikrotikRouterOSPing
title = Edge Router
menu = Edge Router
source = <Local Router_Internal_IP>
psource = <WAN/Public Facing IP Address or other Internal Facing Interface/VLAN IP>

++ Targets_Of_Interest_a
title = Targets of Interest a
menu = Targets of Interest a

# Child
++ target1a
menu = Target 1a
title = Target 1a
# source = will use Parent
# psource = will use Parent
host = <IP_of_interest>
# ssh_port = 22 or change to your non-standard port #
# UNCOMMENT next 2 lines if you want to filter debug info for this target
#debug = true
#debug_logfile = /tmp/smokeping_target1a.log

# Child
++ target2a
menu = Target 2a
title = Target 2a
# source = will use Parent
# psource = will use Parent
host = <IP_of_interest>
# ssh_port = 22 or change to your non-standard port #
# UNCOMMENT next 2 lines if you want to filter debug info for this target
#debug = true
#debug_logfile = /tmp/smokeping_target2a.log

# Parent
+ Remote_Edgerouter
# Define some defaults for this sections Targets 
probe = OpenSSHMikrotikRouterOSPing
title = Remote Edge Router
menu = Remote Edge Router
source = <Remote Router Public IP or Private IP if over a VPN>
psource = <WAN/Public Facing IP Address or other Internal Facing Interface/VLAN IP>

++ Targets_Of_Interest_b
title = Targets of Interest b
menu = Targets of Interest b

# Child
++ target1b
menu = Target 1b
title = Target 1b
# source = will use Parent
# psource = will use Parent
host = <IP_of_interest>
# ssh_port = 22 or change to your non-standard port #
# UNCOMMENT next 2 lines if you want to filter debug info for this target
#debug = true
#debug_logfile = /tmp/smokeping_target1b.log

# Child
++ target2b
menu = Target 2b
title = Target 2b
# source = will use Parent
# psource = will use Parent
host = <IP_of_interest>
# ssh_port = 22 or change to your non-standard port #
# UNCOMMENT next 2 lines if you want to filter debug info for this target
#debug = true
#debug_logfile = /tmp/smokeping_target2b.log
gabrielmangieri commented 3 years ago

Thank you very much for the prompt and extremely detailed response. I will attempt to put this into practice and will let you know if I have any other questions.

tonydm commented 3 years ago

You are very welcome. I will leave this issue open for another week to give you time to play with it. If you like, a star would be greatly appreciated.

Thank you very much

Tony

gabrielmangieri commented 3 years ago

Tony,

I implemented your suggestions and it is working very well. Thank you again for the detailed and helpful information.

-Gabriel