Cacti batch add host Nic script

Source: Internet
Author: User
Tags net snmp snmp

The cacti server deployed by the company is used to monitor network card traffic of all servers and add scripts in batches.

#! /Bin/bash # Add host for cactipath =/var/www/html/cacti/cliphp =/usr/bin/phpdevice = $ path/add_device.phpgraphs = $ path/add_graphs.phptree = $ path /add_tree.phpcommunity_name = xxxxxxcat. /hosts | while read host; dohost_ip = 'echo $ host | awk '{print $1} ''host _ name = 'echo $ host | awk' {print $2} ''#3 UCD/NET SNMP host $ PHP $ device -- Description = "$ host_name" -- IP = "$ host_ip" -- template = 3 -- version = 2 -- community = "$ community_name" host_ids = '$ PHP $ graphs -- list-hosts | grep $ host_ip | awk '{print $1} ''#16 in/out bytes networks = 'snmpwalk-V 2C-C $ community_name $ host_ip ifdesc | awk '{print $6}' | grep ^ ETH [0-9] $ 'for network in $ networks; do $ PHP $ graphs -- Host-id = "$ host_ids" -- Graph-type = DS -- Graph-template-id = 2 -- SNMP-query-id = 1 -- SNMP-Query -type-id = 16 -- SNMP-field = ifdescr -- SNMP-value = "$ network" done $ PHP $ graphs -- Host-id = "$ host_ids" -- Graph-type = DS -- Graph-template-id = 2 -- SNMP-query-id = 1 -- SNMP-query-type-id = 16 -- SNMP-field = ifdescr -- SNMP-value = "Lo "# Add devices to the corresponding group # default tree (built-in) -- tree-id = 1. You need to create a web program and view its tree ID: PHP add_tree.php -- list-trees $ PHP $ tree -- Host-id = "$ host_ids" -- type = node -- node-type = host -- tree-id = 1 done



This article is from the blog of the "Bremen band" and will not be reposted!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.