Mostly work related stuff which I would've entered into my "Log book". Instead of hosting it on an intranet site, outsourcing the hosting to blogger!
Saturday, December 21, 2024
capturing the screen in 4K resolution without a 4K monitor - with an NVidia graphics card on Linux
Sunday, December 08, 2024
Azure AD graph retirement
There was an email from Microsoft Azure, "Migrate Service Principals from the retiring Azure AD Graph APIs to Microsoft Graph" - clicking through, the recommendation only showed the id of the function or resource using the deprecated API, and did not provide any other information.
After an internet search, this faq showed how to identify it -
https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-faq#as-an-it-admin-how-do-i-identify-apps-in-my-tenant-that-use-azure-ad-graph
(It was not an application which I had created, it says the owner is "Power Virtual Agents Service" - so no action was taken. More info - https://techcommunity.microsoft.com/blog/azure-ai-services-blog/use-your-own-data-to-create-a-power-virtual-agent-with-azure-openai-service/3891860 )
automating user preferences modifications on Moodle - SikuliX
and so on.
Moodle database server overloaded - fixes
Since I'd set up CPU and disk space monitoring emails on some of our servers, I started getting CPU usage alert emails regularly from the mysql database server VM which served some of our Moodle instances. CPU usage kept going up, not declining even during night hours.
Troubleshooting -
- Checked 'currently running tasks' in all Moodle instances - Site administration > Server > Tasks > Tasks running now. Deleted the 3 tasks seen to be running for over an hour (delete modules) in the database table - since these were adhoc tasks, from the {task_adhoc} table based on adhoc taskid.
- Checked task logs, filtered for tasks taking longer than 3 seconds, and changed the scheduled tasks settings inside those Moodle instances to reduce the frequency of those tasks. Did this for all five Moodle instances. On the newest instance, changed the following in
Site Administration > Server > Tasks > Scheduled tasks- \enrol_category\task\enrol_category_sync - */5 instead of * (once every five minutes instead of every minute)
- \local_edwiserreports\task\send_scheduled_emails 05 instead of */5 (once an hour instead of once a minute)
- \local_edwiserreports\task\update_course_progress_data 39 instead of */5
- \mod_customcert\task\issue_certificates_task (once a day instead of every minute)
- \mod_forum\task\cron_task (once an hour instead of every minute)
- \core\task\search_index_task */47 instead of */30
- \enrol_category\task\enrol_category_sync - */5 instead of * (once every five minutes instead of every minute)
- The newest instance had thousands of errors being generated by mod_forum - failed to send notifications - and also another instance had thousands of errors from 'failed to send login notifications' at the time of migration in May. Deleted all these failed adhoc tasks from prefix_task_adhoc for both these instances. (For deleting the rows, since the number of rows were so large, it was much faster to create a query like
delete from our_db.prefix_task_adhoc where classname like '%send_user_notif%' (24k rows)
instead of deleting via the DBeaver GUI. - I had tried various options to prevent mod_forum from throwing errors for 'failed to send notifications'. Finally, the options which worked seemed to be:
+ Enable mobile notifications in Site Administration > General > Notification settings
+ Enable Subscribed forum posts notifications for Web and Mobile, also in Site Administration > General > Notification settings, default notification preferences
+ Enable Subscribed forum digests notifications for Web, Mobile and Email
+ Go to each user and change their forum notification preferences to Digest instead of No digest (each post separate email) - I'll write a separate post on how I automated this - Site Administration > Users , find the user, click on the user profile, Administration > Preferences and there, change forum preferences and notification preferences as above.
GMail rate limiting and Moodle
Some of our Moodle instances which used XOAUTH to send emails via smtp.gmail.com had issues with temporary authentication failures. Apparently GMail's smtp servers have started rate limiting after approx 100 emails were sent in 3 minutes by Moodle. Mostly mod_forum email digests.
Since Moodle itself doesn't seem to have any provision for rate limiting, we need to set up some mail relay which can retry mails which get throttled.
SSMTP which is currently installed on the server, doesn't seem to support any advanced features like rate limiting.
Since I'm familiar with Postfix, looked up ways to send emails from Postfix through google's smtp servers - https://computingforgeeks.com/
After setting up postfix as above, and changing the outgoing mail configuration on our Moodle instances to the default values (which would use the server default, ie postfix), emails seem to be going out fine.
For checking the postfix logs for errors,
journalctl -t postfix/smtp | more
journalctl -t postfix/smtp -f # for tailing the logs
With the postfix config with a single relayhost, there are a few errors once in a while "Network unreachable" but a second later, the mail gets sent. So, use of postfwd or extra config was not needed. If needed in future, multiple postfix instances or the use of multiple relay hosts based on authentication might be options.
Currently sending two large instances' emails through these, 250 emails have gone out last night with no problems as seen via the gmail interface in the sent folder.
Monday, December 02, 2024
human body anatomy - using the free z-anatomy blender model
- to delete text labels, we can select all text labels by going to Object menu, Select all by type and choosing Text
- Rendering in eevee or cycles causes a cut-away view, while workbench rendering engine gives a whole face. This is probably due to some "hide" setting somewhere, but I just went with workbench rendering instead of trying to troubleshoot.
- to turn on visibility for all objects in a collection, we have to Alt-left-click on the render / viewport icon as required. ALT clicking is the trick.
- to move camera to current view, the shortcut is Ctrl+Alt+Numpad 0. Or can change the shortcut on machines which don't have the numpad, in
File > User Preferences > Input, search for camera, the pref is 'align camera to view'. For Blender 4.2, the menu is Edit > Preferences > Keymap - to prevent camera being deleted with lasso select, just hide it - select the object in object mode, Object menu > Show/Hide > Hide selected (or H is the shortcut key, Shift H to unhide after the delete operations are done.)
- Working with objects inside a collection - simply selecting the collection and deleting it does not delete the objects inside the collection. To select all objects in a collection - right-click the collection and choose Select objects. Then, Del key or x or object menu > delete
Saturday, November 30, 2024
ffmpeg commands - image sequence to mp4
Tuesday, November 26, 2024
upgrade Moodle 4.4 to 4.5
Since the theme for some of our Moodle instances was "Moove" and this theme had some updates which would work on 4.5 only after upgrading the theme, first changed the theme to the built-in theme "Boost" from the UI, completed the upgrade, upgraded the plugins including the Moove theme, changed back to Moove theme, OK.
The upgrade itself was
screen
cd /var/www/theLMSgit
sudo -u www-data /usr/bin/php admin/cli/maintenance.php --enable
git config core.filemode false
#git branch --track MOODLE_405_STABLE origin/MOODLE_405_STABLE - this was done earlier.
git checkout MOODLE_405_STABLE
git pull
sudo chown -R azureuser:www-data .
sudo chmod -R 775 .
sudo -u www-data /usr/bin/php admin/cli/upgrade.php
Sunday, November 24, 2024
Activity dashboard in google docs
There was a request from a user that he wanted activity to be turned on -
he is not able to see who all opened the document through the shared link.
Copy-pasting from my reply -
linux desktop shortcut to open a directory in terminal
in our case, xfce4-terminal --working-directory=/the/relevant/directory
Friday, November 22, 2024
show the rules for creating username on Moodle - email based signup
There was a request for a method to show the rules for creating usernames (shouldn't have spaces, should be only lowercase) for new users registering on Moodle.
While a help message is provided for the password, similar information is not provided for username...
My reply was:
https://our.moodle.server/admin/settings.php?section=manageauths
There is an "instructions" field available at the above link, which you can use to provide instructions to the people logging in. Maybe that might help you.
(Another option is to remove the option for users to enter Username, and instead only use Email address as username. But I'm not sure how to do that.)
With this "instructions" field the problem seems to be mitigated - these instructions are shown on the login screen itself.
Wednesday, November 20, 2024
referer in apache logs not seen in awstats
Trying to set up awstats for one of our servers which needed referer information to be captured - the referer info was not being displayed initially.
https://simonecarletti.com/
better to have separate logs for each virtual server. So, set that up.
Saturday, November 09, 2024
OpenSpace - running version 0.20.1 on Linux Mint 22
sudo apt install libboost1.74-dev
with
sudo apt install libboost-all-dev following https://askubuntu.com/questions/922625/cannot-install-libboost-all-dev-because-dependencies-are-not-getting-installed
make -j 2
doing 2 concurrent jobs instead of unlimited concurrent jobs - and now the linker complained that some symbols were not found. I suspected that this was due to the interrupted builds due to the crashes - so,
make clean
sudo apt install task-xfce-desktop -y
moving from Azure CDN
The Azure portal had emailed us that the Azure CDN from Edgio would be retiring, and that since Edgio had gone into bankruptcy, service continuity was iffy. Their "recommended replacement" Azure Front Door Standard or Premium, looked pricey:
Front Door seems to have a minimum monthly cost of $35,
https://azure.microsoft.com/en-us/pricing/details/frontdoor/
So, instead, shall I just migrate the content elsewhere?
Currently, only old issues of a newsletter seems to be on cdn.ourdomain.org - content being served from a particular storage container.
I could move all the stuff there to a github pages repository instead, and map cdn.ourdomain.org to that - Github pages is free, (limited to 2 GB per repository).
Another option is that I can configure a cheap VM to point to the relevant container, mounting the container with blobfuse -
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-how-to-mount-container-linux?tabs=RHEL
Looking at the size of the content, which was only 780 MB of archival content and not expected to grow, thought of going with github pages.
Created a github pages repository,
put all the files there,
and changed cdn.ourdomain.org CNAME record to point there instead of the CDN.
Tested with google site:cdn.ourdomain.org for old cached links, working with the new site - like
http://cdn.ourdomain.org/sssihms/wp-content/uploads/2018/01/nameoffile.pdf
OK.
Wednesday, November 06, 2024
Database connection failed error on Moodle instance - enable service to make it start automatically on reboot
The problem was that I had not "enable"d the tunnel service (details in a previous post) which was tunneling the database connection over ssh - so, on server reboot, the tunnel service was not restarting automatically. We need to do
sudo systemctl enable name-of-our-service
to make it start automatically on reboot, and then
sudo systemctl start name-of-our-service
to actually start it the first time.
Saturday, November 02, 2024
Lenovo Thinkcentre desktop - Linux Mint notes
Decided to try out Linux Mint on one of the desktops which had Windows 10 installed. To minimize interference with the borrowed machine, we installed Linux on a separate 256 GB SSD. To connect the SSD, we disconnected the CD/DVD drive.
To boot into the install USB, F10 is the key we have to press on boot, which gives the option to go into System Settings or BIOS.
The machine was rebooting instead of shutting down when the 'Shut down' option was chosen.
https://askubuntu.com/questions/1321208/computer-reboots-instead-of-shutting-down
All Power > "Power on X" settings should be turned off in BIOS. I also found a setting which said, "When lose power" --> "go back to previous state". Changed that to 'shut down', too.
With these changes, the machine shuts down. But when power is removed and re-applied to the SMPS (by putting on the UPS the next day), the machine still automatically boots even without pressing the power button - so a separate switchable plug would be desirable.
Then, added swap to prevent sudden freezes due to memory issues (though system freezes due to insufficient power is still possible, the SMPS is underpowered) -
https://thelinuxcode.com/add-swap-space-linux-mint/
free -h
sudo fallocate -l 32G /swapfile
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
free -h
Edit: The above method of adding a swap file does not persist on rebooting - apparently it will persist only if added to /etc/fstab - so I added a line to root cron -
sudo crontab -e
#(at the bottom of the file)
# all other cron jobs must be above this
@reboot swapon /swapfile
Tuesday, October 29, 2024
updating a dot net app running on Ubuntu
When replacing the compiled dll for a dot net app running on Linux - Ubuntu 24.04 server - we need to reload the daemons.
Just
sudo service ourapi restart
results in
Warning: The unit file, source configuration file or drop-ins of ourapi.service changed on disk. Run 'systemctl daemon-reload' to reload units.
73:~$ sudo systemctl daemon-reload
Then,
73:~$ sudo service ourapi restart
73:~$ sudo service ourtestapi restart
are done without errors or warnings.
Sunday, October 27, 2024
troubleshooting a cron job - Ubuntu 24.04
https://gist.github.com/santhoshvr/bd6db5b1cab4f8d181d2ac2b59dd08aa
which bash
was actually /usr/bin/bash and not /bin/bash
upgrade options for Windows 10 PCs
Friday, October 25, 2024
New reasons prevent pages from being indexed - Google
Search Console has identified that some pages on your site are not being indexed due to the following new reason: Alternative page with proper canonical tag
According to this blogger support page,
"So there is nothing you need to do."
The m=1 page (mobile page) was not being indexed, but the non-mobile page was being indexed. That's fine, so no action needed.
Thursday, October 24, 2024
moving multiple Moodle instances from Ubuntu 20.04 to 24.04
Table of contents
Setting up the server VMs
Instead of a bitnami MySQL server, opted for a minimal Ubuntu 24.04 VM image for both the database server as well as the php application server.A good guide for LAMP installation - https://www.digitalocean.com/community/tutorials/how-to-install-lamp-stack-on-ubuntu
https://tracker.moodle.org/browse/MDL-81172
Site administrations > Courses > Asynchronous backup/restore
Confirm Asynchronous backups are still disabled
Enable Asynchronous backups
Enabled all the tickboxes in
admin/settings.php?section=asyncgeneralsettings
would fail, saying user not found. Even supplying the command-line parameters -n and - user directory would indicate user not found. Finally, just ran a script from the moodle directory, which just had lines like
1. Remove the site identifier from the database:
Delete from {config} where name = 'siteidentifier';
delete from {registration_hubs};
2. Clear the cache:
php admin/cli/purge_caches.php
3. Attempt a new manual registration (admin/registration/index.php)
set global slow_query_log_file ='/var/log/mysql/slow-query.log';
set global slow_query_log = 'ON';
show variables like '%slow%';
tail -f /var/log/mysql/slow-query.log
did not show any. Disabled the binary logs as noted above. The problem still persists with 150 to 180% cpu usage for mysql. Took several instances out of proxying via cloudflare - that made the sites load a bit snappier. But the database is still overloaded.
Issue certificates task
\mod_customcert\task\issue_certificates_task
This is doing heavy database reads - > 27K records, and taking nearly 5 minutes to complete. And once it is done, it starts again.
We can either
(a) clean up the database so that only a few certificates remain - probably not desirable, since we would need the teachers / students to retain their certificates in their accounts
(b) change the scheduling to only once a day, at midnight
According to the docs, the scheduled task emails the certificate to the users / teachers if they have not yet received it.
https://docs.moodle.org/403/en/Custom_certificate_module
So hopefully it should be fine if I change the scheduling to only once a day in the middle of the night - so I did that.
server/admin/message.php
That is the page where we can disable all email / mobile / web notifications and also disable new login notification. So, disabled new login notifications for every instance. I asked if I can turn off all notifications except email notifications for password reset etc for the five instances, but apparently they need the notifications to increase user engagement.
From https://docs.moodle.org/401/en/Category_enrolments
Warning: The use of the category enrolments plugin may cause performance problems. If so, it is recommended that you use Cohort sync instead, though this will require a cohort sync enrolment method to be added to each course in the category.
Changed this from * to */5 (every 5 minutes.) in Site Administration > Server > Tasks > Scheduled tasks.
Award badge - currently set to */5, changed to */7
sending badges - */5 changed to */9
Edit: Also did the MySQL optimizations noted in a separate post on tuning mysql for Moodle.
sudo npm install forever -g
https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04
and a restart of apache or reboot just to make sure, and the problem went away.