Skip to content
Permalink
Browse files

Change writeout methodology

  • Loading branch information...
NEMS Linux
NEMS Linux committed Sep 10, 2019
1 parent da1804c commit de8bfad2143748745f31f20a8b77404daf9e8ce5
Showing with 7 additions and 2 deletions.
  1. +4 −0 fixes.sh
  2. +3 −2 perfdata-purge
@@ -46,6 +46,10 @@
fi
fi

# Clear old perfdata from the log (user-enabled in NEMS SST)
/usr/local/share/nems/nems-scripts/perfdata-purge


# Update apt here so we don't have to do it below
apt clean
apt update --allow-releaseinfo-change
@@ -10,11 +10,11 @@
foreach ($perfdata as $line) {
$tmp = explode('||',$line);
$timestamp = intval($tmp[0]);
if ($timestamp < strtotime($cutoff . ' days ago')) {
if ($timestamp > strtotime($cutoff . ' days ago')) {
if (strlen($timestamp) > 0 && $timestamp > 0) {
// Found some timestamps that are older than $cutoff.
// Delete those lines from $file using sed.
$result = shell_exec("/bin/sed -i '/^$timestamp||/d' $file");
file_put_contents($file.'~~', $line);
$counter++;
echo '.';
}
@@ -25,6 +25,7 @@
$perfdata = null;
if ($counter > 0) {
rename($file.'~~',$file);
echo 'Purged all perfdata that is older than ' . $cutoff . ' days.';
} else {
echo 'There was no perfdata older than ' . $cutoff . ' days. Nothing purged.';

0 comments on commit de8bfad

Please sign in to comment.
You can’t perform that action at this time.