Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #8769] Improve error message for invalid field access #2557

Closed
icinga-migration opened this issue Mar 16, 2015 · 16 comments
Milestone

Comments

@icinga-migration
Copy link
Member

@icinga-migration icinga-migration commented Mar 16, 2015

This issue has been migrated from Redmine: https://dev.icinga.com/issues/8769

Created by satock on 2015-03-16 14:32:36 +00:00

Assignee: gbeutner
Status: Resolved (closed on 2015-03-19 12:49:35 +00:00)
Target Version: 2.3.3
Last Update: 2015-03-19 12:49:35 +00:00 (in Redmine)

Icinga Version: r2.3.2-1
Backport?: Not yet backported
Include in Changelog: 1

hello,

i have der problem, when i have more als five custom attributes to apply a service.

apply Service "Postfix Mail Queue" {
        import "generic-service-perf"

        check_command = "check_nrpe_check_mailq_postfix"


        if (host.vars.role.linux.mail.postfix.qwarn) {
                vars.warn = host.vars.role.linux.mail.postfix.qwarn
                vars.crit = host.vars.role.linux.mail.postfix.qcrit

        } else {
                vars.warn = "200"
                vars.crit = "1000"
        }

critical/config: Error: Invalid field name: 'qwarn'
Location:
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(32):
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(33):
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(34):  if (host.vars.role.linux.mail.postfix.qwarn) {
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(35):   vars.warn = host.vars.role.linux.mail.postfix.qwarn
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(36):   vars.crit = host.vars.role.linux.mail.postfix.qcrit

icinga2 - The Icinga 2 network monitoring daemon (version: r2.3.2-1)

Copyright (c) 2012-2015 Icinga Development Team (https://www.icinga.org)
License GPLv2+: GNU GPL version 2 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Application information:
  Installation root: /usr
  Sysconf directory: /etc
  Run directory: /run
  Local state directory: /var
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid
  Application type: icinga/IcingaApplication

thanks

Attachments

Changesets

2015-03-19 12:48:31 +00:00 by (unknown) ab36912

Improve error message for invalid field access

fixes #8769

2015-03-19 12:48:51 +00:00 by (unknown) 6812e26

Improve error message for invalid field access

fixes #8769
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 14:35:40 +00:00

  • Description updated
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 14:43:58 +00:00

Kann es sein, dass das Attribut 'host.vars.role.linux.mail.postfix.' bei einem deiner Hosts kein Dictionary sondern evtl. ein anderer Typ (String, Array, Number) ist, der keine Felder unterstützt?

Hier ein Beispiel, wie man es mit der Konsole reproduzieren kann:

$ icinga2 console
Icinga (version: v2.3.0-42-g1eef024)
<1> => a = "test"
null
<2> => a.b
       ^^^
Invalid field name: 'b'
<3> => 

Um herauszufinden, welcher deiner Hosts dafür verantwortlich ist, kannst du die log-Funktion in deinem Apply aufrufen:

apply Service "Postfix Mail Queue" {
        import "generic-service-perf" 

        check_command = "check_nrpe_check_mailq_postfix" 

        log("Host '" + host.name + "' hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix) + "'.")

        if (host.vars.role.linux.mail.postfix.qwarn) {
                vars.warn = host.vars.role.linux.mail.postfix.qwarn
                vars.crit = host.vars.role.linux.mail.postfix.qcrit

        } else {
                vars.warn = "200" 
                vars.crit = "1000" 
        }
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 14:44:22 +00:00

  • Category set to Configuration
  • Status changed from New to Feedback
  • Assigned to set to satock
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 14:45:11 +00:00

UPDATE:

i have the problem only in the conditional statements

sorry, for the bad information

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 14:51:33 +00:00

@Kein Dictionary sondern evtl. ein anderer Typ (String, Array, Number) ist

host-config

vars.role.linux["mail"] = {
amavisd = true
postfix = { qwarn= "200"; qcrit = "1500"; }
.....
}

Das ist richtig ...

Ich habe das Problem aber nur in den "if" Anweisungen

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 14:55:49 +00:00

Bitte hänge mal ein minimales Configbeispiel an das Ticket, was dieses Problem demonstriert (idealerweise ein Host + ein apply und keine anderen Variablen). Ich kann das hier bei mir so nicht reproduzieren.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 14:56:44 +00:00

Und zusätzlich auch die Ausgabe der log-Funktion, die du anhand meines Beispiels in deine Config eingebaut hast.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 15:10:42 +00:00

  • File added Bug_8769.txt

    ################################################################################
    object Host "mailserver" {
    import "linux-deb-host"

      display_name          = "mailserver"
      address               = "192.168.1.1"
    
    
      vars.role.linux["mail"] = {
          postfix = {  qwarn = "200"; qcrit = "1500"; }
          amavisd = true
      }
    

    }

    apply Service "Postfix Mail Queue" {
    import "generic-service-perf"

          check_command = "check_nrpe_check_mailq_postfix"
    
          if (host.vars.role.linux.mail.postfix.qwarn) {
                  vars.warn = host.vars.role.linux.mail.postfix.qwarn
                  vars.crit = host.vars.role.linux.mail.postfix.qcrit
    
          } else {
                  vars.warn = "200"
                  vars.crit = "1000"
          }
    
    
          assign where host.vars.role.linux.mail.postfix
    

    }

    ----------- Log ----------------

    log("Host '" + host.name + "' Postfix hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix) + "'.")
    log("Host '" + host.name + "' Postfix QWarn hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qwarn) + "'.")
    log("Host '" + host.name + "' Postfix QCrit hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qcrit) + "'.")

    information/config: Host 'mailserver' Postfix hat als Wert '{"queuecrit":"1500","queuewarn":"200"}'.
    information/config: Host 'mailserver' Postfix QWarn hat als Wert 'null'.
    information/config: Host 'mailserver' Postfix QCrit hat als Wert 'null'.

Ich hoffe das reicht ... :-)

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 15:11:38 +00:00

ps.
auch bei LOG kommt ...

critical/config: Error: Invalid field name: 'qwarn'
Location:
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(32):
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(33):  log("Host '" + host.name + "' Postfix hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix) + "'.")
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(34):  log("Host '" + host.name + "' Postfix QWarn hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qwarn) + "'.")
                                                                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(35):  log("Host '" + host.name + "' Postfix QCrit hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qcrit) + "'.")
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(36):
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 15:14:35 +00:00

Die normalen Apply Rules ziehen, sprich die Services werden bei den Hosts erstellt.
Hatte jetzt nur bei den "if" Anweisungen und beim Logging-Eintrag das " Invalid field name" Problem.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by satock on 2015-03-16 15:27:36 +00:00

sorry habe jetzt einen neuen Log-Output ... hab da mit andern vars gespielt ...

information/config: Host 'mailserver' Postfix hat als Wert '{"qcrit":"1500","qwarn":"200"}'.
information/config: Host 'mailserver' Postfix QWarn hat als Wert '"200"'.
information/config: Host 'mailserver' Postfix QCrit hat als Wert '"1500"'.

critical/config: Error: Invalid field name: 'qwarn'
Location:
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(32):
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(33):  log("Host '" + host.name + "' Postfix hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix) + "'.")
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(34):  log("Host '" + host.name + "' Postfix QWarn hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qwarn) + "'.")
                                                                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(35):  log("Host '" + host.name + "' Postfix QCrit hat als Wert '" + Json.encode(host.vars.role.linux.mail.postfix.qcrit) + "'.")
/etc/icinga2/zones.d/basicchecks/linux/mail/postfix.conf(36):

lasse ich nun die "role" in den vars weg und bin somit unter den fünf - dann geht es ...

        log("Host '" + host.name + "' Postfix hat als Wert '" + Json.encode(host.vars.linux.mail.postfix) + "'.")
        log("Host '" + host.name + "' Postfix QWarn hat als Wert '" + Json.encode(host.vars.linux.mail.postfix.qwarn) + "'.")
        log("Host '" + host.name + "' Postfix QCrit hat als Wert '" + Json.encode(host.vars.linux.mail.postfix.qcrit) + "'.")
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 16, 2015

Updated by gbeutner on 2015-03-16 16:39:31 +00:00

Davon abgesehen dass deine minimale Beispielconfig nicht ohne Änderungen funktioniert, verursacht sie hier das Problem nicht. Bitte teste dies einmal mit einer komplett neuen Icinga-Installation und schicke mir dann eine neue Config mit der das Problem auftritt.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 19, 2015

Updated by satock on 2015-03-19 09:05:37 +00:00

Kurzes Update.

Ich hab das mal mit andern vars versucht - ala vars.test.test1.test2.test3 usw. hier funktioniert es. Ich schau mir das nochmals genauer an.
Ticket kann geschlossen werden ..

Vielen Dank !

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 19, 2015

Updated by mfriedrich on 2015-03-19 09:32:53 +00:00

  • Subject changed from More as five Custom Attributes to Improve error message for invalid field access
  • Status changed from Feedback to Assigned
  • Assigned to changed from satock to gbeutner
  • Target Version set to 2.3.3
  • Estimated Hours set to 1
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 19, 2015

Updated by gbeutner on 2015-03-19 12:47:58 +00:00

Improved error message:

<1> => "test".a
       ^^^^^^^^
Invalid field access (for value of type 'String'): 'a'
@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Mar 19, 2015

Updated by Anonymous on 2015-03-19 12:49:35 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset ab36912.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.