collectd
yum -y install perl-ExtUtils-Embed perl-ExtUtils-MakeMaker liboping*
# wget https://collectd.org/files/collectd-5.5.0.tar.gz
wget http://ops:123123 @soft2.ops .ac .cn :78 /collectd/collectd-5.5 .0 .tar .gz
tar xf collectd-5.5 .0 .tar .gz
cd collectd-5.5 .0
./configure --enable-cpu --enable-df --enable-disk --enable-interface --enable-load --enable-memory --enable-ping --enable-swap --enable-users --enable-uptime --enable-conntrack --enable-contextswitch --enable-tcpconns
make
cp contrib/redhat/init.d -collectd /etc/rc.d /init.d /collectd
chmod +x /etc/rc.d /init.d /collectd
ln -s /opt/collectd/sbin/collectdmon /usr/sbin/
ln -s /opt/collectd/sbin/collectd /usr/sbin/
collectd 配置
vim /etc/collectd.conf
BaseDir "/opt/collectd"
PIDFile "/run/collectd.pid"
Hostname "192.168.126.17"
Interval 60
<loadplugin df>
Interval 120
</loadplugin>
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin processes
LoadPlugin users
<plugin interface>
Interface "eth1"
IgnoreSelected false
</plugin>
<plugin network>
Server "127.0.0.1" "25826"
</plugin>
influxdb
cat <<EOF | sudo tee /etc/yum.repos .d /influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata .com /rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata .com /influxdb.key
EOF
yum -y install influxdb
service influxdb start
启动后TCP端口:8083 为InfluxDB 管理控制台
TCP端口:8086 为客户端和InfluxDB通信时的HTTP API
启动后InfluxDB用户认证默认是关闭的,先创建用户:geekwolf geekwolf
命令行输入influx
基本使用
# 使用influxdb进入命令行
create database collectdb
show databases
show users
create user ops with password '123123'
grant all privileges on collectdb to ops
CREATE USER test WITH PASSWORD 'password' WITH ALL PRIVILEGES
CREATE USER "admin" WITH PASSWORD 'verysecret' WITH ALL PRIVILEGES
开启验证
修改配置文件启用认证
sed -i ’s#auth -enabled = false #auth -enabled = true #g ’ /etc/influxdb/influxdb. conf
service influxdb restart
influxdb开启对collectd的支持
[[collectd]]
enabled = true
bind-address = "0.0.0.0:25826"
database = "collectdb"
typesdb = "/opt/collectd/share/collectd/types.db"
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0 in
其他
collectd插件描述
collectd plugins:
--enable-all-plugins enable all plugins (auto by def )
--enable-aggregation Aggregation plugin
--enable-amqp AMQP output plugin
--enable-apache Apache httpd statistics
--enable-apcups Statistics of UPSes by APC
--enable-apple_sensors Apple 's hardware sensors
--enable-aquaero Aquaero 's hardware sensors
--enable-ascent AscentEmu player statistics
--enable-barometer Barometer sensor on I2C
--enable-battery Battery statistics
--enable-bind ISC Bind nameserver statistics
--enable-ceph Ceph daemon statistics
--enable-conntrack nf_conntrack statistics
--enable-contextswitch context switch statistics
--enable-cpufreq CPU frequency statistics
--enable-cpu CPU usage statistics
--enable-csv CSV output plugin
--enable-curl CURL generic web statistics
--enable-curl_json CouchDB statistics
--enable-curl_xml CURL generic xml statistics
--enable-cgroups CGroups CPU usage accounting
--enable-dbi General database statistics
--enable-df Filesystem usage statistics
--enable-disk Disk usage statistics
--enable-drbd DRBD statistics
--enable-dns DNS traffic analysis
--enable-email EMail statistics
--enable-entropy Entropy statistics
--enable-ethstat Stats from NIC driver
--enable-exec Execution of external programs
--enable-fhcount File handles statistics
--enable-filecount Count files in directories
--enable-fscache fscache statistics
--enable-gmond Ganglia plugin
--enable-hddtemp Query hddtempd
--enable-interface Interface traffic statistics
--enable-ipc IPC statistics
--enable-ipmi IPMI sensor statistics
--enable-iptables IPTables rule counters
--enable-ipvs IPVS connection statistics
--enable-irq IRQ statistics
--enable-java Embed the Java Virtual Machine
--enable-load System load
--enable-logfile File logging plugin
--enable-log_logstash Logstash json_event compatible logging
--enable-lpar AIX logical partitions statistics
--enable-lvm LVM statistics
--enable-madwifi Madwifi wireless statistics
--enable-match_empty_counter
The empty counter match
--enable-match_hashed The hashed match
--enable-match_regex The regex match
--enable-match_timediff The timediff match
--enable-match_value The value match
--enable-mbmon Query mbmond
--enable-md md (Linux software RAID ) devices
--enable-memcachec memcachec statistics
--enable-memcached memcached statistics
--enable-memory Memory usage
--enable-mic Intel Many Integrated Core stats
--enable-modbus Modbus plugin
--enable-multimeter Read multimeter values
--enable-mysql MySQL statistics
--enable-netapp NetApp plugin
--enable-netlink Enhanced Linux network statistics
--enable-network Network communication plugin
--enable-nfs NFS statistics
--enable-nginx nginx statistics
--enable-notify_desktop Desktop notifications
--enable-notify_email Email notifier
--enable-ntpd NTPd statistics
--enable-numa NUMA virtual memory statistics
--enable-nut Network UPS tools statistics
--enable-olsrd olsrd statistics
--enable-onewire OneWire sensor statistics
--enable-openldap OpenLDAP statistics
--enable-openvpn OpenVPN client statistics
--enable-oracle Oracle plugin
--enable-perl Embed a Perl interpreter
--enable-pf BSD packet filter (PF ) statistics
--enable-pinba Pinba statistics
--enable-ping Network latency statistics
--enable-postgresql PostgreSQL database statistics
--enable-powerdns PowerDNS statistics
--enable-processes Process statistics
--enable-protocols Protocol (IP , TCP , ...) statistics
--enable-python Embed a Python interpreter
--enable-redis Redis plugin
--enable-routeros RouterOS plugin
--enable-rrdcached RRDTool output plugin
--enable-rrdtool RRDTool output plugin
--enable-sensors lm_sensors statistics
--enable-serial serial port traffic
--enable-sigrok sigrok acquisition sources
--enable-smart SMART statistics
--enable-snmp SNMP querying plugin
--enable-statsd StatsD plugin
--enable-swap Swap usage statistics
--enable-syslog Syslog logging plugin
--enable-table Parsing of tabular data
--enable-tail Parsing of logfiles
--enable-tail_csv Parsing of CSV files
--enable-tape Tape drive statistics
--enable-target_notification
The notification target
--enable-target_replace The replace target
--enable-target_scale The scale target
--enable-target_set The set target
--enable-target_v5upgrade
The v5upgrade target
--enable-tcpconns TCP connection statistics
--enable-teamspeak2 TeamSpeak2 server statistics
--enable-ted Read The Energy Detective values
--enable-thermal Linux ACPI thermal zone statistics
--enable-threshold Threshold checking plugin
--enable-tokyotyrant TokyoTyrant database statistics
--enable-turbostat Advanced statistic on Intel cpu states
--enable-unixsock Unixsock communication plugin
--enable-uptime Uptime statistics
--enable-users User statistics
--enable-uuid UUID as hostname plugin
--enable-varnish Varnish cache statistics
--enable-virt Virtual machine statistics
--enable-vmem Virtual memory statistics
--enable-vserver Linux VServer statistics
--enable-wireless Wireless statistics
--enable-write_graphite Graphite / Carbon output plugin
--enable-write_http HTTP output plugin
--enable-write_kafka Kafka output plugin
--enable-write_log Log output plugin
--enable-write_mongodb MongoDB output plugin
--enable-write_redis Redis output plugin
--enable-write_riemann Riemann output plugin
--enable-write_sensu Sensu output plugin
--enable-write_tsdb TSDB output plugin
--enable-xmms XMMS statistics
--enable-zfs_arc ZFS ARC statistics
--enable-zookeeper Zookeeper statistics
collectd默认安装方式后的启动文件
#!/bin/bash
. /etc/init.d/functions
RETVAL=0
ARGS=""
prog="collectdmon"
prefix="/opt/collectd"
service="collectd"
CONFIG=${prefix} /etc/collectd.conf
COLLECTD=${prefix} /sbin/collectd
COLLECTDMONPIDDIR="/var/run"
COLLECTDMONPID="$COLLECTDMONPIDDIR /collectdmon.pid"
MAXWAIT=30
if [ -r /etc/sysconfig/$service ]; then
. /etc/sysconfig/$service
fi
if [[ ! -d $COLLECTDMONPIDDIR ]]; then
mkdir -p $COLLECTDMONPIDDIR
[ -n "${RUNAS} " ] && chown "${RUNAS} :" "$COLLECTDMONPIDDIR "
fi
check_config () {
if test ! -r "$CONFIG " ; then
return 2
fi
if ! $COLLECTD -t -C "$CONFIG " ; then
return 1
fi
return 0
}
start () {
echo -n $"Starting collectd: "
check_config
rc="$?"
if test "$rc " -ne 0 ; then
RETVAL=6
echo $"not starting due to configuration error"
failure $"not starting $service due to configuration error"
else
daemon --user "${RUNAS:-root} " $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG " $ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service
fi
}
stop () {
echo -n $"Stopping collectd: "
killproc -p $COLLECTDMONPID -d $MAXWAIT $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$service
}
restart () {
check_config
rc="$?"
if test "$rc " -ne 0 ; then
RETVAL=6
echo $"not restarting due to configuration error"
failure $"not restarting $service due to configuration error"
else
stop
start
fi
}
case "$1 " in
start)
start
;;
stop)
stop
;;
status)
status -p $COLLECTDMONPID $prog
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/$service ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $?