Skip to content
Snippets Groups Projects
Commit 1f42c0a2 authored by Felix Moser's avatar Felix Moser
Browse files

adding scalability

parent c247814a
Branches Packaging
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
#include <fcntl.h>
#include <string.h>
static const char *PIPE_TWO = "/tmp/pipeTwo";
static const char *PIPE_TWO = "/tmp/cpu_freq";
static void read_cpu_freq_and_write(int fd)
{
......@@ -25,7 +25,7 @@ static void read_cpu_freq_and_write(int fd)
char message[128];
snprintf(message, sizeof(message), "%.3f", freq);
ssize_t written = write(fd, message, strlen(message) + 1);
ssize_t written = write(fd, message, strlen(message));
if (written < 0) {
perror("write to pipeTwo");
} else {
......
......@@ -5,7 +5,7 @@
#include <fcntl.h>
#include <string.h>
static const char *PIPE_ONE = "/tmp/pipeOne";
static const char *PIPE_ONE = "/tmp/cpu_temp";
static void read_cpu_temp_and_write(int fd)
{
......@@ -27,7 +27,7 @@ static void read_cpu_temp_and_write(int fd)
// Schreiben, aber NICHT den FD schließen.
// Nur so viele Bytes schreiben, wie tatsächlich gebraucht werden.
ssize_t written = write(fd, message, strlen(message) + 1);
ssize_t written = write(fd, message, strlen(message));
if (written < 0) {
perror("write to pipeOne");
} else {
......
#!/bin/bash
#Prozesse starten
/usr/local/bin/cpu_temp &
/usr/local/bin/cpu_freq &
sleep 200
# Gleiche Argumente in die main übergeben
/usr/local/bin/main "$@"
# Damit das Skript nicht sofort beendet, bleibst du in einer Endlosschleife
while true
do
sleep 3600
......
No preview for this file type
......@@ -60,7 +60,7 @@ void build_crc_checksum(char *package, size_t package_size) {
char tmp[32];
// z.B. " CRC=0x1A2B3C4D"
snprintf(tmp, sizeof(tmp), " CRC=0x%08lX", (unsigned long)c);
snprintf(tmp, sizeof(tmp), " CRC=0x%08lX", c);
// ans package anhängen
strncat(package, tmp, package_size - strlen(package) - 1);
......@@ -70,7 +70,7 @@ void send_package(const char *package, const int fdCharDev) {
char transmitBuf[256] = {0};
// Kopiere Package in transmitBuf
snprintf(transmitBuf, sizeof(transmitBuf), package);
snprintf(transmitBuf, sizeof(transmitBuf), "%s", package);
const ssize_t written = write(fdCharDev, transmitBuf, strlen(transmitBuf));
if (written < 0) {
......@@ -142,6 +142,7 @@ int main(const int argc, char *argv[]) {
return 1;
}
}
build_crc_checksum(package, sizeof(package));
// Jetzt an /dev/packet_receiver schicken
if (strlen(package) > 0) {
......
[Unit]
Description=Monitoring Processes
Description=Monitoring Processes and sending to character device
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/process_monitoring.sh
ExecStart=/usr/local/bin/process_monitoring.sh /tmp/cpu_temp /tmp/cpu_freq
Restart=always
[Install]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment