Ad Widget

Collapse

User Parameter not Working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • houranit
    Junior Member
    • May 2014
    • 8

    #1

    User Parameter not Working

    Hello,

    Im trying to pass a variable into the User Parameter, in order to run a local command. When I run the command locally i get the expected result, but when I configure the UserParameter locally, and then try to call it from Zabbix, I get a "Not supported by Zabbix Agent".

    My UserParameter is:
    UserParameter=FileCount2[*],dir $1 /b/a-d | find /c /v ""

    My Item is created as Zabbix Agent:
    FileCount2[c:\inetpub\wwwroot]

    The results from running the commmand locally:
    C:\>dir c:\inetpub\wwwroot\ /b/a-d | find /c /v ""
    2

    Any help would be greatly appreciated, thanks all!
  • jlrd
    Junior Member
    • Oct 2012
    • 11

    #2
    I had some frustration early on with UserParameters. They are powerful but very finicky at times. I think what is happening in your case is you are passing "C:\inetpub\wwwroot" as a parameter. Parameters aren't very forgiving with special characters, and I'm pretty sure the path separators \ are treated as special characters.

    I found myself keeping a couple test hosts with the agent running in DebugLevel=4 mode so I could troubleshoot my UserParameters. You should also set LogFile and LogFileSize in the agentd.conf so you can hunt down the the results of the check.

    Its also helpful to take a look at zabbix_get.exe, which in most packages is in the same directory as the agent exe. You can test it over and over using the following from a command prompt:

    zabbix_get.exe -s 127.0.0.1 -k FileCount[C:\inetpub\wwwroot]

    or if you have a recent version of PowerShell (--% tells PowerShell to stop parsing the cmd as PowerShell):
    zabbix_get.exe --% -s 127.0.0.1 -k FileCount[C:\inetpub\wwwroot]

    Using zabbix_get.exe is a lot more useful then hopping back and forth in the frontend waiting for the check to happen. Also make sure that your Server= value in your config includes 127.0.0.1 so that zabbix_get.exe is allowed locally.

    I suspect that after its all said and done you will have to do something like:

    UserParameter=FileCount.WebRoot,dir C:\inetpub\wwwroot /b/a-d | find /c /v ""
    UserParameter=FileCount.UserContent,dir D:\users\content /b/a-d | find /c /v ""

    as the UserParameter, creating a UP for each directory, hard coded. Or you will have to create some kind of script to take "obfuscated" input parameters and then return a result. ala:

    UserParameter=FileCount[*],FileCount.bat $1 $2 $3

    Then call it with FileCount[C,inetpub,wwwroot] and FileCount[D,users,content] or something where the parameters get generically passed to a bat/script and the logic internal to that script knows how to generate a path, run the cmd, and return the result. More complex but more useful going forward.

    UserParameters are powerful but tricky at times. I've gone the scripted route on most of my UP's so that I can have more control. If you do go that route also make sure to properly set the Timeout= value on your client, and possibly the proxy and/or servers depending on whether you do Active or Passive checks. When you run a script to return a UserParamter 3 seconds (the default, i've increased mine to 30) is rather short and can lead to additional troubleshooting frustrations.

    Hopefully I've given you some avenues to try. On Windows and Zabbix the UserParameters are essential IMHO. Once you get them working its well worth the investment.

    Comment

    • houranit
      Junior Member
      • May 2014
      • 8

      #3
      Wow! Thanks so much for taking the time to put that post together. I eventually ended up doing most of what you mentioned, and like you said, it was a huge help!

      My goal was to be able to execute the Item using UP alone, without the need to deploy a BAT on each server I need that UP on. I did have to settle for a BAT to wrap around the CMD line, and echo back the results.

      Thanks again for this post, it should be stickied! So much useful info on how to troubleshoot and setup UP's

      Comment

      Working...