Page 1 of 3

Check http MD5 question

Posted: Wed May 08, 2013 1:42 pm
by benningtonr
I am trying to implement this into nagios and not quite sure how to proceed.

Any and all help would be greatly appriciated.

https://github.com/AppliedTrust/nagios- ... k_http_md5


#!/usr/bin/php -q
<?php
# ------------------------------------------------------------------
# We offer no warantee or guarantee - use this code at your own risk!
# All code is Copyright (C) 2011, Applied Trust Engineering, Inc.
# ------------------------------------------------------------------

# wget -q -O - http://appliedtrust.com | md5sum

$url = $argv[1];
$md5 = $argv[2]." -";

$status=0;

$md5new = `wget -q -O - "$url" | md5sum`;
$md5new= rtrim($md5new);

if (strcmp($md5new, $md5)==0) {
echo "HTTPMD5sum OK: MD5sum matches\n";
} else {
$status=2;
echo "HTTPMD5sum CRITICAL: MD5sum doesn't match: ".$md5new."\n";
}

exit($status);

Re: Check http MD5 question

Posted: Wed May 08, 2013 2:00 pm
by abrist
You will need to install the plugin to the XI box and create a command for it. See the following documentation:

http://assets.nagios.com/downloads/nagi ... ios_XI.pdf

Re: Check http MD5 question

Posted: Wed May 08, 2013 2:28 pm
by benningtonr
I installed a file i created called check_http_md5.pl, but I get this when I try to test

[root@nagios libexec]# ./check_http_md5.pl
Extension './check_http_md5.pl' not present.
[root@nagios libexec]# ./check_http_md5
-bash: ./check_http_md5: No such file or directory
[root@nagios libexec]# ./check_http_md5 arg1
-bash: ./check_http_md5: No such file or directory
[root@nagios libexec]# ./check_http_md5.pl
Extension './check_http_md5.pl' not present.
[root@nagios libexec]# ./check_http_md5.pl -H
Extension '' not present.
[root@nagios libexec]# ./check_http_md5 -H localhost
-bash: ./check_http_md5: No such file or directory
[root@nagios libexec]#


the file is there when I do an ls on the directory

Re: Check http MD5 question

Posted: Wed May 08, 2013 2:50 pm
by benningtonr
i took the .pl extention off and it is still not seen by the ./
Yes i can see the file is there.


[root@nagios libexec]# ./check_icmp
check_icmp: No hosts to check
[root@nagios libexec]# ./check_http_md5
Extension './check_http_md5' not present.
[root@nagios libexec]#

Re: Check http MD5 question

Posted: Wed May 08, 2013 4:29 pm
by sreinhardt
According the script this should be a php file, so pl would not be applicable, however either .php or no extension should be fine. Please list the directory and return the output so we can check a few things.

Code: Select all

ll /usr/local/nagios/libexec/

Re: Check http MD5 question

Posted: Thu May 09, 2013 8:08 am
by benningtonr

Code: Select all

[root@nagios libexec]# ll /usr/local/nagios/libexec/
total 5060
-rwxr-xr-x. 1 root   root    65068 Aug 29  2011 check_apt
-rwxr-xr-x  1 apache apache   3888 Apr 11 18:15 check_asa_vpn.pl
-rwxr-xr-x. 1 root   root     6897 Aug 29  2011 check_asterisk.pl
-rwxrwxrwx  1 root   root     5728 Aug 20  2012 check_barracuda_mailqueue
-rwxr-xr-x  1 root   root     1821 Jul 25  2012 check_barracuda.ncfg
-rwxr-xr-x  1 apache apache   8551 Dec 18 14:41 check_bgp.0.3.pl
-rwxr-xr-x  1 apache apache   6923 Feb 15 17:07 check_bgp_ipv6.pl
-rwxr-xr-x  1 root   root     8397 Aug 13  2012 check_bgp.pl
-rwxr-xr-x  1 nagios users    4173 Oct 24  2012 check_bl
-rwxr-xr-x  1 nagios users    2289 Oct 24  2012 check_bpi.php
-rwxr-xr-x. 1 root   root     2274 Aug 29  2011 check_breeze
-rwxr-xr-x  1 apache apache   5298 Apr 11 16:23 check_brocade_transceiver.pl
-rwxr-xr-x  1 apache apache  14192 Aug 15  2012 check_cap
-rwxr-xr-x  1 apache apache 153882 Apr 11 18:09 check_chassis_brocade.pl
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_clamd -> check_tcp
-rwxr-xr-x. 1 root   root    40575 Aug 29  2011 check_cluster
-r-sr-xr-x. 1 root   root    73301 Aug 29  2011 check_dhcp
-rwxr-xr-x. 1 root   root    71777 Aug 29  2011 check_dig
-rwxr-xr-x. 1 root   root   101991 Aug 29  2011 check_disk
-rwxr-xr-x. 1 root   root     8163 Aug 29  2011 check_disk_smb
-rwxr-xr-x. 1 root   root    79570 Aug 29  2011 check_dns
-rwxr-xr-x. 1 root   root    36412 Aug 29  2011 check_dummy
-rwxr-xr-x  1 nagios users    5625 Oct 24  2012 check_em01.pl
-rwxr-xr-x  1 nagios users   38345 Oct 24  2012 check_email_delivery
-rwxr-xr-x  1 nagios users   20511 Oct 24  2012 check_email_delivery_epn
-rwxr-xr-x. 1 root   root    20039 Aug 29  2011 check_email_loop.pl
-rwxr-xr-x  1 nagios users   28665 Jul 24  2012 check_emc_clariion.pl
-rwxr-xr-x  1 nagios users   82841 Oct 24  2012 check_esx3.pl
-rwxr-xr-x. 1 root   root     3143 Aug 29  2011 check_file_age
-rwxr-xr-x. 1 root   root     6395 Aug 29  2011 check_flexlm
-rwxr-xr-x. 1 root   root    74960 Aug 29  2011 check_fping
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_ftp -> check_tcp
-rwxr-xr-x  1 nagios users    3437 Oct 24  2012 check_ftp_fully
-rwxr-xr-x. 1 root   root    73830 Aug 29  2011 check_hpjd
-rwxr-xr-x. 1 root   root   171978 Aug 29  2011 check_http
-rwxr-xr-x  1 apache apache    671 May  8 19:45 check_http_md5
-r-sr-xr-x. 1 root   root    80061 Aug 29  2011 check_icmp
-rwxr-xr-x. 1 root   root    47064 Aug 29  2011 check_ide_smart
-rwxr-xr-x. 1 root   root    15310 Aug 29  2011 check_ifoperstatus
-rwxr-xr-x. 1 root   root    12853 Aug 29  2011 check_ifstatus
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_imap -> check_tcp
-rwxr-xr-x  1 nagios users   35413 Oct 24  2012 check_imap_receive
-rwxr-xr-x  1 nagios users   15576 Oct 24  2012 check_imap_receive_epn
-rwxr-xr-x. 1 root   root     7429 Aug 29  2011 check_ircd
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_jabber -> check_tcp
-rwxr-xr-x. 1 root   root    59134 Aug 29  2011 check_ldap
lrwxrwxrwx. 1 root   root       10 Aug 29  2011 check_ldaps -> check_ldap
-rwxr-xr-x. 1 root   root    59194 Aug 29  2011 check_load
-rwxr-xr-x. 1 root   root     6062 Aug 29  2011 check_log
-rwxr-xr-x. 1 root   root    20367 Aug 29  2011 check_mailq
-rwxr-xr-x. 1 root   root    47300 Aug 29  2011 check_mrtg
-rwxr-xr-x. 1 root   root    46703 Aug 29  2011 check_mrtgtraf
-rwxr-xr-x. 1 root   root    12537 Oct 24  2012 check_mssql
-rwxr-xr-x  1 nagios users   13759 Oct 24  2012 check_mssql_database.py
-rwxr-xr-x  1 nagios users   20336 Oct 24  2012 check_mssql_server.py
-rwxr-xr-x. 1 root   root    78008 Aug 29  2011 check_mysql
-rwxr-xr-x. 1 root   root    98711 Aug 29  2011 check_mysql_health
-rwxr-xr-x. 1 root   root    71648 Aug 29  2011 check_mysql_query
-rwxr-xr-x. 1 root   root    59417 Aug 29  2011 check_nagios
-rwxr-xr-x  1 nagios users    6364 Oct 24  2012 check_nagios_performance.php
-rwxr-xr-x  1 nagios users   17400 Oct 24  2012 check_nagiosxiserver.php
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_nntp -> check_tcp
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_nntps -> check_tcp
-rwxrwxr-x. 1 nagios nagios  69216 Aug 29  2011 check_nrpe
-rwxr-xr-x. 1 root   root    74851 Aug 29  2011 check_nt
-rwxr-xr-x. 1 root   root    76550 Aug 29  2011 check_ntp
-rwxr-xr-x. 1 root   root    68987 Aug 29  2011 check_ntp_peer
-rwxr-xr-x. 1 root   root    66180 Aug 29  2011 check_ntp_time
-rwxr-xr-x. 1 root   root   102418 Aug 29  2011 check_nwstat
-rwxr-xr-x. 1 root   root     8366 Aug 29  2011 check_oracle
-rwxr-xr-x. 1 root   root    60153 Aug 29  2011 check_overcr
-rwxr-xr-x. 1 root   root    55894 Aug 29  2011 check_pgsql
-rwxr-xr-x. 1 root   root    80896 Aug 29  2011 check_ping
-rwxr-xr-x  1 nagios nagios   6183 Oct 31  2012 check_pnp_rrds.pl
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_pop -> check_tcp
-rwxr-xr-x. 1 root   root   281655 Oct 24  2012 check_postgres.pl
-rwxr-xr-x. 1 root   root    80817 Aug 29  2011 check_procs
-rwxr-xr-x  1 nagios users   23327 Oct 24  2012 check_radius_adv
-rwxr-xr-x. 1 root   root    57100 Aug 29  2011 check_real
-rwxr-xr-x. 1 root   root     9707 Aug 29  2011 check_rpc
-rwxr-xr-x. 1 root   root     9232 Aug 29  2011 check_rrdtraf
-rwxr-xr-x. 1 root   root     5299 Aug 29  2011 check_rrdtraf.php
-rwxr-xr-x. 1 root   root     1176 Aug 29  2011 check_sensors
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_simap -> check_tcp
-rwxr-xr-x. 1 root   root     7599 Aug 29  2011 check_sip
-rwxr-xr-x. 1 root   root   119329 Aug 29  2011 check_smtp
-rwxr-xr-x  1 nagios users   20226 Oct 24  2012 check_smtp_send
-rwxr-xr-x  1 nagios users   10440 Oct 24  2012 check_smtp_send_epn
-rwxr-xr-x. 1 root   root   119321 Aug 29  2011 check_snmp
-rwxr-xr-x  1 root   root     2969 Jul 25  2012 check_snmp_barracuda
-rwxr-xr-x. 1 root   root    10951 Aug 29  2011 check_snmp_boostedge.pl
-rwxr-xr-x. 1 root   root    17866 Aug 29  2011 check_snmp_cpfw.pl
-rwxr-xr-x. 1 root   root     8747 Aug 29  2011 check_snmp_css_main.pl
-rwxr-xr-x. 1 root   root    16786 Aug 29  2011 check_snmp_css.pl
-rwxr-xr-x  1 apache apache  97676 Feb 19 16:43 check_snmp_environment.pl
-rwxr-xr-x. 1 root   root    33562 Aug 29  2011 check_snmp_env.pl
-rwxr-xr-x  1 nagios users   23464 Oct 24  2012 check_snmp_generic.pl
-rwxr-xr-x. 1 root   root    31919 Aug 29  2011 check_snmp_int.pl
-rwxr-xr-x. 1 root   root    10108 Aug 29  2011 check_snmp_linkproof_nhr.pl
-rwxr-xr-x. 1 root   root    22839 Oct 24  2012 check_snmp_load.pl
-rwxr-xr-x  1 nagios users   22845 Oct 24  2012 check_snmp_load_wizard.pl
-rwxr-xr-x. 1 root   root    18734 Aug 29  2011 check_snmp_mem.pl
-rwxr-xr-x. 1 root   root    11898 Aug 29  2011 check_snmp_nsbox.pl
-rwxr-xr-x. 1 root   root    26182 Oct 24  2012 check_snmp_process.pl
-rwxr-xr-x  1 nagios users   26183 Oct 24  2012 check_snmp_process_wizard.pl
-rwxr-xr-x. 1 root   root    25483 Oct 24  2012 check_snmp_storage.pl
-rwxr-xr-x  1 nagios users   25484 Oct 24  2012 check_snmp_storage_wizard.pl
-rwxr-xr-x. 1 root   root    14489 Aug 29  2011 check_snmp_vrrp.pl
-rwxr-xr-x. 1 root   root    12058 Oct 24  2012 check_snmp_win.pl
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_spop -> check_tcp
-rwxr-xr-x. 1 root   root    54402 Aug 29  2011 check_ssh
-rwxr-xr-x  1 nagios users    8337 Oct 24  2012 check_ssh_expect.pl
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_ssmtp -> check_tcp
-rwxr-xr-x. 1 root   root    61634 Aug 29  2011 check_swap
-rwxr-xr-x. 1 root   root   105714 Aug 29  2011 check_tcp
-rwxr-xr-x. 1 root   root    57050 Aug 29  2011 check_time
lrwxrwxrwx. 1 root   root        9 Aug 29  2011 check_udp -> check_tcp
-rwxr-xr-x. 1 root   root    67522 Aug 29  2011 check_ups
-rwxr-xr-x. 1 root   root    56145 Aug 29  2011 check_users
-rwxr-xr-x  1 nagios users      77 Jul 30  2012 check_vmware_config_vcenter01
-rwxr-xr-x  1 nagios users   59991 Jul 24  2012 check_vmware.pl
-rwxr-xr-x. 1 root   root     3019 Aug 29  2011 check_wave
-rwxr-xr-x. 1 root   root      307 Aug 29  2011 check_webinject.sh
-rwxr-xr-x  1 apache apache    840 May 23  2012 check_website_speed.php
-rwxr-xr-x  1 nagios users    7065 Oct 24  2012 check_win_snmp_disk.pl
-rwxr-xr-x  1 nagios users    2405 Oct 24  2012 check_wmi_plus.conf
-rwxr-xr-x  1 nagios users   46543 Oct 24  2012 check_wmi_plus.ini
-rwxr-xr-x  1 nagios users  237155 Oct 24  2012 check_wmi_plus.pl
-rwxr-xr-x  1 apache apache   3611 Dec 19 17:15 NagiosMonitoring_ExchangeQueueHealth.ps1
-rwxr-xr-x. 1 root   root    60559 Aug 29  2011 negate
-rwxr-xr-x  1 nagios nagios  42724 Oct 31  2012 process_perfdata.pl
-rwxr-xr-x. 1 root   root    54056 Oct 31  2012 send_nsca
-rwxr-xr-x  1 root   root    12022 Jul 25  2012 sgichk_cuda_queues.pl
-rwxr-xr-x. 1 root   root    55590 Aug 29  2011 urlize
-rwxr-xr-x. 1 root   root     2035 Aug 29  2011 utils.pm
-rwxr-xr-x. 1 root   root      862 Aug 29  2011 utils.sh
You have new mail in /var/spool/mail/root
[root@nagios libexec]#

Re: Check http MD5 question

Posted: Thu May 09, 2013 9:42 am
by scottwilkerson
I tested this script and did find a bug (missing one space), modified version is below

Code: Select all

#!/usr/bin/php -q
<?php
# ------------------------------------------------------------------
# We offer no warantee or guarantee - use this code at your own risk!
# All code is Copyright (C) 2011, Applied Trust Engineering, Inc.
# ------------------------------------------------------------------

# wget -q -O - http://appliedtrust.com | md5sum

$url = $argv[1];
$md5 = $argv[2]."  -";

$status=0;

$md5new = `wget -q -O - "$url" | md5sum`;
$md5new= rtrim($md5new);

if (strcmp($md5new, $md5)==0) {
echo "HTTPMD5sum OK: MD5sum matches\n";
} else {
$status=2;
echo "HTTPMD5sum CRITICAL: MD5sum doesn't match: ".$md5new."\n";
}

exit($status);
I tested this script running

Code: Select all

./check_http_md5 http://appliedtrust.com 6106a27fb2286565467e1f88c143798f

Re: Check http MD5 question

Posted: Thu May 09, 2013 9:53 am
by benningtonr
I copied the items into notepad, saved it with no extension and uploaded it as a plugin, then at the CLI ran the following.

[root@nagios libexec]# ./check_http_md5 http://appliedtrust.com 6106a27fb2286565467e1f88c143798f
Could not open input file: http://appliedtrust.com
[root@nagios libexec]#

Re: Check http MD5 question

Posted: Thu May 09, 2013 10:20 am
by lmiltchev
What is the output of the following command?

Code: Select all

which md5sum
Try changing the ownership of the plugin:

Code: Select all

cd /usr/local/nagios/libexec
chown root.root check_http_md5
and try running the check again.

I am not familiar with this plugin, and using the help ("-h") flag, didn't provide me with much info... :) However, I was able to get:

Code: Select all

[root@testbox libexec]#  wget -q -O - http://appliedtrust.com | md5sum
da95e2f28e2f6e78d5d3e4dfdbfc387b  -
[root@testbox libexec]# ./check_http_md5 http://appliedtrust.com da95e2f28e2f6e78d5d3e4dfdbfc387b
HTTPMD5sum OK: MD5sum matches

Re: Check http MD5 question

Posted: Thu May 09, 2013 10:26 am
by lmiltchev
Actually, I believe I know what's the issue. Since you used Notepad, most probably you have windows EOL. Open the plugin in vi:

Code: Select all

vi check_http_md5
type:

Code: Select all

:set ff=unix
hit "Enter", save and exit (:wq)

Try running the plugin again. Hope this helps.