Skip to main content

Hi,

We are using Centreon Open Tickets (Version centreon-open-tickets-21.10.1-1).

It has been configured with rules to create ticket on our Jira infra.

Afiter follwowing this documentation : 

Integration Open-Tickets - Accueil DIS - Centreon - Wiki (vaudoise.ch)

… we can now open a ticket manually  from the’Custom View’ page… this iw working Well.

 

But now we would like that tickets are created automatically when a Centreon Services reaches it critical hard State.

To do this, I need to configure a Notification Command : but its means that we must to know the syntax on how to create a ticket in command line.

On our poller we installed this package:

centreon-plugin-Notification-Centreon-Opentickets-Api-20221017-094659.el7.centos.noarch

It provides this plugin : ‘/usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl’

 

The modes availables are .

   close-host
   close-service
   open-host
   open-service
 

… So we should be able to create a ticket in command line with this plugin, but I cannot find the correct Syntax :

Currently I tried : 

/usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode open-service --rule-name '$MY_RULENAME' --host-id $MYHOST_ID--service-id $MYSERVICE_ID--service-state WARNING --service-output TEST --api-hostname $MY_CENTREON_ALIASh --api-proto https --api-port 443 --api-username apirest_user --api-password "XXXX" 

 

NOTE: The arguments beginning by $ are some variables on my side : Centreon server, Service ID … etc.

… But I get thi error “UNKNOWN: Authentication error tcode: '404'] message: 'Object not found']””

 

Did domeone tried to open Jira Tickets automatically (Or in command line)  ?

 

Thanks 

👋

 

@glepinay can you run your command with --debug to see what else we get. Wondering if the “ --api-hostname “ is solving properly.

 

🤔


Hello,

When you solved the usage problem of the centreon-plugins, you could try an other way to close and open ticket with CRITICAL and OK state by using the event handler.

More specially the Global Event Handler : Auto Remediation | Centreon Documentation (All Hosts and All Services of your poller) 

You could adapt this script Auto Remediation | Centreon Documentation just for the HARD State Type for State OK to close ticket and the HARD State Type for State CRITICAL to open it.

Regards,

Greg


Hi,

 

Here is below the command line I tried:

/usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode open-service --rule-name 'OpenTickets-Vaudoise' --host-id 1959 --service-id 6756 --service-state WARNING --service-output TEST_GLE --api-hostname centreon.vaudoise.ch --api-proto https --api-port 443 --url-path '/centreon/api/' --api-username apirest_user --api-password "XXXXXXX" --debug

I tried with different --api-hostname (Fqdn, hostname, Ip address9 …. but the result is the same.

 

THE RESULT IS:

 

UNKNOWN: Authentication error ecode: '404'] 4message: 'Object not found']
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?action=authenticate
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type: application/x-www-form-urlencoded

password=Maging32_04&username=apirest_user
======> response done
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
.….………….…………………………….………….
Keep-Alive: timeout=5, max=100
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

{"authToken":"HJVsLdWFipre3yATvo2gG0g2OOblvxinqx8OFrQuQga908mv4Te0fucOb5wttVSu"}
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?object=centreon_openticket&action=openService
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type:  application/json
Centreon-Auth-Token:  HJVsLdWFipre3yATvo2gG0g2OOblvxinqx8OFrQuQga908mv4Te0fucOb5wttVSu

{"rule_name":"OpenTickets-Vaudoise","service_output":"TEST_GLE","host_id":"1959","service_state":"WARNING","service_id":"6756","select":{},"extra_properties":{}}
======> response done
HTTP/1.1 404 Object not found
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
……….……….….…………...
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

"Method not found"
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?action=authenticate
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type: application/x-www-form-urlencoded

password=Maging32_04&username=apirest_user
======> response done
HTTP/1.1 200 OK
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
Content-Type: application/json;charset=utf-8
Client-Date: Wed, 16 Nov 2022 06:41:03 GMT
Client-Peer: 172.21.3.55:443
Client-Response-Num: 3
Client-SSL-Cert-Issuer: /DC=ch/DC=vaudoise/CN=Vaudoise Assurances Issuing CA 01
Client-SSL-Cert-Subject: /C=CH/ST=VD/L=Lausanne/O=Vaudoise Assurances/OU=Vaudoise Assurances IT/CN=centreon.vaudoise.ch
Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

{"authToken":"ku1aAXKv9tsSePnBBn2BQ3AEE5QKaHDSDjxAjyS2RNbDtOA8hAGTPl+UKu3XbYc4"}
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?object=centreon_openticket&action=openService
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type:  application/json
Centreon-Auth-Token:  ku1aAXKv9tsSePnBBn2BQ3AEE5QKaHDSDjxAjyS2RNbDtOA8hAGTPl+UKu3XbYc4

{"rule_name":"OpenTickets-Vaudoise","service_output":"TEST_GLE","host_id":"1959","service_state":"WARNING","service_id":"6756","select":{},"extra_properties":{}}
======> response done
HTTP/1.1 404 Object not found
Date: Wed, 16 Nov 2022 06:41:03 GMT
Server: Apache
Content-Type: application/json;charset=utf-8
Client-Date: Wed, 16 Nov 2022 06:41:03 GMT
Client-Peer: 172.21.3.55:443
Client-Response-Num: 4
Client-SSL-Cert-Issuer: /DC=ch/DC=vaudoise/CN=Vaudoise Assurances Issuing CA 01
Client-SSL-Cert-Subject: /C=CH/ST=VD/L=Lausanne/O=Vaudoise Assurances/OU=Vaudoise Assurances IT/CN=centreon.vaudoise.ch
Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

"Method not found"
 

 

If I triy the same command but with this URL :  --url-path '/centreon/api/latest/'

I get a different error :

UNKNOWN: Authentication error rcode: '500'] Imessage: 'Internal Server Error']

======> response done
HTTP/1.1 500 Internal Server Error
{"code":500,"message":"No route found for \"POST \/\""}

 

Thanks

 

 

 


Hi,

 

Here is below the command line I tried:

/usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode open-service --rule-name 'OpenTickets-Vaudoise' --host-id 1959 --service-id 6756 --service-state WARNING --service-output TEST_GLE --api-hostname centreon.vaudoise.ch --api-proto https --api-port 443 --url-path '/centreon/api/' --api-username apirest_user --api-password "XXXXXXX" --debug

I tried with different --api-hostname (Fqdn, hostname, Ip address9 …. but the result is the same.

 

THE RESULT IS:

 

UNKNOWN: Authentication error ecode: '404'] 4message: 'Object not found']
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?action=authenticate
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type: application/x-www-form-urlencoded

password=XXXXXX&username=apirest_user
======> response done
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
.….………….…………………………….………….
Keep-Alive: timeout=5, max=100
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

{"authToken":"HJVsLdWFipre3yATvo2gG0g2OOblvxinqx8OFrQuQga908mv4Te0fucOb5wttVSu"}
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?object=centreon_openticket&action=openService
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type:  application/json
Centreon-Auth-Token:  HJVsLdWFipre3yATvo2gG0g2OOblvxinqx8OFrQuQga908mv4Te0fucOb5wttVSu

{"rule_name":"OpenTickets-Vaudoise","service_output":"TEST_GLE","host_id":"1959","service_state":"WARNING","service_id":"6756","select":{},"extra_properties":{}}
======> response done
HTTP/1.1 404 Object not found
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
……….……….….…………...
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

"Method not found"
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?action=authenticate
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type: application/x-www-form-urlencoded

password=XXXXX&username=apirest_user
======> response done
HTTP/1.1 200 OK
Date: Wed, 16 Nov 2022 06:41:02 GMT
Server: Apache
Content-Type: application/json;charset=utf-8
Client-Date: Wed, 16 Nov 2022 06:41:03 GMT
Client-Peer: 172.21.3.55:443
Client-Response-Num: 3
Client-SSL-Cert-Issuer: /DC=ch/DC=vaudoise/CN=Vaudoise Assurances Issuing CA 01
Client-SSL-Cert-Subject: /C=CH/ST=VD/L=Lausanne/O=Vaudoise Assurances/OU=Vaudoise Assurances IT/CN=centreon.vaudoise.ch
Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

{"authToken":"ku1aAXKv9tsSePnBBn2BQ3AEE5QKaHDSDjxAjyS2RNbDtOA8hAGTPl+UKu3XbYc4"}
======> request send
POST https://centreon.vaudoise.ch:443/centreon/api/index.php?object=centreon_openticket&action=openService
Accept: application/json
User-Agent: centreon::plugins::backend::http::useragent
Content-Type:  application/json
Centreon-Auth-Token:  ku1aAXKv9tsSePnBBn2BQ3AEE5QKaHDSDjxAjyS2RNbDtOA8hAGTPl+UKu3XbYc4

{"rule_name":"OpenTickets-Vaudoise","service_output":"TEST_GLE","host_id":"1959","service_state":"WARNING","service_id":"6756","select":{},"extra_properties":{}}
======> response done
HTTP/1.1 404 Object not found
Date: Wed, 16 Nov 2022 06:41:03 GMT
Server: Apache
Content-Type: application/json;charset=utf-8
Client-Date: Wed, 16 Nov 2022 06:41:03 GMT
Client-Peer: 172.21.3.55:443
Client-Response-Num: 4
Client-SSL-Cert-Issuer: /DC=ch/DC=vaudoise/CN=Vaudoise Assurances Issuing CA 01
Client-SSL-Cert-Subject: /C=CH/ST=VD/L=Lausanne/O=Vaudoise Assurances/OU=Vaudoise Assurances IT/CN=centreon.vaudoise.ch
Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
X-Frame-Options: sameorigin
X-Powered-By: PHP/8.0.18

"Method not found"
 

 

If I triy the same command but with this URL :  --url-path '/centreon/api/latest/'

I get a different error :

UNKNOWN: Authentication error ncode: '500'] message: 'Internal Server Error']

======> response done
HTTP/1.1 500 Internal Server Error
{"code":500,"message":"No route found for \"POST \/\""}

 

Thanks

 

 

 

 


Hello,

I'm not user of OpenTicket module.

You could edit your post, because we could seen credential.

I can see authentication is OK, but the service, or host you request seems not found.

Are you sure about the service_id and/or host_id are good.

I don't understand, you have a Object not Found and a Method not found.

About the syntax of command i prefer use = and ‘ like you have exemple here : https://docs.centreon.com/docs/integrations/notifications/plugin-telegram/#command-creation-in-centreon

So :

/usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin=notification::centreon::opentickets::api::plugin --mode=’open-service’ --rule-name='OpenTickets-Vaudoise' --host-id=’1959’ --service-id=’6756’ --service-state=’WARNING’ --service-output=’TEST_GLE’ --api-hostname=’centreon.vaudoise.ch’ --api-proto=’https' --api-port=’443’ --api-username=’apirest_user’ --api-password=XXXXXXX --debug

 

Regards,


Latest News from Centreon support :

The Open Ticket Web Api is only available from version 22.10.

On my side this version will be installed in a few month only … so we have to wait…

Thanks to all of you for your help :-)

 


 Hi all,

 

I have a more easy problem but I am not able to solve it.

My problem is that , the notifications command which appears in the  centengin.log , which suppose to create a Jira ticket is not executed on the server automatically.

If I run it manually it is working. It is creating the ticket.

 

>2023-02-15T13:34:27.407+01:00] 0notifications] ninfo] f4136078] Raw notification command: /bin/bash /usr/lib/centreon/plugins/wrapper_service_ticket.sh "$NOTIFICATIONTYPE$" "$HOSTID$" "$HOSTNAME$" "$SERVICEOUTPUT$" "$SERVICESTATE$" "$SERVICEID$" "$SERVICEDESC$" "idemiaJiraTestCustomProvider" "10.234.18.120" "openticketjira" "O*FTEIr0" "7" "$_SERVICECRITICALITY_LEVEL$" "$_SERVICESLA$"
r2023-02-15T13:34:27.407+01:00] 0notifications] ninfo] f4136078] Processed notification command: /bin/bash /usr/lib/centreon/plugins/wrapper_service_ticket.sh "PROBLEM" "5134" "hostname.idemia.com" "HTTP WARNING: HTTP/1.1 404 Not Found - 492 bytes in 0.029 second response time" "WARNING" "14223" "check_https://site.idemia.com" "idemiaJiraTestCustomProvider" "10.234.18.120" "openticketjira" "xxxxxx" "7" "4" "gold"
 

 

Thank you

 


Hey , I can’t find the user and password of the open ticket api (centreon_notification_centreon_opentickets_api.pl)  , where can I find it please?

Thank you.


Hi, if it's not too late for you, you can follow this article just published: https://thewatch.centreon.com/product-how-to-21/how-to-create-automatic-tickets-on-itsm-tool-with-open-tickets-extension-3899

Regards.


Reply