Chapter VIII: VALUE/REGEXP in Action
As said above, with the current XML size values are measured in Units. The current Unit Size is given by hrStorageAllocationUnits, but the reading of it is like 4096 Bytes. To use this in any calculations, we must get rid of the string Bytes. This can be done by the VALUE/REGEXP Feature of cacti's XML definitions. So please change
| Code: |
<hrStorageAllocationUnits>
<name>Allocation Units (Bytes)</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.25.2.3.1.4</oid>
</hrStorageAllocationUnits> |
by
| Code: |
<hrStorageAllocationUnits>
<name>Allocation Units (Bytes)</name>
<method>walk</method>
<source>VALUE/REGEXP:([0-9]*) Bytes</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.25.2.3.1.4</oid>
</hrStorageAllocationUnits> |
To proove this, goto your device and again Verbose Query our Data Query to see:
snmptable-dev-30
Now select Create Graphs for this Host and notice the change of the column Allocation Units (Bytes). The string "Bytes" has gone:
snmptable-dev-31
To use these values, we define a CDEF:
snmptable-cdef-01
Notice, that with recent releases of cacti, it is possible to use |query_*| values within CDEFs. Finally, goto Graph Templates and use this CDEF with all Graph Items:
snmptable-gt-10
Change the Base Value to 1024 for Bytes -> kBytes and the y-axis description to Bytes:
snmptable-gt-11
Now the Graph looks like
snmptable-graph-10
Please find the resources attached. Due to upload limitations, I had to rename them to *.txt. Please save them as pure *.xml files. Save hrStorageTable.xml into ./resource/snmp/queries and import all templates from cacti_graph_template_host_mib_hrstoragetable.xml.
| Attachment | Size |
|---|---|
| cacti_graph_template_host_mib_hrstoragetable.xml_.txt | 14.82 KB |
| hrStorageTable.xml_.txt | 1.25 KB |





