Friend, the discharge and swelling of the penis is called "Balanoposthitis." The discharge is common especially in intact males, it is caused by an infection. It is important that you stop him from licking has this will cause more inflammation. As far as the scrotum, the black color is a sign of chronic inflammation. Similar to the penis, licking will cause more inflammation and irritation.
I would recommend a hands on examination with family vet; he may need antibiotics orally and prescription anti inflammatory medications. In the meantime this is what you can do:
1- Need to stop him from licking or he is going to delay healing. Pick up an ecollar (cone) in your local pet store to stop him from licking/gnawing at affected area.
2- Pick up in your local pharmacy "Hibiclens" antimicrobial soap or chlorhexiderm scrub. Wash both testicles and penis with this soap 2-3 times a day. If you do not find the above soap use over the counter antibacterial soap.
3- After washing affected area as above apply a topical antibiotic like neosporin or bacitracin. Do this 2-3 times a day for the next 7-10 days.
Note: Make sure you keep the tip of the penis moist, you can use the topical antibiotic or vaseline. If he strains and is having difficulty urinating I would have him checked by ER veterinarian, he will need to be catheterized to urinate or his bladder could be damaged.
4- Follow up with your family veterinarian.
Please do not forget to rate my answer - I hope you found it to be excellent. If there’s more I can do, please use the reply tab and let me know. It’s my goal to provide you with excellent service." Thank you for your business and I hope to work with you again soon!