Skip to content

kga/go-check-css-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-check-css-selector

Check if a CSS selector exists in the HTML DOM of a specified URL.

Synopsis

go-check-css-selector -U <URL> -S <CSS_SELECTOR>

Description

This plugin fetches the specified URL and checks whether the given CSS selector exists in the HTML DOM. It returns:

  • OK if the selector is found
  • CRITICAL if the selector is not found
  • UNKNOWN if there is an error accessing the URL or parsing the HTML

Installation

Using go install

go install github.com/kga/go-check-css-selector@latest

Building from source

git clone https://github.com/kga/go-check-css-selector.git
cd go-check-css-selector
go build

Usage

Command line

go-check-css-selector -U https://example.com -S "div.content"

With mackerel-agent

Add the following configuration to your mackerel-agent.conf:

[plugin.checks.go-check-css-selector-sample]
command = ["go-check-css-selector", "-U", "https://example.com", "-S", "div.content"]

Options

  -U, --url=      URL to check (required)
  -S, --selector= CSS selector to find in the DOM (required)

Examples

Check if a specific element exists on a page:

go-check-css-selector -U https://example.com -S "#main-content"

Check for a button with a specific class:

go-check-css-selector -U https://example.com -S "button.submit-btn"

Check for nested elements:

go-check-css-selector -U https://example.com -S "div.header nav.menu ul li"

Author

kga

About

Mackerel plugin to check if DOM node exists in URL with CSS selector

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages