Skip to content

Commit a5c39d5

Browse files
author
Sina Kashipazha
committed
Added remote logging capability to virtual router, console proxy ,and secondary storage.
1 parent 72182b6 commit a5c39d5

File tree

9 files changed

+76
-3
lines changed

9 files changed

+76
-3
lines changed

server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
4444
public static final ConfigKey<Boolean> NoVncConsoleSourceIpCheckEnabled = new ConfigKey<Boolean>("Advanced", Boolean.class, "novnc.console.sourceip.check.enabled", "false",
4545
"If true, The source IP to access novnc console must be same as the IP in request to management server for console URL. Needs to reconnect CPVM to management server when this changes (via restart CPVM, or management server, or cloud service in CPVM)", false);
4646

47+
static final ConfigKey<Boolean> ConsoleProxyRemoteLoggingEnabled = new ConfigKey<>("Advanced", Boolean.class, "consoleproxy.remote.logging.enabled", "false",
48+
"If true, console proxy will forward console proxy logs to <consoleproxy.remote.logging.address>", true, ConfigKey.Scope.Global);
49+
50+
static final ConfigKey<String> ConsoleProxyRemoteLoggingAddress = new ConfigKey<>("Advanced", String.class, "consoleproxy.remote.logging.address", "",
51+
"Console proxy forwards its logs to this address", true, ConfigKey.Scope.Global);
52+
4753
public void setManagementState(ConsoleProxyManagementState state);
4854

4955
public ConsoleProxyManagementState getManagementState();

server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,9 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
12191219
}
12201220
buf.append(" zone=").append(dest.getDataCenter().getId());
12211221
buf.append(" pod=").append(dest.getPod().getId());
1222+
buf.append(" remoteloggingenabled=").append(ConsoleProxyRemoteLoggingEnabled.value());
1223+
buf.append(" remoteloggingaddress=").append(ConsoleProxyRemoteLoggingAddress.value());
1224+
12221225
buf.append(" guid=Proxy.").append(profile.getId());
12231226
buf.append(" proxy_vm=").append(profile.getId());
12241227
if (disableRpFilter) {
@@ -1580,7 +1583,8 @@ public String getConfigComponentName() {
15801583

15811584
@Override
15821585
public ConfigKey<?>[] getConfigKeys() {
1583-
return new ConfigKey<?>[] { NoVncConsoleDefault, NoVncConsoleSourceIpCheckEnabled };
1586+
return new ConfigKey<?>[] { NoVncConsoleDefault, NoVncConsoleSourceIpCheckEnabled,
1587+
ConsoleProxyRemoteLoggingEnabled, ConsoleProxyRemoteLoggingAddress };
15841588
}
15851589

15861590
protected ConsoleProxyStatus parseJsonToConsoleProxyStatus(String json) throws JsonParseException {

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
114114
static final ConfigKey<Double> RouterHealthChecksMaxMemoryUsageThreshold = new ConfigKey<Double>(Double.class, "router.health.checks.max.memory.usage.threshold",
115115
"Advanced", "100", "Max Memory Usage threshold as % above which check is considered a failure.",
116116
true, ConfigKey.Scope.Zone, null);
117+
static final ConfigKey<Boolean> RouterRemoteLoggingEnabled = new ConfigKey<>(Boolean.class, "router.remote.logging.enabled",
118+
"Advanced", "false", "If true, Router VM will forward console proxy logs to <router.remote.logging.address>",
119+
true, ConfigKey.Scope.Zone, null);
120+
static final ConfigKey<String> RouterRemoteLoggingAddress = new ConfigKey<>(String.class, "router.remote.logging.address",
121+
"Advanced", "", "Router VMs forward their logs to this address",
122+
true, ConfigKey.Scope.Zone, null);
117123

118124
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M
119125
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,9 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile
20492049

20502050
buf.append(" type=" + type + rpFilter);
20512051

2052+
buf.append(" remoteloggingenabled=").append(RouterRemoteLoggingEnabled.value());
2053+
buf.append(" remoteloggingaddress=").append(RouterRemoteLoggingAddress.value());
2054+
20522055
final String domain_suffix = dc.getDetail(ZoneConfig.DnsSearchOrder.getName());
20532056
if (domain_suffix != null) {
20542057
buf.append(" dnssearchorder=").append(domain_suffix);
@@ -3238,7 +3241,9 @@ public ConfigKey<?>[] getConfigKeys() {
32383241
RouterHealthChecksFreeDiskSpaceThreshold,
32393242
RouterHealthChecksMaxCpuUsageThreshold,
32403243
RouterHealthChecksMaxMemoryUsageThreshold,
3241-
ExposeDnsAndBootpServer
3244+
ExposeDnsAndBootpServer,
3245+
RouterRemoteLoggingEnabled,
3246+
RouterRemoteLoggingAddress
32423247
};
32433248
}
32443249

services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
266266
static final ConfigKey<Integer> MaxNumberOfSsvmsForMigration = new ConfigKey<Integer>("Advanced", Integer.class, "max.ssvm.count", "5",
267267
"Number of additional SSVMs to handle migration of data objects concurrently", true, ConfigKey.Scope.Global);
268268

269+
static final ConfigKey<Boolean> SecondaryStorageRemoteLoggingEnabled = new ConfigKey<>( "Advanced", Boolean.class,"secondary.storage.remote.logging.enabled", "false",
270+
"If true, secondary storage will forward secondary storage logs to <secondary.storage.remote.logging.address>", false, ConfigKey.Scope.Global);
271+
272+
static final ConfigKey<String> SecondaryStorageRemoteLoggingAddress = new ConfigKey<>( "secondary.storage.remote.logging.address", String.class, "Advanced", "",
273+
"Secondary storage forwards its logs to this address", true, ConfigKey.Scope.Global);
274+
269275
public SecondaryStorageManagerImpl() {
270276
}
271277

@@ -1080,6 +1086,8 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
10801086

10811087
buf.append(" zone=").append(dest.getDataCenter().getId());
10821088
buf.append(" pod=").append(dest.getPod().getId());
1089+
buf.append(" remoteloggingenabled=").append(SecondaryStorageRemoteLoggingEnabled.value());
1090+
buf.append(" remoteloggingaddress=").append(SecondaryStorageRemoteLoggingAddress.value());
10831091

10841092
buf.append(" guid=").append(profile.getVirtualMachine().getHostName());
10851093

@@ -1420,7 +1428,7 @@ public String getConfigComponentName() {
14201428

14211429
@Override
14221430
public ConfigKey<?>[] getConfigKeys() {
1423-
return new ConfigKey<?>[] {NTPServerConfig, MaxNumberOfSsvmsForMigration};
1431+
return new ConfigKey<?>[] {NTPServerConfig, MaxNumberOfSsvmsForMigration, SecondaryStorageRemoteLoggingEnabled, SecondaryStorageRemoteLoggingAddress};
14241432
}
14251433

14261434
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$InputFileName /var/log/cloud.log
2+
$InputFileTag cloud
3+
$InputFileStateFile stat-file1-cloud
4+
$InputFileSeverity info
5+
$InputFileFacility local7
6+
$InputFilePollInterval 1
7+
$InputFilePersistStateInterval 1
8+
$InputRunFileMonitor
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Create an additional socket in haproxy's chroot in order to allow logging via
2+
# /dev/log to chroot'ed HAProxy processes
3+
$AddUnixListenSocket /var/lib/haproxy/dev/log
4+
5+
$InputFileName /var/log/haproxy.log
6+
$InputFileTag haproxy
7+
$InputFileStateFile stat-file1-haproxy
8+
$InputFileSeverity info
9+
$InputFileFacility local7
10+
$InputFilePollInterval 1
11+
$InputFilePersistStateInterval 1
12+
$InputRunFileMonitor

systemvm/debian/opt/cloud/bin/setup/common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ parse_cmd_line() {
759759
ntpserverlist)
760760
export NTP_SERVER_LIST=$VALUE
761761
;;
762+
remoteloggingenabled)
763+
export REMOTE_LOGGGING_ENABLED=$VALUE
764+
;;
765+
remoteloggingaddress)
766+
export REMOTE_LOGGGING_ADDRESS=$VALUE
767+
;;
762768
esac
763769
done
764770
echo -e "\n\t}\n}" >> ${CHEF_TMP_FILE}

systemvm/debian/opt/cloud/bin/setup/postinit.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,28 @@
2020

2121
# Eject cdrom if any
2222
eject || true
23+
. /opt/cloud/bin/setup/common.sh
24+
25+
setup_remote_logging(){
26+
echo "${REMOTE_LOGGGING_ENABLED,,}"
27+
# Remove curent configuration
28+
sed -i '/imudp/d' /etc/rsyslog.conf
29+
sed -i '/3914/d' /etc/rsyslog.conf
30+
if [[ "${REMOTE_LOGGGING_ENABLED,,}" == "true" ]]; then
31+
sed -i '/^# provides UDP syslog*/a $ModLoad imudp\n$UDPServerRun 3914' /etc/rsyslog.conf
32+
fi
33+
34+
echo "*.* @${REMOTE_LOGGGING_ADDRESS}" > /etc/rsyslog.d/99-fwd.conf
35+
36+
systemctl restart rsyslog
37+
}
2338

2439
# Restart journald for setting changes to apply
2540
systemctl restart systemd-journald
2641

42+
# Setup remote logging
43+
setup_remote_logging
44+
2745
TYPE=$(grep -Po 'type=\K[a-zA-Z]*' /var/cache/cloud/cmdline)
2846
if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ]
2947
then

0 commit comments

Comments
 (0)