Added asterboard and check_web_site_size

dev
Eric Loyd 1 year ago
parent 8e48aabf0f
commit 1e8f9c1f0f

@ -0,0 +1,73 @@
There are some minor steps needed to install Asterboard and there are
some assumptions as to how your data is logged.
*** ASSUMPTIONS
* Your data is sent from one or more Asterisk servers running v 1.8 or higher.
* Your data is tagged from Asterisk as being the "asterisk" program (this is
the "-t" parameter from the setup-linux.sh script).
* Asterisk uses "from-trunk" context for all incoming calls and "from-internal"
for all outgoing calls (or at least, the final context before sending
calls out goes through from-internal).
*** INSTALLING
Note: Older (pre 1.4.0) versions of NLS used a different directory for logstash
patterns. If the directory in step 1a does not exist, use step 1b. You do not
need to perform both steps.
1a) Copy "asterisk" to logstash's patterns directory:
cp asterisk /usr/local/nagioslogserver/logstash/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-0.1.10/patterns
1b) Copy "asterisk" to older logstash patterns directory:
cp asterisk /usr/local/nagioslogserver/logstash/patterns
2) Log in to Nagios Log Server and go to "Administration"
Go to "Global Configuration"
Add a filter called "Asterisk" with the following content:
if [program] == 'asterisk' {
grok {
match => ['message', '%{ASTLOG}']
}
}
Save and Apply your new global configuration
3) Install the dashboard itself by going to the "Dashboard" screen
Click the "Load" icon near the top right
Select "Advanced" from the bottom of the pop-up
Choose "Browse" and browse to where you saved the asterboard.json file
You can now save your new dashboard as whatever you want, but as it is primarily
showing "Concurrent Calls" we use "Concurrent Calls."
New Asterisk log data will now be parsed into the following fields:
asterisk_app Set, Macro, Dial, etc
asterisk_app_params Parameters to above
asterisk_channel SIP/1234@context (for instance)
asterisk_context 1234@from-intenal:1 or 1234@from-trunk:1
asterisk_ext 1234
asterisk_extension Internal extension used in transfers, etc
asterisk_sip_channel SIP/1234
asterisk_src_file pbx.c for outbound calls
These terms are also available for general Asterisk log file searching/analysis
though some are not used or useful for this particular dashboard.
Note that if you added Asterisk data prior to loading the global filter, that
data will not have the appropriate terms parsed and will not show up in the
call details, but they will show up in the overall counts. Only new data added
after applying the global filter will show phone numbers and trunk information.
Feel free to contact me with questions:
Author: Eric Loyd <eric@bitnetix.com>
Copyleft 2014 by Eric Loyd
Last updated 23-Mar-2016

@ -0,0 +1,51 @@
SIP_HEADER [A-Z_]+
ASTLEVEL (?:VERBOSE|ERROR|NOTICE|INFO|DEBUG|DTMF|WARNING)
ASTLANGUAGE [a-z]{1,3}
# Special pattern for "Ext." Logs
ASTEXTNO [A-Za-z0-9_]+
# Valid DTMF keys
ASTDTMF [0-9#*]
# Log source file (Normally a c file)
ASTSRC [-a-z._0-9/]+
# Registration info
ASTREGISTRATION %{USERNAME}@%{IPORHOST}
# Context
ASTCONTEXTEXTENSION [A-Za-z0-9*#~_]+
ASTCONTEXTNAME [-a-z0-9]+
ASTCONTEXTPOSITION \d+
ASTCONTEXT %{ASTCONTEXTEXTENSION:asterisk_ext}@%{ASTCONTEXTNAME}:%{ASTCONTEXTPOSITION}
# Application
ASTAPP [A-Z][A-Za-z0-9]+
ASTAPP_AUDIOFILE [-a-zA-Z0-9_./]+
# Interfaces
AST_SIP_INTERFACE SIP/[-_A-Za-z0-9]+
ASTINTERFACE %{AST_SIP_INTERFACE}
# Channels
ASTCHANNEL_SIP %{AST_SIP_INTERFACE:asterisk_sip_channel}-[a-f0-9]+
ASTCHANNEL_LOCAL Local/[-a-z0-9@;]+
ASTCHANNEL (:?%{ASTCHANNEL_SIP}|%{ASTCHANNEL_LOCAL})
# Different log content types
ASTCONTENT_CHANNELEVENT1 (:?CDR updated on|Timeout on|Stopped music on hold on|Started music on hold, class '%{ASTAPP_AUDIOFILE}', on|(:?Begin|End) MixMonitor Recording) %{ASTCHANNEL:asterisk_channel}
ASTCONTENT_CHANNELEVENT2 (Locally bridging )?%{ASTCHANNEL:asterisk_channel}.*%{ASTCHANNEL:asterisk_channel}
ASTCONTENT_CHANNELEVENT3 %{ASTCHANNEL:asterisk_channel} is ringing
ASTCONTENT_EXECUTE Executing \[%{ASTCONTEXT:asterisk_context}\] %{ASTAPP:asterisk_app}\("%{ASTCHANNEL:asterisk_channel}", "%{GREEDYDATA:asterisk_app_params}"\) in new stack
ASTCONTENT_CHANNELJUMP Channel '%{ASTCHANNEL:asterisk_channel}' jumping out of macro '%{ASTCONTEXTNAME:asterisk_context}'
ASTCONTENT_GOTO Goto \(%{ASTCONTEXTNAME:asterisk_context},%{ASTCONTEXTEXTENSION:asterisk_extension},%{ASTCONTEXTPOSITION:asterisk_context_position}\)
ASTCONTENT_SIPCOSMARK Using SIP RTP CoS mark %{NUMBER}
ASTCONTENT_ASTMANAGER Manager '%{USERNAME:asterisk_manager_name}' logged (:?off|on) from %{IPORHOST:asterisk_manager_host}
ASTCONTENT_CDRUPDATE on %{ASTCHANNEL:asterisk_channel}
ASTCONTENT_PLAYAUDIO <%{ASTCHANNEL:asterisk_channel}> Playing '%{ASTAPP_AUDIOFILE:audiofile}' \(language '%{ASTLANGUAGE}'\)
ASTCONTENT_REGISTRATION_TIMEOUT Registration for '%{ASTREGISTRATION}' timed out, trying again \(Attempt #%{NUMBER:asterisk_registration_attempt}\)
ASTCONTENT_INVALID_EXTENSION Invalid extension '%{ASTCONTEXTEXTENSION:asterisk_extension}' in context '%{ASTCONTEXTNAME:asterisk_context}' on %{ASTCHANNEL}
ASTCONTENT_CONNECTION_REFUSED Connect attempt from '%{IPORHOST:asterisk_connection_refused_host}' unable to authenticate
ASTCONTENT_QUEUE_EVENT Added interface '%{ASTINTERFACE}' to queue '%{NOTSPACE:asterisk_queue}'
ASTCONTENT_UNKNOWN_SIPMESSAGE Unable to parse %{SIP_HEADER:sip_header} message from %{ASTREGISTRATION:asterisk_external}
ASTCONTENT_SPAWN Spawn extension \(%{ASTCONTEXTNAME:asterisk_context}, %{ASTCONTEXTEXTENSION:asterisk_extension}, %{ASTCONTEXTPOSITION:asterisk_context_position}\) exited .* on '%{ASTCHANNEL:asterisk_channel}'
ASTCONTENT_USERINPUT User entered '%{DATA:asterisk_userinput}'
ASTCONTENT_DTMF DTMF (:?begin|end)(:? passthrough| ignored)? '%{ASTDTMF:asterisk_dtmf_number}'(:? received)? on %{ASTCHANNEL}(:?, duration %{NUMBER:asterisk_dtmf_duration} ms)?
ASTCONTENT [-=\s]*(:?%{ASTCONTENT_EXECUTE}|%{ASTCONTENT_CHANNELJUMP}|%{ASTCONTENT_GOTO}|%{ASTCONTENT_PLAYAUDIO}|%{ASTCONTENT_SPAWN}|%{ASTCONTENT_ASTMANAGER}|%{ASTCONTENT_DTMF}|%{ASTCONTENT_REGISTRATION_TIMEOUT}|%{ASTCONTENT_CHANNELEVENT1}|%{ASTCONTENT_CHANNELEVENT2}|%{ASTCONTENT_CHANNELEVENT3}|%{ASTCONTENT_INVALID_EXTENSION}|%{ASTCONTENT_CONNECTION_REFUSED}|%{ASTCONTENT_QUEUE_EVENT}|%{ASTCONTENT_USERINPUT}|%{ASTCONTENT_UNKNOWN_SIPMESSAGE}|%{ASTCONTENT_SIPCOSMARK}|%{GREEDYDATA})
# different log types
ASTLOG1 \[%{TIMESTAMP_ISO8601:timestamp}\] %{ASTLEVEL:severity}\[\d+\]\[.*\] %{ASTSRC:asterisk_src_file}:%{ASTCONTENT}
ASTLOG2 \[%{TIMESTAMP_ISO8601:timestamp}\] %{ASTLEVEL:severity}\[\d+\] Ext. %{ASTEXTNO}: %{GREEDYDATA}
ASTTIMEOUT Packet timed out after %{NUMBER}ms with no response
ASTLOG ^(:?%{ASTLOG1}|%{ASTLOG2}|%{ASTTIMEOUT})

@ -0,0 +1,45 @@
#!/bin/sh
# curl -s https://www.homedepot.com/p/HDX-Black-5-Tier-Plastic-Garage-Storage-Shelving-Unit-36-in-W-x-74-in-H-x-18-in-D-241592/306331734 | grep -v href | md5sum | awk '{print $1}'
verbose=""
size=0
while [ -n "$1" ]; do
case "$1" in
-v) verbose="true"; shift 1;;
-u) url="$2"; shift 2;;
-s) size="$2"; shift 2;;
*) shift 1;;
esac
done
# curl -skL "https://www.wyze.com/products/wyze-cam-v3" -w '%{size_download}' -o /dev/null
agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
[ -n "$verbose" ] && echo "DEBUG: curl --connect-timeout 10 -A \"$agent\" -skL \"$url\" -w \"%{size_download}\" -o /dev/null"
checkSize=$(curl --connect-timeout 10 -A "$agent" -skL "$url" -w "%{size_download}" -o /dev/null)
status=$?
if [ "$status" != "0" ]; then
sleep 2
checkSize=$(curl --connect-timeout 10 -A "$agent" -skL "$url" -w "%{size_download}" -o /dev/null)
status=$?
fi
case $status in
0) ;;
3) echo "UNKNOWN: malformed URL $url" && exit 3;;
6) echo "WARNING: could not resolve host for $url" && exit 3;;
7) echo "WARNING: could not connect to host $url" && exit 1;;
28) echo "WARNING: curl timeout" && exit 1;;
35) echo "WARNING: TLS/SSL handshake failure - $output" && exit 1;;
47) echo "WARNING: too many redirects" && exit 1;;
52) echo "WARNING: $url returned no data" && exit 1;;
esac
if [ "$size" = "$checkSize" ]; then
echo "OK; received $size bytes|bytes=${checkSize}B"
exit 0
else
echo "CRITICAL; $checkSize is not expected value of $size bytes|bytes=${checkSize}B"
exit 2
fi
Loading…
Cancel
Save