I have done this a while ago for all oracle tablespaces in question. I updated the custom graph every night in the case some new tablespaces arrised or have been deleted. The following script isn’t workin anymore but maybe it give some hints to create an own:
IFS=$'\n'
echo -n > $OMD_ROOT/tmp/check_mk/graph
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
{'db_usage_prod': {'elements': [],
'graph_options': {'consolidation_function': None,
'explicit_vertical_range': (None,
None),
'omit_zero_metrics': False,
'unit': 'bytes'},
'metrics': [{'color': '#00ffc6',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_prod | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('rrd',
'$host',
u'$service',
'tablespace_used',
'max'),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'stack',
'title': u'Sum of Used Space',
'visible': True},
{'color': '#f4eee2',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_prod | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('operator',
'-',
[('rrd',
'$host',
u'$service',
'tablespace_size',
'max'),
('rrd',
'$host',
u'$service',
'tablespace_used',
'max')]),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'stack',
'title': u'Sum of Free Space',
'visible': True},
{'color': '#006040',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_prod | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('rrd',
'$host',
u'$service',
'tablespace_size',
'max'),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'line',
'title': u'Sum of Used Space',
'visible': True}],
'name': 'db_usage_prod',
'owner': 'omdadmin',
'public': True,
'title': 'Used space on tablespaces PSAPSR3 Production',
'topic': 'FS'},
'db_usage_test': {'elements': [],
'graph_options': {'consolidation_function': None,
'explicit_vertical_range': (None,
None),
'omit_zero_metrics': False,
'unit': 'bytes'},
'metrics': [{'color': '#00ffc6',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_test | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('rrd',
'$host',
u'$service',
'tablespace_used',
'max'),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'stack',
'title': u'Sum of Used Space',
'visible': True},
{'color': '#f4eee2',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_test | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('operator',
'-',
[('rrd',
'$host',
u'$service',
'tablespace_size',
'max'),
('rrd',
'$host',
u'$service',
'tablespace_used',
'max')]),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'stack',
'title': u'Sum of Free Space',
'visible': True},
{'color': '#006040',
'expression': ('operator',
'+',
[
EOD
for i in `cat $OMD_ROOT/local/bin/query_services_ora_tablespace_test | $OMD_ROOT/bin/lq`
do
host=`echo $i | cut -d';' -f1`
service=`echo $i | cut -d';' -f2`
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
('rrd',
'$host',
u'$service',
'tablespace_size',
'max'),
EOD
done
cat >> $OMD_ROOT/tmp/check_mk/graph << EOD
]),
'line_type': 'line',
'title': u'Sum of Available Space',
'visible': True}],
'name': 'db_usage_test',
'owner': 'omdadmin',
'public': True,
'title': 'Used space on tablespaces PSAPSR3 Test',
'topic': 'FS'}}
EOD
unset IFS
cp $OMD_ROOT/tmp/check_mk/graph $OMD_ROOT/var/check_mk/web/omdadmin/user_custom_graphs.mk
The query service-files look like the following:
GET services
Columns: host_name service_description
Filter: service_description ~~ <TABLESPACE> .*
Filter: host_custom_variables ~~ TAGS <SOME TAG>