Hostname | DateTime | Update Count |
---|---|---|
${host['hostname']} | ${host['datetime']} | ${host['updatecount']} |
This page permanently redirects to gemini://m0yng.uk/2020/08/aptChecker---Keeping-too-many-things-updated/.
Created 2020-08-26
Modified 2021-02-10
=> Tagged
It's an obvious problem to me that I have too many computers, and keeping on top of which have been updated recently is... not simple.
I've finally got around to making a semi solution, using a bash script and some PHP! Is there a better way? Almost certainly! Would it work easily and quickly on even a raspberry pi v1 and zero without stopping them doing the thing I want them to do? Maybe not.
=> I've added some new bits (remote server checks), detailed in part two
=> Pager showing that radiopi-10 has 18 updates available [IMG]
apt update
and then apt list --upgradeable
to count how many packages could be updated.
/etc/cron.daily/
so should run every day
json
file, but also:
html
page
json
The page is simple, and looks like this (I could probably format the date time, but meh.)
=> Screenshot white text on black in a table showing update counts for different systems [IMG]
#!/bin/bash hostname=$(hostname) datetime=$(date --iso-8601=seconds) apt update updatecount=$(apt list --upgradeable | wc -l) # correct for always getting at least one, even if there are none updatecount=$((updatecount - 1)) echo $updatecount curl -X POST -F "hostname=$hostname" -F "datetime=$datetime" -F "updatecount=$updatecount" http://myserver/aptCounter.php
(string) $_POST['hostname'], "datetime" => (string) $_POST['datetime'], "updatecount" => (int) $_POST['updatecount'], ]; $hostname = $newEntry->hostname; $aptCounterData[$newEntry->hostname] = $newEntry; file_put_contents("aptCounter.json", json_encode($aptCounterData)); if ($newEntry->updatecount > 0) { echo $newEntry->updatecount; $url = 'http://www.hampager.de:8080/calls'; $data = array('text' => "M0YNG: $newEntry->hostname has $newEntry->updatecount updates available.", 'callSignNames' => ['m0yng'], 'transmitterGroupNames' => ['UK-ALL'], 'emergency' => 'false'); $auth = base64_encode('m0yng:mypassword'); $options = array( 'http' => array( 'header' => "Content-type: application/json\r\nAuthorization: Basic $auth", 'method' => 'POST', 'content' => json_encode($data), ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result); } echo "Done."; exit(); } else if ($_SERVER['QUERY_STRING'] == 'format=json') { header('Content-Type: application/json'); echo json_encode($aptCounterData); } else { usort($aptCounterData, function ($a, $b) {return $a['updatecount'] < $b['updatecount'];}); ?>aptChecker Counts aptChecker Counts
0) { } $host['goodbad'] = ($host['updatecount'] > 0 ? 'bad' : 'good'); echo " Hostname DateTime Update Count "; } ?> ${host['hostname']} ${host['datetime']} ${host['updatecount']}
-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
๐ค Black Lives Matter
๐๐ค๐ Trans Rights are Human Rights
โค๏ธ๐งก๐๐๐๐ Love is Love
Copyright ยฉ 2024 Christopher M0YNG - It is forbidden to use any part of this site for crypto/NFT/AI related projects.
=> Code snippets are licenced under the Hippocratic License 3.0 (or later.)
Page generated 2024-12-13 by Complex 19
text/gemini;lang=en
This content has been proxied by September (3851b).