Hello,
I am creating a Cacti script data query and I would like to pass some custom host specific (i.e. per host) variables to the script, e.g. username and password. They are separate to the SNMP variables.
I have followed the excellent Script Data Query walkthrough, and successfully created and tested a script and XML file. I now just want to know if I can pass a couple of extra variables to the script.
These variables are used by the script to authenticate to the host during its indexed GET queries. Ideally I would like the username and password to be saved along with the other host properties on the Cacti Devices screen, but I have seen no way of adding custom fields to this screen so I don't hold much hope for that possibility.
I have considered (and remain open to) alternative methods of getting the information to the script, e.g.
- I cannot hijack (i.e. re-purpose) the |snmp_variables| or |host_variables|, they are all needed.
- I could get the administrator to enter the username and password for each host into a file on the Cacti server, and have the script read them from there, but this is inconvenient and I really would rather maintain this information through the Cacti WebUI.
Can anyone help please?
Can I pass custom variables to a Cacti script data query?
Moderators: Developers, Moderators
-
- Posts: 4
- Joined: Mon Nov 25, 2013 12:30 am
Re: Can I pass custom variables to a Cacti script data query
You can pass custom variables, for example look at any one of the Data Input Methods scripts. specify the variables by brackets. The Data Template will then have a Custom Data section at the bottom, to which you check the "Use Per-Data Source Value". These topics are covered in http://docs.cacti.net/
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
-
- Posts: 4
- Joined: Mon Nov 25, 2013 12:30 am
Re: Can I pass custom variables to a Cacti script data query
Thanks, I saw the section on Creating a Data Input Method, but thought that the part about specifying per data source variables inside <>'s in the input string applied only to Script/Command type Data Input Methods, and not to Get Script Data (Indexed) Data Queries (which is the sort of thing I think I need to be doing). Perhaps I misunderstood something.
The Perl script I wrote uses a mixture of SNMP and HTTP-requests to query the host and retrieve per interface statistics from the host's GUI, e.g.
Interface 1 unicast rx:100 tx:5,
Interface 2 unicast rx:250 tx:45,
Interface 3 dropped rx:50 tx:0,
Interface 4 utilization rx:60 tx:40,
etc
Most of the interface activity types that my script queries are counters, but some return a percentage value, e.g. utilization.
Here is some sample output:
It is just a script however, and I can always change it.
For each interface I want to create a separate graph for the different activity types (i.e. counters), e.g. unicast, multicast, dropped, utilization, other, etc. Each graph will show rx and tx data. For example, host-1 will have unicast, multicast and dropped graphs (each showing rx and tx data) for interfaces 1A to 12B.
It seems to me like I need to use a Get Script Data (Indexed) Data Query for something like this, and now I just want to know if I can pass a couple of extra variables to the script somehow. Again, perhaps I've missed something.
I have tried setting up an experimental Data Input Method with the input string shown below and the associated input fields.
Using this method, I think that for each interface on the host I would need to create a new Data Input Method for each of the 12 different activity types and then an accompanying data template and graph template. If I understand this correctly, a Get Script Data (Indexed) Data Query seems a more appropriate way of getting the data.
Any other advice you can provide will be greatly appreciated.
Thank you.
The Perl script I wrote uses a mixture of SNMP and HTTP-requests to query the host and retrieve per interface statistics from the host's GUI, e.g.
Interface 1 unicast rx:100 tx:5,
Interface 2 unicast rx:250 tx:45,
Interface 3 dropped rx:50 tx:0,
Interface 4 utilization rx:60 tx:40,
etc
Most of the interface activity types that my script queries are counters, but some return a percentage value, e.g. utilization.
Here is some sample output:
Code: Select all
> query.pl 10.0.0.5 admin mypass HTTP public 2c 161 2500 10 "" "" "" "" "" "" get dropped 11A
rx:0 tx:2975618
For each interface I want to create a separate graph for the different activity types (i.e. counters), e.g. unicast, multicast, dropped, utilization, other, etc. Each graph will show rx and tx data. For example, host-1 will have unicast, multicast and dropped graphs (each showing rx and tx data) for interfaces 1A to 12B.
It seems to me like I need to use a Get Script Data (Indexed) Data Query for something like this, and now I just want to know if I can pass a couple of extra variables to the script somehow. Again, perhaps I've missed something.
I have tried setting up an experimental Data Input Method with the input string shown below and the associated input fields.
Code: Select all
perl <path_cacti>/scripts/query.pl <host> <gui_u> <gui_p> <proto> <community> <version> <port> <timeout> <oids> "<username>" "<password>" "<auth_proto>" "<priv_pass>" "<priv_proto>" get unicast <int>
Any other advice you can provide will be greatly appreciated.
Thank you.
Re: Can I pass custom variables to a Cacti script data query
Exactly, as it automates a lot of the otherwise manual parameter filling for each data source. Of course, an indexed script query takes a lot more time to develop but is worth it in the end, especially if you want to automate its deployment to numerous devices.MisterJingo wrote:Using this method, I think that for each interface on the host I would need to create a new Data Input Method for each of the 12 different activity types and then an accompanying data template and graph template. If I understand this correctly, a Get Script Data (Indexed) Data Query seems a more appropriate way of getting the data..
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
Who is online
Users browsing this forum: No registered users and 7 guests