Edit custom graphs directly

Dear CMK-Support,

We need to configure hundreds of custom graphs for File System’s storage devices and would like to know if this can be done using scripting.

Is it possile to edit direclty the custom graphs config files? Where are they stored?

Thanks in advance

1 Like

Looks like many struggeling with this task :wink:
Similiar Task/Problem here: Interface 95 Percentile

Even nicer, more beneficial and more CMK Style would be the following option:

tagging those services and then go into custom graphing and create a template/rule for all services matching this tag.
Even based on any other filter we are using in CMK

1 Like

Thank you! Can you create something like a tutorial for the idea?

@hhpetrov
Its not available that function, apparently. Just an Idea how it would be useful for many CMK Users.

Hi,

Thanks for reply.

Sorry, I’m little bit lost, ¿is it possible to use tags in the graph designer? I dont see it, or ¿do you mean to create custom template/rule to achieve this?

Thanks

no its not available apparently - was just a suggestion how it could be implemented.
Definitely there is a need for this and super usefull in daily business, especially if there is the need to analyse problems or create special graphs for dashboards and other needs

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>