Add scripts to create myops-getqueryview:
[myops.git] / web / collect / server / summarize_logs.sh
diff --git a/web/collect/server/summarize_logs.sh b/web/collect/server/summarize_logs.sh
new file mode 100755 (executable)
index 0000000..c18b1a6
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+PREFIX=/var/www/html/uploadlogs/raw/old
+
+# get keys
+key_list="bootcd_version
+fs_status
+iptables_status
+kernel_version
+netflow
+netflow_live
+nm_running
+nodemanager_running
+plc_config
+real_bootcd_kernel_version
+real_bootcd_version
+"
+
+DATE=$( date --date "1 hour ago" +%Y-%m-%dT%H )
+#DATE=$1
+
+# get count of unique values from keys
+echo $START Hours ago == $DATE
+c=`ls $PREFIX/$DATE/*--upload | wc -l`
+if [[ $c -gt 2 ]] ; then
+    for key in $key_list ; do 
+        echo $key
+        c=`grep -E -h "^$key " $PREFIX/$DATE/*--upload | wc -l`
+               if [[ $c -gt 2 ]] ; then
+                       grep -E -h "^$key " $PREFIX/$DATE/*--upload | \
+                               awk '{if ( NF == 2 ) { print $0, "unknown" } else { print $0 } }' | \
+                               awk '{if ( $3 == "Linux" ) { print $1, $2, $5 } else { print $0 } }'  | \
+                               sed -e 's/^.* : //g' -e 's/ /_/g' -e 's/.*running_:/no/' -e 's/.*status_:/none/g' | \
+                               awk -F. '{ if ( $2 == "" ) { print $1 } else if ( $3 == "" ) { printf("%s.%s\n", $1, $2) } else { printf("%s.%s.%s\n", $1, $2, $3)} }' | \
+                               sed -e 's/Multiple_IO_errors.*/error/' \
+                                       -e 's/\/home\/pl_monitor.*/error/' \
+                                       -e 's/Unable_to_find.*/error/'  \
+                                       -e 's/.*cannot_touch.*/error/'  \
+                                       -e 's/No_kernel_at_.*/error/' | \
+                               sort | uniq -c | \
+                               sed -e 's/\./_/g' -e 's/\//_/g' | awk 'BEGIN{total=0} { total += $1 ; print $0 } END { print total, "total"}' | \
+                               while read value value_name ; do 
+                                       #echo -e "\tmyops.$key.$value_name $value $DATE" 
+                                       #echo -e "\t"/root/load-graphite.py --target "myops.$key.$value_name" --date $DATE  --value $value
+                                       /usr/share/myops/web/collect/server/load-graphite.py --target "myops.$key.$value_name" --date $DATE  --value $value
+                                       sleep .2
+                               done
+               fi
+    done
+fi
+