Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem Using Groups #34

Open
Drabbies opened this issue Jul 12, 2019 · 2 comments
Open

Problem Using Groups #34

Drabbies opened this issue Jul 12, 2019 · 2 comments

Comments

@Drabbies
Copy link

I started using oxidized-scripts and it works awesome so thank you! when i try to run the script against all devices in my router.db file, it says that it loads all of the devices, but the command does not get sent to any of them.

[me@oxidized ~]# oxs --group ios 'sh run | include hostname'
I, [2019-07-12T07:25:39.425244 #31393] INFO -- : lib/oxidized/nodes.rb: Loading nodes
I, [2019-07-12T07:25:39.585747 #31393] INFO -- : lib/oxidized/nodes.rb: Loaded 52 nodes
[me@oxidized ~]#

When i list the nodes, they all show up

[me@oxidized ~]# oxs --list-nodes
I, [2019-07-12T07:26:34.893654 #32157] INFO -- : lib/oxidized/nodes.rb: Loading nodes
I, [2019-07-12T07:26:35.060313 #32157] INFO -- : lib/oxidized/nodes.rb: Loaded 52 nodes
10.9.101.2:
ip => 10.9.101.2
group =>
model => IOS
input => [Oxidized::SSH, Oxidized::Telnet]
output => Oxidized::Git
auth => {:username=>"oxidized", :password=>"Ox1d1z3d"}
prompt => (?-mix:^([\w.@()-]+[#>]\s?)$)
vars =>
stats => #Oxidized::Node::Stats:0x0000000002ca8df0
retry => 0
repo => /home/me/gitrepo.git
192.168.101.2:
ip => 192.168.101.2
group =>
model => IOS
input => [Oxidized::SSH, Oxidized::Telnet]
output => Oxidized::Git
auth => {:username=>"oxidized", :password=>"Ox1d1z3d"}
prompt => (?-mix:^([\w.@()-]+[#>]\s?)$)
vars =>
stats => #Oxidized::Node::Stats:0x0000000002cb1c98
retry => 0
repo => /home/me/gitrepo.git

Is there something wrong with my Syntax?

Thanks

@talabs
Copy link

talabs commented Jan 27, 2021

Was any resolution found to this? I am new to LibreNMS and Oxidized and tried to run a small set of commands using Oxidized-script against a group of devices. If I run it against a single device it work fine, but when I run it against the group I get the below debug output.

D, [2021-01-27T16:00:46.983375 #3656393] DEBUG -- : resolving DNS for 10.32.50.20...
D, [2021-01-27T16:00:46.983386 #3656393] DEBUG -- : IPADDR
D, [2021-01-27T16:00:46.983407 #3656393] DEBUG -- : node.rb: resolving node key 'model', with passed global value of '' and node value 'ironware'
D, [2021-01-27T16:00:46.983420 #3656393] DEBUG -- : node.rb: setting node key 'model' to value 'brocade' from global
D, [2021-01-27T16:00:46.983433 #3656393] DEBUG -- : node.rb: returning node key 'model' with value 'ironware'
D, [2021-01-27T16:00:46.983448 #3656393] DEBUG -- : node.rb: resolving node key 'input', with passed global value of 'ssh, telnet' and node value ''
D, [2021-01-27T16:00:46.983461 #3656393] DEBUG -- : node.rb: returning node key 'input' with value 'ssh, telnet'
D, [2021-01-27T16:00:46.983477 #3656393] DEBUG -- : node.rb: resolving node key 'output', with passed global value of 'file' and node value ''
D, [2021-01-27T16:00:46.983491 #3656393] DEBUG -- : node.rb: returning node key 'output' with value 'file'
D, [2021-01-27T16:00:46.983503 #3656393] DEBUG -- : node.rb: resolving node key 'username', with passed global value of '' and node value ''
D, [2021-01-27T16:00:46.983529 #3656393] DEBUG -- : node.rb: setting node key 'username' to value 'fooname' from global
D, [2021-01-27T16:00:46.983543 #3656393] DEBUG -- : node.rb: returning node key 'username' with value 'fooname'
D, [2021-01-27T16:00:46.983554 #3656393] DEBUG -- : node.rb: resolving node key 'password', with passed global value of '' and node value ''
D, [2021-01-27T16:00:46.983567 #3656393] DEBUG -- : node.rb: setting node key 'password' to value 'foopassword' from global
D, [2021-01-27T16:00:46.983580 #3656393] DEBUG -- : node.rb: returning node key 'password' with value 'foopassword'
I, [2021-01-27T16:00:46.983608 #3656393] INFO -- : lib/oxidized/nodes.rb: Loaded 415 nodes

If I run it with a single device:

~/.config/oxidized/oxs# oxs -x snmp_host_add 10.32.96.10
I, [2021-01-27T16:08:35.905807 #3693779] INFO -- : lib/oxidized/nodes.rb: Loading nodes
D, [2021-01-27T16:08:35.933452 #3693779] DEBUG -- : resolving DNS for 10.32.96.10...
D, [2021-01-27T16:08:35.933502 #3693779] DEBUG -- : IPADDR
D, [2021-01-27T16:08:35.933575 #3693779] DEBUG -- : node.rb: resolving node key 'model', with passed global value of '' and node value 'ironware'
D, [2021-01-27T16:08:35.933597 #3693779] DEBUG -- : node.rb: setting node key 'model' to value 'brocade' from global
D, [2021-01-27T16:08:35.933626 #3693779] DEBUG -- : node.rb: returning node key 'model' with value 'ironware'
D, [2021-01-27T16:08:35.933648 #3693779] DEBUG -- : lib/oxidized/node.rb: Loading model "ironware"
D, [2021-01-27T16:08:35.934591 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added all to the commands list
D, [2021-01-27T16:08:35.934634 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added show version to the commands list
D, [2021-01-27T16:08:35.934660 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added show chassis to the commands list
D, [2021-01-27T16:08:35.934677 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added show flash to the commands list
D, [2021-01-27T16:08:35.934695 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added show module to the commands list
D, [2021-01-27T16:08:35.934710 #3693779] DEBUG -- : lib/oxidized/model/model.rb Added show running-config to the commands list
D, [2021-01-27T16:08:35.934936 #3693779] DEBUG -- : node.rb: resolving node key 'input', with passed global value of 'ssh, telnet' and node value ''
D, [2021-01-27T16:08:35.934968 #3693779] DEBUG -- : node.rb: returning node key 'input' with value 'ssh, telnet'
D, [2021-01-27T16:08:36.018575 #3693779] DEBUG -- : node.rb: resolving node key 'output', with passed global value of 'file' and node value ''
D, [2021-01-27T16:08:36.018654 #3693779] DEBUG -- : node.rb: returning node key 'output' with value 'file'
D, [2021-01-27T16:08:36.019596 #3693779] DEBUG -- : node.rb: resolving node key 'username', with passed global value of '' and node value ''
D, [2021-01-27T16:08:36.019636 #3693779] DEBUG -- : node.rb: setting node key 'username' to value 'fooname' from global
D, [2021-01-27T16:08:36.019655 #3693779] DEBUG -- : node.rb: returning node key 'username' with value 'sabrocade'
D, [2021-01-27T16:08:36.019671 #3693779] DEBUG -- : node.rb: resolving node key 'password', with passed global value of '' and node value ''
D, [2021-01-27T16:08:36.019684 #3693779] DEBUG -- : node.rb: setting node key 'password' to value 'foopassword' from global
D, [2021-01-27T16:08:36.019701 #3693779] DEBUG -- : node.rb: returning node key 'password' with value 'foopassword'
I, [2021-01-27T16:08:36.019756 #3693779] INFO -- : lib/oxidized/nodes.rb: Loaded 1 nodes
D, [2021-01-27T16:08:36.019819 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: Connecting to 10.32.96.10
D, [2021-01-27T16:08:36.019899 #3693779] DEBUG -- : AUTH METHODS::["none", "publickey", "password"]
D, [2021-01-27T16:08:38.574947 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:39.378167 #3693779] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login commands at 10.32.96.10
D, [2021-01-27T16:08:39.378250 #3693779] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login command: "", block: nil at 10.32.96.10
D, [2021-01-27T16:08:39.378278 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:39.378471 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:39.779866 #3693779] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login command: "skip-page-display", block: nil at 10.32.96.10
D, [2021-01-27T16:08:39.779928 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb skip-page-display @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:39.780076 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:40.181589 #3693779] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login command: "terminal length 0", block: nil at 10.32.96.10
D, [2021-01-27T16:08:40.181662 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb terminal length 0 @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:40.181838 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:40.583441 #3693779] DEBUG -- : lib/oxidized/model/model.rb Executing conf t
D, [2021-01-27T16:08:40.583501 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb conf t @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:40.583660 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:41.185746 #3693779] DEBUG -- : lib/oxidized/model/model.rb Executing snmp-server host 10.32.93.12 version v2c foocommunity
D, [2021-01-27T16:08:41.185807 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb snmp-server host 10.32.93.12 version v2c foocommunity @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:41.186840 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:41.588452 #3693779] DEBUG -- : lib/oxidized/model/model.rb Executing wr me
D, [2021-01-27T16:08:41.588517 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb wr me @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:41.588668 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
D, [2021-01-27T16:08:43.293615 #3693779] DEBUG -- : lib/oxidized/model/model.rb Executing
D, [2021-01-27T16:08:43.293677 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb @ 10.32.96.10 with expect: /^.
(telnet|ssh)@.+[>#]\s?$/i
D, [2021-01-27T16:08:43.293818 #3693779] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^.*(telnet|ssh)@.+[>#]\s?$/i] at 10.32.96.10
......Write startup-config done.
Copy STARTUP CONFIG FILE to standby MP, please wait.
.Startup config sync to standby MP is Done.

It just never seems to start the actual SSH process when I load the group vs a single host.

@talabs
Copy link

talabs commented Jan 28, 2021

So I figured this out. Turns out when LibreNMS pushes the groups to Oxidized it will only push the first group. For alerting I have a groups that includes all devices and for other reasons I have groups based on device.os. I was trying to push to all ironware devices by calling the ironware group, but when I checked the assigned groups in oxidized they were all assigned to the group that included all devices.

I could see solving this by having multiple groups in LibreNMS that are pushed to oxidized and then just insuring those groups are all part of the Alert Rules. (This is a LibreNMS side fix). You could allow multiple groups in Oxidized, or you could allow oxs to call by device.os since the OS in oxidized is known.

    "hostname": "10.32.68.70",
    "os": "ironware",
    "ip": "",
    "group": "All_Devices"

It would be nice is oxs outputted a message that no devices matched group at the end.

I'll keep digging but posting this to help others who may come across this post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants