major changes in branchTwo

This commit is contained in:
Wolfgang Hottgenroth 2018-06-28 16:01:22 +02:00
parent 29208faaec
commit 46057cac31
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
2 changed files with 41 additions and 16 deletions

View File

@ -1,23 +1,32 @@
define(`TITLE', `Something completely different: SNMP to MySQL')
define(`DATE', `2015-10-12')
define(`CONTENT', `
<!-- { "title", "Something completely different: SNMP to MySQL" } -->
<h1>#title#</h1>
<p>
I'm helping to maintain a fleet of about 50 printers in a charity distributed over about 30 locations in the city. Now, we wanted to know how much the individual printers are used to get some numbers for an effort to reduce the number of printers.
</p>
<p>
So, what is more self-evident then using SNMP to query the total page counter on a daily base - or better on an hourly base since the printers are switched off at this or that time and those we at least get sometimes valid data.
</p>
<p>
Typical monitoring tools like Cacti or Zabbix are very good in drawing nice graphs but not so good in delivering absolute numbers. So I decided to write something on my own: query some devices for some SNMP data points and store the results in a database. Which devices and which data points and which combinations? Everything in the database too.
</p>
<p>
I looked for a SNMP library, first in Python, then in Java - since I'm quite familiar with these languages - but everything I found was rather complicated to use. Then I looked for something in C# and found ''SnmpSharpNet''. Still not that easy to use but easier then what I found in Python or Java.
</p>
<p>
For that reason I started coding the little tool in C#. And what I did is working very well now. Configuration and error-handling is not perfect yet, but it is working. Enough for today.
</p>
<p>
BTW: I switched developing the code between Microsoft Visual Studio 2013 (on Windows) and Xamarin Studio (on the Mac) and run the tool on Linux. Works without any problem. Very nice!
<!--more-->
</p>
[code language="csharp"]
<pre>
<code language="csharp">
namespace Snmp2Mysql
{
@ -67,9 +76,11 @@ namespace Snmp2Mysql
}
}
}
[/code]
</code>
</pre>
[code language="SQL"]
<pre>
<code language="SQL">
CREATE TABLE `device_t` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`address` varchar(45) NOT NULL,
@ -107,7 +118,8 @@ CREATE TABLE `collecteddata_t` (
PRIMARY KEY (`id`),
KEY `devicedataitem_fk_idx` (`devicedataitem`),
CONSTRAINT `devicedataitem_fk` FOREIGN KEY (`devicedataitem`) REFERENCES `devicedataitem_t` (`id`)
[/code]
</code>
<pre>
And here are the sources:
@ -116,5 +128,3 @@ And here are the sources:
I'm using GPL code from MySQL (the MySQL Connector for .NET), find it here <a href="http://dev.mysql.com/downloads/connector/net/" target="_blank">http://dev.mysql.com/downloads/connector/net/</a> and the SNMP library from <a href="http://www.snmpsharpnet.com" target="_blank">http://www.snmpsharpnet.com</a>.
Ah, evaluation of the data? Haven't thought about, maybe using some tricky SQL statement or an Excel pivot table. I'll come back about that.
')

View File

@ -1,19 +1,34 @@
define(`TITLE', `Why always SPI CS on pin 10?')
define(`DATE', `2016-03-03')
define(`CONTENT', `
<!--{ "title": "Why always SPI CS on pin 10?" } -->
<h1>#title#</h1>
<p>
Thank you, Ladyada, for <a href="https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2">this great display</a>.
</p>
<p>
But why is TFT CS on pin 10?
</p>
<p>
<a href="http://a385e5.files.wordpress.com/2016/03/bildschirmfoto-2016-03-03-um-21-48-49.png" rel="attachment wp-att-711"><img src="http://a385e5.files.wordpress.com/2016/03/bildschirmfoto-2016-03-03-um-21-48-49.png" alt="Bildschirmfoto 2016-03-03 um 21.48.49" width="722" height="449" class="alignnone size-full wp-image-711" /></a>
</p>
<p>
Pin 10 is also the SPI CS for the Ethernet shield. Why not, for instance, pin 6:
</p>
<p>
<a href="http://a385e5.files.wordpress.com/2016/03/img_1211-e1457038834523.jpg" rel="attachment wp-att-712"><img src="http://a385e-5.de/wp-content/uploads/IMG_1211-e1457038834523-1024x768.jpg" alt="IMG_1211" width="474" height="356" class="alignnone size-large wp-image-712" /></a>
</p>
<p>
Carefully lift pin 9 of the level shifter and connect it using a thin wire with pin 6 of the Arduino connector.
</p>
<p>
And voila, both the display and the ethernet shield is working:
</p>
<p>
<a href="http://a385e5.files.wordpress.com/2016/03/img_1212-e1457039094609.jpg" rel="attachment wp-att-713"><img src="http://a385e-5.de/wp-content/uploads/IMG_1212-e1457039094609-1024x768.jpg" alt="IMG_1212" width="474" height="356" class="alignnone size-large wp-image-713" /></a>
')
</p>