Dynamic amount of output varriables

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
jctresbon
Posts: 5
Joined: Wed Jul 08, 2015 4:07 pm

Dynamic amount of output varriables

Post by jctresbon »

Hi there

if this has been covered in another post, I haven't been able to find it.

we have a powershell script that outputs the below information about exchange servers under our care. This script detects the number of exchange databases on the server in question and then gathers statistics about them like the size and amount of whitespace in the databases.

the problem is not about how to get the variables into Cacti, the tutorials on setting up the data inputs with scripts are clear. my problem is how can I account for a dynamic amount of databases in an exchange server then map them correctly to the output variables in the data input method. To help, think of exchange in this case as an SQL server with multiple schemas/databases that I need to gather stats on.

another factor to consider:

The database count could change at any moment on any server, more often then not there will be an additional database/schema added, though it could happen that a database may be removed.

Example server 1

PS C:\scripts> C:\scripts\ps.ps1
ExDBOneName:DB01
ExDBOneSize:370816
ExDBOneFreespace:668
ExDBTwoName:DB02
ExDBTwoSize:412288
ExDBTwoFreespace:99
ExDBThreeName:DB03
ExDBThreeSize:496384
ExDBThreeFreespace:118
ExDBFourName:DB04
ExDBFourSize:520576

Example Server 2

PS C:\scripts> C:\scripts\ps.ps1
ExDBOneName:DB
ExDBOneSize:370816
ExDBOneFreespace:668
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Dynamic amount of output varriables

Post by BSOD2600 »

You're going to need to enhance the script and wrap it up into a script data query. http://docs.cacti.net/manual:088:3a_adv ... alkthrough

Sounds like you'll want to use the dbname as the index.
jctresbon
Posts: 5
Joined: Wed Jul 08, 2015 4:07 pm

Re: Dynamic amount of output varriables

Post by jctresbon »

Hi there

thanks, found the data query last night
DB names are unique, though im just going to mod the script to output the counter as the index

by what I can tell, I need to make the output similar to an indexed SNMP walk for the data query to function correctly.

I rejiggered my output from the script and it currently looks something like this
index:1
dbname:DB01
DbSize:370816
dbFreeSpace:668
index:2
dbname:DB02
DbSize:412288
dbFreeSpace:99

would be the variables I put in the data query XML so that things are parsed correctly, look like this? (pretend there is an IF definition and XML surrounding the variables as per the walk though)

index
dbname
dbFreeSpace
DbSize
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Dynamic amount of output varriables

Post by BSOD2600 »

Sure, if you do it similar to the guide I linked, that'll be fine. The disk and cpu script queries which come with cacti are also good examples of how to build one.
Personally, I'd want the db name in the graph, so would recommend keeping it and using that as the index. With data input fields, they can be used in graphs :)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests