Ad Widget

Collapse

Not possible to add any working UserParameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jozef Pazin
    Junior Member
    • Mar 2023
    • 4

    #1

    Not possible to add any working UserParameter

    Hi, I want to monitor one file with only one row (numeric value).
    But always when I modify zabbix_agent2.conf and restart zabbix service (version 6.0 on linux debian) I get this:

    Code:
    systemctl status zabbix-agent2.service
    ● zabbix-agent2.service - Zabbix Agent 2
    Loaded: loaded (/lib/systemd/system/zabbix-agent2.service; enabled; vendor preset: enabled)
    Active: activating (auto-restart) (Result: exit-code) since Wed 2023-03-01 17:36:47 CET; 4s ago
    Process: 15749 ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE (code=exited, status=2)
    Main PID: 15749 (code=exited, status=2)
    CPU: 20ms
    Mar 01 17:36:47 web systemd[1]: zabbix-agent2.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
    Mar 01 17:36:47 web systemd[1]: zabbix-agent2.service: Failed with result 'exit-code'.
    My UserParameter looks like:

    Code:
    UserParameter=export.ok,cat /data/info/export.ok.state
    I tried even this:

    Code:
    UserParameter=export.ok,echo "1"
    But this is also wrong for zabbix agent and ends with the same error (service exited, status invalidargument).
    Without UserParameter everything look working ok.
  • Jozef Pazin
    Junior Member
    • Mar 2023
    • 4

    #2
    Today I tried an example directly from the documentation UserParameter:

    Code:
    UserParameter=system.test,who|wc -l
    But zabbix service failed to start again.

    Code:
    Mar 02 09:15:04 web systemd[1]: zabbix-agent2.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
    Mar 02 09:15:04 web systemd[1]: zabbix-agent2.service: Failed with result 'exit-code'.​
    Exact zabbix version: zabbix_agent2 (Zabbix) 6.0.13
    Revision fdfa8cef9ce 1 February 2023, compilation time: Feb 1 2023 10:20:18
    Plugin communication protocol version is 6.0.13​

    Comment

    • Jozef Pazin
      Junior Member
      • Mar 2023
      • 4

      #3
      I just found out from the log that it may be related to an active check.
      Solution: It works if I set ServerActive and Hostname and thus the agent starts behaving as active.

      Oh, this would really be worth mentioning in the documentation.​

      Please, if someone has access to edit the documentation and it is really the case that UserParameters are enabled only with ServerActive,
      could you add this information there.

      Thank you very much​

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        Originally posted by Jozef Pazin
        is really the case that UserParameters are enabled only with ServerActive,
        No, it is not the case. Custom items (UserParameter) work for passive checks too.

        Have you looked at the log on the system where the agent is running, to see if there are any clues in the agent log file about what the actual problem is?

        Comment

        • Semiadmin
          Senior Member
          • Oct 2014
          • 1625

          #5
          By the way, why do you need a userparameter if there is a standard vfs.file.contents?

          Comment

          • Jozef Pazin
            Junior Member
            • Mar 2023
            • 4

            #6

            Thank you for response.

            After your suggestion, I tried again, and you are right, now, regardless of filling out the active check or disabling it, the agent is still functional. So it had to be a different situation.
            I no longer have the logs from 2 days ago, but after some testing I ends with the equivalent situation.

            This is my full configuration now: (command: cat /etc/zabbix/zabbix_agent2.conf | grep -e "^[^# ].*$")

            Code:
            PidFile=/var/run/zabbix/zabbix_agent2.pid
            LogFile=/var/log/zabbix/zabbix_agent2.log
            LogFileSize=0
            Server=10.114.1.94,zabbix
            ServerActive=10.114.1.94
            Hostname=web
            Timeout=25
            Include=/etc/zabbix/zabbix_agent2.d/*.conf
            PluginSocket=/run/zabbix/agent.plugin.sock
            UserParameter=export.ok,cat /data/info/export.ok.info
            ControlSocket=/run/zabbix/agent.sock
            Include=./zabbix_agent2.d/plugins.d/*.conf
            AllowKey=system.run[*]​
            After multiple restarting (command: systemctl restart zabbix-agent2.service) I still can not start agent correctly: (command: systemctl status zabbix-agent2.service)

            Code:
            zabbix-agent2.service - Zabbix Agent 2
            Loaded: loaded (/lib/systemd/system/zabbix-agent2.service; enabled; vendor preset: enabled)
            Active: activating (auto-restart) (Result: exit-code) since Fri 2023-03-03 [B]11:45:19 CET; 1s ago[/B]
            Process: 52464 ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE (code=exited, status=2)
            Main PID: 52464 (code=exited, status=2)
            CPU: 19ms
            Mar 03 11:45:19 web systemd[1]: zabbix-agent2.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
            Mar 03 11:45:19 web systemd[1]: zabbix-agent2.service: Failed with result 'exit-code'.​​
            But if I wait about 1 minute.. agent starts and run immediate after restart.

            Code:
            zabbix-agent2.service - Zabbix Agent 2
            Loaded: loaded (/lib/systemd/system/zabbix-agent2.service; enabled; vendor preset: enabled)
            Active: active (running) since Fri 2023-03-03 11:46:31 CET; 24s ago
            Main PID: 52601 (zabbix_agent2)
            Tasks: 6 (limit: 9421)
            Memory: 7.6M
            CPU: 27ms
            CGroup: /system.slice/zabbix-agent2.service
            └─52601 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf​
            So I checked logs:

            Code:
            2023/03/03 11:45:06.151564 [101] cannot connect to [10.114.1.94:10051]: dial tcp :0->10.114.1.94:10051: i/o timeout
            2023/03/03 11:45:06.151589 [101] active check configuration update from host [web] started to fail
            2023/03/03 11:45:19.790266 Zabbix Agent 2 stopped. (6.0.13)
            2023/03/03 11:45:19.814910 Starting Zabbix Agent 2 (6.0.13)​
            It looks like it has a problem with the active check, but in the end it started anyway and is awake.

            I can not figure out how I got to this state the last time adding an active check helped, but I assume I waited a long time before checking the service status.
            By default I wait around 5 seconds and then check the status. Apparently, zabbix somehow tries to start again, so I have to check the status with a longer time interval.

            So probably everything is working, only I obviously can't wait a while or wait without checking if the service is working (and instead I'll spend an hour writing on the forum )

            I modified the configuration as originally intended, restarted the agent, waited 2 minutes and everything seems to be fine.
            Thank you for your support.

            Semiadmin, thanks for the suggestion, the original command in UserParameter was more complicated, I modified it to the simplest version as I was looking for a solution.​​

            Comment

            Working...