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.

Nagios

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 192.168.100.10 -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:

195d194
< $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
1056c1050
< 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

Share

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.
Share

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):

    [servername]
    host = 192.168.0.10
    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.
    [freetds]
    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
    field1
    101
    102
    103
    105
    106
    108
    109
    (7 rows affected)
    1> quit
    [root@techpain]#

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
address 192.168.0.10
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.

Share

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%';"
field1
------
100
101
102
105
106
108
109

 (7 rows affected)
1> quit
C:Userstechpain>

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
Share

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

sensors-detect
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-*
lm78-*

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:

#!/bin/bash

# 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 ]
then
echo "OK - $TEMP1,$TEMP2,$TEMP3,$TEMP4 - cool as the other side of the pillow"
exit 0
else
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
fi

lm_sensors monitoring script output - techpain.com

Share

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 192.168.1.100

Duration is 0d 0h 0m 0s

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

http://nagios.mydomain.com/nagios/

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.

Share

Configuring System Alerts in Windows Server 2003

Create an Alert in System Monitor to Track Free Disk Space

1. Click Start, point to Administrative Tools, and then click Performance.
2. Expand Performance Logs and Alerts.
3. Right-click Alerts, and then click New Alert Settings.
4. In the New Alert Settings box, type a name for the new alert (for example, Free disk space), and then click OK.

The AlertName dialog box appears, in which you configure settings for the alert that you created.
5. Click the General tab, and then in the Comment box, type something like Monitors free disk space on C drive.

Windows Alerts - Low Disk Space Alert

Configure the Alert

1. Click Add to open the Add Counters dialog box.
2. Click Select counters from computer, and then select your computer in the list.
3. In the Performance object box, click LogicalDisk.
4. Click Select counters from list, and then click % Free Space.
5. Click Select interfaces from list, and then click the logical drive or volume that you want to monitor.
6. Click Add to add the counter, and then click Close.
7. In the Alert when the value is box, click Under, and then type the value that you want in the Limit box. For example, to trigger an alert message when free disk space is under 9%, type 9.
8. Accept the default value of 5 seconds in the Sample data interval, or specify the value that you want.
9. Click Apply.
10. Click the Action tab, and then specify the action or actions that you want to perform when an alert occurs, as follows:

  •  If you want the Performance Logs and Alerts service to create an entry in the application log of event viewer when an alert occurs, click to select the Log an entry in the application event log check box.
  • If you want the Performance Logs and Alerts service to trigger the Messenger service to send a message, click to select the Send a network message to check box, and then type the IP address or name of the computer on which the alert should be displayed.
  • To run a counter log when an alert occurs, click to select the Start performance data log check box, and then specify the counter log that you want to run.
  • To run a command or program when an alert occurs, click to select the Run this program check box, and then type the file path and name of the program or command that you want to run. Or, click Browse to locate the file.

When an alert occurs, the service creates a process and runs the specified command file. The service also copies any command-line arguments that you define to the command line that is used to run the file. Click Command Line Arguments, and then click to select the appropriate check boxes to include the arguments that you want to implement when the program is run.
11. Click Apply.
12. Click the Schedule tab, and then specify the start and stop parameters for the scan, as follows:
          1. Under Start scan, do one of the following:

  • Click Manually if you want to manually start the scan. After you select this option, right-click the alert in the right pane, and then click Start to start the scan.
    • Click At to start the scan at a specific time and date, and then specify the time and date that you want.

              2. Under Stop scan, do one of the following:

    • Click Manually if you want to manually stop the scan. After you click this option, right-click the alert in the right pane, and then click Stop to stop the scan.
    • Click After to stop the scan after a specified duration, and then specify the time interval that you want.
    • Click At to stop the scan at a specific time and date, and then specify the time and date that you want.

              3. If you want to start a new scan after the alert scan is complete, click After, and then click to select the Start a new scan check box.

    Taken (and then edited) from the Microsoft KB

    Share

    Get DSL statistics from your Cisco modem

    show dsl interface ATM

    An example from cisco.com:

    router# show dsl int atm0
    Alcatel 20150 chipset information

    ATU-R (DS) ATU-C (US)
    Modem Status: Showtime (DMTDSL_SHOWTIME)
    DSL Mode: ITU G.992.1 (G.DMT)
    ITU STD NUM: 0x01 0x1
    Vendor ID: 'ALCB' 'ALCB'
    Vendor Specific: 0x0000 0x0000
    Vendor Country: 0x00 0x0F
    Capacity Used: 85% 98%
    Noise Margin: 13.5 dB 7.0 dB
    Output Power: 9.5 dBm 12.0 dBm
    Attenuation: 1.5 dB 3.5 dB
    Defect Status: None None
    Last Fail Code: None
    Selftest Result: 0x00
    Subfunction: 0x15
    Interrupts: 5940 (0 spurious)
    PHY Access Err: 0
    Activations: 1
    SW Version: 3.670
    FW Version: 0x1A04

    Interleave Fast Interleave Fast
    Speed (kbps): 0 8128 0 864
    Reed-Solomon EC: 0 0 0 0
    CRC Errors: 0 0 0 7
    Header Errors: 0 0 0 2
    Bit Errors: 0 0
    BER Valid sec: 0 0
    BER Invalid sec: 0 0

    DMT Bits Per Bin
    00: 0 0 0 0 0 0 0 7 6 7 9 A B C C C
    10: C C C C C C B B B B A 9 A 9 0 0
    20: 0 0 0 0 0 0 2 2 3 4 4 5 6 6 7 7
    30: 7 8 8 8 9 9 9 A A A A A A B B B
    40: B B B B B B B B B B B A B B B B
    50: B B B B B B B B B B B B 2 B B B
    60: B B B B B B B B B B B B B B B B
    70: B B B B B B B B B B B B B B B B
    80: B B B B B B B B B B B B B B B B
    90: B B B B B B B B B B B B B B B B
    A0: B B B B B B B B B B B B B B B B
    B0: B B B B B B B B B B B B A B A A
    C0: A A A A A A A A A A A A A A A A
    D0: A A A A A A A A A A A 9 9 9 9 9
    E0: 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 8
    F0: 8 8 8 8 8 8 7 7 7 7 6 6 5 5 4 4

    DSL – SNR, Attenuation, and CRC’s (taken from DSLreports.com)

    SN Margin (AKA Signal-to-Noise Margin or Signal-to-Noise Ratio)
    Relative strength of the DSL signal to Noise ratio. 6dB is the lowest dB manufactures specify for modem to be able to sync. In some instances interleaving can help raise the noise margin to an acceptable level. The higher the number the better for this measurement.
    6dB or below is bad and will experience no sync or intermittent sync problems
    7dB-10dB is fair but does not leave much room for variances in conditions
    11dB-20dB is good with no sync problems
    20dB-28dB is excellent
    29dB or above is outstanding

    Line Attenuation
    Measure of how much the signal has degraded between the DSLAM and the modem. Maximum signal loss recommendation is usually about 60dB. The lower the dB the better for this measurement.
    20dB and below is outstanding
    20dB-30dB is excellent
    30dB-40dB is very good
    40dB-50dB is good
    50dB-60dB is poor and may experience connectivity issues
    60dB or above is bad and will experience connectivity issues

    CRC Errors (Cyclic Redundancy Check)
    CRC is a method of detecting errors in data transmission. A high CRC count in itself is not really cause for alarm. However, any increase in CRCs after your initial connection is established is a problem and usually points to a physical issue somewhere.

    thanks again, Chris!

    Share

    Share