Page 1 of 2
Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 11:02 am
by tonkaUser
Hi,
Our SNMP community string has special characters (! and &). If we use the wizard to configure Network Switch / Router, then the services do not work and we need to escape special characters. We have 10s of routers/switches to monitor. Each of the port statuses has the port number, so we cannot use Bulk Modification tool.
I want config files to be created with the escaped community string.
I started looking at /usr/local/nagiosxi/html/includes/configwizards/switch/switch.inc.php. Is that the right approach to hack this page so configs are generated correctly? Is there an update that we can take that will escape special chars?
Thanks
Re: Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 12:51 pm
by tmcdonald
Re: Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 1:01 pm
by tonkaUser
Once I define the community string as a macro (with escaped special chars), how would I tell network wizard to use that when generating the config files?
Re: Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 3:42 pm
by npolovenko
@tonkaUser, Yes, you'd define macros in:
Code: Select all
/usr/local/nagios/etc/resource.cfg
$USER7$=User*!name
$USER8$=Pass*!Word
Then restart Nagios and use macros inside the wizard:
Re: Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 5:02 pm
by tonkaUser
Thanks. I added the macro.
Just to confirm. I still need to change /usr/local/nagiosxi/html/includes/configwizards/switch/switch.inc.php:1027 to refer to the newly created macro instead of using $snmpopts['snmpcommunity'] right ?
When I used the wizard, I did not see an option to select a macro for SNMP community string.
Thanks!
Re: Switch monitor when community string has special chars
Posted: Fri Jan 26, 2018 5:58 pm
by tonkaUser
I changed switch.inc.php to use a user macro and it seems to work. It's a little bit hacky, but I will take it.
Re: Switch monitor when community string has special chars
Posted: Mon Jan 29, 2018 2:06 am
by tacolover101
tonkaUser wrote:I changed switch.inc.php to use a user macro and it seems to work. It's a little bit hacky, but I will take it.
you went the hacky way bud. that's the great thing about IT - always a solution.
with what the folks above were mentioning - you'd substitute $USER8$ in place of your community string, which Nagios would then parse to reference your comm string.
Re: Switch monitor when community string has special chars
Posted: Mon Jan 29, 2018 10:36 am
by tonkaUser
When you said "you'd substitute $USER8$ in place of your community string, " do you mean I can do it using Nagios UI? WOuld I do it when using the wizard or after the wizard was ran to change all the services that were affected?
Thanks!
Re: Switch monitor when community string has special chars
Posted: Mon Jan 29, 2018 11:33 am
by kyang
Thanks
@tacolover101 for the help!
@tonkaUser, Yes, you would use $USER8$ (which is your community string in resource.cfg)
Typing in $USER8$ in the community string option when using the Network/switch wizard, would use your special characters password.
Let us know if you have any more questions!
Re: Switch monitor when community string has special chars
Posted: Mon Jan 29, 2018 12:24 pm
by tonkaUser
Thanks. It's clear what you meant now.
I defined $USER9$ as a community string that has all special characters escaped.
I just tried to use $USER9$ as the SNMP community string for the router/switch wizard and the wizard had a problem connecting to the device. I think the issue is that the wizard needs to take SNMP community as-is without escaping special chars when it connects to the device. When the wizard is generating the config files, the special chars should be escaped (e.g. when "check_command" adds the SNMP string, it has to use the escaped version). It feels that the wizard should have smarts to escape any special chars.
Thanks for your help all. It's resolved.