Skip to content

Commit ee81905

Browse files
committed
merging usage
1 parent c56432b commit ee81905

24 files changed

+3835
-0
lines changed

usage/.classpath

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/core"/>
6+
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/utils"/>
7+
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
8+
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/premium"/>
9+
<classpathentry kind="src" path="/api"/>
10+
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
11+
<classpathentry kind="output" path="bin"/>
12+
</classpath>

usage/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>usage</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3+
4+
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
5+
6+
<!-- ============================== -->
7+
<!-- Append messages to the console -->
8+
<!-- ============================== -->
9+
10+
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11+
<param name="Target" value="System.out"/>
12+
<param name="Threshold" value="INFO"/>
13+
14+
<layout class="org.apache.log4j.EnhancedPatternLayout">
15+
<param name="ConversionPattern" value="%d{ABSOLUTE}{GMT} %5p %c{1}:%L - %m%n"/>
16+
</layout>
17+
</appender>
18+
19+
<!-- ================================ -->
20+
<!-- Append messages to the usage log -->
21+
<!-- ================================ -->
22+
23+
<!-- A time/date based rolling appender -->
24+
<appender name="USAGE" class="org.apache.log4j.rolling.RollingFileAppender">
25+
<param name="Append" value="true"/>
26+
<param name="Threshold" value="DEBUG"/>
27+
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
28+
<param name="FileNamePattern" value="@USAGELOG@.%d{yyyy-MM-dd}{GMT}.gz"/>
29+
<param name="ActiveFileName" value="@USAGELOG@"/>
30+
</rollingPolicy>
31+
32+
<layout class="org.apache.log4j.EnhancedPatternLayout">
33+
<param name="ConversionPattern" value="%d{ISO8601}{GMT} %-5p [%c{3}] (%t:%x) %m%n"/>
34+
</layout>
35+
</appender>
36+
37+
<!-- ================ -->
38+
<!-- Limit categories -->
39+
<!-- ================ -->
40+
41+
<category name="com.cloud">
42+
<priority value="DEBUG"/>
43+
</category>
44+
45+
<!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
46+
<category name="org.apache">
47+
<priority value="INFO"/>
48+
</category>
49+
50+
<category name="org">
51+
<priority value="INFO"/>
52+
</category>
53+
54+
<category name="net">
55+
<priority value="INFO"/>
56+
</category>
57+
58+
<!-- ======================= -->
59+
<!-- Setup the Root category -->
60+
<!-- ======================= -->
61+
62+
<root>
63+
<level value="INFO"/>
64+
<appender-ref ref="CONSOLE"/>
65+
<appender-ref ref="USAGE"/>
66+
</root>
67+
68+
</log4j:configuration>

usage/conf/usage-components.xml.in

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
usage-components.xml is the configuration file for the VM Ops
4+
usage servers.
5+
6+
Here are some places to look for information.
7+
- To find out the general functionality that each Manager
8+
or Adapter provide, look at the javadoc for the interface
9+
that it implements. The interface is usually the
10+
"key" attribute in the declaration.
11+
- To find specific implementation of each Manager or
12+
Adapter, look at the javadoc for the actual class. The
13+
class can be found in the <class> element.
14+
- To find out the configuration parameters for each Manager
15+
or Adapter, look at the javadoc for the actual implementation
16+
class. It should be documented in the description of the
17+
class.
18+
- To know more about the components.xml in general, look for
19+
the javadoc for ComponentLocator.java.
20+
21+
If you found that the Manager or Adapter are not properly
22+
documented, please contact the author.
23+
-->
24+
<components.xml>
25+
<usage-server>
26+
<dao name="VM Instance" class="com.cloud.vm.dao.VMInstanceDaoImpl"/>
27+
<dao name="User VM" class="com.cloud.vm.dao.UserVmDaoImpl"/>
28+
<dao name="ServiceOffering" class="com.cloud.service.dao.ServiceOfferingDaoImpl">
29+
<param name="cache.size">50</param>
30+
<param name="cache.time.to.live">-1</param>
31+
</dao>
32+
<dao name="Events" class="com.cloud.event.dao.EventDaoImpl"/>
33+
<dao name="UserStats" class="com.cloud.user.dao.UserStatisticsDaoImpl"/>
34+
<dao name="IP Addresses" class="com.cloud.network.dao.IPAddressDaoImpl"/>
35+
<dao name="Usage" class="com.cloud.usage.dao.UsageDaoImpl"/>
36+
<dao name="Domain" class="com.cloud.domain.dao.DomainDaoImpl"/>
37+
<dao name="Account" class="com.cloud.user.dao.AccountDaoImpl"/>
38+
<dao name="UserAccount" class="com.cloud.user.dao.UserAccountDaoImpl"/>
39+
<dao name="Usage VmInstance" class="com.cloud.usage.dao.UsageVMInstanceDaoImpl"/>
40+
<dao name="Usage Network" class="com.cloud.usage.dao.UsageNetworkDaoImpl"/>
41+
<dao name="Usage IPAddress" class="com.cloud.usage.dao.UsageIPAddressDaoImpl"/>
42+
<dao name="Usage Volume" class="com.cloud.usage.dao.UsageVolumeDaoImpl"/>
43+
<dao name="Usage Storage" class="com.cloud.usage.dao.UsageStorageDaoImpl"/>
44+
<dao name="Usage Load Balancer Policy" class="com.cloud.usage.dao.UsageLoadBalancerPolicyDaoImpl"/>
45+
<dao name="Usage Port Forwarding Rule" class="com.cloud.usage.dao.UsagePortForwardingRuleDaoImpl"/>
46+
<dao name="Usage Network Offering" class="com.cloud.usage.dao.UsageNetworkOfferingDaoImpl"/>
47+
<dao name="Usage Job" class="com.cloud.usage.dao.UsageJobDaoImpl"/>
48+
<dao name="Configuration" class="com.cloud.configuration.dao.ConfigurationDaoImpl"/>
49+
<dao name="Alert" class="com.cloud.alert.dao.AlertDaoImpl"/>
50+
<dao name="Usage Event" class="com.cloud.event.dao.UsageEventDaoImpl"/>
51+
<manager name="usage manager" class="com.cloud.usage.UsageManagerImpl">
52+
<param name="period">DAILY</param> <!-- DAILY, WEEKLY, MONTHLY; how often it creates usage records -->
53+
</manager>
54+
<manager name="Alert Manager" class="com.cloud.usage.UsageAlertManagerImpl">
55+
</manager>
56+
</usage-server>
57+
</components.xml>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# chkconfig: 35 99 10
4+
# description: CloudStack Usage Monitor
5+
6+
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
7+
8+
. /etc/rc.d/init.d/functions
9+
10+
whatami=cloud-usage
11+
12+
# set environment variables
13+
14+
SHORTNAME="$whatami"
15+
PIDFILE=@PIDDIR@/"$whatami".pid
16+
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
17+
LOGFILE=@USAGELOG@
18+
PROGNAME="CloudStack Usage Monitor"
19+
USER=@MSUSER@
20+
21+
unset OPTIONS
22+
[ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
23+
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
24+
PROG=@LIBEXECDIR@/usage-runner
25+
26+
start() {
27+
echo -n $"Starting $PROGNAME: "
28+
if hostname --fqdn >/dev/null 2>&1 ; then
29+
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
30+
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" -u "$USER" "$PROG" $OPTIONS
31+
RETVAL=$?
32+
echo
33+
else
34+
failure
35+
echo
36+
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
37+
RETVAL=9
38+
fi
39+
[ $RETVAL = 0 ] && touch ${LOCKFILE}
40+
return $RETVAL
41+
}
42+
43+
stop() {
44+
echo -n $"Stopping $PROGNAME: "
45+
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
46+
RETVAL=$?
47+
echo
48+
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
49+
}
50+
51+
52+
# See how we were called.
53+
case "$1" in
54+
start)
55+
start
56+
;;
57+
stop)
58+
stop
59+
;;
60+
status)
61+
status -p ${PIDFILE} $SHORTNAME
62+
RETVAL=$?
63+
;;
64+
restart)
65+
stop
66+
sleep 3
67+
start
68+
;;
69+
condrestart)
70+
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
71+
stop
72+
sleep 3
73+
start
74+
fi
75+
;;
76+
*)
77+
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
78+
RETVAL=3
79+
esac
80+
81+
exit $RETVAL
82+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# chkconfig: 35 99 10
4+
# description: CloudStack Usage Monitor
5+
6+
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
7+
8+
. /etc/rc.d/init.d/functions
9+
10+
whatami=cloud-usage
11+
12+
# set environment variables
13+
14+
SHORTNAME="$whatami"
15+
PIDFILE=@PIDDIR@/"$whatami".pid
16+
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
17+
LOGFILE=@USAGELOG@
18+
PROGNAME="CloudStack Usage Monitor"
19+
USER=@MSUSER@
20+
21+
unset OPTIONS
22+
[ -r @SYSCONFDIR@/sysconfig/"$SHORTNAME" ] && source @SYSCONFDIR@/sysconfig/"$SHORTNAME"
23+
DAEMONIZE=@BINDIR@/@PACKAGE@-daemonize
24+
PROG=@LIBEXECDIR@/usage-runner
25+
26+
start() {
27+
echo -n $"Starting $PROGNAME: "
28+
if hostname --fqdn >/dev/null 2>&1 ; then
29+
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
30+
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" -u "$USER" "$PROG" $OPTIONS
31+
RETVAL=$?
32+
echo
33+
else
34+
failure
35+
echo
36+
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
37+
RETVAL=9
38+
fi
39+
[ $RETVAL = 0 ] && touch ${LOCKFILE}
40+
return $RETVAL
41+
}
42+
43+
stop() {
44+
echo -n $"Stopping $PROGNAME: "
45+
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
46+
RETVAL=$?
47+
echo
48+
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
49+
}
50+
51+
52+
# See how we were called.
53+
case "$1" in
54+
start)
55+
start
56+
;;
57+
stop)
58+
stop
59+
;;
60+
status)
61+
status -p ${PIDFILE} $SHORTNAME
62+
RETVAL=$?
63+
;;
64+
restart)
65+
stop
66+
sleep 3
67+
start
68+
;;
69+
condrestart)
70+
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
71+
stop
72+
sleep 3
73+
start
74+
fi
75+
;;
76+
*)
77+
echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
78+
RETVAL=3
79+
esac
80+
81+
exit $RETVAL
82+

0 commit comments

Comments
 (0)