vCenter datastore monitoring script with multiple inputs
Moderators: Developers, Moderators
vCenter datastore monitoring script with multiple inputs
Hi all and thanks for looking at my post!
I'm very new to Cacti, and have maybe jumped in at the deep end slightly.
I've got a script that I've slightly adjusted from it's original use case as a Nagios plugin.
The script queries the vCenter API to get various values about a specifed datstore.
The script is called with two arguments; vCenter server and the name of the datastore, and it outputs 4 metrics.
For example;
./my_script.sh vc_name datastore_name
used_percentage:35 capacityGB:2559 free_spaceGB:902 used_spaceGB:1656
After an initial learning curve, I managed to get Cacti graphing these metrics by hard-coding the vcenter name and datastore in the Data Input Method page along with the script.
This though obviously isn't scalable, as I'd like to be able to have a single Data Input Method that would allow me to use the vCenter name and datastore name as variable elsewhere.
Now, having the <host> variable in place and graphing against the vCenter server isn't an issue, but I'm really struggling with the second "datastore" variable, as can't see how this would be set or called.
Apologies for what is probably a very newbie problem, but i can't find the solution anywhere else on the forum or elsewhere.
Many thanks for any suggestions and help with this.
I'm very new to Cacti, and have maybe jumped in at the deep end slightly.
I've got a script that I've slightly adjusted from it's original use case as a Nagios plugin.
The script queries the vCenter API to get various values about a specifed datstore.
The script is called with two arguments; vCenter server and the name of the datastore, and it outputs 4 metrics.
For example;
./my_script.sh vc_name datastore_name
used_percentage:35 capacityGB:2559 free_spaceGB:902 used_spaceGB:1656
After an initial learning curve, I managed to get Cacti graphing these metrics by hard-coding the vcenter name and datastore in the Data Input Method page along with the script.
This though obviously isn't scalable, as I'd like to be able to have a single Data Input Method that would allow me to use the vCenter name and datastore name as variable elsewhere.
Now, having the <host> variable in place and graphing against the vCenter server isn't an issue, but I'm really struggling with the second "datastore" variable, as can't see how this would be set or called.
Apologies for what is probably a very newbie problem, but i can't find the solution anywhere else on the forum or elsewhere.
Many thanks for any suggestions and help with this.
Re: vCenter datastore monitoring script with multiple inputs
where you get the data store names? Is your script able to return datastore names?
Let the Cacti grow!
Re: vCenter datastore monitoring script with multiple inputs
Yes, my original version of the script actually gave an output of all datastore names followed by percent usage, for example;
datastore1:22 datastore2:11 and so on...
I changed it so that I would instead provide the datastore name as an input so it would give me multiple metric outputs for each datastore instead, but the list of datastores is still there if needed
datastore1:22 datastore2:11 and so on...
I changed it so that I would instead provide the datastore name as an input so it would give me multiple metric outputs for each datastore instead, but the list of datastores is still there if needed
Re: vCenter datastore monitoring script with multiple inputs
I hope I'm not mistaken. Try to look at your_cacti/scripts/query_unix_partitions.pl and your_cacti/resource/script_queryies/unix_disk.xml and data_collection -> data queries -> UNIx - Get Mounted Partitions.
I think that there is the same situation
I think that there is the same situation
Let the Cacti grow!
Re: vCenter datastore monitoring script with multiple inputs
Thanks. I've found the Unix perl script and XML file. I just need to spend some time understanding how it fits together and how to translate this this into the vCenter method.
I've also been advised that there are likely existing scripts and templates to do what I want which might be easier than trying to do it from scratch.
I've also been advised that there are likely existing scripts and templates to do what I want which might be easier than trying to do it from scratch.
Re: vCenter datastore monitoring script with multiple inputs
Try our documentation:
https://docs.cacti.net/How-To-Script-Data-Queries.md
https://docs.cacti.net/How-To-Script-Data-Queries.md
Let the Cacti grow!
Re: vCenter datastore monitoring script with multiple inputs
Thanks, that looks really useful.
Re: vCenter datastore monitoring script with multiple inputs
Hi again. Thanks for the previous info and link to the documentation.
I've been spending a few days on and off working on this, but have yet to make it work with my scripts.
Currently, I have two scripts.
1.) A script that displays a list of datastore names as gathered via the vSphere API.
The output looks like this;
./vc_datastore_get_list.sh vc-server-1
datastore-1,datastore-2,datastore-3
and so on.
2.) A script that gets the required values for; used_percentage, capacity, free_space and used_space for a datastore. The output looks like this;
./query_datastore_disk_usage.sh vc-server-1 datastore-1
used_percentage:34 capacity:2748510633984 free_space:952080793600 used_space:1796429840384
Below is the XML file I've created to handle these fields.
I'm trying to follow the documentation whilst attempting to cater it to my specific requirement, but so far, failing.
Would you please be able to give any advice on my current approach, and any next steps I need to take to get this working with a query and data inputs?
Many kind thanks!
XML file contents;
<interface>
<name>Get Datastore Disk Usage</name>
<script_path>/usr/share/cacti/scripts/query_datastore_disk_usage.sh</script_path>
<arg_prepend>|host_hostname| |arg1| |arg2|</arg_prepend>
<output_delimiter> </output_delimiter>
<fields>
<used_percentage>
<name>Used Percentage</name>
<direction>output</direction>
<query_name>used_percentage</query_name>
</used_percentage>
<capacityGB>
<name>Capacity</name>
<direction>output</direction>
<query_name>capacity</query_name>
</capacityGB>
<free_spaceGB>
<name>Free Space</name>
<direction>output</direction>
<query_name>free_space</query_name>
</free_spaceGB>
<used_spaceGB>
<name>Used Space</name>
<direction>output</direction>
<query_name>used_space</query_name>
</used_spaceGB>
</fields>
</interface>
I've been spending a few days on and off working on this, but have yet to make it work with my scripts.
Currently, I have two scripts.
1.) A script that displays a list of datastore names as gathered via the vSphere API.
The output looks like this;
./vc_datastore_get_list.sh vc-server-1
datastore-1,datastore-2,datastore-3
and so on.
2.) A script that gets the required values for; used_percentage, capacity, free_space and used_space for a datastore. The output looks like this;
./query_datastore_disk_usage.sh vc-server-1 datastore-1
used_percentage:34 capacity:2748510633984 free_space:952080793600 used_space:1796429840384
Below is the XML file I've created to handle these fields.
I'm trying to follow the documentation whilst attempting to cater it to my specific requirement, but so far, failing.
Would you please be able to give any advice on my current approach, and any next steps I need to take to get this working with a query and data inputs?
Many kind thanks!
XML file contents;
<interface>
<name>Get Datastore Disk Usage</name>
<script_path>/usr/share/cacti/scripts/query_datastore_disk_usage.sh</script_path>
<arg_prepend>|host_hostname| |arg1| |arg2|</arg_prepend>
<output_delimiter> </output_delimiter>
<fields>
<used_percentage>
<name>Used Percentage</name>
<direction>output</direction>
<query_name>used_percentage</query_name>
</used_percentage>
<capacityGB>
<name>Capacity</name>
<direction>output</direction>
<query_name>capacity</query_name>
</capacityGB>
<free_spaceGB>
<name>Free Space</name>
<direction>output</direction>
<query_name>free_space</query_name>
</free_spaceGB>
<used_spaceGB>
<name>Used Space</name>
<direction>output</direction>
<query_name>used_space</query_name>
</used_spaceGB>
</fields>
</interface>
Re: vCenter datastore monitoring script with multiple inputs
Again - here is describes all what you need. You have to create single script for it.
https://docs.cacti.net/How-To-Script-Data-Queries.md
If you show me your scripts I will try to help you. Please send it to petr.macek@kostax.cz
https://docs.cacti.net/How-To-Script-Data-Queries.md
If you show me your scripts I will try to help you. Please send it to petr.macek@kostax.cz
Let the Cacti grow!
Who is online
Users browsing this forum: No registered users and 3 guests