Permalink
Browse files

Add check_file_exists plugin

  • Loading branch information...
1 parent ef33753 commit a56cb8a0ba4d0c7456d0adca385361d658877367 Andrew Libby committed Sep 12, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 check_file_exists
View
@@ -0,0 +1,28 @@
+#! /bin/bash
+#
+# Author : Diego Martin Gardella [dgardella@gmail.com]
+# Desc : Plugin to verify if a file exists
+#
+#
+
+PROGNAME=`basename $0`
+PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+
+. $PROGPATH/utils.sh
+
+if [ "$1" = "" ]
+then
+ echo -e " Use : $PROGNAME <file_name> -- Ex : $PROGNAME /etc/hosts \n "
+ exit $STATE_UNKNOWN
+fi
+
+
+if [ -f $1 ]
+then
+ echo "OK - $1 : EXISTS :: `head -3 $1`" # shows the first three lines of the file
+ exit $STATE_OK
+else
+ echo "CRITICAL : $1 Does NOT exists "
+ exit $STATE_CRITICAL
+fi
+

0 comments on commit a56cb8a

Please sign in to comment.