-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsplunksend.sh
executable file
·84 lines (76 loc) · 1.86 KB
/
splunksend.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
splunk_server="your event collector splunk server URL"
splunk_autorization="Splunk authorization ID"
datetime=$(date '+%d/%m/%Y %H:%M:%S');
fail=0
display_usage() {
echo -e "\nUsage:\nsplunksend.sh [arguments] \n"
echo "requiere arguments (argument=value):"
echo -e "-source= source in splunk"
echo -e "-site= Desired site URL to check"
echo -e "-expiration= SSL cert expiration date"
echo -e "-days_left= Days left to SSL expiration"
echo -e "-status= SSL cert status"
echo -e "-sslinfo= SSL cert info"
}
for i in "$@"
do
case $i in
-site=*)
site="${i#*=}"
shift # past argument=value
;;
-source=*)
source_info="${i#*=}"
shift # past argument=value
;;
-expiration=*)
expiration="${i#*=}"
shift # past argument=value
;;
-days_left=*)
days_left="${i#*=}"
shift # past argument=value
;;
-status=*)
status="${i#*=}"
shift # past argument=value
;;
-sslinfo=*)
sslinfo="${i#*=}"
shift # past argument=value
;;
-help|--help)
display_usage
exit 1
shift # past argument with no value
;;
esac
done
if ([ -z "$site" ]) then
echo "-site not found"
fail=1
fi
if ([ -z "$source_info" ]) then
echo "-source not found"
fail=1
fi
if ([ -z "$expiration" ]) then
echo "-expiration not found"
fail=1
fi
if ([ -z "$days_left" ]) then
echo "-days_left not found"
fail=1
fi
if ([ -z "$status" ]) then
echo "-status not found"
fail=1
fi
if ([ -z "$sslinfo" ]) then
echo "-sslinfo not found"
fail=1
fi
if [ "$fail" -eq 0 ];then
send=$(curl -s -k "$splunk_server" -H "$splunk_autorization" -d '{"sourcetype":"_json", "source":"'"$source_info"'", "event":{"site":"'"$site"'", "expiration":"'"$expiration"'" , "days_left":"'"$days_left"'", "status":"'"$status"'","date":"'"$datetime"'","sslinfo":"'"$sslinfo"'"}}')
fi