EMC CLARiiON Monitoring – Adding TCP port variable

Modified check_emc_clariion.pl script to specify a different (variable) TCP port for EMC CLARiiON monitoring via Nagios, Cacti, or otherwise.


I’ve been using the check_emc_clariion.pl script for a while to monitor an EMC CLARiiON SAN, but recent issues made me realize the need to use the same check for another host. The problem is the hosts are behind a firewall and using port forwarding – fine for one host on the default port (17894), but I needed to specify a different TCP port to use for the new host.

I updated the check_emc_clariion.pl script to include a TCP port variable, for use like so:

root@host:~#/usr/lib/nagios/plugins/check_emc_clariion.pl -H -u user -p password -t faults --warn 50 --crit 70 --tcp_port=17895
The array is operating normally.

Here is a diff of the original script and my changes:

< $opt_tcp_port 214,217d212 < my $opt_tcp_port = ''; < < ### set tcp port < $opt_tcp_port=17894; 272,273c267 < 'paths=s' => $opt_pathcount,
< 'tcp_port=s' => $opt_tcp_port
> 'paths=s' => $opt_pathcount
< open( NAVICLIOUT, "$NAVICLI_CMD -h $opt_host -Port $opt_tcp_port Faults -list |" ); --- > open( NAVICLIOUT, "$NAVICLI_CMD -h $opt_host -Port 17894 Faults -list |" );

EMC CLARiiON - Nagios

EMC CARiiON - Status Detail

EMC CLARiiON - Cacti graph


Android Apps

Updated list available at https://techpain.com/android-apps-march2017/

My favorite System and Network related Android apps. At the time of this post they are all free and none of them require a rooted device.

  • Mocha VNC Lite: Mocha VNC provides access to VNC Servers. Windows and Mac OS X compatible.
  • uNagi: A Nagios and Incinga client. My favorite features: Allows connections over https, acknowledge notifications, view service and host problems, no additional Nagios plugins required.
  • 2Xclient: An easy to use RDP client.
  • OpenVPN Connect: VPN client for the OpenVPN Access Server, Private Tunnel and OpenVPN Community.
  • Lookout Security & Antivirus: Protection against malware and viruses.
  • FoxFi: Wifi tethering without a rooted device.
  • Fing – Network Tools: Network discover, ping, traceroute, DNS lookup, port scan, and more.
  • Glympse: Not necessarily an app for just tech types, but great for letting people know where you are and when you’ll get to your destination.
  • Quickoffice: View and edit Word, Excel, and PowerPoint files, view PDF’s.
  • Wifi Analyzer: Show information about wifi networks; Channels, stength, and more.
  • WordPress: Easily, write, edit, and publish WordPress posts on WordPress.com AND self-hosted WordPress sites.
  • OpenSignal: Locate better cellular coverage or wi-fi, report dropped calls, and much more.
  • Speedtest.net: Ookla speedtest shows upload and download speeds, as well as ping times.
  • Name.com for Android: Name.com is one of the best registrars out there. This app allows you to manage your Name.com registered domains, including renewal and DNS management. Check domain name availability, register new domain names, and search for domain names based on your geographical location.
  • Servers Ultimate: Turn your Android phone in to a multipurpose server.
  • AndFTP: FTP client that manages multiple FTP connections
  • AirDroid: Connect to your Android phone from your computer to manages SMS and more – with no wires.

MSSQL Query from Linux- FreeTDS for Nagios Monitoring

FreeTDS for MSSQL queries from Linux

Using FreeTDS

Need to monitor a MSSQL server instance from Nagios? You can use FreeTDS to execute a MSSQL query from a Linux box.

Here’s how:

  1. Install FreeTDS:
    yum install freetds
  2. Configure FreeTDS (vi /usr/local/etc/freetds.conf):

    host =
    port = 1433
    tds version = 8.0
  3. Configure ODBC driver for FreeTDS (/etc/odbcinst.ini):

    # Define where to find the driver for the Free TDS connections.
    Description = MS SQL database access with Free TDS
    Driver = /usr/lib/libtdsodbc.so
    Setup = /usr/lib/libtdsS.so
    UsageCount = 1
  4. Test connectivity:

    [root@techpain]# tsql -H servername -p 1433 -U dbuser -P dbpass
    locale is "en_US.UTF-8"
    locale charset is "UTF-8"
    using default charset "UTF-8"
    1> select field11 from column1 where field1 like '10%'
    2> GO
    (7 rows affected)
    1> quit

Nagios MSSQL query

FreeTDS is cool because it allows you to use Nagios to query a MSSQL server using check_mssql command. Here’s how:

Download the check_mssql plugin to the plugins dir on your Nagios server. You can find it at the Nagios Exchange site.

Create command, host, and service definitions for it:

define command {
command_name check_mssql
command_line $USER1$/check_mssql -H hostname -U dbuser -P dbpass -q "select count(*) from column1 where field1 like '10%';" -r "7" -w 8 -c 10

define host {
host_name ServerName
alias MSSQL server
check_command check-host-alive
notification_interval 15
notification_options d,u,r
max_check_attempts 3
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_period 24x7
notification_period 24x7
contact_groups admins

define service {
use generic-service
host_name ServerName
service_description MSSQLquery
check_command check_mssql

In the above example, Nagios executes the query expects a return of 7, warns at 8, and goes crit at 10.


Execute a MSSQL query from DOS prompt – Nagios Monitoring using ‘sqlcmd’

MSSQL - sqlcmd

Using ‘sqlcmd’

You can use sqlcmd to execute a MSSQL query right from the DOS prompt. Here’s an example:

C:Userstechpain>sqlcmd -S servername -d dbname -U dbuser-P dbpass -q "select field1 from column1 where field1 like '10%';"

 (7 rows affected)
1> quit

sqlcmd sytax

-a packet_size
-A (dedicated administrator connection)
-b (terminate batch job if there is an error)
-c batch_terminator
-C (trust the server certificate)
-d db_name
-e (echo input)
-E (use trusted connection)
-f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
-h rows_per_header
-H workstation_name
-i input_file
-I (enable quoted identifiers)
-k[1 | 2] (remove or replace control characters)
-K application_intent
-l login_timeout
-L[c] (list servers, optional clean output)
-m error_level
-M multisubnet_failover
-N (encrypt connection)
-o output_file
-p[1] (print statistics, optional colon format)
-P password
-q "cmdline query"
-Q "cmdline query" (and exit)
-r[0 | 1] (msgs to stderr)
-R (use client regional settings)
-s col_separator
-S [protocol:]server[instance_name][,port]
-t query_timeout
-u (unicode output file)
-U login_id
-v var = "value"
-V error_severity_level
-w column_width
-W (remove trailing spaces)
-x (disable variable substitution)
-X[1] (disable commands, startup script, environment variables and optional exit)
-y variable_length_type_display_width
-Y fixed_length_type_display_width
-z new_password
-Z new_password (and exit)

-? (usage)

For more details on command line options, see http://technet.microsoft.com/

Nagios MSSQL query

The sqlcmd tool is awesome because it allows you to use Nagios and NSclient/nrpe to query a MSSQL server. Here’s how:

  1. Create a .bat on your MSSQL server that contains your query and sends the output to a .txt file
  2. Configure the Windows firewall and NSclient/nrpe check on the MSSQL server
  3. Configure a Windows NSclient/NRPE check in Nagios to check the .txt file
  4. Profit

Monitoring Temperature and Fans with lm_sensors

How to install and configure lm_sensors for temp and fan monitoring

Install the lm_sensors package

sudo yum install lm_sensors or sudo apt install lm-sensors

Configure lm_sensors

Enter ‘YES’ for all prompts
Check what module: cat /etc/sysconfig/lm_sensors
Load the module: modprobe (module name)

Check temperature and fan data

(in Fahrenheit): sensors -f

lm_sensors - techpain.com

lm_sensors Manual Page

Usage: sensors [OPTION]... [CHIP]...
-c, --config-file     Specify a config file (default: /etc/sensors.conf)
-h, --help            Display this help text
-s, --set             Execute `set' statements (root only)
-f, --fahrenheit      Show temperatures in degrees fahrenheit
-A, --no-adapter      Do not show adapter for each chip
-U, --no-unknown      Do not show unknown chips
-u, --unknown         Treat chips as unknown ones (testing only)
-v, --version         Display the program version Use `-' after `-c' to read the config file from stdin.
If no chips are specified, all chip info will be printed.
Example chip names:
lm78-i2c-0-2d   *-i2c-0-2d
lm78-i2c-0-*    *-i2c-0-*
lm78-i2c-*-2d   *-i2c-*-2d
lm78-i2c-*-*    *-i2c-*-*
lm78-isa-0290   *-isa-0290
lm78-isa-*      *-isa-*

Configure monitoring

Write a script to cron or check via Nagios/nrpe. This can be as simple or complex as you like. I like to use something like this since it checks each temp individually, and has a separate threshold for each in a single script:


# By techpain 2012-12-11
# Check temperatures

TEMP1=$(sensors -f | grep -A3 'k8temp-pci-00c3' | grep Core0 | awk '{print $3}' | sed 's/\+//' | sed 's/.\{4\}$//')
TEMP2=$(sensors -f | grep -A3 'k8temp-pci-00c3' | grep Core1 | awk '{print $3}' | sed 's/\+//' | sed 's/.\{4\}$//')
TEMP3=$(sensors -f | grep -A3 'k8temp-pci-00cb' | grep Core0 | awk '{print $3}' | sed 's/\+//' | sed 's/.\{4\}$//')
TEMP4=$(sensors -f | grep -A3 'k8temp-pci-00cb' | grep Core1 | awk '{print $3}' | sed 's/\+//' | sed 's/.\{4\}$//')

if [ $TEMP1 -le 85 ] && [ $TEMP2 -le 75 ] && [ $TEMP3 -le 100 ] && [ $TEMP4 -le 100 ]
echo "OK - $TEMP1,$TEMP2,$TEMP3,$TEMP4 - cool as the other side of the pillow"
exit 0
logger "WARN - $TEMP1,$TEMP2,$TEMP3,$TEMP4 - it's getting hot in here"
echo "WARN - $TEMP1,$TEMP2,$TEMP3,$TEMP4 - it's getting hot in here"
exit 1

lm_sensors monitoring script output - techpain.com


Nagios email – Customize Nagios Notifications

Nagios - Customize your Nagios notifications

Add more info to your Nagios notifications

I finally got tired of getting Nagios notifications that didn’t have all the info I wanted in them. Specifically, I was guessing if the problem had been acknowledged based on the notification interval (how long since I received the last notification), or logging in to Nagios to check.
I decided to customize the Nagios email notifications by editing the # 'host-notify-by-email' command definition, which is the notification type that I’ve been using.

Before, the # 'host-notify-by-email' command definition looked like this:

command[host-notify-by-email]=/bin/echo -e "***** Nagios *****nnHost "$HOSTALIAS$" is $HOSTSTATE$!nn$HOSTADDRESS$nnDate/Time: $DATETIME$n" | /bin/mail -s 'Host $HOSTNAME$ is $HOSTSTATE$!' $CONTACTEMAIL$

which produced a notification that simply included the hostname, the state, and the date/time. I hopped on over to the Nagios Macros page at Sourceforge and grabbed what I wanted, then edited the # 'host-notify-by-email' command definition as follows:

# 'host-notify-by-email' command definition
define command{

     command_name host-notify-by-email
command_line /bin/echo -e "***** Nagios *****nnThis is a $NOTIFICATIONTYPE$ notice that "$HOSTALIAS$" is $HOSTSTATE$!nnHost IP is $HOSTADDRESS$nnDuration is $HOSTDURATION$nnDate/Time: $LONGDATETIME$nnhttp://nagios.mydomain.com/nagios/nnnNagios SummarynTotal Unhandled Host Problems:$TOTALHOSTPROBLEMSUNHANDLED$nTotal Unhandled Service Problems:$TOTALSERVICEPROBLEMSUNHANDLED$" | /bin/mail -s 'Host $HOSTNAME$ is $HOSTSTATE$!' $CONTACTEMAIL$

Now my Nagios email notifications look like this:

***** Nagios *****

This is a PROBLEM notice that DevServer is DOWN!

Host IP is

Duration is 0d 0h 0m 0s

Date/Time: Tue Aug 3 13:19:25 PDT 2010


Nagios Summary
Total Unhandled Host Problems:1
Total Unhandled Service Problems:0

The “This is a PROBLEM notice” part is created by the $NOTIFICATIONTYPE$ macro. This is nice because it tells you what kind of notification it is (“PROBLEM”, “RECOVERY”, “ACKNOWLEDGEMENT”, “FLAPPINGSTART”, “FLAPPINGSTOP”, “FLAPPINGDISABLED”, “DOWNTIMESTART”, “DOWNTIMEEND”, or “DOWNTIMECANCELLED”), which is much more useful than just getting another DOWN notice when a problem is acknowledged.

Check out my other Nagios posts, and please leave a comment if you have another tip or trick on customizing your Nagios notifications.


Cool Nagios Plugins

check_updates – Check updates on RPM based systems

Check updates is a Nagios monitoring system plugin to check if an RPM-based system (Red Hat, Fedora, or CentOS) is up to date.

nagios-check_bl – Check blacklists

nagios-check_bl is a Nagios plugin that checks whether a server is in any known anti-spam block lists.

check_http – Check if a website is up

This plugin will attempt to open an HTTP connection with the host. Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL other errors return STATE_UNKNOWN. Successful connects, but incorrect reponse messages from the host result in STATE_WARNING return values. If you are checking a virtual server that uses ‘host headers’ you must supply the FQDN (fully qualified domain name) as the [host_name] argument.
This plugin can also check whether an SSL enabled web server is able to serve content (optionally within a specified time) or whether the X509 certificate is still valid for the specified number of days.
You can get check_http here.