Code: Select all
#!/bin/bash
usage () {
echo "usage: ./batch_add_graphs.sh -g graphtemplateid -h hosttemplateid"
echo "get graph templates from \"php add_graph_template.php --list-graph-templates\""
echo "get host templates from \"php host_update_template.php --list-host-templates\""
exit 1;
}
if [ -z $1 ]; then usage; fi
while getopts g:h: OPTS; do
case $OPTS in
g) GRAPHTEMPLATEID=${OPTARG};;
h) HOSTTEMPLATEID=${OPTARG};;
*) usage;;
esac
done
HOSTS=$(mysql -ucactiuser -pcactiuser cacti -NBe "select id from host where host_template_id = ${HOSTTEMPLATEID}")
for NEWGRAPHS in $HOSTS; do php -q add_graphs.php --graph-type=cg --host-id=${NEWGRAPHS} --graph-template-id=${GRAPHTEMPLATEID}; done
Code: Select all
# ./batch_add_graphs.sh -g 1034 -h 53
Graph Added - graph-id: (89056) - data-source-ids: (109573)
Graph Added - graph-id: (89057) - data-source-ids: (109574)
Graph Added - graph-id: (89058) - data-source-ids: (109575)
Graph Added - graph-id: (89059) - data-source-ids: (109576)
Graph Added - graph-id: (89060) - data-source-ids: (109577)
Graph Added - graph-id: (89061) - data-source-ids: (109578)
Graph Added - graph-id: (89062) - data-source-ids: (109579)
Graph Added - graph-id: (89063) - data-source-ids: (109580)
Graph Added - graph-id: (89064) - data-source-ids: (109581)
Graph Added - graph-id: (89065) - data-source-ids: (109582)
Graph Added - graph-id: (89066) - data-source-ids: (109583)
Graph Added - graph-id: (89067) - data-source-ids: (109584)
Graph Added - graph-id: (89068) - data-source-ids: (109585)
Graph Added - graph-id: (89069) - data-source-ids: (109586)
Graph Added - graph-id: (89070) - data-source-ids: (109587)
Graph Added - graph-id: (89071) - data-source-ids: (109588)
Graph Added - graph-id: (89072) - data-source-ids: (109589)
Graph Added - graph-id: (89073) - data-source-ids: (109590)
Graph Added - graph-id: (89074) - data-source-ids: (109591)
Graph Added - graph-id: (89075) - data-source-ids: (109592)
Graph Added - graph-id: (89076) - data-source-ids: (109593)
Graph Added - graph-id: (89077) - data-source-ids: (109594)
Graph Added - graph-id: (89078) - data-source-ids: (109595)
Graph Added - graph-id: (89079) - data-source-ids: (109596)
Graph Added - graph-id: (89080) - data-source-ids: (109597)
Graph Added - graph-id: (89081) - data-source-ids: (109598)
Graph Added - graph-id: (89082) - data-source-ids: (109599)
Graph Added - graph-id: (89083) - data-source-ids: (109600)