shell script not working properly as Nagios plugin
Assaf Flatto
nagios at flatto.net
Fri Jul 20 14:17:43 CEST 2012
On 20/07/12 12:41, vishesh kumar wrote:
> Hi Members,
>
> I wrote below script to monitor ssh traffic
>
> +++++++++++++++++++++++++++++++++++++++++++
> a=$(/usr/bin/sudo /sbin/iptables -vL|/bin/grep ':ssh'|/bin/awk '{print
> $1}')
> if [ $a -gt 3 ]; then
> echo "SSH aatempt is TOO High | $a"
> exit 2
> else
> if [ $a -gt 2 ]; then
> echo "SSH aatempt is Average | $a"
> exit 1
> else
> echo "No SSH attempts | $a"
> exit 0
> fi
> fi
> exit 3
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> This script is working fine on shell and returning "SSH attempt is too
> high" . But when i run it via nagios the output returned OK and print
> "No SSH attempts".
>
> What I can notice that variable a not holding any value while running
> via nagios , while its working fine when running via shell.
>
> Can you please drive me in right direction ?
>
>
> Thanks
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
Is your nagios user defined as allowed to use sudo ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20120720/78ed1aa1/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list