Dear Expert
is there any command line utility (shell / perl / php script) to delete any service?
an example looks like
root#del_nagios_service "host" "service"
regards
root cmd line utility to delete service
Re: root cmd line utility to delete service
I assume that you don't want to use the REST API to delete services, correct? If this is the case, you could use the "ccm_delete_object.php" script, located in the "/usr/local/nagiosxi/scripts" directory.
Usage:
where you substitute <id> with the actual ID of the object.
Hope this helps.
Usage:
Example:# php ccm_delete_object.php --help
Deletes an object (or list of objects) from the CCM database.
Usage: ./ccm_delete_host.php [option] ..
Example: Remove all services from service with config name localhost
./ccm_delete_host.php -t service -c localhost
Usage Options:
-t|--type <type> Object type (host, service, contact, timeperiod)
-i|--id <object id> (OPTIONAL) Object ID
\Host Type Options:
-n|--name <host name> (OPTIONAL) Host name (host type only)
Service Type Options:
-c|--config <config name> (OPTIONAL) Config name to remove all services from (service type only)
Help and Logging:
-h|--help Print out help output
Code: Select all
php /usr/local/nagiosxi/scripts/ccm_delete_object.php -t service -i <id>Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: root cmd line utility to delete service
yes lmiltchev, u r correct, we don't want to use REST API , but you (NAGIOSxi) not displaying OBJECTid, plz plz mention object id in the another column every where , its very very important too (same as DISPLAY_NAME, plz show ObjectID every where) in
Home Operations Center
Home Host Detail
Home Service Detail
till you implement above, is there any way, just we provide below detail and our job can done?
root#del_nagios_service "host" "service" <<<< v r interested deleting SERVICE not Host
Home Operations Center
Home Host Detail
Home Service Detail
till you implement above, is there any way, just we provide below detail and our job can done?
root#del_nagios_service "host" "service" <<<< v r interested deleting SERVICE not Host
Re: root cmd line utility to delete service
Object ID is shown in the CCM....but you (NAGIOSxi) not displaying OBJECTid...
If your user has root access but doesn't have access to the CCM, you could try obtaining the ID via a mysql query. This is an example bash script that you could probably use:
find_ip
Code: Select all
#!/bin/bash
echo "select id from tbl_service where service_description='$1' and config_name='$2';"|mysql -u root -pnagiosxi nagiosql|tail -1Examples:
Code: Select all
./find_ip '<service_description>' '<config_name>'Code: Select all
[root@main-nagios-xi tmp]# ./find_ip 'PING' 'localhost'
1
[root@main-nagios-xi tmp]# ./find_ip 'HTTP' 'localhost'
8
[root@main-nagios-xi tmp]# ./find_ip 'Ping' 'MacOSX'
204
[root@main-nagios-xi tmp]# ./find_ip 'Cron Scheduling Daemon' 'CentOS-NRPE'
84Code: Select all
php /usr/local/nagiosxi/scripts/ccm_delete_object.php -t service -i <id>You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!