OTRS 4 Systemmonitoring mit Incident verknüpfen

Moderator: crythias

Post Reply
etmiesje
Znuny newbie
Posts: 5
Joined: 03 Feb 2007, 12:35

OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by etmiesje »

Hello everybody,
in English now :-) // German text in the end
---------------
I have lost some knowledge in OTRS during the last 4 years, and now I need some help with OTRS 4, ITSM and OTRS::Systemmonitoring

Following Scenario:
Nagios will send Mail to OTRS
- in the Service Definition of Nagios I have a specific Variable _Service MySQL added
In the Nagios Mail to OTRS this Information is available.

In OTRS I have the ITSM MOdules and have specified a Service 'MySQL'. The Host of Nagios is configured in the CMDB with exact the same name.

Now I want to have a association of the CRITICAL Service with the CI that is associated with the OTRS Service MySQL.

Any help would be appreciated.

regards,
Christian

-----------------------------

Hallo zusammen,
ich habe ca. 4 Jahre kein OTRS mehr angefasst. Leider stehe ich nun am Schlauch mit der Version 4, ITSM und OTRS Systemmonitoring

Folgendes Szenario:
Nagios sendet E-Mail an OTRS:
- im Service ist eine spezifische Variable _Service MySQL hinterlegt
in der E-Mail kommt der Wert NAGIOS__SERVICE auch an. --> done

In OTRS habe ich einen Service --> MySQL und in der CMDB den Host aus der Nagiosconfig mit dem Service MySQL verknüpft.

Wie bekomme ich nun die Verbindung hin, dass die Nagios Variable NAGIOS__SERVICE umgesetzt wird in den Service für OTRS, damit ich diese im Stat Modul mit auswerten kann?

Viele Grüße und herzlichen Dank,
Christian
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by RStraub »

I don't completly understand what you want. Could you rephrase that in OTRS wording?

You want to ... link an incoming mail depending on a string in the body with a CI ?
Or do you want to change the incident state of a service ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
etmiesje
Znuny newbie
Posts: 5
Joined: 03 Feb 2007, 12:35

Re: OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by etmiesje »

I want to have an overview in the stats - Module, how many incidents exists for a service and within that the Incidents from the CI, that are associated to the Service should be included in the count.

In the E-Mail from Nagios is a Body Test ITSM Service: MySQL and in OTRS exists the Service MySQL. So this will be my key for the service and the CI

So I think, I need both you asking for.

Thank your for your help,

Christian
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by RStraub »

I wrote a module that does exactly this, but links a mail with CI, not a service.

On monday I'll post you the example text, you might work from there.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by jojo »

Linking a CI to a ticket on incoming system monitoring mail and changing the CI incident state is a default behavour of the OTRS System Monitoring module. Please check sysconfig for the settings
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: OTRS 4 Systemmonitoring mit Incident verknüpfen

Post by RStraub »

Right, but for some reason I can't remember we decided not to use the System Monitoring. Anyhow, here is what the event does:

1) Listens to ArticleCreate
2) Polls TicketData (to check the Title against an regex) ->

Code: Select all

    my %Ticket = $Self->{TicketObject}->TicketGet(
        TicketID => $Param{Data}->{TicketID},
        UserID   => 1,
    );
    
    return unless ($Ticket{Title} =~ /ThisIsYourMatchingRegex .*/);
3) Poll ArticleData (to save the values you are looking for ->

Code: Select all

    my %Data = $Self->{TicketObject}->ArticleGet(
        ArticleID       => $Param{Data}->{ArticleID},
        DynamicFields   => 0,
#       Extended        => 1,
    );
    
    for my $line (split /^/, $Data{Body} ) {
        if ($line =~ /FirstMatchingRegex: (.*)/m) {
            $FirstVariableToSaveValue = $1;
        }
        if ($line =~ /SecondMatchingRegex (.*)/m) {
            $SecondVariableToSaveValue = $1;
        }
    }
4) Lookup the ConfigItemIDs that match these values ->

Code: Select all

   my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearchExtended(
      ClassIDs => [$YourClassID],
      What => [
        {
           "[%]{'Version'}[%]{'Key_Of_The_Matching_Field'}[%]{'Content'}" => "%$ValueYouWantToMatch%",
        },
      ],
   );
5) Link the Ticket with the CI ->

Code: Select all

#   Creating the link:
    my $LinkObject = Kernel::System::LinkObject->new( %{$Self} );
    if ( !$LinkObject ) {
        $Self->{LogObject}->Log( Priority => 'error', Message => "Need LinkObject!" );
        return;
    }

    my $Success = $LinkObject->LinkAdd(
        SourceObject    => 'Ticket',
        SourceKey       => $Param{Data}->{TicketID},
        TargetObject    => 'ITSMConfigItem',
        TargetKey       => @$ConfigItemIDs,
        Type            => 'RelevantTo',
        State           => 'Valid',
        UserID          => '1',
    );
6) Poll newest version of the CI and then set the new IncidentState:

Code: Select all

    my $VersionID = $ConfigItemObject->VersionAdd(
        ConfigItemID => @$ConfigItemIDs,
        Name         => $OldVersion{Name},
        DefinitionID => $OldVersion{DefinitionID},
        DeplStateID  => $OldVersion{DeplStateID},
        XMLData      => $OldVersion{XMLData},
        InciStateID  => $NewInciStateID,
        UserID       => 1,
    );
Does this help you?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Post Reply