From 139020c862ea724920702161e98f513385ec5103 Mon Sep 17 00:00:00 2001
From: alexhigh <alex@artica.es>
Date: Mon, 5 May 2014 11:25:27 +0000
Subject: [PATCH] 2014-05-05  Alejandro Gallardo <alejandro.gallardo@artica.es>

	* bin/pandora_server: Added checks and warnings for
	too many threads and verbosity 10.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9860 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog          |  5 +++++
 pandora_server/bin/pandora_server | 31 +++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 0893445f8f..6c5b3f5280 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-05  Alejandro Gallardo <alejandro.gallardo@artica.es>
+
+	* bin/pandora_server: Added checks and warnings for
+	too many threads and verbosity 10.
+
 2014-05-03  Junichi Satoh <junichi@rworks.jp>
 
 	* util/pandora_manage.pl: Added new CLI functions to manage special
diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server
index 4e36f68e8d..cc5e2d27a8 100755
--- a/pandora_server/bin/pandora_server
+++ b/pandora_server/bin/pandora_server
@@ -380,6 +380,37 @@ foreach my $server (@Servers) {
 	$server->upEvent ();
 }
 
+# Check if the Data Server has too many threads 
+if ($Config{'dataserver_threads'} > 5) {
+	logger (\%Config, "[W] Server " . $Config{'servername'} . " have configured " . $Config{'dataserver_threads'}
+		. " threads for the data server. You should not use more than 5 threads for this server", 1);
+	print_message (\%Config, " [W] Server " . $Config{'servername'} . " have configured " . $Config{'dataserver_threads'}
+		. " threads for the data server. You should not use more than 5 threads for this server", 1);
+	pandora_event (\%Config, "Server " . $Config{'servername'} . " have configured "
+		. $Config{'dataserver_threads'} . " threads for the data server", 0, 0, 3, 0, 0, 'system', 0, $DBH);
+}
+
+# Check if the Pandora Server has too many threads 
+my $totalThreads = 0;
+foreach my $server (@Servers) {
+	$totalThreads += $server->getNumThreads ();
+}
+if ($totalThreads > 40) {
+	logger (\%Config, '[W] Server ' . $Config{'servername'} . ' have configured a total of ' . $totalThreads
+		. ' threads. This setup is not recommended, you should reduce the number of total threads below 40', 1);
+	print_message (\%Config, ' [W] Server ' . $Config{'servername'} . ' have configured a total of ' . $totalThreads
+		. ' threads. This setup is not recommended, you should reduce the number of total threads below 40', 1);
+	pandora_event (\%Config, 'Server ' . $Config{'servername'} . ' have configured a total of ' . $totalThreads
+		. ' threads', 0, 0, 3, 0, 0, 'system', 0, $DBH);
+}
+
+# Check if the log verbosity is set to 10
+if ($Config{'verbosity'} == 10) {
+	logger (\%Config, '[W] Log verbosity is set to 10. This will degrade the server performance. Please set to a lower value ASAP', 1);
+	print_message (\%Config, ' [W] Log verbosity is set to 10. This will degrade the server performance. Please set to a lower value ASAP', 1);
+	pandora_event (\%Config, 'Log verbosity is set to 10. This will degrade the server performance', 0, 0, 1, 0, 0, 'system', 0, $DBH);
+}
+
 # Main loop
 my $time_ref = time ();
 while (1) {