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

adding scalability

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