Syntax Command Check_netstat_conn
-
ednaldojta
- Posts: 103
- Joined: Tue Apr 07, 2015 7:52 am
Re: Syntax Command Check_netstat_conn
Everything worked! Thank you very much! The fight was great but we did it!
: D: D: D
Just a question. If the check is Nagios every 5 minutes for example. Then it will run the "netstat -an | grep 5666 | wc -l" every 5 minutes right?
: D: D: D
Just a question. If the check is Nagios every 5 minutes for example. Then it will run the "netstat -an | grep 5666 | wc -l" every 5 minutes right?
Re: Syntax Command Check_netstat_conn
Good news. Yes, if the check interval is set to 5 minutes, then it will run every 5 minutes.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
ednaldojta
- Posts: 103
- Joined: Tue Apr 07, 2015 7:52 am
Re: Syntax Command Check_netstat_conn
Friends, just one more thing! how do I put the status CRITICAL, WARNING, etc. and starting the parameters generate an alert in Nagios?
He also did not ta generating graphic
He also did not ta generating graphic
Re: Syntax Command Check_netstat_conn
The script should be returning performance data, is it not working for you?
As this is just a simple script, you'll need to manually edit these in the bash file. This page does a good job explaining what lt (less than), and ge (greater or equal) do http://tldp.org/LDP/abs/html/comparison-ops.html
I've added some comments to help make sense of it, does this make sense?
As this is just a simple script, you'll need to manually edit these in the bash file. This page does a good job explaining what lt (less than), and ge (greater or equal) do http://tldp.org/LDP/abs/html/comparison-ops.html
I've added some comments to help make sense of it, does this make sense?
Code: Select all
#OK is <80
#WARNING is 80-90
#CRITICAL is >90
#anything less than 80 is OK
if [ $count -lt 80 ]
then
state="OK"
#anything greater or equal to 80, AND less than 90.
elif [ $count -ge 80 ] && [ $count -lt 90 ]
then
state="WARNING"
#greater or equal to 90
elif [ $count -ge 90 ]
then
state="CRITICAL"
Former Nagios Employee
-
ednaldojta
- Posts: 103
- Joined: Tue Apr 07, 2015 7:52 am
Re: Syntax Command Check_netstat_conn
How would the script along with the syntax
netstat -an | grep 5666 | wc -l?
netstat -an | grep 5666 | wc -l?
Re: Syntax Command Check_netstat_conn
What exactly are you asking?
The modified part above is not the entire script, it is only there to outline the changes needed for warning / critical thresholds.
The modified part above is not the entire script, it is only there to outline the changes needed for warning / critical thresholds.
Former Nagios Employee
-
ednaldojta
- Posts: 103
- Joined: Tue Apr 07, 2015 7:52 am
Re: Syntax Command Check_netstat_conn
Yes, I got it!
my script is basic. It is just like is below.
##############################
#! / Bin / bash
# Status CRITICAL - WARNING - OK - WARNING
STAT1 = OK
STAT2 = WARNING
stat3 = CRITICAL
port1 = 5666
port2 = 9012
port3 = 8080
port4 = 443
port5 = 9015
arg1 = `netstat -an | grep $ port1 | wc -l `
if [ "$ arg1" -lt 2]
Then
echo "$ arg1 Connections is $ STAT1"
elif [ "$ arg1" -gt 2]
Then
echo "$ arg1 Connections is $ STAT2"
else
echo "$ arg1 Connections is $ arg3"
fi
################################
How would this syntax within this scritp.
Basically! I'm want this syntax
"Netstat -an | grep 5666 | wc -l"
and starting from a certain number of connections it becomes critical, ok or warning!
my script is basic. It is just like is below.
##############################
#! / Bin / bash
# Status CRITICAL - WARNING - OK - WARNING
STAT1 = OK
STAT2 = WARNING
stat3 = CRITICAL
port1 = 5666
port2 = 9012
port3 = 8080
port4 = 443
port5 = 9015
arg1 = `netstat -an | grep $ port1 | wc -l `
if [ "$ arg1" -lt 2]
Then
echo "$ arg1 Connections is $ STAT1"
elif [ "$ arg1" -gt 2]
Then
echo "$ arg1 Connections is $ STAT2"
else
echo "$ arg1 Connections is $ arg3"
fi
################################
How would this syntax within this scritp.
Basically! I'm want this syntax
"Netstat -an | grep 5666 | wc -l"
and starting from a certain number of connections it becomes critical, ok or warning!
-
ednaldojta
- Posts: 103
- Joined: Tue Apr 07, 2015 7:52 am
Re: Syntax Command Check_netstat_conn
Yes, but only with this script I can not change the status OK for worning or CRITICAL starting from a certain number of connections.
I want to run this scritp with a trasheroud.
I want to run this scritp with a trasheroud.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Syntax Command Check_netstat_conn
You need to define the exit code and exit using that code.
Code: Select all
##############################
#! / Bin / bash
# Status CRITICAL - WARNING - OK - WARNING
STAT1 = OK
STAT2 = WARNING
stat3 = CRITICAL
port1 = 5666
port2 = 9012
port3 = 8080
port4 = 443
port5 = 9015
exitcode = 3
arg1 = `netstat -an | grep $ port1 | wc -l `
if [ "$ arg1" -lt 2]
Then
echo "$ arg1 Connections is $ STAT1"
exitcode = 0
elif [ "$ arg1" -gt 2]
Then
echo "$ arg1 Connections is $ STAT2"
exitcode = 1
else
echo "$ arg1 Connections is $ arg3"
exitcode = 2
fi
exit $exitcode
################################As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.