Skip to content

Commit d08644d

Browse files
author
var-dev
committed
new file: Dockerfile
new file: README.md new file: activation.json new file: rsyslog-include.conf new file: rsyslog.conf new file: runapp.sh
0 parents  commit d08644d

File tree

6 files changed

+195
-0
lines changed

6 files changed

+195
-0
lines changed

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM alpine:3.7
2+
LABEL maintainer="var-dev@github"
3+
LABEL cisco.descriptor-schema-version="2.6" \
4+
       cisco.info.name="rsyslog" \
5+
       cisco.info.description="Cisco iox rsyslog" \
6+
       cisco.info.version="0.1" \
7+
       cisco.info.author-link=" https://github.com/var-dev/iox-rsyslog-alpine " \
8+
       cisco.info.author-name="var-dev" \
9+
        cisco.type=docker \
10+
        cisco.cpuarch=x86_64 \
11+
        cisco.resources.profile=custom \
12+
        cisco.resources.cpu=800 \
13+
        cisco.resources.memory=1024 \
14+
        cisco.resources.disk=10 \
15+
        cisco.resources.network.0.interface-name=eth0 \
16+
cisco.resources.network.0.ports.udp=514 \
17+
        cisco.resources.network.1.interface-name=eth1 \
18+
cisco.resources.network.1.ports.udp=514 \
19+
# cisco.monitor.script="healthprobe.sh" \
20+
cisco.startup.rootfs="rootfs.tar" \
21+
cisco.startup.target="/runapp.sh"
22+
ADD http://alpine.adiscon.com/[email protected] /etc/apk/keys
23+
RUN echo 'http://alpine.adiscon.com/3.7/stable' >> /etc/apk/repositories \
24+
&& apk update \
25+
&& apk add --no-cache rsyslog rsyslog-elasticsearch rsyslog-omstdout \
26+
&& rm -rf /var/cache/apk/*
27+
28+
COPY rsyslog.conf /etc/rsyslog.conf
29+
COPY runapp.sh /runapp.sh

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# iox-rsyslog-alpine
2+
## Build. Install. Start.
3+
```
4+
docker build -t iox-rsyslog-alpine . && \
5+
rm -f package.* rootfs.tar && \
6+
ioxclient docker package iox-rsyslog-alpine . && \
7+
ioxclient application install rsyslog package.tar && \
8+
ioxclient application activate --payload activation.json rsyslog && \
9+
ioxclient app appdata upload rsyslog ../rsyslog-include.conf rsyslog-include.conf && \
10+
ioxclient application start rsyslog
11+
```
12+
## Uninstall.
13+
```
14+
ioxclient application stop rsyslog && \
15+
ioxclient application deactivate rsyslog && \
16+
ioxclient application uninstall rsyslog
17+
```
18+
## Upgrade.
19+
```
20+
docker build -t iox-rsyslog-alpine . && \
21+
rm -f package.* rootfs.tar && \
22+
ioxclient docker package iox-rsyslog-alpine . && \
23+
ioxclient application stop rsyslog && \
24+
ioxclient application deactivate rsyslog && \
25+
ioxclient application upgrade rsyslog package.tar && \
26+
ioxclient application activate --payload activation.json rsyslog && \
27+
ioxclient app appdata upload rsyslog ../rsyslog-include.conf rsyslog-include.conf && \
28+
ioxclient application start rsyslog
29+
```

activation.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"resources": {
3+
"auto_remove": false,
4+
"cpu": "800",
5+
"disk": "10",
6+
"memory": "2048",
7+
"network": [
8+
{
9+
"interface-name": "eth0",
10+
"intf-matched": true,
11+
"ipv4": {
12+
"default": true,
13+
"dns": [
14+
"10.0.0.1"
15+
],
16+
"gateway": "10.10.80.1",
17+
"ip": "10.10.80.20",
18+
"mode": "static",
19+
"prefix": "24"
20+
},
21+
"network-name": "VPG0"
22+
},
23+
{
24+
"interface-name": "eth1",
25+
"intf-matched": true,
26+
"ipv4": {
27+
"dns": "",
28+
"ip": "10.10.71.10",
29+
"mode": "static",
30+
"prefix": "24"
31+
},
32+
"network-name": "mgmt-bridge100"
33+
}
34+
],
35+
"profile": "custom",
36+
"vcpu": "1"
37+
},
38+
"startup": {
39+
"runtime_options": "-e NB_SECRET_KEY=SECRET_KEY"
40+
}
41+
}

rsyslog-include.conf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module(load="omelasticsearch")
2+
3+
# define a template to specify which fields we send
4+
5+
template(name="LogseneFormat" type="list" option.json="on") {
6+
constant(value="{")
7+
constant(value="\"@timestamp\":\"")
8+
property(name="timereported" dateFormat="rfc3339")
9+
constant(value="\",\"message\":\"")
10+
property(name="msg")
11+
constant(value="\",\"host\":\"")
12+
property(name="hostname")
13+
constant(value="\",\"severity\":\"")
14+
property(name="syslogseverity-text")
15+
constant(value="\",\"facility\":\"")
16+
property(name="syslogfacility-text")
17+
constant(value="\",\"syslog-tag\":\"")
18+
property(name="syslogtag")
19+
constant(value="\",\"source\":\"")
20+
property(name="programname")
21+
constant(value="\"}")
22+
}
23+
24+
25+
template(name="LogseneInputTemplate" type="list")
26+
{
27+
# standard syslog fields
28+
constant(value="<")
29+
property(name="pri")
30+
constant(value=">")
31+
property(name="timereported" dateFormat="rfc3164")
32+
constant(value=" ")
33+
property(name="hostname")
34+
constant(value=" ")
35+
property(name="syslogtag")
36+
# CEE-formatted JSON message over syslog
37+
constant(value="@cee: {\"logsene-app-token\": \"TOKEN\", \"message\": \"")
38+
property(name="msg" format="json") # original syslog message goes in the "message" field
39+
constant(value="\"}\n")
40+
}
41+
42+
action(type="omelasticsearch"
43+
template="LogseneFormat" # the template that you defined earlier
44+
searchIndex="TOKEN"
45+
server="logsene-receiver.sematext.com"
46+
serverport="80"
47+
bulkmode="on"
48+
queue.dequeuebatchsize="100" # how many messages to send at once
49+
action.resumeretrycount="-1" # buffer messages if connection fails
50+
errorfile="/data/logs/omelasticsearch.log")
51+

rsyslog.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module(load="imudp")
2+
input(type="imudp" port="514")
3+
module(load="pmciscoios")
4+
5+
global(workDirectory="/var/lib/rsyslog")
6+
7+
include(
8+
file="/data/appdata/rsyslog-include.conf"
9+
mode="optional"
10+
)
11+
12+
*.* /dev/console

runapp.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
if [ -f /data/.env ]
4+
then
5+
source /data/.env
6+
fi
7+
8+
start_app() {
9+
while [ ${app_restart} ]; do
10+
echo "Starting rsyslogd"
11+
/usr/sbin/rsyslogd -n -f /etc/rsyslog.conf > /data/logs/rsyslog.log 2>&1 &
12+
pid=$!
13+
echo "PID=$pid"
14+
wait "$pid"
15+
sleep 1
16+
done
17+
}
18+
19+
_term() {
20+
echo "Caught SIGTERM signal!"
21+
echo "Terminating!"
22+
app_restart=""
23+
pidof rsyslogd | xargs kill -TERM
24+
}
25+
26+
trap _term SIGTERM
27+
28+
app_restart=true
29+
30+
start_app
31+
echo "done. PID=$pid"
32+
33+
exit 0

0 commit comments

Comments
 (0)