Cacti

From Wiki
Jump to: navigation, search

Find host id:

php add_graphs.php --list-hosts | awk '/hostname/ {print $1}'

add a device:

php add_device.php --description=vz021 --ip=vz021.example.com --avail=snmp --template=9 --version=2 --community=community --port=162

Add several devices at once:

#!/bin/bash
while read host; do
    desc=`echo $host | cut -d '.' -f 1`
    php /var/lib/cacti/cli/add_device.php --description=$desc --ip=$host --avail=snmp --template=1 --version=3 --username=snmp_user \
    --password=password --authproto=SHA --privproto=AES128 --privpass=privpass
done < /root/hosts.txt

add graph template to host:

php add_graph_template.php --host-id=$ID --graph-template-id=149

add graph to host:

templates=`php /var/lib/cacti/cli/add_graphs.php --list-graph-templates --host-template-id=1 | awk '/^[0-9][0-9]/ {print $1}'`
for id in $templates; do php add_graphs.php --host-id=<id> --graph-type=cg --graph-template-id=$id; done

Create graphs for multiple hosts:

cd /var/lib/cacti/cli
for hostid in {1..85}; do for id in $templates; do php add_graphs.php --host-id=${hostid} --graph-type=cg --graph-template-id=${id}; done; done

Network graphs:

php add_graphs.php --graph-type=ds --graph-template-id=2 --host-id=ID --snmp-query-id=1 --snmp-query-type-id=14 --snmp-field=ifIndex --snmp-value=2

CPU graphs:

for hostid in {1..85}; do php add_graphs.php --host-id=${hostid} --graph-type=cg --graph-template-id=4; done

Add host to tree:

php add_tree.php --type=node --node-type=host --parent-node=<pnode> --tree-id=<tid>  --host-id=<id>

update graph templates to the same width:

Login to the database.
update graph_templates_graph SET width=620;

Add unbound graphs for node:

for graphid in {111..118}; do php add_graphs.php --host-id=$hostid --graph-type=cg --graph-template-id=$graphid; done

Create mysql user for cacti stats:

GRANT SUPER, PROCESS ON *.* TO 'cactistats'@'1.2.3.4' IDENTIFIED BY "s3cret";