Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4b20cb2
Added Memory Statistics Daemon to collect, store, and manage memory u…
Arham-Nasir Sep 26, 2024
03d0650
Merge branch 'sonic-net:master' into feature/memory-statistics-daemon…
Arham-Nasir Oct 14, 2024
27a31e1
Add SyslogLogger class for syslog message logging
Arham-Nasir Oct 23, 2024
6569ac7
Merge branch 'feature/memory-statistics-daemon-process' of github.com…
Arham-Nasir Oct 23, 2024
4ef28ef
Added Dict2Obj for dict-object conversion and Utility class for date …
Arham-Nasir Oct 23, 2024
08cddde
Added TimeProcessor class to handle time validation, date parsing, an…
Arham-Nasir Oct 24, 2024
b886d0f
Add MemoryReportGenerator class for generating formatted memory stati…
Arham-Nasir Oct 24, 2024
565201e
Add MemoryEntryManager class for managing and formatting memory entries
Arham-Nasir Oct 31, 2024
f068c78
Add SocketHandler class for UNIX socket communication
Arham-Nasir Nov 4, 2024
2b01214
Adjusting the recomemnded file permission for unix socket
Arham-Nasir Nov 4, 2024
d7f3fb9
Added the MemoryStatisticsService, Daemonizer,MemoryStatisticsProcess…
Arham-Nasir Nov 5, 2024
4f84986
update the memory_statistics handler file
Arham-Nasir Nov 19, 2024
e96bb24
Improved the config_db functionality to handle validation more gracef…
Arham-Nasir Nov 29, 2024
8478b8a
Resolved issues to improve reliability
Arham-Nasir Dec 11, 2024
86d7713
Enhance Daemonizer with robust validation
Arham-Nasir Dec 13, 2024
f8f960c
Update memory statistics collection and retention logic
Arham-Nasir Jan 17, 2025
e5634d9
Replace pickle with JSON for secure serialization
Arham-Nasir Jan 22, 2025
e014037
Refactored error handling and validation for robustness
Arham-Nasir Mar 9, 2025
c28cebd
update memory_statistics code
Arham-Nasir Apr 7, 2025
7f95411
Add memory statistics service setup
Arham-Nasir Apr 14, 2025
935f6da
Pulled Changes from the Remote Master BuildImage
Arham-Nasir May 5, 2025
b9f31ea
updated the mem-stats code
Arham-Nasir May 6, 2025
5e994d9
remove the all the generic exceptions and update code
Arham-Nasir May 12, 2025
3f9667e
update the memstats file
Arham-Nasir May 13, 2025
cf7649e
Merge branch 'master' of github.com:Arham-Nasir/sonic-buildimage into…
Arham-Nasir May 14, 2025
56ed56e
update mem-stats
Arham-Nasir May 15, 2025
7a31207
update memory statistics service file
Arham-Nasir May 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,21 @@ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable resolvconf.service
sudo mkdir -p $FILESYSTEM_ROOT/etc/resolvconf/update-libc.d/
sudo cp $IMAGE_CONFIGS/resolv-config/update-containers $FILESYSTEM_ROOT/etc/resolvconf/update-libc.d/

# Create memory statistics directories
sudo mkdir -p $FILESYSTEM_ROOT/etc/memory_statistics/
sudo mkdir -p $FILESYSTEM_ROOT/var/log/memory_statistics/
# Copy and set permissions for systemd service file
sudo install -m 0600 $IMAGE_CONFIGS/memory_statistics/memory_statistics.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/
# Copy and set permissions for daemon
sudo install -m 0755 $IMAGE_CONFIGS/memory_statistics/memory_statistics_service.py $FILESYSTEM_ROOT/usr/bin/
# Copy set permissions configuration file
sudo install -m 0644 $IMAGE_CONFIGS/memory_statistics/memory_statistics.conf $FILESYSTEM_ROOT/etc/memory_statistics/
# Register the service
echo "memory_statistics.service" | sudo tee -a $GENERATED_SERVICE_FILE
# Set ownership for memory statistics log directory
sudo chown -R root:root $FILESYSTEM_ROOT/var/log/memory_statistics/
sudo chmod 755 $FILESYSTEM_ROOT/var/log/memory_statistics/

# Copy initial interfaces configuration file, will be overwritten on first boot
sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/interfaces
sudo mkdir -p $FILESYSTEM_ROOT/etc/network/interfaces.d
Expand Down
11 changes: 11 additions & 0 deletions files/image_config/memory_statistics/memory_statistics.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Memory Statistics Daemon Configuration
Copy link
Contributor

@xincunli-sonic xincunli-sonic Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it better if these configurations can put into config db instead of a static conf file? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have stored configurations in both config_db and a static conf file for flexibility and reliability.

At startup, the daemon reads default settings from the conf file to ensure a consistent state after a restart. During runtime, the daemon dynamically updates its configuration from config_db without needing a restart. This approach combines the stability of predefined defaults with the convenience of live updates, ensuring predictable behavior and seamless adaptability.

[default]

# Enable or disable memory statistics collection
enabled=false

# Interval for memory data collection (in minutes)
sampling_interval=5

# Duration for which memory data is retained (in days)
retention_period=15
13 changes: 13 additions & 0 deletions files/image_config/memory_statistics/memory_statistics.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Memory Statistics Daemon
After=network.target redis.service
Requires=redis.service

[Service]
ExecStart=/usr/bin/memory_statistics_service.py
Restart=on-failure
RestartSec=5
EnvironmentFile=-/etc/memory_statistics/memory_statistics.conf

[Install]
WantedBy=multi-user.target
Loading
Loading