Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Transforming a value to string to use in custom error message

Transforming a value to string to use in custom error message

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 30.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    DanG
    wrote on last edited by
    #1

    Current I report the current value of the DCI using the %<currentValue>
    For the ServiceCheck.HTTP the value can be 0 to 3.
    I would rather have a textual description instead of the numerical value. I thought of using a the transformation script but this will change the type from int to string which cannot be graphed.
    Another place where I could do this is in the filtering script where CUSTOM_MESSAGE can be set.

    sub main()
    {
     CUSTOM_MESSAGE = "";
     
     if($1->value == 2)
     {
      CUSTOM_MESSAGE = "cannot connect to server";
     }
     else
     if($1->value == 3)
     {
      CUSTOM_MESSAGE = "content of does not match";
     }

      return true;
    }

    How do I test the “value” within the filtering script ($1->value above does not work of course) ?
    Or maybe there's a better solution?

    Regards,

    Dan

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi!

      I would suggest calling a script from macro, like this:

      1. Create script called "ServiceStateName" in script library:
      state = GetEventParameter($event, "currentValue");
      switch(state)
      {
         case 0:
            return "OK";
         case 1:
            return "error in parameters";
         case 2:
            return "cannot connect to server";
         case 3:
            return "content of does not match";
      }
      return "UNKNOWN";
      
      1. Use %[ServiceStateName] instead of %<currentValue>

      Best regards,
      Victor

      1 Reply Last reply
      0
      • D
        D
        DanG
        wrote on last edited by
        #3

        Hi Victor,

        Your solution is elegant and works like a charm. Tanks!

        Kind regards,

        Dan

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups