Display specific string on a xml through the check_vpn plugn
Display specific string on a xml through the check_vpn plugn
On nagios core I can use:
define service{
use generic-service
host_name W Des Moines IA VPN
service_description W Des Moines xxxxx Status Check
check_command check_vpn_WD_IA_TOC!pptp!username!password!require-mppe!; check_http -H 10.xxx.xx.xxx -f follow -u "/service/status/inspire" -s "FAIL"
}
And this will log into the VPN then check the site for the word FAIL
Is there a plugin to display a specific word that I could use in conjunction with the check_vpn plugin for nagiosxi? Perhaps to display the version number on the status page?
Thank you!
define service{
use generic-service
host_name W Des Moines IA VPN
service_description W Des Moines xxxxx Status Check
check_command check_vpn_WD_IA_TOC!pptp!username!password!require-mppe!; check_http -H 10.xxx.xx.xxx -f follow -u "/service/status/inspire" -s "FAIL"
}
And this will log into the VPN then check the site for the word FAIL
Is there a plugin to display a specific word that I could use in conjunction with the check_vpn plugin for nagiosxi? Perhaps to display the version number on the status page?
Thank you!
Re: Display specific string on a xml through the check_vpn p
Just to note, anything that works in Core should also work in XI.
You could write something custom out (which it sounds like you've done this far). Are you trying to have it pull a certain string of text, from a specific place then? I imagine you could do this with some regex matching, and a wrapper script to pull information accordingly. Just need to parse it all properly. Could you provide screenshots as an example?
You could write something custom out (which it sounds like you've done this far). Are you trying to have it pull a certain string of text, from a specific place then? I imagine you could do this with some regex matching, and a wrapper script to pull information accordingly. Just need to parse it all properly. Could you provide screenshots as an example?
Former Nagios Employee
Re: Display specific string on a xml through the check_vpn p
Are you aware of a plugin that reports the return of a string? (I've seen there are temperature checks that I believe display the current temp)
I need to report on screen from an xml something like the following (this is directly from the *.php page):
<xxxxx version="1.4.3.5852" IP="10.xxx.xxx.xxx" Mode="Optimized" IsOptimisedMode="True" DetectorSwitchEnabled="False">
I need to report on screen from an xml something like the following (this is directly from the *.php page):
<xxxxx version="1.4.3.5852" IP="10.xxx.xxx.xxx" Mode="Optimized" IsOptimisedMode="True" DetectorSwitchEnabled="False">
Re: Display specific string on a xml through the check_vpn p
I can check through the vpn for error or success, but am looking for a way to display the results on nagios:
declare -r DEFAULT_TEST_URL=http://10.xx.xx.xx
# check_vpn lock, for preventing multiple access to resources
CHECK_VPN_LOCK=/var/run/check_vpn
# global error/success string to report errors
ERROR_STRING="good"
SUCCESS_STRING="bad, whatever"
# returns a free vpn device
# $1 - device prefix (tun/tap/ppp)
allocate_vpn_device() {
local device_prefix=$1; shift
local i
for i in `seq 0 255`; do
! ifconfig ${device_prefix}$i >& /dev/null && \
echo "${device_prefix}$i" && \
return 0
done
return 1
}
declare -r DEFAULT_TEST_URL=http://10.xx.xx.xx
# check_vpn lock, for preventing multiple access to resources
CHECK_VPN_LOCK=/var/run/check_vpn
# global error/success string to report errors
ERROR_STRING="good"
SUCCESS_STRING="bad, whatever"
# returns a free vpn device
# $1 - device prefix (tun/tap/ppp)
allocate_vpn_device() {
local device_prefix=$1; shift
local i
for i in `seq 0 255`; do
! ifconfig ${device_prefix}$i >& /dev/null && \
echo "${device_prefix}$i" && \
return 0
done
return 1
}
Re: Display specific string on a xml through the check_vpn p
Which result are you trying to display? Any screenshots will help to show us as well.
You could probably grep a line of the XML, and then assign that to a variable which you can then echo.
You could probably grep a line of the XML, and then assign that to a variable which you can then echo.
Former Nagios Employee
Re: Display specific string on a xml through the check_vpn p
It would ultimately display this:
OK: VPN to 'xxx.xx.10.46' up and running on 'ppp1', 'http://10.xxx.xx.234' reachable, 'version1.6.0.6720'
I have been trying to change variables in check_string/check_http_content plugins - but they only are search for a specific string - instead of reporting it
I have the check_vpn, then check http within the vpn working - just not a way to report a variable
I have been changing around this check: https://exchange.nagios.org/directory/P ... gs/details to see if there is a way to have it report 'version' instead of say 'temperature'
The xml is just a status.php page displaying the variables of the application processor (version, IP, DNS, things of that matter)
So far I have come up with this:
[root@svaksaaXXXX libexec]# ./check_vpn_Statler_VA_Processor -t pptp -H xxx.xxx.127.194 -u <username> -p <password> -- require-mppe; ./check_string -H http://192.168.27.100/specialcalls.php -s "xxxx version" -w 1.4 -c 20
OK: VPN to 'xxx.xxx.127.194' up and running on 'ppp0', 'http://192.168.27.100' reachable|time=0.061s;size=0B
sh: /usr/bin/lynx: No such file or directory
Use of uninitialized value $value in string eq at ./check_string line 44.
CRITICAL Search string has no value !
OK: VPN to 'xxx.xx.10.46' up and running on 'ppp1', 'http://10.xxx.xx.234' reachable, 'version1.6.0.6720'
I have been trying to change variables in check_string/check_http_content plugins - but they only are search for a specific string - instead of reporting it
I have the check_vpn, then check http within the vpn working - just not a way to report a variable
I have been changing around this check: https://exchange.nagios.org/directory/P ... gs/details to see if there is a way to have it report 'version' instead of say 'temperature'
The xml is just a status.php page displaying the variables of the application processor (version, IP, DNS, things of that matter)
So far I have come up with this:
[root@svaksaaXXXX libexec]# ./check_vpn_Statler_VA_Processor -t pptp -H xxx.xxx.127.194 -u <username> -p <password> -- require-mppe; ./check_string -H http://192.168.27.100/specialcalls.php -s "xxxx version" -w 1.4 -c 20
OK: VPN to 'xxx.xxx.127.194' up and running on 'ppp0', 'http://192.168.27.100' reachable|time=0.061s;size=0B
sh: /usr/bin/lynx: No such file or directory
Use of uninitialized value $value in string eq at ./check_string line 44.
CRITICAL Search string has no value !
Re: Display specific string on a xml through the check_vpn p
Thank you for the lead - I am looking into site grep checks now 
Re: Display specific string on a xml through the check_vpn p
It seems the right terminology I am looking for is a check that prints page content - I found something I could possibly adjust:
https://exchange.nagios.org/directory/P ... rm/details
check_form.pl -u -f -e (-c -w )
-u # url string to post form data against
-e # string to query on the authenticated page
-f # post string
-c # the number of seconds to wait before a going critical
-w # the number of seconds to wait before a flagging a warning
-n do not follow redirection
-d prints page contents (debugging info)
-s prints status code (debugging info)
e.g check_form.pl -u https://foobar.com -f "login=foo&password=bar" -e "Hello sweetie" -c 10 -w 3 -v
Which currently I have showing:
[root@svaksaa2605 libexec]# ./check_vpn_Statler_VA_Processor -t pptp -H xxx.xxx.127.194 -u <username> -p <password> -- require-mppe; ./check_form.pl -u http://192.168.27.100/specialcalls.php -d -f "<application name>" -e "version" -c 30 -w 5 -v -d
OK: VPN to 'xxx.xxx.127.194' up and running on 'ppp0', 'http://192.168.27.100' reachable|time=0.062s;size=0B
timeout at ./check_form.pl line 91.
Are there any other plugins for printing page content? (p.s. Thank you very very much for the assistance so far!)
https://exchange.nagios.org/directory/P ... rm/details
check_form.pl -u -f -e (-c -w )
-u # url string to post form data against
-e # string to query on the authenticated page
-f # post string
-c # the number of seconds to wait before a going critical
-w # the number of seconds to wait before a flagging a warning
-n do not follow redirection
-d prints page contents (debugging info)
-s prints status code (debugging info)
e.g check_form.pl -u https://foobar.com -f "login=foo&password=bar" -e "Hello sweetie" -c 10 -w 3 -v
Which currently I have showing:
[root@svaksaa2605 libexec]# ./check_vpn_Statler_VA_Processor -t pptp -H xxx.xxx.127.194 -u <username> -p <password> -- require-mppe; ./check_form.pl -u http://192.168.27.100/specialcalls.php -d -f "<application name>" -e "version" -c 30 -w 5 -v -d
OK: VPN to 'xxx.xxx.127.194' up and running on 'ppp0', 'http://192.168.27.100' reachable|time=0.062s;size=0B
timeout at ./check_form.pl line 91.
Are there any other plugins for printing page content? (p.s. Thank you very very much for the assistance so far!)
Re: Display specific string on a xml through the check_vpn p
Well, the standard check_http string search will output whatever search term you provide it, but only on a failure:
I assume this output is going to change, so a static string search for the whole pattern won't work? If this is the case you might either need to get creative with your search strings, or write some wrapper/glue code to get the proper output.
Code: Select all
[root@localhost libexec]# ./check_http -H www.google.com -s hello
HTTP CRITICAL: HTTP/1.1 200 OK - string 'hello' not found on 'http://www.google.com:80/' - 11002 bytes in 0.167 second response time |time=0.166844s;;;0.000000 size=11002B;;;0
[root@localhost libexec]# ./check_http -H www.google.com -s google
HTTP OK: HTTP/1.1 200 OK - 10981 bytes in 0.245 second response time |time=0.245156s;;;0.000000 size=10981B;;;0
Former Nagios employee
Re: Display specific string on a xml through the check_vpn p
Well I found a good work around for now:
adding to check_vpn:
# test in front of google.com
declare -r DEFAULT_TEST_URL=http://10.121.30.60
# check_vpn lock, for preventing multiple access to resources
CHECK_VPN_LOCK=/var/run/check_vpn
# global error string to report errors
#ERROR_STRING=""
SUCCESS_STRING="1.4.5.6154"
...........
...........
if [ $? -eq 0 ] && wait_for_vpn_to_come_up $type $lns $device; then
local tmp_perf_data=`mktemp`
if vpn_connectivity_check $device $test_url > $tmp_perf_data; then
echo "OK: VPN to '$lns' up and running on '$device', '$test_url' reachable, version '$SUCCESS_STRING'|"`cat $tmp_perf_data`
else
echo "Warning: VPN ($type) up, connectivity check failed to '$test_url'|"`cat $tmp_perf_data`
retval=1
fi
rm -f $tmp_perf_data
else
echo "Critical: VPN ($type) connection failed to '$lns': '$ERROR_STRING'"
retval=2
fi
Now output states:
OK: VPN to 'xx.xx.91.66' up and running on 'ppp2', 'http://10.121.30.60' reachable, version '1.4.5.6154'
adding to check_vpn:
# test in front of google.com
declare -r DEFAULT_TEST_URL=http://10.121.30.60
# check_vpn lock, for preventing multiple access to resources
CHECK_VPN_LOCK=/var/run/check_vpn
# global error string to report errors
#ERROR_STRING=""
SUCCESS_STRING="1.4.5.6154"
...........
...........
if [ $? -eq 0 ] && wait_for_vpn_to_come_up $type $lns $device; then
local tmp_perf_data=`mktemp`
if vpn_connectivity_check $device $test_url > $tmp_perf_data; then
echo "OK: VPN to '$lns' up and running on '$device', '$test_url' reachable, version '$SUCCESS_STRING'|"`cat $tmp_perf_data`
else
echo "Warning: VPN ($type) up, connectivity check failed to '$test_url'|"`cat $tmp_perf_data`
retval=1
fi
rm -f $tmp_perf_data
else
echo "Critical: VPN ($type) connection failed to '$lns': '$ERROR_STRING'"
retval=2
fi
Now output states:
OK: VPN to 'xx.xx.91.66' up and running on 'ppp2', 'http://10.121.30.60' reachable, version '1.4.5.6154'