Ad Widget

Collapse

No login permissions - Zabcon

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lflaimer
    Junior Member
    • Oct 2009
    • 13

    #1

    No login permissions - Zabcon

    When I try to add a new item, I receive as answer "No login permissions.
    I added the user to the API group and the API access is enabled.
    What am I missing ?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Does the user also have permissions to add items to the host in question?
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • nelsonab
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2006
      • 1233

      #3
      Also how did you install Zabcon? The preferred way is to use the Rubygem

      gem install zabcon

      That should install very 0.0.5 of the zabcon gem and 0.0.2 of the Ruby API gem along with all other requirements.
      RHCE, author of zbxapi
      Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
      Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        i'd also suggest providing zabbix and zabcon versions, as well the exact command you are using
        Zabbix 3.0 Network Monitoring book

        Comment

        • mucknet
          Member
          • Dec 2004
          • 59

          #5
          Originally posted by nelsonab
          Also how did you install Zabcon? The preferred way is to use the Rubygem

          gem install zabcon

          That should install very 0.0.5 of the zabcon gem and 0.0.2 of the Ruby API gem along with all other requirements.

          I'm having the same issue.

          * Zabbix 1.8.4 on RHEL 5.4 x64
          * I installed ruby 1.8.6(p420) from source, compiling in readline, and openssl.
          * I installed gems 1.3.7 (which I believe is the latest supported by ruby 1.8.6) from source as well
          * I did: gem install json parseconfig highline zabcon zbxapi

          I am able to login to my server using zabcon.rb, and I'm able to view things, but I can't add an item:
          [root@admin3 ruby]# ./lib/ruby/gems/1.8/bin/zabcon.rb
          Unable to find a default configuration file
          x86_64-linux
          Checking dependencies
          Welcome to Zabcon.
          Use the command 'help' to get help on commands
          +> login http://localhost/zabbix/ user1 zabbixpass
          http://localhost/zabbix/ connected
          API Version: 1.3
          +> get user
          User result set
          +--------+-----------+
          | userid | alias |
          +--------+-----------+
          | 1 | Admin |
          | 2 | guest |
          | 3 | user_test |
          | 4 | user1 |
          +--------+-----------+
          4 rows total
          +> add item type=trapper hostid=10053 description="Stats:app4:PageGen:GET:/Home" key="stats-app4-PageGen-GET-_Home"
          No login permissions
          +>
          * "user1" is a Zabbix Super administrator, and has API access enabled.
          * This host was recently upgraded from zabbix 1.4.2, and hasn't shown any sign of problems (I upgraded to 1.6 first, and then to 1.8.4)
          * I do not have an "API" group or anything, but I have enabled the Zabbix Administrators group with API access.
          * I have also tried using the Admin user, same result.

          I have to add a lot of items, and any help would be greatly appreciated

          Comment

          • mucknet
            Member
            • Dec 2004
            • 59

            #6
            Similar results when I try to add host, but the error is slightly different
            +> add host host=test1234 dns=none.com port=10050 groups=none useip=0
            You do not have permission to perform that operation
            One thing to note is that zabbix is not installed in the root dir of my web server, it is accessed by http://hostname/zabbix -- would be strange if that mattered, but FYI.

            Edit: Nothing is showing up in zabbix_server.log on debug level 3, and I'm pretty sure nothing is showing up on debug level 4 (its hard to tell because there is so much data, but when I tried searching for the host id, or the username, nothing showed up)

            Comment

            • nelsonab
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2006
              • 1233

              #7
              Sorry, I've been a little busy lately. Increasing the debug level will show you nothing since the query is to the web server not the zabbix server. The API is implemented in the PHP web frontend.

              If you can please send me a zabcon debug output I can have a look at that. you can either post it here or email it to nelsonab (at) red-tux.net. You will need to check the output and format over your password in the output. I'll have this fixed in later relases.

              To increase the debug level either start zabcon with "-d 6" for debug level 6. Or after you have started zabcon (and logged in), issue the command "set env debug=6". If you do this after you log in, no password data is output.

              From there I may be able to get a better idea what is going on.
              RHCE, author of zbxapi
              Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
              Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

              Comment

              • mucknet
                Member
                • Dec 2004
                • 59

                #8
                I tried to post it here, but the forum software complained I was trying to post too many Images

                I sent it to your email. Thanks.

                Comment

                • nelsonab
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Sep 2006
                  • 1233

                  #9
                  Code:
                  D4 ..././zbxapi.rb:do_request:251 Sending: {"auth":"e424427e11437cbf564a922315c82eed","id":3,"method":"item.create","params":{"key_":"stats-app4-PageGen-GET-_Home","type":2,"description":"Stats:app4:PageGen:GET:/Home","hostid":10054},"jsonrpc":"2.0"}
                  D4 ..././zbxapi.rb:do_request:258 Response Code: 200
                  D4 ..././zbxapi.rb:do_request:259 Response Body:  {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid  params.","data":"[ CItem::create ] Cannot create Item"},"id":3}
                  D2 .../libs/exceptions.rb:initialize:46 Exception raised:  ZbxAPI_ExceptionLoginPermission
                  D2 .../libs/exceptions.rb:initialize:47 params: {:retry=>true}
                  No  login permissions
                  Ok it looks like the problem is two fold. First it is giving a generic error saying it cannot create the item. However the error message returned by Zabcon is unrelated to the actual error. This is because Zabcon uses the error number to key it's own error messages, currently the API does not use unique error numbers, just text.

                  Is the item already created?
                  RHCE, author of zbxapi
                  Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                  Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                  Comment

                  • mucknet
                    Member
                    • Dec 2004
                    • 59

                    #10
                    Originally posted by nelsonab
                    Code:
                    D4 ..././zbxapi.rb:do_request:251 Sending: {"auth":"e424427e11437cbf564a922315c82eed","id":3,"method":"item.create","params":{"key_":"stats-app4-PageGen-GET-_Home","type":2,"description":"Stats:app4:PageGen:GET:/Home","hostid":10054},"jsonrpc":"2.0"}
                    D4 ..././zbxapi.rb:do_request:258 Response Code: 200
                    D4 ..././zbxapi.rb:do_request:259 Response Body:  {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid  params.","data":"[ CItem::create ] Cannot create Item"},"id":3}
                    D2 .../libs/exceptions.rb:initialize:46 Exception raised:  ZbxAPI_ExceptionLoginPermission
                    D2 .../libs/exceptions.rb:initialize:47 params: {:retry=>true}
                    No  login permissions
                    Ok it looks like the problem is two fold. First it is giving a generic error saying it cannot create the item. However the error message returned by Zabcon is unrelated to the actual error. This is because Zabcon uses the error number to key it's own error messages, currently the API does not use unique error numbers, just text.

                    Is the item already created?

                    Hi Nelson, Thanks so much for the quick response!

                    You are right, the item was already there - But it wasn't before I tried adding it with the API. This is my first time using zabcon, so I suppose its possible I missed the successful response the first time or something? And with the login error I was receiving, I didn't even think to check and see if the item did indeed get created anyway...

                    In either case, it does appear to be working now. Thank you for your help, and sorry for the false alarm!

                    P.S. any plans to add support for adding graphs?

                    Is there a good tutorial available for using the raw API? (which I assume is my only choice for adding graphs right now)

                    Comment

                    • richlv
                      Senior Member
                      Zabbix Certified Trainer
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Oct 2005
                      • 3112

                      #11
                      here's a very hackish script that uses bash, zabcon & api to create graphs. while not exactly what you will need, maybe it helps to understand the syntax & approach used.
                      oh, the link

                      Join the friendly and open Zabbix community on our forums and social media platforms.
                      Zabbix 3.0 Network Monitoring book

                      Comment

                      • Aly
                        ZABBIX developer
                        • May 2007
                        • 1126

                        #12
                        http://www.zabbix.com/documentation/...i/graph/create
                        Zabbix | ex GUI developer

                        Comment

                        • nelsonab
                          Senior Member
                          Zabbix Certified SpecialistZabbix Certified Professional
                          • Sep 2006
                          • 1233

                          #13
                          Mucknet is having issues creating an item not a graph. Aly, here what was sent back and forth, where is the error?

                          Code:
                          Sending: {"auth":"e424427e11437cbf564a922315c82eed","id":3,"method":"item.create","params":{"key_":"stats-app4-PageGen-GET-_Home","type":2,"description":"Stats:app4:PageGen:GET:/Home","hostid":10054},"jsonrpc":"2.0"}
                          Response Code: 200
                          Response Body:  {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid  params.","data":"[ CItem::create ] Cannot create Item"},"id":3}
                          Looks to me like a permissions issue, but he is saying the user used in this transaction is a Zabbix Superuser.
                          RHCE, author of zbxapi
                          Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                          Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                          Comment

                          • dimi
                            Junior Member
                            Zabbix Certified Trainer

                            • Nov 2004
                            • 13

                            #14
                            Hi thanks for your great idea of a CLI tool for zabbix!!
                            I have play with it and seems to works well, i have found the same issue of the topic using this command:


                            > add host host=ciao dns=ciao.it groups=6 useip=0

                            The User & Password are correct also i have test the same command from the web gui without problem.

                            Can you give me some tips?
                            Thanks so much


                            Debug log
                            --------------------
                            9 .../libs/argument_processor.rbarams_to_hash:240 parsed: {"groups"=>"none", "host"=>"ciao", "dns"=>"ciao.it"}
                            D9 .../libs/argument_processor.rbarams_to_hash:204 parsing: useip=0
                            D9 .../libs/argument_processor.rbarams_to_hash:240 parsed: {"groups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}
                            D7 .../libs/argument_processor.rb:default_helper:315 default helper: {"groups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}
                            D9 .../libs/argument_processor.rb:safe_split:126 line: nil
                            D9 .../libs/argument_processor.rb:safe_split:127 boundary: ,
                            D6 .../libs/command_tree.rbarse:93 received from argument processor: {:show_params=>nil, :api_params=>{"groups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}}
                            D6 .../libs/zabcon_core.rb:start:218 Results from parse: {:show_params=>nil, roc=>#<Method: ZbxCliServer#addhost>, ptions=>{{:server=>#<ZbxCliServer:0x2ac02e3a7c80 @password="zabcon", @server=#<ZabbixAPI:0x2ac02e3a7c30 @application=#<ZbxAPI_Application:0x2ac02e3a77f8 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @minor=3, @password="zabcon", @id=8, @item=#<ZbxAPI_Item:0x2ac02e3a7898 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @usergroup=#<ZbxAPI_UserGroup:0x2ac02e3a7910 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @user_name="zabcon", @major=1, @history=#<ZbxAPI_History:0x2ac02e3a7780 @server=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @user=#<ZbxAPI_User:0x2ac02e3a7b68 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @trigger=#<ZbxAPI_Trigger:0x2ac02e3a77d0 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @hostgroup=#<ZbxAPI_HostGroup:0x2ac02e3a7820 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @url=#<URI::HTTP:0x2ac02e3a7938 URL:http://sangest/zabbix/api_jsonrpc.php>, @host=#<ZbxAPI_Host:0x2ac02e3a78c0 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>, @orig_url="http://sangest/zabbix", @auth="c453156ba06d1c2d0bd11104fb789273", @sysmap=#<ZbxAPI_Sysmap:0x2ac02e3a77a8 @parent=#<ZabbixAPI:0x2ac02e3a7c30 ...>>>, @user="zabcon", @server_url="http://sangest/zabbix", @debuglevel=9>}=>true}, :api_params=>{"groups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}, :helpproc=>#<Proc:0x00002ac02e1fd038@./libs/command_help.rb:64>}
                            D4 .../libs/zabcon_core.rb:start:228 Calling function: {:show_params=>nil, roc=>#<Method: ZbxCliServer#addhost>, ptions=>{{:server=>#<ZbxCliServer:0x2ac02e3a7c80 @password="zabc ..... ups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}, :helpproc=>#<Proc:0x00002ac02e1fd038@./libs/command_help.rb:64>}
                            D6 .../libs/zbxcliserver.rb:addhost:77 {"groups"=>"none", "useip"=>0, "host"=>"ciao", "dns"=>"ciao.it"}
                            D4 ..././zbxapi.rb:do_request:250 Sending: {"auth":"c453156ba06d1c2d0bd11104fb789273","method ":"host.create","id":8,"params":{"groups":"none"," useip":0,"host":"ciao","dns":"ciao.it"},"jsonrpc": "2.0"}
                            D4 ..././zbxapi.rb:do_request:252 Response Code: 200
                            D4 ..././zbxapi.rb:do_request:253 Response Body: {"jsonrpc":"2.0","error":{"code":-32500,"message":"Application error.","data":"[ CHost::create ] No permissions !"},"id":8}
                            D2 .../libs/exceptions.rb:initialize:43 Exception raised: ZbxAPI_ExceptionPermissionError
                            D2 .../libs/exceptions.rb:initialize:44 params: {:retry=>true}
                            You do not have permission to perform that operation

                            Comment

                            • nicolasg
                              Member
                              • Apr 2011
                              • 50

                              #15
                              Also having the same problem here, I can add a user but when trying to add a host I got a permission error> I'm using a users credentials that have full access to perform this operation on the Zabbix Web GUI :

                              Code:
                              echo "add user name=Test_User alias=TestAlias passwd=test_pass" | zabcon.rb
                              Created userid: 12
                              
                              echo "add host host=Test_host dns=del.com port=10050 status=monitored groups=ABC_Group" | zabcon.rb
                              You do not have permission to perform that operation
                              Zabbix version ->1.8.4
                              zabcon version -> 0.0.6

                              Any help will be appreciated.
                              Last edited by nicolasg; 29-07-2011, 12:04.

                              Comment

                              Working...