YATG::Tutorial - A simple YATG tutorial
This tutorial will teach you how to set up YATG using a very simple configuration.
Although we could use "any" configuration format, let's start with a simple YAML configuration file:
--- yatg: oids: "sysUpTime": [disk] "ifHCInOctets": [ifindex, disk] "ifHCOutOctets": [ifindex, disk] communities: [public] disk_root: '.' dbi_connect: - "dbi:SQLite:database.db" dbi_ip_query: 'select ip from device;'
This configuration file lists a few oids (sysUpTime, ifHCInOctets, ifHCOutOctets), and describes how to store each one (disk).
sysUpTime
ifHCInOctets
ifHCOutOctets
disk
It's important to note that some oids represent scalar values (for instance, sysUpTime), while others represent arrays. For instance, ifHCInOctets may refer to several interfaces in the same machine: ifHCInOctets.0, ifHCInOctets.1, and so on.
ifHCInOctets.0
ifHCInOctets.1
You should hint YATG about these indexed interfaces, with the keyword ifindex.
ifindex
This is a list of community strings recognized by the monitored networks. In our case we'll use the default "public" community string.
This configuration item specifies the root of the "disk" storage. By default it is /var/lib/yatg, but we'll use the current directory ('.') instead.
/var/lib/yatg
.
YATG uses an external database to store a list of IPs. By default it uses NetDisco schema; but NetDisco requires additional setup and configuration, so we'll use a simpler SQLite database, consisting of a single table.
YATG uses a database to store the list of IPs it will monitor. We'll use the following script to create such a database, using SQLite:
CREATE TABLE device ( id INTEGER AUTO_INCREMENT PRIMARY KEY, ip VARCHAR(15) ); INSERT INTO device (id, ip) VALUES (1, '127.0.0.1');
Save this file as "database.sql" and create the database with the command:
sqlite3 database.db < database.sql
If no problems occur, you can start YATG.
By now, you should have the following files in your working directory:
config.yaml # configuration file database.sql # sql schema database.db # database file
Just execute yatg_updater, using the configuration file as parameter:
yatg_updater config.yaml
YATG will store the information gathered via SNMP in a sub-directory called 127.0.0.1.
127.0.0.1
The "disk" storage requires Tie::File::FixedRecLen. Make sure you have this module installed.
Nelson Ferraz <nferraz@gmail.com>
<nferraz@gmail.com>
Thanks to Oliver Gorwits who created YATG.
Copyright (c) 2007 Nelson Ferraz. All Rights Reserved.
This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself.
To install YATG::Config, copy and paste the appropriate command in to your terminal.
cpanm
cpanm YATG::Config
CPAN shell
perl -MCPAN -e shell install YATG::Config
For more information on module installation, please visit the detailed CPAN module installation guide.