Hi Team,
We have a project going on using mod-gearman and need to configure network devices in monitoring,
many devices have over 500 ports in there and we need to add it via using CCM and its getting very difficult to add. please help or give any soluion for this,
we have tried using API option but its giving kind a error is there any other way to this can we do auto discovery or add services in services.cfg file sort of it will help.
[root@Nagios ~]# curl -XPOST "http://IP/nagiosxi/api/v1/config/servic ... D&pretty=1" -d "host_name=test&service_description=bandwidth&check_command=check_bandwidth!htread 4" > 600 " " > 800 "!!!!!!!&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1"
-bash: !htread: event not found
Service add via CLI
Re: Service add via CLI
Make sure your Bash commands contain proper escaping:
http://wiki.bash-hackers.org/syntax/quoting
! is a reserved Bash character and appears in your command. Also, several un-escaped double-quotes (") appear in your command.
I would also batch-up your several hundred transactions without &applyconfig=1 set. You really don't want to be applying the configuration for every single transaction if there's a bunch of them -- it'll take forever. Set them all up first, then apply the configuration in the very final request.
http://wiki.bash-hackers.org/syntax/quoting
! is a reserved Bash character and appears in your command. Also, several un-escaped double-quotes (") appear in your command.
I would also batch-up your several hundred transactions without &applyconfig=1 set. You really don't want to be applying the configuration for every single transaction if there's a bunch of them -- it'll take forever. Set them all up first, then apply the configuration in the very final request.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Service add via CLI
Your API command needs to escape ! and if you are adding additional " in the arguments like so:
Code: Select all
curl -XPOST "http://IP/nagiosxi/api/v1/config/service?apikey=APIdD&pretty=1" -d "host_name=test&service_description=bandwidth&check_command=check_bandwidth\!htread 4\" > 600 \" \" > 800 \"\!\!\!\!\!\!\!&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1"