Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
projects:telegraph [2017/01/12 22:44] 127.0.0.1 external edit |
projects:telegraph [2018/11/11 20:34] darron [Reporting] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Telegraph | + | ==== Telegraph ==== |
<wrap right> | <wrap right> | ||
{{: | {{: | ||
</ | </ | ||
- | Telegraph is a project | + | Telegraph is a multi-purpose tool which provides sensor probes, data gathering, web graphing |
- | server | + | |
- | A number of external SNMP daemon | + | For sensors, Telegraph provides a number of external |
- | to capture values | + | |
- | An example | + | Telegraph can also use ICMP to measure network latency when gathering data. For SNMP polling, Telegraph also supports network interface names which are mapped when querying. |
- | graphs like this one shown here. | + | |
+ | Telegraph is run from CRON at regular 5 minute intervals for data gathering and the probes are configured within the net-snmp config. Although the probes are designed for the Raspberry Pi, the gathering host need only run Linux. | ||
+ | |||
+ | PHP scripts demonstrate | ||
+ | |||
+ | Telegraph can also report via e-mail, XMPP, or HTTP POST when either a target is offline or a retrieved value falls outside a specified range. | ||
=== Install === | === Install === | ||
+ | |||
+ | First install mercurial to download telegraph. | ||
< | < | ||
+ | sudo apt-get install mercurial | ||
hg clone http:// | hg clone http:// | ||
cd telegraph | cd telegraph | ||
</ | </ | ||
- | At this time you must read the file named README in the telegraph directory. | + | Now view the instructions found in the README |
- | This file explains the installation | + | |
+ | === Sensor probes === | ||
+ | |||
+ | For the SNMP (simple network management protocol) daemon, Telegraph supplies the following sensor probe processes which may be used. | ||
+ | |||
+ | ^ Process ^ Use ^ | ||
+ | | ads1115 | ||
+ | | bh1750fvi | Illuminance | | ||
+ | | bme280 | ||
+ | | bmp180 | ||
+ | | bmp280 | ||
+ | | dht11 | Humidity + temperature | | ||
+ | | ds18b20 | ||
+ | | ds3231 | ||
+ | | lm75 | Temperature | | ||
+ | | mcp3008 | ||
+ | | pcf8591 | ||
+ | | si7021 | ||
+ | | soc | Temperature | | ||
+ | | tc74 | Temperature | | ||
+ | | tm7705 | ||
+ | | tsl2561 | ||
+ | |||
+ | Analog to digital conversion devices all provide the following features. | ||
+ | |||
+ | ^ Name ^ Use ^ Schematic ^ | ||
+ | | RAW DATA | Device specific value | | | ||
+ | | LEVEL | Value scaled 0..1 | | | ||
+ | | SCALE LEVEL| value scaled 0..N | | | ||
+ | | RESISTANCE | Resistance calculation | ||
+ | | VOLTAGE | ||
+ | | LM19 | Temperature | ||
+ | | LM35 | Temperature | ||
+ | | LM335 | Temperature | ||
+ | | MCP9700 | ||
+ | | MCP9701 | ||
+ | | TMP36 | Temperature | ||
+ | | LDR | Light calculation | ||
+ | | NTC | Temperature calculation |VCC - R - LEVEL - NTC - GND| | ||
+ | |||
+ | Each probe has a set of command line arguments specific to that probe type. | ||
- | Telegraph may be installed once all requirements are met, with | ||
< | < | ||
- | make | + | $ bmp180 |
- | make install | + | USAGE: bmp180 I2C-DEV I2C-ADDR MODE |
+ | Program to query the BMP180. | ||
+ | |||
+ | Error: missing arg(s). | ||
+ | |||
+ | MODE: | ||
+ | 0 TEMPERATURE | ||
+ | 2 PRESSURE | ||
+ | |||
+ | VERSION: | ||
+ | 1.0 | ||
+ | U | ||
</ | </ | ||
- | === SNMPD (snmpd.conf) === | + | I2C-DEV represents the device node of the i2c bus the device is on. The I2C-ADDR is the bus address. MODE determines what type of reading is required. |
- | SNMPD is set up to return a value when probed for the CPU temperature on a Raspberry Pi. | + | In operation it can look like this: |
+ | < | ||
+ | $ bmp280 /dev/i2c-1 0x76 0 | ||
+ | 20.741 | ||
+ | |||
+ | $ bmp280 /dev/i2c-1 0x76 2 | ||
+ | 1003.037 | ||
+ | |||
+ | $ bmp280 /dev/i2c-1 0x76 1 | ||
+ | U | ||
+ | </ | ||
+ | |||
+ | In the first two instances, temperature and pressure are retrieved, in the last case U is returned which represents UNKNOWN since this device doesn' | ||
+ | |||
+ | For analog to digital conversion, all levels and calculations are referenced to the 3V3 supply voltage. For example, the VOLTAGE calculation simply takes the LEVEL value and multiplies it by 3.3. | ||
+ | |||
+ | For the light calculation (lux) the following formula is used. | ||
+ | < | ||
+ | log(lux) = (log(ldr) - intercept) / slope | ||
+ | </ | ||
+ | |||
+ | The slope and intercept are device dependant and this may be calculated using the Telegraph ' | ||
+ | |||
+ | The NTC calculation uses this formula. | ||
+ | < | ||
+ | 1/T = 1/To + 1/B . ln(R/Ro) | ||
+ | </ | ||
+ | |||
+ | B is known as the NTC B25 value and Ro is R25 on the datasheet for the device. R is the known resistance of the device at the current temperature and the B25/R25 values are representative of room temperature at 25'C. | ||
+ | |||
+ | === SNMP === | ||
+ | |||
+ | The SNMP configuration uses the net-snmp extend feature to configure SNMPD to return values when probed. The extend feature | ||
+ | allows an arbitrary process to report a text string which is returned to the client. For RRD and Telegraph, this value is | ||
+ | text string representing a numerical value, else U which means UKNOWN. | ||
+ | |||
+ | / | ||
< | < | ||
rocommunity public X.X.X.X/24 | rocommunity public X.X.X.X/24 | ||
Line 38: | Line 130: | ||
</ | </ | ||
- | === Telegraph (cpu.xml) | + | In this simple example, a net-snmp extend is set to return the CPU temperature when queried. |
+ | |||
+ | After changing the snmp config it must be restart for the new setting to take efect. | ||
+ | |||
+ | < | ||
+ | / | ||
+ | </ | ||
+ | === Data gathering | ||
This configuration file sets up a query for the above cpu temperature in snmpd.conf. | This configuration file sets up a query for the above cpu temperature in snmpd.conf. | ||
+ | / | ||
< | < | ||
<?xml version=" | <?xml version=" | ||
- | < | + | < |
- | < | + | < |
- | | + | < |
- | </ | + | < |
</ | </ | ||
</ | </ | ||
+ | |||
+ | The title is used by both graphing and reporting. For graphing it will appear at | ||
+ | the head of a graph and with reporting it will be the subject of the report. | ||
+ | |||
+ | The rrd file is where data is stored, by default this will be in / | ||
+ | but a path may be specified if required. | ||
+ | |||
+ | Multiple queries may be entered, starting at source 0 and incrementing by one for | ||
+ | each new query. | ||
+ | |||
+ | Only similar data types can exist in one configuration file, for example, only | ||
+ | temperature or only network activity. Data types cannot be mixed and demand | ||
+ | separate configurations and databases. | ||
+ | |||
+ | If an RRD file exists and a new query is added, it will not work and a new column | ||
+ | must be added to the RRD file beforehand. | ||
+ | |||
+ | Telegraph supplies a command line tool ' | ||
+ | to allow new sources to be added easily to an already existing RRD file. | ||
+ | |||
+ | |||
+ | |||
+ | |||
=== CRON === | === CRON === | ||
- | A CRON job will run every 5 minutes to update the RRD. | + | CRON |
< | < | ||
- | */5 * * * * / | + | */5 * * * * / |
</ | </ | ||
+ | This cron job will fetch values and store them in the database as configured by cpu.xml | ||
+ | |||
+ | The -d option is a delay value, it can be used to delay the process from cron | ||
+ | when multiple telegraph processes are executed in parallel to stagger their | ||
+ | processing and potential load on the system or target systems. | ||
+ | |||
+ | < | ||
+ | */5 * * * * / | ||
+ | */5 * * * * / | ||
+ | </ | ||
=== World wide web === | === World wide web === | ||
- | Example | + | Example |
- | demonstrate | + | with PHP scripts that are installed in / |
- | stored within | + | |
+ | The london demo can be seen [[http:// | ||
+ | graphs may be slightly dated. | ||
+ | |||
+ | The demo has been designed to work with apache2 but nginx will also work well. | ||
+ | |||
+ | === Reporting === | ||
+ | |||
+ | Telegraph can report problems it finds when gathering data or when a returned value is out of range. | ||
+ | |||
+ | Problem reports are of two types, DOWN and UP, which signify if a source was not available or available to be queried. This could mean that the SNMP service was offline, or that ICMP PING could not reach a host. | ||
+ | |||
+ | A DOWN report will occur when a problem is found, and an UP when the problem is resolved. Whilst a service continues | ||
+ | |||
+ | Range reports occur when a value goes below or equal to a preset LOW value or becomes equal to or rises above an preset HIGH value in the configuration. This could be used to send reports when temperature goes too low or rises too high, for example. Range reports only work with both LOW and HIGH values | ||
+ | |||
+ | Three types of report delivery exist, e-mail, XMPP and HTTP POST. | ||
+ | |||
+ | E-mail reporting requires sendmail or equivalent to be installed and XMPP demands a valid jabber/xmpp account to use as a sender. HTTP POST is set up to work with the RUN/STOP watchdog service at [[https:// | ||
+ | |||
+ | The Telegraph XML configuration file is updated for reporting. | ||
+ | |||
+ | < | ||
+ | <monitor host=" | ||
+ | <report type=" | ||
+ | <report type=" | ||
+ | <report type=" | ||
+ | </ | ||
+ | |||
+ | The monitor line sets up an SQL database file used to monitor query state (UP, DOWM, LOW and HIGH). | ||
+ | |||
+ | The three report lines demonstrate sending reports. The first is e-mail, the second sends a jabber message to the destination using credentials found in | ||
+ | the file / | ||
+ | |||
+ | The content of a report contains 1 or more lines in CSV format. | ||
+ | |||
+ | Here is an ICMP report of hosts which do not respond to ICMP PING. | ||
+ | < | ||
+ | "Pi2 AR9271", | ||
+ | "Pi4 BCM43143", | ||
+ | "PiC AR9287", | ||
+ | "PiE RTL8191SU", | ||
+ | </ | ||
+ | |||
+ | The columns are name, host, query type, status, value. For ICMP value will be 0 or 1. | ||
+ | |||
+ | This is a range report. | ||
+ | < | ||
+ | "Pi7 DS18B20 room", 192.168.0.167, | ||
+ | </ | ||
+ | |||
+ | This report show that a HIGH level of 20 has been reached by a temperature probe. | ||
+ | |||
+ | |||
+ | === Other tools === | ||
+ | |||
+ | If you want to use the telegraph probes with SNMP but not use Telegraph to gather data then you can use the Telegraph ' | ||
+ | |||
+ | For example, for the following SNMP configuration. | ||
+ | |||
+ | < | ||
+ | extend cpu / | ||
+ | </ | ||
+ | |||
+ | The MIB can be determined with extend. | ||
+ | |||
+ | < | ||
+ | $ extend cpu | ||
+ | 1.3.6.1.4.1.8072.1.3.2.3.1.1.3.99.112.117 | ||
+ | </ | ||
+ | |||
+ | Test it somewhat like this. | ||
+ | |||
+ | < | ||
+ | $ snmpget -v2c -c public X.X.X.X 1.3.6.1.4.1.8072.1.3.2.3.1.1.3.99.112.117 | ||
+ | NET-SNMP-EXTEND-MIB:: | ||
+ | </ | ||
- | The demo can be seen [[http:// | + | How you use the MIB in other tools is of course, tool specific. |