GithubHelp home page GithubHelp logo

migcm / nagios-check_curl Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 10.0 40 KB

NRPE Plugin - Check a web page contents for specific search terms. Built on check_curl2 posted on Nagios Exchange by nagiosexchange

License: GNU General Public License v3.0

PHP 100.00%

nagios-check_curl's Introduction

nagios-check_curl

Check a web page contents for specific search terms. Built on check_curl2 posted on Nagios Exchange by nagiosexchange. Added capability to define authentication type, number of apparitions of Grep, header values, HTTP expected code, etc.

Syntax and options:

-Me Protocol (Custom string for request. Available protocols: HTTP, FTP, IMAP, POP3 and SMTP)
-U URL (s)
-A Agent (s)(default: Mozilla/5.0 ... )
-a Authentication (s)(example: '[user]:[password]')
-ao Authentication method to use (example: 'CURLAUTH_DIGEST')
-G Search that the indicated text exist on the page (can be set multiple times)
-NG Search that the indicated text not exist on the page (can be set multiple times)
-Gn Number of apparitions of Grep
-he Any other tags to be sent in http header. Use multiple times for additional headers (example: 'X-Requested-Auth: Digest')
-L Show page (-)
-F Follow redirects (-)
-I Ignore SSL certificate errors (-)
-X Exclude performance data (default: include)
-Tc Critical page return time (i)
-Tw Warning page return time (i)
-Sbc Critical page size below SIZE (i)
-Soc Critical page size over SIZE (i)
-Sbw Warning page size below SIZE (i)
-Sow Warning page size over SIZE (i)
-S Find string between ARG1 and ARG2, return first match (s s) (example: value=\" \" )
-T Timeout (i)(default: 10sec)
-O Output Driven Check - Page Should respond with \"Status: OK\" or otherwise
-hc HTTP expected code (default: 200)
-tag Tag to identify the check in the return message
-Px Set proxy to use
-PxPort proxy port
-PxAuth User name and password to use for proxy authentication

Examples:

check_curl -U http://test.example.net

check_curl -U http://test.example.net:8888/info -he 'X-Requested-Auth: Digest' -ao CURLAUTH_DIGEST -a "USER:PASSWORD" -G searchme -G searchme2

check_curl -U http://test.example.net:8888/info -a "USER:PASSWORD" -G "<status>0</status>" -Gn 5

check_curl -Px 'testproxy.net' -PxPort '8080' -PxAuth 'PROXY_USER:PROXY_PASSWORD' -U http://test.example.net

nagios-check_curl's People

Contributors

jazzl0ver avatar migcm avatar mtdeguzis avatar stevenbarre avatar tmorik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nagios-check_curl's Issues

Adding options for proxy

Hello,

I'd like to suggest the following options for proxy settings. Could you take a look and added them to a new version of check_curl if you think they are ok?

case '-Px':
	if ($Pocet > $i + 1) {
		curl_setopt($ch, CURLOPT_PROXY, $argv[++$i]);
		if ($Debug)
			echo "\nDEBUG: -Px " . $argv[$i];
	} else {
		echo "UNKNOWN - ERROR in parsing argument -Px: missing value\n";
		exit(3);
	}
	break;

case '-PxPort':
	if ($Pocet > $i + 1) {
		curl_setopt($ch, CURLOPT_PROXYPORT, $argv[++$i]);
		if ($Debug)
			echo "\nDEBUG: -PxPort " . $argv[$i];
	} else {
		echo "UNKNOWN - ERROR in parsing argument -PxPort: missing value\n";
		exit(3);
	}
	break;

case '-PxAuth':
	if ($Pocet > $i + 1) {
		curl_setopt($ch, CURLOPT_PROXYUSERPWD, $argv[++$i]);
		if ($Debug)
			echo "\nDEBUG: -PxAuth " . $argv[$i];
	} else {
		echo "UNKNOWN - ERROR in parsing argument -PxPort: missing value\n";
		exit(3);
	}
	break;    

Adding -Me option for Method selection

Hi I have added the following option in my local version of the script

-Me POST (in order to support htpps method POST for example)

Could you add that the a new version of the script?

cheers
s-tobe
...
switch ($argv[$i]) {
case '-Me':
if ($Pocet > $i + 1) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $argv[++$i]);
if ($Debug)
echo "\nDEBUG: -Me " . $argv[$i];
} else {
echo "UNKNOWN - ERROR in parsing argument -Me: missing value\n";
exit(3);
}
break;

case '-U':
....

contradictory size options

Hello,
maybe it´s a misunderstanding of the readme from myself but it seems that the options Sbc,Soc,Sbw and Sow are not working as expected.

Example 1:
./check_curl -U https://XXXXXXXX/sitemap-1.xml -Sbc 5000000 -F
CRITICAL - Page size 21332497B below limit 5000000B | |time=6.961 size=21332497

In that case I would have expect an okay state because the size of the side is greater than my threshold.

Example 2:
/nagios-check_curl$ ./check_curl -U https://XXXXXXX/sitemap-1.xml -Soc 5000000 -F
OK - Page size 21332497 between the limits | |time=5.297 size=21332497

The reverse of example 1. I would have expect an critical state due the size of the page is greater than my threshold.

If you switch the greater and lesser sign in the ifelse statements it should work fine.

Can you please take a look.

Thank you.

No Result. Need a little help

Hi there

I'm trying to use this plugin to check a command that i run on the command line like this.

 curl "http://127.0.0.1:8001/data/run?script=plot1=GETDATA(CODE=SPX:5,DATERANGE=Last%20Week)"

It returns a response like this

{
  "datalists" : [
    {
      "properties" : {
        "SCRIPT" : "GETDATA(CODE=SPX:5,DATERANGE=Last Week)",
        "TICKER" : "SPX",
        "PRODID" : "5",
        "Tool Name" : "",
        "CODE" : "S&P 500 INDEX - SPX (WI)",
        "Currency" : "USD",
        "Use Source Timeframe" : "False"
      },
      "date" : [
      ],
      "data" : [
        [
          1531094400000,
          "2775.62",
          "2784.65",
          "2770.73",
          "2784.17",
          "1859165478.00",
          "0.00"
        ],
        [
          1531180800000,
          "2788.56",
          "2795.58",
          "2786.24",
          "2793.84",
          "1743427932.00",
          "0.00"
        ],
        [
          1531267200000,
          "2779.82",
          "2785.91",
          "2770.77",
          "2774.02",
          "1806015298.00",
          "0.00"
        ],
        [
          1531353600000,
          "2783.14",
          "2799.22",
          "2781.53",
          "2798.29",
          "1862928000.00",
          "0.00"
        ],
        [
          1531440000000,
          "2796.93",
          "2804.53",
          "2791.69",
          "2801.31",
          "1757998396.00",
          "0.00"
        ]
      ]
    }
  ]
}

I'd like to be able to check the response for SPX

I've tried this command but get no response. just returns to the next line on the command line.

./check_curl -U "http://127.0.0.1:8001/data/run?script=plot1=GETDATA(CODE=SPX:5,DATERANGE=Last%20Week)" -G SPX

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.