{"id":686,"date":"2016-05-16T23:23:48","date_gmt":"2016-05-17T04:23:48","guid":{"rendered":"http:\/\/www.anthonyreinke.com\/?p=686"},"modified":"2016-05-16T23:30:46","modified_gmt":"2016-05-17T04:30:46","slug":"geist-watchdog-15-snmp-and-splunk","status":"publish","type":"post","link":"https:\/\/anthonyreinke.com\/index.php\/2016\/05\/16\/geist-watchdog-15-snmp-and-splunk\/","title":{"rendered":"Geist Watchdog 15, SNMP, and Splunk"},"content":{"rendered":"<p>I have a few of the <a href=\"http:\/\/www.itwatchdogs.com\/temperature-humidity-climate-monitor-watchdog-15poe-p72.html\">Geist Watchdog 15<\/a> devices in my data center. \u00a0They do a good job monitoring, but getting data out of them isn&#8217;t as easy as it could be. \u00a0Their latest firmware does introduce JSON over XML. \u00a0Unfortunately, there is no way to do API calls to return certain time frames. \u00a0You have to download the whole log file. \u00a0Geist heavily uses the SNMP method to pull the information. \u00a0While this is normally ok, but you do need the <a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/geist_bb_mib.zip\">custom MIB file<\/a>\u00a0for the device which makes it a pain. \u00a0I tried multiple ways to have Splunk grab the values from the device, but failed each time. \u00a0With a deadline to produce a dashboard (it was 11pm and we had people visiting the office at 8am), I put my <a href=\"http:\/\/www.google.com\">Google<\/a>, Linux, and <a href=\"https:\/\/www.splunk.com\">Splunk<\/a> skills to a test.<\/p>\n<p>First, let&#8217;s install the SNMP tools.<\/p>\n<p><span style=\"color: #008000;\"># yum install net-snmp net-snmp-devel net-snmp-utils<\/span><\/p>\n<p><span style=\"color: #008000;\"> <span style=\"color: #000000;\">Let&#8217;s check where the default location of the MIBs are. <\/span><\/span><\/p>\n<pre><span style=\"color: #008000;\">\r\n# net-snmp-config --default-mibdirs\r\n<\/span><span style=\"color: #ff0000;\">\/root\/.snmp\/mibs:\/usr\/share\/snmp\/mibs<\/span><\/pre>\n<p>We will want to copy the MIBs to the second location.<\/p>\n<pre><span style=\"color: #008000;\"># cp \/tmp\/geist_bb_mib.mib\u00a0\/usr\/share\/snmp\/mibs\/geist_bb_mib.mib<\/span>\r\n<span style=\"color: #ff00ff;\">(Source location will differ. \u00a0The location \/tmp\/ was where I copied the file to)<\/span><\/pre>\n<p>Referencing the\u00a0<a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/geist_bb_mibsheet.zip\">MIB Worksheet<\/a>, we can find the OID for the items we want. \u00a0In this script I selected:\u00a0internalName,\u00a0internalTemp,\u00a0internalDewPoint,\u00a0internalHumidity,\u00a0tempSensorName,\u00a0tempSensorTemp<\/p>\n<p>Geist does not put the first period for the OID. \u00a0In the worksheet they list\u00a0internalName as\u00a0<span style=\"color: #ff00ff;\">1.3.6.1.4.1.21239.5.1.2.1.3<\/span> where the SNMP call would be to <span style=\"color: #ff00ff;\">.1.3.6.1.4.1.21239.5.1.2.1.3<\/span>. \u00a0We also need to reference the device ID for the OID at the end of the OID. \u00a0The base for the Remote Temperature Sensor is\u00a0<span style=\"color: #ff00ff;\">.1.3.6.1.4.1.21239.5.1.4.1.3<\/span>. \u00a0To call the first Remote Temperature Sensor I would reference\u00a0<span style=\"color: #ff00ff;\">.1.3.6.1.4.1.21239.5.1.4.1.3.1<\/span> and the second Sensor is\u00a0<span style=\"color: #ff00ff;\">.1.3.6.1.4.1.21239.5.1.4.1.3.2<\/span>.<\/p>\n<p>To make the call to the device using SNMP, we will be using the snmpget command.<\/p>\n<pre><span style=\"color: #008000;\"># \/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.3.1<\/span><\/pre>\n<p><span style=\"color: #ff00ff;\">-m all<\/span> = Use all of the MIB files<br \/>\n<span style=\"color: #ff00ff;\">-Ov<\/span> = Print values only<br \/>\n<span style=\"color: #ff00ff;\">-v 2c<\/span> = Use version 2c<br \/>\n<span style=\"color: #ff00ff;\">-c \u00a0public<\/span> = Use the public snmp string<br \/>\n<span style=\"color: #ff00ff;\">10.10.10.10<\/span> = IP address of the Watchdog 15<br \/>\n<span style=\"color: #ff00ff;\">.1.3.6.1.4.1.21239.5.1.4.1.3.1<\/span> =\u00a0tempSensorName for\u00a0Device 1<\/p>\n<pre><span style=\"color: #ff0000;\">STRING:\u00a0ExternalTempSensor1<\/span><\/pre>\n<p>We are almost there. \u00a0Now to clear up the return to only give us the second part of the response.<\/p>\n<pre><span style=\"color: #008000;\"> # \/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.3.1 | awk '{print $2}'\r\n <\/span><span style=\"color: #ff0000;\">ExternalTempSensor1<\/span><\/pre>\n<p>Great, now we are getting just the value. \u00a0Time to tie the field and value together. \u00a0Since the internal name is going to be the same but we are gathering multiple values, I am also adding the _temp so I am able to tell which field I am getting.<\/p>\n<pre><span style=\"color: #008000;\">InternalName01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.3.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">InternalTemp01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.5.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section01=$InternalName01\"_temp,\"$InternalTemp01\r\n echo $Section01\r\n <span style=\"color: #ff0000;\">ExternalTempSensor1_temp,871<\/span>\r\n <\/span><\/pre>\n<p>Almost there, now let&#8217;s add a date\/time stamp.<\/p>\n<pre><span style=\"color: #008000;\">InternalName01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.3.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">InternalTemp01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public\u00a010.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.5.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section01=$InternalName01\"_temp,\"$InternalTemp01\r\n echo -e `date --rfc-3339=seconds`\",\"$Section01\r\n <span style=\"color: #ff0000;\">2016-05-16 22:07:57-05:00,ExternalTempSensor1_temp,871<\/span>\r\n <\/span><\/pre>\n<p>I repeated the section for the different pieces of sensor data I wanted and ended up with a small script.<\/p>\n<pre><span style=\"color: #008000;\">#!\/bin\/bash<\/span>\r\n\r\n<span style=\"color: #008000;\">InternalName01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.3.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">InternalTemp01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.5.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section01=$InternalName01\"_temp,\"$InternalTemp01<\/span>\r\n <span style=\"color: #008000;\">echo -e `date --rfc-3339=seconds`\",\"$Section01<\/span>\r\n\r\n<span style=\"color: #008000;\">InternalDewPoint01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.7.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section02=$InternalName01\"_dewpoint,\"$InternalDewPoint01<\/span>\r\n <span style=\"color: #008000;\">echo -e `date --rfc-3339=seconds`\",\"$Section02<\/span>\r\n\r\n<span style=\"color: #008000;\">InternalHumidity01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.2.1.6.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section03=$InternalName01\"_humidity,\"$InternalHumidity01<\/span>\r\n <span style=\"color: #008000;\">echo -e `date --rfc-3339=seconds`\",\"$Section03<\/span>\r\n\r\n<span style=\"color: #008000;\">RemoteName01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.3.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">RemoteTemp01=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.5.1 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section04=$RemoteName01\"_temp,\"$RemoteTemp01<\/span>\r\n <span style=\"color: #008000;\">echo -e `date --rfc-3339=seconds`\",\"$Section04<\/span>\r\n\r\n<span style=\"color: #008000;\">RemoteName02=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.3.2 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">RemoteTemp02=`\/usr\/bin\/snmpget -m all -Ov -v 2c -c public 10.10.10.10 .1.3.6.1.4.1.21239.5.1.4.1.5.2 | awk '{print $2}'`<\/span>\r\n <span style=\"color: #008000;\">Section05=$RemoteName02\"_temp,\"$RemoteTemp02<\/span>\r\n <span style=\"color: #008000;\">echo -e `date --rfc-3339=seconds`\",\"$Section05<\/span>\r\n\r\n<span style=\"color: #ff0000;\">2016-05-16 22:12:57-05:00,Base_temp,873<\/span>\r\n <span style=\"color: #ff0000;\">2016-05-16 22:12:57-05:00,Base_dewpoint,620<\/span>\r\n <span style=\"color: #ff0000;\">2016-05-16 22:12:57-05:00,Base_humidity,43<\/span>\r\n <span style=\"color: #ff0000;\">2016-05-16 22:12:57-05:00,ExternalSensor1_temp,688<\/span>\r\n <span style=\"color: #ff0000;\">2016-05-16 22:12:57-05:00,ExternalSensor2_temp,717<\/span><\/pre>\n<p>I created a folder \/opt\/scripts\/ and \/opt\/scripts\/logs\/. \u00a0I placed the script in\u00a0\/opt\/scripts\/ and named it geist.sh. \u00a0I set the script to be able to run with:<\/p>\n<pre><span style=\"color: #008000;\"># chmod +x\u00a0\/opt\/scripts\/geist.sh<\/span><\/pre>\n<p>I then add it to the crontab.<\/p>\n<pre><span style=\"color: #008000;\"># crontab -e<\/span><\/pre>\n<p><span style=\"color: #ff00ff;\">*\/1 * * * *\u00a0\/opt\/scripts\/geist.sh &gt;&gt; \/opt\/scripts\/logs\/`date +&#8221;%Y%d%m&#8221;`_geist.log<\/span><\/p>\n<p>You can verify that the script is set to run with:<\/p>\n<p># crontab -l<\/p>\n<pre><span style=\"color: #ff0000;\">*\/1 * * * *\u00a0\/opt\/scripts\/geist.sh &gt;&gt; \/opt\/scripts\/logs\/`date +\"%Y%d%m\"`_geist.log<\/span><\/pre>\n<p>Now we can log in to Splunk and add the log in to Splunk. \u00a0After you log in, go to Settings and then Data inputs.<\/p>\n<p><a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/datainputs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-691 size-full\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/datainputs.png\" alt=\"datainputs\" width=\"606\" height=\"184\" \/><\/a><\/p>\n<p>Under the Files &amp; directories, click the Add new link.<\/p>\n<p><a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/addnew.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-692\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/addnew.png\" alt=\"addnew\" width=\"762\" height=\"70\" \/><\/a><\/p>\n<p>Under the Full path to your data, enter the path to the log file you are writing in the crontab. \u00a0Check the box for the More settings option.<\/p>\n<p><a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/adddata1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-693 aligncenter\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/adddata1.png\" alt=\"adddata1\" width=\"709\" height=\"316\" \/><\/a><\/p>\n<p>You can set the Host that will be indexed with your data. \u00a0In the source type, select From list and then select csv. \u00a0You then can select an index for the log files.<\/p>\n<p><a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/adddata2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-694 aligncenter\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2016\/05\/adddata2.png\" alt=\"adddata2\" width=\"496\" height=\"530\" \/><\/a><\/p>\n<p>Now we will set up the field extractions. \u00a0You will need to edit the props.conf and transforms.conf files. \u00a0If you want to keep this in a certain application, change the file path to <span style=\"color: #ff00ff;\">$SPLUNK_HOME\/etc\/apps\/{appname}\/local\/props.conf<\/span>.<\/p>\n<pre><span style=\"color: #008000;\"># vi $SPLUNK_HOME\/etc\/system\/local\/props.conf<\/span><\/pre>\n<pre><span style=\"color: #ff00ff;\">[csv]<\/span>\r\n<span style=\"color: #ff00ff;\"> REPORT-Geist = REPORT-Geist<\/span>\r\n\r\n<span style=\"color: #008000;\"># vi $SPLUNK_HOME\/etc\/system\/local\/transforms.conf<\/span>\r\n\r\n<span style=\"color: #ff00ff;\">[REPORT-Geist]<\/span>\r\n<span style=\"color: #ff00ff;\"> DELIMS = \",\"<\/span>\r\n<span style=\"color: #ff00ff;\"> FIELDS = \"DateTime\",\"SensorName\",\"SensorValue\"<\/span><\/pre>\n<p>Restart Splunk and you should be able to search you SNMP values.<\/p>\n<pre><span style=\"color: #008000;\"># $SPLUNK_HOME\/bin\/splunk restart<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have a few of the Geist Watchdog 15 devices in my data center. \u00a0They do a good job monitoring, but getting data out of them isn&#8217;t as easy as it could be. \u00a0Their latest firmware does introduce JSON over XML. \u00a0Unfortunately, there is no way to do API calls to return certain time frames. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-686","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/comments?post=686"}],"version-history":[{"count":6,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/686\/revisions"}],"predecessor-version":[{"id":700,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/686\/revisions\/700"}],"wp:attachment":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/media?parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/categories?post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/tags?post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}