Browse code

set of simple SQL queries to determine server status

Jiri Kuthan authored on 22/09/2004 03:41:12
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,46 @@
1
+#!/bin/sh
2
+#
3
+# examples for gaining some interesting values from SIP DB
4
+#
5
+
6
+SERUN=ser
7
+SERDB=ser
8
+DBHOST=localhost
9
+
10
+# ------------
11
+
12
+
13
+
14
+usage() {
15
+COMMAND=`basename $0`
16
+cat <<EOF
17
+usage: $COMMAND logged_cnt
18
+       $COMMAND natted_cnt
19
+
20
+EOF
21
+} #usage
22
+
23
+query() {
24
+	mysql -h $DBHOST -u$SERUN -p -e "$1" $SERDB
25
+}
26
+
27
+
28
+case $1 in
29
+
30
+	logged_cnt)
31
+		query "select count(distinct username,domain) from location;"
32
+		;;
33
+	natted_cnt)
34
+		query "select count(distinct username,domain) from location 
35
+			where flags>0;"
36
+		;;
37
+
38
+	*)
39
+		usage
40
+		exit 1
41
+		;;
42
+	
43
+esac
44
+
45
+
46
+