Ad Widget

Collapse

folder path in userparameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wamsterdam
    Member
    • Apr 2013
    • 34

    #1

    folder path in userparameter

    Hi,

    I have created a custom low level discovery (powershell) script to return me all user folders on a windows share. I would like to pass the folder path as a parameter to the script like so:

    Zabbix key:
    vfs.fs.discovery_users[C:\users, discover]

    Zabbix agent.conf:
    UserParameter=vfs.fs.discovery_users[*],powershell.exe C:\Tools\WindowsSearch.ps1 $1 $2

    Problem is, the UserParameter does not - by default - accept special characters. Is there another way to get this to work, other than to set UnsafeUserParameters=1 in agent.conf?

    TIA,
    Wouter
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    One way could be to use a non-special-character or term as replacement that gets then converted by your script appropriately. Another way could be to encode the parameter (e.g. by base64) and decode it within your script.

    Comment

    • gofree
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2017
      • 400

      #3
      HI guys, Im also looking in to this and tryinh to get it work


      my script


      param( $x )
      WRITE-HOST "{"
      WRITE-HOST "`"data`":["
      Get-ChildItem -Path $x -Attributes !Hidden+Directory|
      ForEach-Object {
      $n = $_ -replace('\\','/')
      WRITE-HOST "`{ `"`{`#FOLDER`}`":`"$n`",`},"}
      WRITE-HOST "]"
      WRITE-HOST "}"



      Userparameter:

      UserParameter=folder.discovery[*],powershell -ExecutionPolicy Bypass -File C:\zabbix\folder_discovery.ps1 -x $1


      When running script from commadline its pretty OK ( mind the C:/ ) I'm trying to avoid using of the unsafe parameters in C:\

      Mine dicovery rule should have syntax


      folder.discovery[C:/]

      When I try from command line I get unsupported item message , butif I run it manually looks OK- any idea ?






      Attached Files

      Comment

      Working...