Question

Event Handler SCRIPT problem

  • 13 January 2023
  • 0 replies
  • 71 views

Badge +2

I have a script that must launch a command when a critical or unknown state in type "HARD" to perform 3 attempts. The problem is that when I add to the script the part (case"$3" in 3) " on types HARD to add an interval of 3 relaunch. I have a syntax error see below

ERROR : Erreur de syntaxe : fin de fichier prématurée

#!/bin/sh

#Titre : Ce script permets de créer un ticket INCIDENT

# Note:
#Le script s'execute uniquement si le service est vérifié 3 fois (dans l'etat type "soft" et status CRITIQUE )
#Dans le cas contraire si le cas est de type "HARD" et de status CRITIQUE le script s'execute de suite sans vérification.


case "$1" in

OK)
    ;;

WARNING)
    ;;

UNKNOWN)
      
    case "$2" in

    SOFT)

        #Troisieme variable derriere la commande d'execution du script ($SERVICEATTEMPT$) 
            case "$3" in

        #"3)" identifie le nombre de tentative avant d'executer le script
            3)

        #commande à executer
            /usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode=open-service --api-hostname='10.241.31.109' --api-port=80 --api-proto=http --api-username=admin --api-password='T' --rule-name='jira' --host-id="$4" --service-id="$5" --service-output="$6" --service-state="$2" --select='jira_project=Incidents ' --select='jira_issuetype=Incident'

            ;;

            esac

        ;;


    HARD)

case "$3" in
            3)

       #commande à executer
         /usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode=open-service --api-hostname='10.241.31.109' --api-port=80 --api-proto=http --api-username=admin --api-password='T' --rule-name='jira' --host-id="$4" --service-id="$5" --service-output="$6" --service-state="$2" --select='jira_project=Incidents ' --select='jira_issuetype=Incident'

        ;;

        esac

    ;;


CRITICAL)
  

    #Deuxième variable derriere la commande d'execution du script ($SERVICESTATETYPE$) 
    case "$2" in

    SOFT)

        #Troisieme variable derriere la commande d'execution du script ($SERVICEATTEMPT$) car nous configurons le nombre de tentatives avant d'executer le script si le type d'etat est SOFT.
            case "$3" in

        # "3)" identifie le nombre de tentative avant d'executer le script
            3)

        #commande à executer
            /usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode=open-service --api-hostname='10.241.31.109' --api-port=80 --api-proto=http --api-username=admin--api-password='T' --rule-name='jira' --host-id="$4" --service-id="$5" --service-output="$6" --service-state="$2" --select='jira_project=Incidents ' --select='jira_issuetype=Incident'

            ;;

            esac

        ;;


    HARD)
            case "$3" in
            3)
            
       #commande à executer
          /usr/lib/centreon/plugins/centreon_notification_centreon_opentickets_api.pl --plugin notification::centreon::opentickets::api::plugin --mode=open-service --api-hostname='10.241.31.109' --api-port=80 --api-proto=http --api-username=admin --api-password='T' --rule-name='jira' --host-id="$4" --service-id="$5" --service-output="$6" --service-state="$2" --select='jira_project=Incidents ' --select='jira_issuetype=Incident'

        ;;

        esac

    ;;

esac

exit 0


0 replies

Be the first to reply!

Reply