Switch monitor when community string has special chars
Switch monitor when community string has special chars
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
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
Take a look at User Macros, muuuuch easier: https://assets.nagios.com/downloads/nag ... Macros.pdf
Former Nagios employee
Re: Switch monitor when community string has special chars
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?
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Switch monitor when community string has special chars
@tonkaUser, Yes, you'd define macros in:
Then restart Nagios and use macros inside the wizard:
Code: Select all
/usr/local/nagios/etc/resource.cfg
$USER7$=User*!name
$USER8$=Pass*!Word
Code: Select all
service nagios restartAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Switch monitor when community string has special chars
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!
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
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.
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: Switch monitor when community string has special chars
you went the hacky way bud. that's the great thing about IT - always a solution.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.
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
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!
Thanks!
-
kyang
Re: Switch monitor when community string has special chars
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!
@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
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.
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.
You do not have the required permissions to view the files attached to this post.