Nagios Exchange Nagios Exchange
  • Home
  • Directory
  • Library
  • Support
  • About

Advanced Search

Build precise queries to find exactly what you need

Search Logic

Select compatible versions

Press ESC to close

Sign In Sign Up



  • Home
  • Directory
  • Library
  • Support
  • About
Plugins4399Themes and Skins13Add-ons753Documentation283Graphics and Logos36View All Categories
LinuxSecuritySNMPFile SystemCloud
New Listings Recently Updated Listings Most Favored Listings Most Popular Listings Most Rated Listings Most Reviewed Listings
Random Project
Other Tutorials And HOWTOs Checking Power Supplies on SuperMicro Servers with Nagios
0.0 (0)
68.4K
RSS Feed
Newest Listings Updated Listings
Top Contributors
Yoann LAMY (7)Julien DESMAREST (6)deskwork_itunes142 (4)Chad Columbus (4)Davide Lemma (4)
See More
Newest Contributors
smolinux (1)juanfertor (1)zsoltaire (1)RavuAlHemio (1)sowoii (1)
See More

Copyright © 2009-2026 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home > Scott Ward
SW

Scott Ward

@swardks

User Stats

Member Since: September 16, 2017

Favorites0

Views

Projects0

No Projects Found
Meraki - Check Device Status

Command only returns code in file

This article was easy enough to follow. I have the check_meraki_status file added to /usr/local/nagios/libexec with same permissions as all other files, code pasted in file, and configured on two hosts, each with one service check. When executing the check, the information only returns the results of the code minus the first line. Current Status: OK (for 0d 0h 10m 37s) Status Information: // $argv[1] is the MAC Address specified on the host definition file for the device, // if specified run code, otherwise, print error message and exit with "Code 3" = "Unknown" if (isset($argv[1])) { // The Meraki Cloud Controller uses a Decimal format of the MAC Address for its SNMP Queries, // here we are converting the MAC Address (XX:XX:XX:XX:XX:XX) to Decimal (X.X.X.X.X.X.X) $macAddress = HexToDecConverter(':', '.', $argv[1]); // Get the name and status from the Meraki Cloud Controller for device identified by newly converted MAC Address $devStatus = shell_exec('/usr/local/bin/snmpwalk -c "Put Your Meraki Cloud Community String Here" -v2c snmp.meraki.com:16100 1.3.6.1.4.1.29671.1.1.4.1.3.' . $macAddress); $devName = shell_exec('/usr/local/bin/snmpwalk -c "Put Your Meraki Cloud Community String Here" -v2c snmp.meraki.com:16100 1.3.6.1.4.1.29671.1.1.4.1.2.' . $macAddress); // Extract the device name from the snmpwalk result, the returned string will be as follows => STRING: "Device Name" $str = $devName; preg_match('/"(.*?)"/', $str, $match); $devName = $match['1']; switch ($devStatus) { // Perform a search on the snmpwalk result for device status, the returned string will be as follows => INTEGER: X // If "1" is found on the string, print "Device Name is Online" and Exit with "Code 0" = "OK" case (strpos($devStatus, 'INTEGER: 1') !== FALSE): print $devName . ' is Online'; EXIT(0); break; // if "0" is found on the string, print "Device Name is Offline" and Exit with "Code 2" = "Critical" case (strpos($devStatus, 'INTEGER: 0') !== FALSE): print $devName . ' is Offline'; EXIT(2); break; default: } } else { print 'MAC Argument Not Provided'; EXIT(3); } // Function to convert MAC Addresses from Hexadecimal (XX.XX.XX.XX.XX.XX) to Decimal Format (X.X.X.X.X.X), you need to provide // the 2 delimeters and the MAC Address you'd like to convert. // $explodeDelimiter is the delimeter of the original MAC Address, in our case is ":" // $implodeDelimiter is the delimeter we want to print on the new MAC Address, in our case is "." function HexToDecConverter($explodeDelimiter, $implodeDelimiter, $mac) { $macOctects = explode($explodeDelimiter, $mac); foreach ($macOctects as &$octects) { $octects = hexdec($octects); } unset($octects); return join($implodeDelimiter, $macOctects); } Performance Data: Current Attempt: 1/3 (HARD state) Last Check Time: 09-16-2017 16:57:20 Check Type: ACTIVE Check Latency / Duration: 0.000 / 0.009 seconds Next Scheduled Check: 09-16-2017 17:07:20 Last State Change: 09-16-2017 16:51:27 Last Notification: N/A (notification 0) Is This Service Flapping? NO (11.84% state change) In Scheduled Downtime? NO Last Update: 09-16-2017 17:01:57 ( 0d 0h 0m 7s ago) Any idea what is causing this? I reviewed the other files though they were all perl so could not verify syntax for Nagios. Thanks!

Reviewed 8 years ago

No Favorites Found

Copyright © 2009-2026 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home Browse Submit Profile