Listen to this Post
Learn the basics of web scraping, JSON assembly, API monitoring with JsonPath, and dependent items in Zabbix. This project demonstrates a complete IX-BR status monitoring setup.
🔗 Video Tutorial: https://lnkd.in/d8krY_9r
🔗 Portfolio Examples: https://lnkd.in/dDDGuqHi
You Should Know:
1. Web Scraping Basics
Extract data from websites using Python with `BeautifulSoup` and requests
:
import requests from bs4 import BeautifulSoup url = "https://example.com" response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') titles = soup.find_all('h1') for title in titles: print(title.text)
2. JSON Assembly & Parsing
Create and parse JSON in Python:
import json data = { "status": "active", "nodes": ["node1", "node2"] } json_str = json.dumps(data) # Convert to JSON string parsed = json.loads(json_str) # Parse back to dict print(parsed["status"])
3. Monitoring APIs with JsonPath
Use `jq` (Linux) to filter JSON responses:
curl -s https://api.example.com/data | jq '.status'
In Python, use `jsonpath-ng`:
from jsonpath_ng import parse data = {"status": "up", "nodes": [{"id": 1}, {"id": 2}]} expr = parse("$.status") matches = [match.value for match in expr.find(data)] print(matches) # Output: ['up']
4. Zabbix Dependent Items
Configure dependent items in Zabbix for API monitoring:
- Master Item: HTTP request to fetch JSON.
- Dependent Item: JsonPath query (e.g.,
$.status
).
Example Zabbix item prototype:
[plaintext]
Type: Dependent item
Key: api.status
Master item: api.raw.data
Preprocessing: JSONPath `$.status`
[/plaintext]
5. Grafana Dashboard Integration
Visualize Zabbix-collected data in Grafana:
- Use the Zabbix plugin.
- Query dependent items for real-time status.
What Undercode Say
Web scraping and API monitoring are essential for IT infrastructure. Automate checks with:
<h1>Linux: Cron job for API health checks</h1> */5 * * * * curl -s https://api.example.com/health | grep -q '"status":"up"' || echo "API Down" | mail -s "Alert" [email protected]
Windows alternative (PowerShell):
Invoke-RestMethod -Uri "https://api.example.com/health" | Select-Object -ExpandProperty status
For Zabbix, always validate JSON responses:
zabbix_sender -z <server> -s "<host>" -k "api.status" -o $(curl -s https://api.example.com | jq -r '.status')
Practice these commands to master monitoring workflows.
Expected Output:
- JSON response parsing.
- Automated API status alerts.
- Zabbix + Grafana dashboards.
🔗 Relevant URLs:
References:
Reported By: Fernando Almondes – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅