list the comments of a service to remove them

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

list the comments of a service to remove them

Postby gba » Mon Oct 21, 2019 11:02 am

Hello,

I'm looking for a bash command to list the comments of a service to list old comments of more than 30 days.
This would allow me to delete them with the following command --> /bin/printf "[%lu] DEL_SVC_COMMENT;1\n" $now > $commandfile


thank you in advance.

(excuse me for my English because I am French)

Gba
Last edited by gba on Wed Oct 23, 2019 3:40 am, edited 1 time in total.
gba
 
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Postby scottwilkerson » Mon Oct 21, 2019 11:51 am

You can get them in JSON with the API
Help -> Objects Reference -> objects/comment

Code: Select all
/nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: list the comments of a service to remove them

Postby lmiltchev » Mon Oct 21, 2019 12:02 pm

As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 12760
Joined: Mon May 23, 2011 12:15 pm

Re: list the comments of a service to remove them

Postby gba » Tue Oct 22, 2019 2:52 am

Hello,

I can not exploit this command ; /nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21

For info I use Thruk.

I looked at your lmiltchev link but it does not work at home.

I would like to list the comments from more than 30 days or the last comments based on a service and delete them with the command printf "[% lu] DEL_SVC_COMMENT; 1 \ n" $now > $commandfile

I really can not ..

Thank you
gba
 
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Postby scottwilkerson » Tue Oct 22, 2019 6:23 am

gba wrote:I can not exploit this command ; /nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21

For info I use Thruk.

You had posted on the NAgios XI group... I moved it to Nagios Core.

If you are using Core you should have the Core JSON CGI and you can get them with a query like the fillowing
Code: Select all
http://xxx.xxx.xxx.xxx/nagios/cgi-bin/statusjson.cgi?query=commentlist&commenttimefield=entrytime&starttime=1569151359&endtime=1571742401


the starttime & endtime are unix timestamps
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: list the comments of a service to remove them

Postby gba » Tue Oct 22, 2019 10:25 am

You had posted on the NAgios XI group... I moved it to Nagios Core.


Sorry I made a mistake ! :roll:

statusjson.cgi shows me a page not found


I found the page containing all comments. By cons I can not sorted them with variables in the URL. Maybe that is not possible.



TY !
Last edited by gba on Wed Oct 23, 2019 3:39 am, edited 1 time in total.
gba
 
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Postby scottwilkerson » Tue Oct 22, 2019 10:33 am

Sorry we do not provide support for thruk, just nagios.

The link I posted exists in a nagios installation.

gba wrote:I found the page containing all comments. By cons I can not sorted them with variables in the URL. Maybe that is not possible.

Code: Select all
http://xx.xx.xx.xxx/thruk/#cgi-bin/extinfo.cgi?type=3#SERVICECOMMENTS


Again, not sure as we have no knowledge of Thruk as we are not the authors
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: list the comments of a service to remove them

Postby gba » Wed Oct 23, 2019 3:39 am

thanks anyway
gba
 
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Postby scottwilkerson » Wed Oct 23, 2019 7:35 am

gba wrote:thanks anyway

good luck!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: Majestic-12 [Bot], MSN [Bot] and 14 guests